Refactor for better organization
This commit is contained in:
@@ -70,6 +70,10 @@
|
|||||||
(u/calls! ^TextureRegion (:object entity#) ~@options)
|
(u/calls! ^TextureRegion (:object entity#) ~@options)
|
||||||
entity#))
|
entity#))
|
||||||
|
|
||||||
|
(defmacro texture!
|
||||||
|
[entity k & options]
|
||||||
|
`(u/call! ^TextureRegion (:object ~entity) ~k ~@options))
|
||||||
|
|
||||||
(defmacro animation
|
(defmacro animation
|
||||||
[duration textures & args]
|
[duration textures & args]
|
||||||
`(Animation. ~duration
|
`(Animation. ~duration
|
||||||
@@ -82,9 +86,3 @@
|
|||||||
(texture* (.getKeyFrame animation total-time true)))
|
(texture* (.getKeyFrame animation total-time true)))
|
||||||
([{:keys [total-time]} ^Animation animation is-looping?]
|
([{:keys [total-time]} ^Animation animation is-looping?]
|
||||||
(texture* (.getKeyFrame animation total-time is-looping?))))
|
(texture* (.getKeyFrame animation total-time is-looping?))))
|
||||||
|
|
||||||
; interop
|
|
||||||
|
|
||||||
(defmacro texture!
|
|
||||||
[entity k & options]
|
|
||||||
`(u/call! ^TextureRegion (:object ~entity) ~k ~@options))
|
|
||||||
|
|||||||
@@ -37,113 +37,6 @@
|
|||||||
[key]
|
[key]
|
||||||
`(u/static-field-lower :scenes :scene2d :utils :Align ~key))
|
`(u/static-field-lower :scenes :scene2d :utils :Align ~key))
|
||||||
|
|
||||||
; widgets
|
|
||||||
|
|
||||||
(defn check-box*
|
|
||||||
[^String text arg]
|
|
||||||
(u/create-entity (CheckBox. text arg)))
|
|
||||||
|
|
||||||
(defmacro check-box
|
|
||||||
[text arg & options]
|
|
||||||
`(let [entity# (check-box* ~text ~arg)]
|
|
||||||
(u/calls! ^CheckBox (:object entity#) ~@options)
|
|
||||||
entity#))
|
|
||||||
|
|
||||||
(defn image*
|
|
||||||
[arg]
|
|
||||||
(u/create-entity
|
|
||||||
(cond
|
|
||||||
(map? arg)
|
|
||||||
(Image. ^TextureRegion (:object arg))
|
|
||||||
(string? arg)
|
|
||||||
(Image. (Texture. ^String arg))
|
|
||||||
:else
|
|
||||||
(Image. arg))))
|
|
||||||
|
|
||||||
(defmacro image
|
|
||||||
[arg & options]
|
|
||||||
`(let [entity# (image* ~arg)]
|
|
||||||
(u/calls! ^Image (:object entity#) ~@options)
|
|
||||||
entity#))
|
|
||||||
|
|
||||||
(defn image-button*
|
|
||||||
[arg]
|
|
||||||
(u/create-entity (ImageButton. arg)))
|
|
||||||
|
|
||||||
(defmacro image-button
|
|
||||||
[arg & options]
|
|
||||||
`(let [entity# (image-button* ~arg)]
|
|
||||||
(u/calls! ^ImageButton (:object entity#) ~@options)
|
|
||||||
entity#))
|
|
||||||
|
|
||||||
(defn image-text-button*
|
|
||||||
[^String text arg]
|
|
||||||
(u/create-entity (ImageTextButton. text arg)))
|
|
||||||
|
|
||||||
(defmacro image-text-button
|
|
||||||
[text arg & options]
|
|
||||||
`(let [entity# (image-text-button* ~text ~arg)]
|
|
||||||
(u/calls! ^ImageTextButton (:object entity#) ~@options)
|
|
||||||
entity#))
|
|
||||||
|
|
||||||
(defn label*
|
|
||||||
[^String text arg]
|
|
||||||
(u/create-entity
|
|
||||||
(if (isa? (type arg) Color)
|
|
||||||
(Label. text (style :label (bitmap-font) arg))
|
|
||||||
(Label. text arg))))
|
|
||||||
|
|
||||||
(defmacro label
|
|
||||||
[text arg & options]
|
|
||||||
`(let [entity# (label* ~text ~arg)]
|
|
||||||
(u/calls! ^Label (:object entity#) ~@options)
|
|
||||||
entity#))
|
|
||||||
|
|
||||||
(defn slider*
|
|
||||||
[{:keys [min max step vertical?]
|
|
||||||
:or {min 0 max 10 step 1 vertical? false}}
|
|
||||||
arg]
|
|
||||||
(u/create-entity
|
|
||||||
(Slider. (float min) (float max) (float step) vertical? arg)))
|
|
||||||
|
|
||||||
(defmacro slider
|
|
||||||
[attrs arg & options]
|
|
||||||
`(let [entity# (slider* ~attrs ~arg)]
|
|
||||||
(u/calls! ^Slider (:object entity#) ~@options)
|
|
||||||
entity#))
|
|
||||||
|
|
||||||
(defn text-button*
|
|
||||||
[^String text arg]
|
|
||||||
(u/create-entity (TextButton. text arg)))
|
|
||||||
|
|
||||||
(defmacro text-button
|
|
||||||
[text arg & options]
|
|
||||||
`(let [entity# (text-button* ~text ~arg)]
|
|
||||||
(u/calls! ^TextButton (:object entity#) ~@options)
|
|
||||||
entity#))
|
|
||||||
|
|
||||||
(defn text-field*
|
|
||||||
[^String text arg]
|
|
||||||
(u/create-entity (TextField. text arg)))
|
|
||||||
|
|
||||||
(defmacro text-field
|
|
||||||
[text arg & options]
|
|
||||||
`(let [entity# (text-field* ~text ~arg)]
|
|
||||||
(u/calls! ^TextField (:object entity#) ~@options)
|
|
||||||
entity#))
|
|
||||||
|
|
||||||
(defn dialog*
|
|
||||||
[text arg]
|
|
||||||
(u/create-entity (Dialog. text arg)))
|
|
||||||
|
|
||||||
(defmacro dialog
|
|
||||||
[text arg & options]
|
|
||||||
`(let [entity# (dialog* ~text ~arg)]
|
|
||||||
(u/calls! ^Dialog (:object entity#) ~@options)
|
|
||||||
entity#))
|
|
||||||
|
|
||||||
; groups
|
|
||||||
|
|
||||||
(defmulti add-to-group! #(-> % first :object type) :default WidgetGroup)
|
(defmulti add-to-group! #(-> % first :object type) :default WidgetGroup)
|
||||||
|
|
||||||
(defmethod add-to-group! WidgetGroup
|
(defmethod add-to-group! WidgetGroup
|
||||||
@@ -168,36 +61,189 @@
|
|||||||
u/create-entity
|
u/create-entity
|
||||||
(add! children)))
|
(add! children)))
|
||||||
|
|
||||||
|
; widgets
|
||||||
|
|
||||||
|
(defn check-box*
|
||||||
|
[^String text arg]
|
||||||
|
(u/create-entity (CheckBox. text arg)))
|
||||||
|
|
||||||
|
(defmacro check-box
|
||||||
|
[text arg & options]
|
||||||
|
`(let [entity# (check-box* ~text ~arg)]
|
||||||
|
(u/calls! ^CheckBox (:object entity#) ~@options)
|
||||||
|
entity#))
|
||||||
|
|
||||||
|
(defmacro check-box!
|
||||||
|
[entity k & options]
|
||||||
|
`(u/call! ^Checkbox (:object ~entity) ~k ~@options))
|
||||||
|
|
||||||
|
(defn dialog*
|
||||||
|
[text arg]
|
||||||
|
(u/create-entity (Dialog. text arg)))
|
||||||
|
|
||||||
|
(defmacro dialog
|
||||||
|
[text arg & options]
|
||||||
|
`(let [entity# (dialog* ~text ~arg)]
|
||||||
|
(u/calls! ^Dialog (:object entity#) ~@options)
|
||||||
|
entity#))
|
||||||
|
|
||||||
|
(defmacro dialog!
|
||||||
|
[entity k & options]
|
||||||
|
`(u/call! ^Dialog (:object ~entity) ~k ~@options))
|
||||||
|
|
||||||
(defn horizontal*
|
(defn horizontal*
|
||||||
[children]
|
[children]
|
||||||
(create-group (HorizontalGroup.) children))
|
(create-group (HorizontalGroup.) children))
|
||||||
|
|
||||||
(defn vertical*
|
|
||||||
[children]
|
|
||||||
(create-group (VerticalGroup.) children))
|
|
||||||
|
|
||||||
(defn table*
|
|
||||||
[children]
|
|
||||||
(create-group (Table.) children))
|
|
||||||
|
|
||||||
(defmacro horizontal
|
(defmacro horizontal
|
||||||
[children & options]
|
[children & options]
|
||||||
`(let [entity# (horizontal* ~children)]
|
`(let [entity# (horizontal* ~children)]
|
||||||
(u/calls! ^HorizontalGroup (:object entity#) ~@options)
|
(u/calls! ^HorizontalGroup (:object entity#) ~@options)
|
||||||
entity#))
|
entity#))
|
||||||
|
|
||||||
(defmacro vertical
|
(defmacro horizontal!
|
||||||
[children & options]
|
[entity k & options]
|
||||||
`(let [entity# (vertical* ~children)]
|
`(u/call! ^HorizontalGroup (:object ~entity) ~k ~@options))
|
||||||
(u/calls! ^VerticalGroup (:object entity#) ~@options)
|
|
||||||
|
(defn image*
|
||||||
|
[arg]
|
||||||
|
(u/create-entity
|
||||||
|
(cond
|
||||||
|
(map? arg)
|
||||||
|
(Image. ^TextureRegion (:object arg))
|
||||||
|
(string? arg)
|
||||||
|
(Image. (Texture. ^String arg))
|
||||||
|
:else
|
||||||
|
(Image. arg))))
|
||||||
|
|
||||||
|
(defmacro image
|
||||||
|
[arg & options]
|
||||||
|
`(let [entity# (image* ~arg)]
|
||||||
|
(u/calls! ^Image (:object entity#) ~@options)
|
||||||
entity#))
|
entity#))
|
||||||
|
|
||||||
|
(defmacro image!
|
||||||
|
[entity k & options]
|
||||||
|
`(u/call! ^Image (:object ~entity) ~k ~@options))
|
||||||
|
|
||||||
|
(defn image-button*
|
||||||
|
[arg]
|
||||||
|
(u/create-entity (ImageButton. arg)))
|
||||||
|
|
||||||
|
(defmacro image-button
|
||||||
|
[arg & options]
|
||||||
|
`(let [entity# (image-button* ~arg)]
|
||||||
|
(u/calls! ^ImageButton (:object entity#) ~@options)
|
||||||
|
entity#))
|
||||||
|
|
||||||
|
(defmacro image-button!
|
||||||
|
[entity k & options]
|
||||||
|
`(u/call! ^ImageButton (:object ~entity) ~k ~@options))
|
||||||
|
|
||||||
|
(defn image-text-button*
|
||||||
|
[^String text arg]
|
||||||
|
(u/create-entity (ImageTextButton. text arg)))
|
||||||
|
|
||||||
|
(defmacro image-text-button
|
||||||
|
[text arg & options]
|
||||||
|
`(let [entity# (image-text-button* ~text ~arg)]
|
||||||
|
(u/calls! ^ImageTextButton (:object entity#) ~@options)
|
||||||
|
entity#))
|
||||||
|
|
||||||
|
(defmacro image-text-button!
|
||||||
|
[entity k & options]
|
||||||
|
`(u/call! ^ImageTextButton (:object ~entity) ~k ~@options))
|
||||||
|
|
||||||
|
(defn label*
|
||||||
|
[^String text arg]
|
||||||
|
(u/create-entity
|
||||||
|
(if (isa? (type arg) Color)
|
||||||
|
(Label. text (style :label (bitmap-font) arg))
|
||||||
|
(Label. text arg))))
|
||||||
|
|
||||||
|
(defmacro label
|
||||||
|
[text arg & options]
|
||||||
|
`(let [entity# (label* ~text ~arg)]
|
||||||
|
(u/calls! ^Label (:object entity#) ~@options)
|
||||||
|
entity#))
|
||||||
|
|
||||||
|
(defmacro label!
|
||||||
|
[entity k & options]
|
||||||
|
`(u/call! ^Label (:object ~entity) ~k ~@options))
|
||||||
|
|
||||||
|
(defn slider*
|
||||||
|
[{:keys [min max step vertical?]
|
||||||
|
:or {min 0 max 10 step 1 vertical? false}}
|
||||||
|
arg]
|
||||||
|
(u/create-entity
|
||||||
|
(Slider. (float min) (float max) (float step) vertical? arg)))
|
||||||
|
|
||||||
|
(defmacro slider
|
||||||
|
[attrs arg & options]
|
||||||
|
`(let [entity# (slider* ~attrs ~arg)]
|
||||||
|
(u/calls! ^Slider (:object entity#) ~@options)
|
||||||
|
entity#))
|
||||||
|
|
||||||
|
(defmacro slider!
|
||||||
|
[entity k & options]
|
||||||
|
`(u/call! ^Slider (:object ~entity) ~k ~@options))
|
||||||
|
|
||||||
|
(defn table*
|
||||||
|
[children]
|
||||||
|
(create-group (Table.) children))
|
||||||
|
|
||||||
(defmacro table
|
(defmacro table
|
||||||
[children & options]
|
[children & options]
|
||||||
`(let [entity# (table* ~children)]
|
`(let [entity# (table* ~children)]
|
||||||
(u/calls! ^Table (:object entity#) ~@options)
|
(u/calls! ^Table (:object entity#) ~@options)
|
||||||
entity#))
|
entity#))
|
||||||
|
|
||||||
|
(defmacro table!
|
||||||
|
[entity k & options]
|
||||||
|
`(u/call! ^Table (:object ~entity) ~k ~@options))
|
||||||
|
|
||||||
|
(defn text-button*
|
||||||
|
[^String text arg]
|
||||||
|
(u/create-entity (TextButton. text arg)))
|
||||||
|
|
||||||
|
(defmacro text-button
|
||||||
|
[text arg & options]
|
||||||
|
`(let [entity# (text-button* ~text ~arg)]
|
||||||
|
(u/calls! ^TextButton (:object entity#) ~@options)
|
||||||
|
entity#))
|
||||||
|
|
||||||
|
(defmacro text-button!
|
||||||
|
[entity k & options]
|
||||||
|
`(u/call! ^TextButton (:object ~entity) ~k ~@options))
|
||||||
|
|
||||||
|
(defn text-field*
|
||||||
|
[^String text arg]
|
||||||
|
(u/create-entity (TextField. text arg)))
|
||||||
|
|
||||||
|
(defmacro text-field
|
||||||
|
[text arg & options]
|
||||||
|
`(let [entity# (text-field* ~text ~arg)]
|
||||||
|
(u/calls! ^TextField (:object entity#) ~@options)
|
||||||
|
entity#))
|
||||||
|
|
||||||
|
(defmacro text-field!
|
||||||
|
[entity k & options]
|
||||||
|
`(u/call! ^TextField (:object ~entity) ~k ~@options))
|
||||||
|
|
||||||
|
(defn vertical*
|
||||||
|
[children]
|
||||||
|
(create-group (VerticalGroup.) children))
|
||||||
|
|
||||||
|
(defmacro vertical
|
||||||
|
[children & options]
|
||||||
|
`(let [entity# (vertical* ~children)]
|
||||||
|
(u/calls! ^VerticalGroup (:object entity#) ~@options)
|
||||||
|
entity#))
|
||||||
|
|
||||||
|
(defmacro vertical!
|
||||||
|
[entity k & options]
|
||||||
|
`(u/call! ^VerticalGroup (:object ~entity) ~k ~@options))
|
||||||
|
|
||||||
; listeners
|
; listeners
|
||||||
|
|
||||||
(defn ^:private gesture-listener
|
(defn ^:private gesture-listener
|
||||||
@@ -286,49 +332,3 @@
|
|||||||
(click-listener options execute-fn!)
|
(click-listener options execute-fn!)
|
||||||
(drag-listener options execute-fn!)
|
(drag-listener options execute-fn!)
|
||||||
(focus-listener options execute-fn!)])
|
(focus-listener options execute-fn!)])
|
||||||
|
|
||||||
; interop
|
|
||||||
|
|
||||||
(defmacro check-box!
|
|
||||||
[entity k & options]
|
|
||||||
`(u/call! ^Checkbox (:object ~entity) ~k ~@options))
|
|
||||||
|
|
||||||
(defmacro image-button!
|
|
||||||
[entity k & options]
|
|
||||||
`(u/call! ^ImageButton (:object ~entity) ~k ~@options))
|
|
||||||
|
|
||||||
(defmacro image-text-button!
|
|
||||||
[entity k & options]
|
|
||||||
`(u/call! ^ImageTextButton (:object ~entity) ~k ~@options))
|
|
||||||
|
|
||||||
(defmacro label!
|
|
||||||
[entity k & options]
|
|
||||||
`(u/call! ^Label (:object ~entity) ~k ~@options))
|
|
||||||
|
|
||||||
(defmacro slider!
|
|
||||||
[entity k & options]
|
|
||||||
`(u/call! ^Slider (:object ~entity) ~k ~@options))
|
|
||||||
|
|
||||||
(defmacro text-button!
|
|
||||||
[entity k & options]
|
|
||||||
`(u/call! ^TextButton (:object ~entity) ~k ~@options))
|
|
||||||
|
|
||||||
(defmacro text-field!
|
|
||||||
[entity k & options]
|
|
||||||
`(u/call! ^TextField (:object ~entity) ~k ~@options))
|
|
||||||
|
|
||||||
(defmacro dialog!
|
|
||||||
[entity k & options]
|
|
||||||
`(u/call! ^Dialog (:object ~entity) ~k ~@options))
|
|
||||||
|
|
||||||
(defmacro horizontal!
|
|
||||||
[entity k & options]
|
|
||||||
`(u/call! ^HorizontalGroup (:object ~entity) ~k ~@options))
|
|
||||||
|
|
||||||
(defmacro vertical!
|
|
||||||
[entity k & options]
|
|
||||||
`(u/call! ^VerticalGroup (:object ~entity) ~k ~@options))
|
|
||||||
|
|
||||||
(defmacro table!
|
|
||||||
[entity k & options]
|
|
||||||
`(u/call! ^Table (:object ~entity) ~k ~@options))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user