Add support for Container entities

This commit is contained in:
Mitchell Kember
2014-04-27 21:39:11 -04:00
parent 8231db2eba
commit 74d3287544

View File

@@ -6,10 +6,10 @@
[com.badlogic.gdx.graphics Color Texture] [com.badlogic.gdx.graphics Color Texture]
[com.badlogic.gdx.graphics.g2d TextureRegion] [com.badlogic.gdx.graphics.g2d TextureRegion]
[com.badlogic.gdx.scenes.scene2d Actor Stage] [com.badlogic.gdx.scenes.scene2d Actor Stage]
[com.badlogic.gdx.scenes.scene2d.ui ButtonGroup CheckBox Dialog [com.badlogic.gdx.scenes.scene2d.ui ButtonGroup CheckBox Container
HorizontalGroup Image ImageButton ImageTextButton Label ScrollPane Dialog HorizontalGroup Image ImageButton ImageTextButton Label
SelectBox Skin Slider Stack Table TextButton TextField Tree ScrollPane SelectBox Skin Slider Stack Table TextButton TextField
Tree$Node VerticalGroup WidgetGroup Window] Tree Tree$Node VerticalGroup WidgetGroup Window]
[com.badlogic.gdx.scenes.scene2d.utils NinePatchDrawable [com.badlogic.gdx.scenes.scene2d.utils NinePatchDrawable
SpriteDrawable TextureRegionDrawable TiledDrawable] SpriteDrawable TextureRegionDrawable TiledDrawable]
[com.esotericsoftware.tablelayout Cell] [com.esotericsoftware.tablelayout Cell]
@@ -187,6 +187,31 @@ based on the file at `path`.
[entity k & options] [entity k & options]
`(u/call! ^Checkbox (u/get-obj ~entity :object) ~k ~@options)) `(u/call! ^Checkbox (u/get-obj ~entity :object) ~k ~@options))
; container
(defn container*
[child]
(ActorEntity. (Table. child)))
(defmacro container
"Returns an entity based on [Container](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Container.html).
(container entity)"
[child & options]
`(let [entity# (container* ~child)]
(u/calls! ^Container (u/get-obj entity# :object) ~@options)
entity#))
(defmacro container!
"Calls a single method on a `container`."
[entity k & options]
`(u/call! ^Container (u/get-obj ~entity :object) ~k ~@options))
(defn container?
"Returns true if `entity` is a `container`."
[entity]
(isa? (type (u/get-obj entity :object)) Container))
; dialog ; dialog
(defn dialog* (defn dialog*