scene2d Table forked up

Getting a bit cozy are you, what with your scene2d application compiling smugly? Say no more, I have a treat for you!

As you know, TableLayout is one of my (Nate’s) OSS projects. The core performs UI toolkit agnostic layout and only a small bridge needs to be written to layout for the toolkit of your choice. The UI toolkits it supports are Swing, Android, TWL and of course libgdx’s scene2d.ui. Sadly, few outside of libgdx have seen the blessed layouting light and continue to plod along with suboptimal tools. Anyway, the bridge makes for some slight API awkwardness and extra indirection under the covers. Since TableLayout is mostly used for scene2d and given that I certainly don’t want to (or plan to) subject myself to the pain of using other UI toolkits, I figured we might as well fork TableLayout and integrate it properly into libgdx.

Rest assured, everything is now completely forked. What is left are two classes: Table and Cell. They work mostly as they did before, but you’ll need to organize your imports since they are now in the scene2d.ui package. The API has changed slightly:

  • Cell#getWidget -> Cell#getActor
  • Cell#setWidget -> Cell#setActor
  • Other methods with “widget” in name -> “actor”, since they take Actor, not Widget.
  • cell.getLayout().getTable() -> cell.getTable()
  • Cell#ignore is gone. This was never used AFAIK mostly on account of not being very useful.
  • TableLayout and Toolkit are gone. Table does it all.

In addition, Value has changed a bit. It is simpler and no longer specific to Table. I plan to use it elsewhere soon, eg in Container.

So there you have it. API breakage should be easy to fix and the new Table works as it did before.

15 thoughts on “scene2d Table forked up

  1. Oh, that’s a shame: the layout framework is both simple to understand and powerful to use.
    I was looking forward to use it in other non-libGdx projects.

    BTW, I was using the ignore() method!
    In my game menus, buttons or screen elements are in tables and I want to hide the cell containing a button when hiding the button.
    I also want to ignore the whole table line if a cell’s content is hidden and the cell was the only cell in the row.
    I was having layouting problems without using ignore().
    Perhapse I can do without ignore(): I will need to have a look when a new libGdx stable release is released.

  2. Hi, just wanted to mention that I am also using “ignore()” – please KEEP IT! Thanks!

  3. @Sébastien TableLayout continues to exist, just libgdx now uses a fork customized for libgdx.

    Ignore was a bit weird. Another way it can be done is to have cell(s) that you set an actor on, or set null to show nothing.

    Ideally Tables would supporting adding/removing a row. It’s a bit tricky to implement though!

  4. Yes, TableLayour is still there. But bug fixes and feature additions will not be synced between both projects.

    OK, when I will be forced to update libGdx I will change the code to set cells with null actor to hide them.

    Will this null-thingy work with rows that have one cell with a null actor?
    Will the row be hidden?
    Or will the table show empty space, possibly changing height at some point?

  5. OK, great. It’s fine with me.
    And thanks for this framework: it’s really simple to use and helped me a lot for my Android game.

  6. Maybe I misunderstood, but is this view usable outside a libgdx Scene? Like, being able to include it in my Android XAML files as it is?

  7. hi i am new to game development.i found libgdx lib to develop game in android. can any one have api to guide me for developing my first android game app

Leave a Reply

Your email address will not be published.