setAlpha(0.5f) on an opaque component


#1

… 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.


#2

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


#3

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


#4

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


#5

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


#6

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.


#7

Would it?

The behavior in my second post is okay?


#8

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.


#9

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


#10

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