Repaint without parent repaint

I would like to call repaint() on a Component without the automatic repaint on the parent Component.

One way is setting the parent component with setOpaque but it is not an option in this case.

The parent Component in this page is not opaque but opaque enough where this child component is to be drawed.

 

Can I achieve this in some way? The only hack I can think of would be adding another layer of Component where the middle layer is opaque and so don't trigger repaint() upwards...but it feels like it could be handled smarter.

Well if your parent is very long to redraw maybe you can set setBufferedToImage() on it if it is not refreshed often.

2 Likes

I've already tried that. It didn't do much difference. The problem is that the parent has many children and all other children are repainted when parent is.

If your component is transparent then you'll have to repaint the parent or it won't know how to compositie the child's background. If the background of the child doesn't change can you set the child to opaque and simply fill it with the same colour as the parent?

The child is set to opaque but did not seem to matter.

Humm if the child which gets repainted is set to opaque, it should work fine.

check the debugger to see where this gets called.

 

Still beware that on OSX, if you get two different child like one on top left and one on bottom right, then everything gets repainted

because the redraw surface is a rectangle not a rectangle list.

Try with JUCE_ENABLE_REPAINT_DEBUGGING see what's going on.

JUCE_ENABLE_REPAINT_DEBUGGING seem to flash the component  who first gets the repaint() call. All seems OK looking at that.

I can however see with debug printouts that the paint()-methods get called.

 

Yes it is OSX b.t.w

 

I got the same issue. I need to redraw one component and it draws all the window. The JUCE_ENABLE_REPAINT_DEBUGGING only show this single component flashing, but by breaking on other paint methods I see they are called as well.

Any idea?

In my case I just made a workarond using parents paintOverChildren since the component wasn't interactive anyhow. (vumeters).

1 Like

Still beware that on OSX, if you get two different child like one on top left and one on bottom right, then everything gets repainted because the redraw surface is a rectangle not a rectangle list.

Relevant for the above issue you mention, could be this commit: (also pasted here for future reference to anyone hitting the same issue with opaque components)

https://github.com/julianstorer/JUCE/commit/e0f5218121054172bf9df6474ae37c29e6d24e11

This is the outcome of another long discussion in this forum about it.

Notice that this may lead to a different set of performance issues, so it should be used with caution (hence the enablement with a macro)

2 Likes

Sorry, but do you remember that workaround? I’m having the same issue described here! Thank you!

I would also be interested to know what your workaround was, if you’re still around. Thanks.