Move ui listener macros to ui.clj
This commit is contained in:
@@ -29,7 +29,7 @@
|
|||||||
OrthogonalTiledMapRenderer]
|
OrthogonalTiledMapRenderer]
|
||||||
[com.badlogic.gdx.math Vector2 Vector3]
|
[com.badlogic.gdx.math Vector2 Vector3]
|
||||||
[com.badlogic.gdx.scenes.scene2d Actor Stage]
|
[com.badlogic.gdx.scenes.scene2d Actor Stage]
|
||||||
[com.badlogic.gdx.scenes.scene2d.utils ActorGestureListener Align
|
[com.badlogic.gdx.scenes.scene2d.utils ActorGestureListener
|
||||||
ChangeListener ClickListener DragListener FocusListener]
|
ChangeListener ClickListener DragListener FocusListener]
|
||||||
[com.badlogic.gdx.utils ScreenUtils Timer$Task]
|
[com.badlogic.gdx.utils ScreenUtils Timer$Task]
|
||||||
[play_clj.entities BundleEntity ShapeEntity]))
|
[play_clj.entities BundleEntity ShapeEntity]))
|
||||||
|
|||||||
@@ -119,29 +119,12 @@ in the `screen`."
|
|||||||
(zoom [e id d]
|
(zoom [e id d]
|
||||||
(execute-fn! on-ui-zoom :event e :initial-distance id :distance d))))
|
(execute-fn! on-ui-zoom :event e :initial-distance id :distance d))))
|
||||||
|
|
||||||
(defmacro actor-gesture-listener!
|
|
||||||
"Calls a single method on the [ActorGestureListener](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/ActorGestureListener.html)
|
|
||||||
in the `screen`."
|
|
||||||
[screen k & options]
|
|
||||||
`(let [listeners# (u/get-obj ~screen :ui-listeners)
|
|
||||||
^ActorGestureListener object#
|
|
||||||
(u/get-obj listeners# :actor-gesture-listener)]
|
|
||||||
(u/call! object# ~k ~@options)))
|
|
||||||
|
|
||||||
(defn ^:private change-listener
|
(defn ^:private change-listener
|
||||||
[{:keys [on-ui-changed]} execute-fn!]
|
[{:keys [on-ui-changed]} execute-fn!]
|
||||||
(proxy [ChangeListener] []
|
(proxy [ChangeListener] []
|
||||||
(changed [e a]
|
(changed [e a]
|
||||||
(execute-fn! on-ui-changed :event e :actor a))))
|
(execute-fn! on-ui-changed :event e :actor a))))
|
||||||
|
|
||||||
(defmacro change-listener!
|
|
||||||
"Calls a single method on the [ChangeListener](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/ChangeListener.html)
|
|
||||||
in the `screen`."
|
|
||||||
[screen k & options]
|
|
||||||
`(let [listeners# (u/get-obj ~screen :ui-listeners)
|
|
||||||
^ChangeListener object# (u/get-obj listeners# :change-listener)]
|
|
||||||
(u/call! object# ~k ~@options)))
|
|
||||||
|
|
||||||
(defn ^:private click-listener
|
(defn ^:private click-listener
|
||||||
[{:keys [on-ui-clicked on-ui-enter on-ui-exit
|
[{:keys [on-ui-clicked on-ui-enter on-ui-exit
|
||||||
on-ui-touch-down on-ui-touch-dragged on-ui-touch-up]}
|
on-ui-touch-down on-ui-touch-dragged on-ui-touch-up]}
|
||||||
@@ -166,14 +149,6 @@ in the `screen`."
|
|||||||
(execute-fn! on-ui-touch-up
|
(execute-fn! on-ui-touch-up
|
||||||
:event e :input-x x :input-y y :pointer p :button b))))
|
:event e :input-x x :input-y y :pointer p :button b))))
|
||||||
|
|
||||||
(defmacro click-listener!
|
|
||||||
"Calls a single method on the [ClickListener](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/ClickListener.html)
|
|
||||||
in the `screen`."
|
|
||||||
[screen k & options]
|
|
||||||
`(let [listeners# (u/get-obj ~screen :ui-listeners)
|
|
||||||
^ClickListener object# (u/get-obj listeners# :click-listener)]
|
|
||||||
(u/call! object# ~k ~@options)))
|
|
||||||
|
|
||||||
(defn ^:private drag-listener
|
(defn ^:private drag-listener
|
||||||
[{:keys [on-ui-drag on-ui-drag-start on-ui-drag-stop
|
[{:keys [on-ui-drag on-ui-drag-start on-ui-drag-stop
|
||||||
on-ui-touch-down on-ui-touch-dragged on-ui-touch-up]}
|
on-ui-touch-down on-ui-touch-dragged on-ui-touch-up]}
|
||||||
@@ -196,14 +171,6 @@ in the `screen`."
|
|||||||
(dragStop [e x y p]
|
(dragStop [e x y p]
|
||||||
(execute-fn! on-ui-drag-stop :event e :input-x x :input-y y :pointer p))))
|
(execute-fn! on-ui-drag-stop :event e :input-x x :input-y y :pointer p))))
|
||||||
|
|
||||||
(defmacro drag-listener!
|
|
||||||
"Calls a single method on the [DragListener](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/DragListener.html)
|
|
||||||
in the `screen`."
|
|
||||||
[screen k & options]
|
|
||||||
`(let [listeners# (u/get-obj ~screen :ui-listeners)
|
|
||||||
^DragListener object# (u/get-obj listeners# :drag-listener)]
|
|
||||||
(u/call! object# ~k ~@options)))
|
|
||||||
|
|
||||||
(defn ^:private focus-listener
|
(defn ^:private focus-listener
|
||||||
[{:keys [on-ui-keyboard-focus-changed on-ui-scroll-focus-changed]}
|
[{:keys [on-ui-keyboard-focus-changed on-ui-scroll-focus-changed]}
|
||||||
execute-fn!]
|
execute-fn!]
|
||||||
@@ -213,14 +180,6 @@ in the `screen`."
|
|||||||
(scrollFocusChanged [e a f]
|
(scrollFocusChanged [e a f]
|
||||||
(execute-fn! on-ui-scroll-focus-changed :event e :actor a :focused? f))))
|
(execute-fn! on-ui-scroll-focus-changed :event e :actor a :focused? f))))
|
||||||
|
|
||||||
(defmacro focus-listener!
|
|
||||||
"Calls a single method on the [FocusListener](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/FocusListener.html)
|
|
||||||
in the `screen`."
|
|
||||||
[screen k & options]
|
|
||||||
`(let [listeners# (u/get-obj ~screen :ui-listeners)
|
|
||||||
^FocusListener object# (u/get-obj listeners# :focus-listener)]
|
|
||||||
(u/call! object# ~k ~@options)))
|
|
||||||
|
|
||||||
(defn ^:private ui-listeners
|
(defn ^:private ui-listeners
|
||||||
[options execute-fn!]
|
[options execute-fn!]
|
||||||
{:actor-gesture-listener (actor-gesture-listener options execute-fn!)
|
{:actor-gesture-listener (actor-gesture-listener options execute-fn!)
|
||||||
|
|||||||
@@ -10,8 +10,10 @@
|
|||||||
Dialog HorizontalGroup Image ImageButton ImageTextButton Label
|
Dialog HorizontalGroup Image ImageButton ImageTextButton Label
|
||||||
ScrollPane SelectBox Skin Slider Stack Table TextButton TextField
|
ScrollPane SelectBox Skin Slider Stack Table TextButton TextField
|
||||||
Tree Tree$Node VerticalGroup WidgetGroup Window]
|
Tree Tree$Node VerticalGroup WidgetGroup Window]
|
||||||
[com.badlogic.gdx.scenes.scene2d.utils NinePatchDrawable
|
[com.badlogic.gdx.scenes.scene2d.utils ActorGestureListener
|
||||||
SpriteDrawable TextureRegionDrawable TiledDrawable]
|
ChangeListener ClickListener DragListener FocusListener
|
||||||
|
NinePatchDrawable SpriteDrawable TextureRegionDrawable
|
||||||
|
TiledDrawable]
|
||||||
[com.esotericsoftware.tablelayout Cell]
|
[com.esotericsoftware.tablelayout Cell]
|
||||||
[play_clj.entities ActorEntity]))
|
[play_clj.entities ActorEntity]))
|
||||||
|
|
||||||
@@ -57,6 +59,47 @@ based on the file at `path`.
|
|||||||
[k]
|
[k]
|
||||||
`~(u/gdx-field :scenes :scene2d :utils :Align (u/key->camel k)))
|
`~(u/gdx-field :scenes :scene2d :utils :Align (u/key->camel k)))
|
||||||
|
|
||||||
|
(defmacro actor-gesture-listener!
|
||||||
|
"Calls a single method on the [ActorGestureListener](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/ActorGestureListener.html)
|
||||||
|
in the `screen`."
|
||||||
|
[screen k & options]
|
||||||
|
`(let [listeners# (u/get-obj ~screen :ui-listeners)
|
||||||
|
^ActorGestureListener object#
|
||||||
|
(u/get-obj listeners# :actor-gesture-listener)]
|
||||||
|
(u/call! object# ~k ~@options)))
|
||||||
|
|
||||||
|
(defmacro change-listener!
|
||||||
|
"Calls a single method on the [ChangeListener](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/ChangeListener.html)
|
||||||
|
in the `screen`."
|
||||||
|
[screen k & options]
|
||||||
|
`(let [listeners# (u/get-obj ~screen :ui-listeners)
|
||||||
|
^ChangeListener object# (u/get-obj listeners# :change-listener)]
|
||||||
|
(u/call! object# ~k ~@options)))
|
||||||
|
|
||||||
|
(defmacro click-listener!
|
||||||
|
"Calls a single method on the [ClickListener](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/ClickListener.html)
|
||||||
|
in the `screen`."
|
||||||
|
[screen k & options]
|
||||||
|
`(let [listeners# (u/get-obj ~screen :ui-listeners)
|
||||||
|
^ClickListener object# (u/get-obj listeners# :click-listener)]
|
||||||
|
(u/call! object# ~k ~@options)))
|
||||||
|
|
||||||
|
(defmacro drag-listener!
|
||||||
|
"Calls a single method on the [DragListener](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/DragListener.html)
|
||||||
|
in the `screen`."
|
||||||
|
[screen k & options]
|
||||||
|
`(let [listeners# (u/get-obj ~screen :ui-listeners)
|
||||||
|
^DragListener object# (u/get-obj listeners# :drag-listener)]
|
||||||
|
(u/call! object# ~k ~@options)))
|
||||||
|
|
||||||
|
(defmacro focus-listener!
|
||||||
|
"Calls a single method on the [FocusListener](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/FocusListener.html)
|
||||||
|
in the `screen`."
|
||||||
|
[screen k & options]
|
||||||
|
`(let [listeners# (u/get-obj ~screen :ui-listeners)
|
||||||
|
^FocusListener object# (u/get-obj listeners# :focus-listener)]
|
||||||
|
(u/call! object# ~k ~@options)))
|
||||||
|
|
||||||
(defn cell!
|
(defn cell!
|
||||||
"Calls a single method on a [Cell](https://github.com/libgdx/libgdx/blob/master/gdx/src/com/esotericsoftware/tablelayout/Cell.java)."
|
"Calls a single method on a [Cell](https://github.com/libgdx/libgdx/blob/master/gdx/src/com/esotericsoftware/tablelayout/Cell.java)."
|
||||||
[^Cell cell & args]
|
[^Cell cell & args]
|
||||||
|
|||||||
Reference in New Issue
Block a user