Created
February 8, 2015 01:17
-
-
Save thepaperpilot/b85857813fc1c785df4b to your computer and use it in GitHub Desktop.
An extension of the LibGDX Table, that wraps actors added to it, based on the table's current width. Use setSize() before adding any actors.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.badlogic.gdx.scenes.scene2d.Actor; | |
import com.badlogic.gdx.scenes.scene2d.ui.Cell; | |
import com.badlogic.gdx.scenes.scene2d.ui.Table; | |
/** Like a table, but wraps widgets to new rows once the preferred width has been reached | |
* @author The Paper Pilot */ | |
public class FlowTable extends Table{ | |
@Override | |
public <T extends Actor> Cell<T> add (T actor) { | |
float oldWith = getWidth(); | |
Cell<T> cell = super.add(actor); | |
while(getWidth() > oldWith) { | |
removeActor(actor); | |
row(); | |
cell = super.add(actor); | |
} | |
return cell; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment