Colour of a child component


#1

Hi.

I have a child component which has a semi-transparent colour, and because of that the final colour of the component is a mixture
of it’s colour and the colour of the parent component.

If I don’t want the child’s colour to be affected by its parent, does the only way is to manually change to parent’s paint() to skip over the child’s area?
If that is the case, it means I have to update paint() every time I change the position of the child component.

In solid colours I just use setOpaque(true) and I save the hidden painting, but that works only in solid colours.

Thanks.


#2

Sorry, I don’t understand the question…


#3

I’ll use another approach:

Is is possible to automatically have a parent component fill all it’s net area (that doesn’t include the child components’ area)?

Something like g.fillAllVisibleArea()

Thanks


#4

I also read you other Thread ( Graphics::fillRoundedRectangle() with setOpaque(true) ), maybe you did understand something fundamentally wrong…
if you have setOpaque(false) (whats default) , you just paint the areas you want to paint, other areas are just untouched (and are “filled” with the underlying components).
If you have setOpaque(true), you have to to fill every pixel in your components area. (with 1.0f alpha)
If you want a mixture just paint with an alpha channel lower than 1.f and setOpaque(false), its total easy!


#5

Yeah, you’re misunderstanding something.

If the child is opaque, then you don’t need to worry about clipping its parent. And if the child is transparent then of course you must paint behind it, otherwise how else could it possibly work?


#6

Yep, got it , thanks guys!