Semi-transparent UI elements

Dec 28, 2011 at 9:31 PM

Looking at the rendering code for the GUI, and it appears to not allow for an alpha parameter anywhere. I'm hoping that I'm missing something and that there is a way to do this, because I'm hesitant to include the entire GUI framework in my project and then start passing values through large chains of code.

So yea, is there any way to set the transparency of a UI element?

Coordinator
Jan 10, 2012 at 9:22 AM

The Skin bitmaps could be designed with alpha blending built into them.

I admit I haven't tried this yet, but the Skin XML files also specify the colors in which the FlatGuiVisualizer will render its stuff, including the Alpha component. I don't know from the top of my head which flags I pass to the SpriteBatch in the FlatGuiGraphics class, but if they allow alpha blending, that could be used, too.

Finally, a Opacity property or something similar could be added to the controls and used by the FlatGuiVisualizer/FlatGuiGraphics pair accordingly. I'm a bit hesitant to do this in the official sources because the results would be... weird: given a 50% transparent window with a 50% transparent button on it, the window would be transparent to what's below it and the button would be drawn on top of that, resulting in only 25% of what's below the window showing through. Coping for that would probably require either some complicated calculations or to draw the entire window onto a render target first.

Jan 10, 2012 at 3:28 PM
Edited Jan 10, 2012 at 3:29 PM

You could add Color with RGBA and just set it in spritebatch.

It would be useful sometime maybe when your going to add some sort of animation.

Jan 11, 2012 at 3:56 AM

Problems such that you describe (transparent on transparent) shouldn't be a reason not to do it - it's up to the user of the gui system to decide how to deal with it. I imagine they would simply accept it in most cases.

Jan 14, 2012 at 4:29 AM
Dracorat wrote:

Problems such that you describe (transparent on transparent) shouldn't be a reason not to do it - it's up to the user of the gui system to decide how to deal with it. I imagine they would simply accept it in most cases.

I agree with this, in my case I may not need buttons in some cases. I may be able to implement it on my own, but I don't know the framework very well. I've implemented double-click event handling, window minimizing/restoring, and render frames in the skin for when a window is hovered over and when a window is being dragged, but I've still only scratched the surface of this large system. I believe the GUI framework alone may have more files than my entire game engine.

Anyway, it would be a nice thing to have, but on the flip-side there are plenty of other things that could be worked on that are probably more important I'm sure.