setAlpha(0.5f) on an opaque component

… of course isn’t very clever, should give at least a warning, or maybe better, juce could handle the situation just right? Currently it produces redraw issues.

I have to specify, i setAlpha(0.5f) on a component, which has child-components which are opaque, this causes redraw issues.

is there a definitive thread that details why you should always (or not) use setOpaque?

This is a good point, actually - I’ll add an assertion to catch this mistake in future!

…hmm, or actually I should just make it work…

1 Like

Please don’t just make it work, as it would mask unintended behavior and lead to severe performance degradation. I would prefer a simple assert that lets me know that I made a mistake.

Would it?

The behavior in my second post is okay?

Well, if my code intends to use “setOpaque (true)”, then everything underneath doesn’t need to be re-drawn. Now if I accidentally use “setAlpha (0.5)” on that component, it would lead to undefined behavior and I would expect an assertion. If @jules “just makes it work”, then that would mean I won’t get that assertion, the component gets drawn “correctly” (albeit with accidental alpha) and I wouldn’t even notice my mistake. Imagine I accidentally use “setAlpha (0.99)”. I could probably not even see the difference and wonder why the performance is taking a hit.

I’d rather be warned about mistakes instead than getting “corrected” behavior that might not be what I intended.

I talking about a child component is opaque, and the parent use setAlpha

That’s different. That should “just work” I guess :smiley: