Container properties

I just noticed some odd behavior with the container component. Perhaps this is by design or I am missing something. If I bind the background color property to a color whose alpha is less than 255, then the opaque property gets set to false and the color does not display (it sets the container to completely transparent regardless of the background property). It seems impossible to have a container that is partially transparent. I just confirmed this for a simpler case – the background color is not bound, I am just setting it in designer. If the alpha is 255, the opaque property is set and the color is displayed. If the alpha is anything less than 255, the opaque property is cleared (and cannot be set) and the color is not displayed.

Yeah I see what you’re saying. This is a side-effect of what the “opaque” property means to Swing. I’ve made a ticket to get this fixed.

The fix for this made it into 7.2.4, which was released today.

Hi Carl,

Thanks for the fix. I am running 7.2.5b1 and I still see some issues with this. For static colors, it seems to work fine, but something isn’t right when you animate the colors. I am using styles to set the colors for a highlight effect when the mouse goes over a container. If I apply identical colors and scripting on a rectangle, I get one result and the same configuration for a container acts differently. The state 0 background colors I have tested are color(255,255,255,85) or color(92,92,92,64). The state 1 color is color(255,255,170,255). For a rectangle, the state 1 color shows as a sort of cream color. For the containers, the background becomes transparent instead of going from partially transparent to opaque and cream colored.

Thanks,
Max

Can you make a simple window that demonstrates what you’re describing and post it here please?

Interesting, when I created a new container for the test window it worked OK. When I copied one of the misbehaving containers to it, it continued to misbehave. Maybe you will see something I am missing.
ContainerHoverTest.vwin (14.9 KB)

I see what’s going on here. When I imported that window, neither container’s hover color worked. I’ll bet if you close your container and re-open it, neither will work either. It wasn’t that one was created in an older version and one was newer - it was that one had been serialized and one was “virgin”.

The problem is that when you set the background to a transparent color, it forces opaque off (this is a requirement of Swing, otherwise it would paint using a dirty buffer). Then when you serialize the window, it notices that opaque has been turned off, and so it interprets that as you having un-checked that property, and so when you hover your mouse over the container and it changes the color to an opaque color, it doesn’t paint it because it thinks you’ve un-checked opaque.

The solution? Add a column to your styles dataset: “opaque”: mouseHover 0 > false, mouseHover 1 > true

Thanks for the reply, Carl. Another workaround that I am using is to just not set the hover color to an opaque color – if I set it to almost opaque (alpha = 254) it works! That is close enough to opaque for me.

Yep, that’ll work too. It only looks at the value of opaque as a hint to not draw the background at all if the background color is totally opaque.