Need a flag if paint was initiated by the os


#1

Hi everybody,
I have a component that calls repaint() controlled by a timer. The repaint() is done only for the changed area since the last call. If now another window e.g. the transport bar is moved over my plugin/component and then removed, I need to repaint this former covered area, too. So the paint() of my component needs to now if it was called by the timer-controlled repaint() or by the os or the ComponentPeer or whatever.

Is there a way to get information about the area of the component that is covered by another window? Or a flag that indicates that a former covered area is visible now?

Thanks


#2

The area you are talking about should be repainted anyway, because the OS will call the paint() method when some region needs to be repainted.


#3

That’s clear and this is the problem, because something in the paint routine has to be handled differently according to the origin of the call. So I need to know who is responsible for the call to paint.


#4

I think I don’t get the problem, sorry.


#5

are you maybe missing the significance of : Component::repaint (const int x, const int y, const int width, const int height) ?

What you are trying to do simply isn’t good practice. What if a repaint call by the OS, and a repaint call by your timer are coalesced into one call back, which is highly likely to happen when the system is under load. What use would a flag be in this case. At best its effect would be benign.


#6

I think you’re right that the idea of using a flag would be a bad design and lead to inconsistent results. I found a way by comparing the areas of Graphics::getClipBounds() in paint() and the Component::repaint (const int x, const int y, const int width, const int height) called by the timer. I wasn’t aware of the fact that several calls might be coalesced into one call back.

Thanks for your help


#7

It sounds like you’re still missing the point - you should never need to know why your paint routine’s getting called. If an area needs painting, you don’t ask why, you just paint it.

If you’re calling repaint() directly, that’s the time when you optimise how much should be redrawn. Your idea about comparing the areas is a lost cause.


#8

Ok, I got it. It turned out that the way my paint routine was implemented was not the way intended by the juce framework.
Thank you for pointing me in the right direction.