Guil - Graphics User Interface Library for libgdx's Scene2d

Any community contributions to libgdx go here! Some may get included in the core API when permission is granted.

Guil - Graphics User Interface Library for libgdx's Scene2d

Postby Rickodesea » Tue Dec 25, 2018 8:28 pm


This is a library designed to make it easier to size and position scene2d actors regardless of the viewport you are using.

Here is example code from the demo:

Code: Select all
public class Game extends ApplicationAdapter {
   public final static float width = 320;
   public final static float height = 16 * width / 9;
   WidgetManager wm;
   Widget widget;
   Widget textbutton;
   Widget label, image, slider;
   Widget textfield;
   ViewportSwitch vps;
   public void create () {
      wm = new WidgetManager(width);
      final Skin skin = new Skin(Gdx.files.internal("skin/default/uiskin.json"));
      widget = new Widget(new Button(skin)); = 0.2f; = 0.1f;
      textbutton = new Widget(new TextButton("NEXT", skin)); = 0.3f; = 0.15f; = 0.2f;
    ChangeListener() {
         public void changed(ChangeEvent event, Actor actor) {
      label = new Widget(new Label("GUIL demo", skin));
      label.setSize(0.3f, 0.1f);
      image = new Widget(new Image(new Texture("badlogic.jpg")));
      image.setSize(0.2f, 0.2f);
      slider = new Widget(new Slider(0, 10, 0.1f, false, skin));
      slider.setDimension(0, 0, 1, 0.1f);
      textfield = new Widget(new TextField("Enter text here...", skin));
      textfield.setPosition(-0.15f, -0.25f);
      textfield.setSize(0.5f, 0.1f);
      vps = new ViewportSwitch(width, height);

   public void render () {, 0, 0, 1);;
      final Label l = (Label);
      l.setText(vps.s()+ " " + vps.w + ", " + vps.h);
   public void resize(int width, int height) {
      wm.resize(width, height);
   public void dispose () {

Try it and let me know what you think. Is this good or is it better to use libgdx's actors directly ?
Posts: 8
Joined: Tue Oct 25, 2016 4:19 am

Re: Guil - Graphics User Interface Library for libgdx's Scen

Postby evilentity » Tue Dec 25, 2018 9:07 pm

Looks interesting, try making the widget generic so you dont have to cast the actor all the time.
Looking for a freelancer? PM me!
Check out libgdx discord server!
Posts: 4867
Joined: Wed Aug 24, 2011 11:37 am

Return to Libgdx Contributions

Who is online

Users browsing this forum: No registered users and 1 guest