Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Top color of a Scene2d.ui window?

Tags:

libgdx

I want to create a UI window in libgdx where the top part (the part containing the title and which allows you to drag the window) has a different background color from the rest of the window. I can only set the background color for the entire window, is it possible to change it for just this top part?

Code so far:

    WindowStyle windowStyle = new WindowStyle(new BitmapFont(), Color.WHITE, skin.newDrawable("white", Color.BLACK));

    Window window = new Window("test", windowStyle);
    window.setMovable(true);
    window.padTop(20);

    stage.addActor(window);
    window.setPosition(100, 100);
    window.setSize(500, 300);
like image 632
mattboy Avatar asked Aug 21 '13 16:08

mattboy


1 Answers

The top bar for UI Windows in libgdx uses the same texture as the whole window. In order to change the color for the top bar the underlying texture file will need to be modified. libgdx treats it as a whole and there is no built-in way to specify separate colors for each component of a window.

There are other ways, but they are non-trivial and requires writing your own widget class to replicate most of the behavior of the built-in Window class.

like image 162
Jyro117 Avatar answered Jan 02 '23 12:01

Jyro117