When I call repaint on my spinner [setOpaque(true)] its parent is also repainted.
Any idea why?
My repaint knowledge isn’t that hot: Should the clip region in the Graphics object match the size of the component being repainted? My component has bounces {6, 4, 16, 16} and the clip area of the Graphics object is {5, 4, 18, 16} !
And we have other cases where I bet this is a problem. Probably explains why my dialog windows repaint constantly even though the progress bar is setOpaque!
Presumably Graphics::fillAll() is my main issue and this already restricts itself to repainting the clip region only. The status bar was more of a problem because of a logo we had on there that was expensive to paint.
On the upside - I know a lot more about repaints now.
If this is unfixable it should be added to the setOpaque documentation as it was an hours work and a couple of reboots to be sure what was happening.
what @dave96 has written, is also my approach, because of the non-integer transformation the borders contains mixed pixel between the parent and the child region.
repaint(1, 1, getWidth()-2,getHeight()-2);
…can fix this, but of cause you need to care that the animation does not goes beyond the borders.
But anyway when you begin to have more than 2 animated objects, alle the objects between this objects also repainted, because the os or juce merge the two repaint regions.
Another experimental approach could be, to add these opaque components directly to the desktop (like the openGL component), which are following the position relative to the window, so the OS-window manager composes the regions without any repainting involved.
There is JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS on macOS but I’ve yet to see any definitive proof as to whether it’s better or not. My gut feeling is that it vastly depends on your UI, its layout and the repaint frequency of each object.
Not sure about other OSes but I wouldn’t rule it out. Even if they don’t do that now, there’s nothing to say it won’t happen in the future…