Repaint without parent repaint


#1

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.


#2

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


#3

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.


#4

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?


#5

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


#6

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.


#7

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

 


#8

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?


#9

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


#10

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)