diff --git a/README.md b/README.md
index da5806f..60931e1 100644
--- a/README.md
+++ b/README.md
@@ -81,7 +81,7 @@ function on_message(self, message_id, message, sender)
end
function on_input(self, action_id, action)
- self.druid:on_input(action_id, action)
+ return self.druid:on_input(action_id, action)
end
```
@@ -113,7 +113,7 @@ function M.update(self, dt)
end
--- Call only if exist interest: const.ON_INPUT or const.ON_SWIPE
+-- Call only if exist interest: const.ON_INPUT or const.ON_INPUT_HIGH
function M.on_input(self, action_id, action)
end
@@ -123,8 +123,8 @@ function M.on_message(self, message_id, message, sender)
end
--- Call only if swipe was started on another component (ex. scroll)
-function M.on_swipe(self)
+-- Call if input was interrupt by previous components (ex. scroll)
+function M.on_input_interrupt(self)
end
@@ -178,7 +178,7 @@ _TODO_
- update
- on_input
- on_message
-- on_swipe
+- on_input_interrupt
- setup_component
- get_style
- set_style
diff --git a/alpha_todo.txt b/alpha_todo.txt
new file mode 100644
index 0000000..fbbf68e
--- /dev/null
+++ b/alpha_todo.txt
@@ -0,0 +1,38 @@
+Simple to-do for Druid Alpha 0.2.0
+
+
+-- High
++ remove button event and match_event from druid
++ add hover component
++ add druid events/triggers? better callback system
++ better name for locale component? lang? lang_text?
++ better name for slider component? Slider is ok
++ Druid store assets - separate repository with rich components (progress_rich migrate)
++ refactor on_swipe. To on_scroll? Add input priority
++ separate custom data and predefined fields in components? Every component have their fields and events
+- add init/remove stuff for every style in component. How to set custom sprites for button states?
+- add druid settings (add auto_focus input and other stuff)
+
++ button add key trigger
+- button polish, actions
++ button and hover click restriction zone?
+
+- unify component api (get/set/to and other general stuff)
+- better callbacks for every components
+- better scroll size management, check different cases. So implicit now
+- better grid + scroll management
+- better default style, add template for custom style
+- add text component for alpha release
+- compare with gooey
+- add docs for all components
+- add docs folder for every component with gifs? Solutions
+- remove component autoremove all children component
+
+
+-- Low
+- add code template and example for user components
+- custom input settings (name of touch, text, etc)
+- add good examples with template and/or nodes (basic component no use any of them)
+- try use final druid in real project (FI uses custom druid) (use in 4321?)
+- ability to relocalize all locale text nodes
+- ability to control buttons via controller. Select it by cursor (d-pad)
diff --git a/config.ld b/config.ld
index 43d3a05..00b4508 100644
--- a/config.ld
+++ b/config.ld
@@ -2,6 +2,10 @@ project='Druid'
title='Defold Druid UI Library'
description='Documentation for Druid Library'
file={"./druid"}
+package='druid'
+sort=false
dir='./docs'
-style='!pale'
+style='!fixed'
+format='discount'
+use_markdown_titles=true
no_space_before_args=true
\ No newline at end of file
diff --git a/docs/index.html b/docs/index.html
index 193baec..8e850b0 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -4,7 +4,7 @@
Defold Druid UI Library
-
+
@@ -37,7 +37,8 @@
druid.checkbox
druid.checkbox_group
druid.grid
- druid.locale
+ druid.input
+ druid.lang_text
druid.progress
druid.radio_group
druid.scroll
@@ -46,8 +47,8 @@
druid.timer
component
druid
- helper
- druid.progress_rich
+ druid_event
+ druid.helper
druid_instance
@@ -85,7 +86,11 @@
Component to handle placing components by row and columns.
- druid.locale
+ druid.input
+ Component to handle hover node interaction
+
+
+ druid.lang_text
Component to handle all GUI texts
Good working with localization system
@@ -123,12 +128,12 @@
Druid UI Library.
- helper
- Text node or icon node can be nil
+ druid_event
+ Lua event small library
- druid.progress_rich
- Component for rich progress component
+ druid.helper
+ Text node or icon node can be nil
druid_instance
@@ -140,7 +145,7 @@
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:09:38
+
Last updated 2020-02-24 00:03:02
diff --git a/docs/ldoc_pale.css b/docs/ldoc_fixed.css
similarity index 95%
rename from docs/ldoc_pale.css
rename to docs/ldoc_fixed.css
index 4202bd3..9b0fc00 100644
--- a/docs/ldoc_pale.css
+++ b/docs/ldoc_fixed.css
@@ -147,16 +147,22 @@ table.index td { text-align: left; vertical-align: top; }
#main {
background-color:#FFFFFF; // #f0f0f0;
- //border-left: 2px solid #cccccc;
+ border-left: 1px solid #cccccc;
}
#navigation {
+ position: fixed;
+ top: 0;
+ left: 0;
float: left;
width: 14em;
vertical-align: top;
background-color:#FFFFFF; // #f0f0f0;
border-right: 2px solid #cccccc;
overflow: visible;
+ overflow-y: scroll;
+ height: 100%;
+ padding-left: 1em;
}
#navigation h2 {
@@ -165,7 +171,6 @@ table.index td { text-align: left; vertical-align: top; }
color:#000000;
text-align: left;
padding:0.2em;
- //border-top:1px solid #dddddd;
border-bottom:1px solid #dddddd;
}
@@ -189,6 +194,7 @@ table.index td { text-align: left; vertical-align: top; }
#content {
margin-left: 14em;
padding: 1em;
+ padding-left: 2em;
width: 700px;
border-left: 2px solid #cccccc;
// border-right: 2px solid #cccccc;
@@ -197,8 +203,10 @@ table.index td { text-align: left; vertical-align: top; }
#about {
clear: both;
- padding: 5px;
+ padding-left: 1em;
+ margin-left: 14em; // avoid the damn sidebar!
border-top: 2px solid #cccccc;
+ border-left: 2px solid #cccccc;
background-color: #ffffff;
}
diff --git a/docs/modules/component.html b/docs/modules/component.html
index 5923cd0..03ef47b 100644
--- a/docs/modules/component.html
+++ b/docs/modules/component.html
@@ -4,7 +4,7 @@
Defold Druid UI Library
-
+
@@ -44,7 +44,8 @@
druid.checkbox
druid.checkbox_group
druid.grid
- druid.locale
+ druid.input
+ druid.lang_text
druid.progress
druid.radio_group
druid.scroll
@@ -53,8 +54,8 @@
druid.timer
component
druid
- helper
- druid.progress_rich
+ druid_event
+ druid.helper
druid_instance
@@ -64,16 +65,11 @@
Module component
Basic class for all Druid components.
-
- To create you component, use `component.create`
+ To create you component, use component.create
-
- setup_component(table, table)
- Setup component context and his style table
-
get_style()
Get current component style table
@@ -115,6 +111,10 @@
Return druid with context of calling component.
+ setup_component(table, table)
+ Setup component context and his style table
+
+
Component.create(name, interest)
Create new component.
@@ -127,37 +127,6 @@
-
-
- setup_component(table, table)
-
-
- Setup component context and his style table
-
-
- Parameters:
-
- table
- style
- Druid style module
-
- table
- style
- Druid style module
-
-
-
- Returns:
-
-
- Component
- Component itself
-
-
-
-
-
-
get_style()
@@ -362,6 +331,37 @@
+
+
+
+ setup_component(table, table)
+
+
+ Setup component context and his style table
+
+
+ Parameters:
+
+ table
+ style
+ Druid style module
+
+ table
+ style
+ Druid style module
+
+
+
+ Returns:
+
+
+ Component
+ Component itself
+
+
+
+
+
@@ -396,7 +396,7 @@
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:09:38
+
Last updated 2020-02-24 00:03:02
diff --git a/docs/modules/druid.back_handler.html b/docs/modules/druid.back_handler.html
index c0b420f..2943f1f 100644
--- a/docs/modules/druid.back_handler.html
+++ b/docs/modules/druid.back_handler.html
@@ -4,7 +4,7 @@
Defold Druid UI Library
-
+
@@ -44,7 +44,8 @@
druid.checkbox
druid.checkbox_group
druid.grid
- druid.locale
+ druid.input
+ druid.lang_text
druid.progress
druid.radio_group
druid.scroll
@@ -53,8 +54,8 @@
druid.timer
component
druid
- helper
- druid.progress_rich
+ druid_event
+ druid.helper
druid_instance
@@ -64,7 +65,9 @@
Module druid.back_handler
Component to handle back key (android, backspace)
-
+
+
+
@@ -148,7 +151,7 @@
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:09:38
+
Last updated 2020-02-24 00:03:02
diff --git a/docs/modules/druid.blocker.html b/docs/modules/druid.blocker.html
index e1924ab..ad72a4e 100644
--- a/docs/modules/druid.blocker.html
+++ b/docs/modules/druid.blocker.html
@@ -4,7 +4,7 @@
Defold Druid UI Library
-
+
@@ -40,7 +40,8 @@
druid.checkbox
druid.checkbox_group
druid.grid
- druid.locale
+ druid.input
+ druid.lang_text
druid.progress
druid.radio_group
druid.scroll
@@ -49,8 +50,8 @@
druid.timer
component
druid
- helper
- druid.progress_rich
+ druid_event
+ druid.helper
druid_instance
@@ -60,7 +61,9 @@
Module druid.blocker
Component to block input on specify zone (node)
-
+
+
+
@@ -74,7 +77,7 @@
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:09:38
+
Last updated 2020-02-24 00:03:02
diff --git a/docs/modules/druid.button.html b/docs/modules/druid.button.html
index 7e0edbc..886be31 100644
--- a/docs/modules/druid.button.html
+++ b/docs/modules/druid.button.html
@@ -4,7 +4,7 @@
Defold Druid UI Library
-
+
@@ -33,6 +33,7 @@
Contents
@@ -44,7 +45,8 @@
druid.checkbox
druid.checkbox_group
druid.grid
- druid.locale
+ druid.input
+ druid.lang_text
druid.progress
druid.radio_group
druid.scroll
@@ -53,8 +55,8 @@
druid.timer
component
druid
- helper
- druid.progress_rich
+ druid_event
+ druid.helper
druid_instance
@@ -64,7 +66,9 @@
Module druid.button
Component to handle basic GUI button
-
+
+
+
@@ -81,6 +85,25 @@
set_click_zone(self, zone)
Strict button click area.
+
+ get_key_trigger(self)
+ Get key-code to trigger this button
+
+
+
+
+
+ Events
+ Component events
+
+
+ Fields
+ Component fields
+
+
+ Style
+ Component style params
+
@@ -180,6 +203,155 @@
+
+
+
+ get_key_trigger(self)
+
+
+ Get key-code to trigger this button
+
+
+ Parameters:
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Events
+
+
+ Component events
+
+
+ Fields:
+
+ on_click
+ druid_event
+ On release button callback
+
+ on_repeated_click
+ druid_event
+ On repeated action button callback
+
+ on_long_click
+ druid_event
+ On long tap button callback
+
+ on_double_click
+ druid_event
+ On double tap button callback
+
+
+
+
+
+
+
+
+
+
+ Fields
+
+
+ Component fields
+
+
+ Fields:
+
+ node
+ node
+ Trigger node
+
+ anim_node
+ node
+ Animation node
+ (default node)
+
+ scale_from
+ vector3
+ Initial scale of anim_node
+
+ pos
+ vector3
+ Initial pos of anim_node
+
+ params
+ any
+ Params to click callbacks
+
+ hover_anim
+ boolean
+ Is hover anim enabled
+
+ hover
+ druid.hover
+ Druid hover logic component
+
+ click_zone
+ node
+ Restriction zone
+ (optional )
+
+
+
+
+
+
+
+
+
+
+ Style
+
+
+ Component style params
+
+
+ Fields:
+
+ on_click
+ function
+ (self, node)
+
+ on_click_disabled
+ function
+ (self, node)
+
+ on_hover
+ function
+ (self, node, hover_state)
+
+ on_set_enabled
+ function
+ (self, node, enabled_state)
+
+ IS_HOVER
+ bool
+
+
+
+
+
+
+
+
+
+
@@ -188,7 +360,7 @@
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:09:38
+
Last updated 2020-02-24 00:03:02
diff --git a/docs/modules/druid.checkbox.html b/docs/modules/druid.checkbox.html
index 51a2f75..66054fe 100644
--- a/docs/modules/druid.checkbox.html
+++ b/docs/modules/druid.checkbox.html
@@ -4,7 +4,7 @@
Defold Druid UI Library
-
+
@@ -40,7 +40,8 @@
druid.checkbox
druid.checkbox_group
druid.grid
- druid.locale
+ druid.input
+ druid.lang_text
druid.progress
druid.radio_group
druid.scroll
@@ -49,8 +50,8 @@
druid.timer
component
druid
- helper
- druid.progress_rich
+ druid_event
+ druid.helper
druid_instance
@@ -60,7 +61,9 @@
Module druid.checkbox
Druid checkbox component
-
+
+
+
@@ -74,7 +77,7 @@
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:09:38
+
Last updated 2020-02-24 00:03:02
diff --git a/docs/modules/druid.checkbox_group.html b/docs/modules/druid.checkbox_group.html
index 0071b08..1c40d26 100644
--- a/docs/modules/druid.checkbox_group.html
+++ b/docs/modules/druid.checkbox_group.html
@@ -4,7 +4,7 @@
Defold Druid UI Library
-
+
@@ -40,7 +40,8 @@
druid.checkbox
druid.checkbox_group
druid.grid
- druid.locale
+ druid.input
+ druid.lang_text
druid.progress
druid.radio_group
druid.scroll
@@ -49,8 +50,8 @@
druid.timer
component
druid
- helper
- druid.progress_rich
+ druid_event
+ druid.helper
druid_instance
@@ -60,7 +61,9 @@
Module druid.checkbox_group
Checkboux group module
-
+
+
+
@@ -74,7 +77,7 @@
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:09:38
+
Last updated 2020-02-24 00:03:02
diff --git a/docs/modules/druid.grid.html b/docs/modules/druid.grid.html
index 9321a7f..69dee2b 100644
--- a/docs/modules/druid.grid.html
+++ b/docs/modules/druid.grid.html
@@ -4,7 +4,7 @@
Defold Druid UI Library
-
+
@@ -40,7 +40,8 @@
druid.checkbox
druid.checkbox_group
druid.grid
- druid.locale
+ druid.input
+ druid.lang_text
druid.progress
druid.radio_group
druid.scroll
@@ -49,8 +50,8 @@
druid.timer
component
druid
- helper
- druid.progress_rich
+ druid_event
+ druid.helper
druid_instance
@@ -60,8 +61,7 @@
Module druid.grid
Component to handle placing components by row and columns.
-
- Grid can anchor your elements, get content size and other
+ Grid can anchor your elements, get content size and other
@@ -75,7 +75,7 @@
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:09:38
+
Last updated 2020-02-24 00:03:02
diff --git a/docs/modules/helper.html b/docs/modules/druid.helper.html
similarity index 70%
rename from docs/modules/helper.html
rename to docs/modules/druid.helper.html
index 0577525..c81e977 100644
--- a/docs/modules/helper.html
+++ b/docs/modules/druid.helper.html
@@ -4,7 +4,7 @@
Defold Druid UI Library
-
+
@@ -44,7 +44,8 @@
druid.checkbox
druid.checkbox_group
druid.grid
- druid.locale
+ druid.input
+ druid.lang_text
druid.progress
druid.radio_group
druid.scroll
@@ -53,8 +54,8 @@
druid.timer
component
druid
- helper
- druid.progress_rich
+ druid_event
+ druid.helper
druid_instance
@@ -62,9 +63,11 @@
-
Module helper
+
Module druid.helper
Text node or icon node can be nil
-
+
+
+
@@ -77,6 +80,14 @@
centrate_icon_with_text([icon_node[, text_node[, margin=0]]])
Center two nodes.
+
+ is_enabled(node)
+ Check if node is enabled in gui hierarchy.
+
+
+ get_pivot_offset(pivot)
+ Get node offset for given gui pivot
+
@@ -152,6 +163,61 @@
+
+
+
+ is_enabled(node)
+
+
+ Check if node is enabled in gui hierarchy.
+ Return false, if node or any his parent is disabled
+
+
+ Parameters:
+
+ node
+ node
+ Gui node
+
+
+
+ Returns:
+
+
+ bool
+ Is enabled in hierarchy
+
+
+
+
+
+
+
+
+ get_pivot_offset(pivot)
+
+
+ Get node offset for given gui pivot
+
+
+ Parameters:
+
+ pivot
+ gui.pivot
+ The node pivot
+
+
+
+ Returns:
+
+
+ vector3
+ Vector offset with [-1..1] values
+
+
+
+
+
@@ -160,7 +226,7 @@
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:09:38
+
Last updated 2020-02-24 00:03:02
diff --git a/docs/modules/druid.html b/docs/modules/druid.html
index 18bfff8..46038ef 100644
--- a/docs/modules/druid.html
+++ b/docs/modules/druid.html
@@ -4,7 +4,7 @@
Defold Druid UI Library
-
+
@@ -44,7 +44,8 @@
druid.checkbox
druid.checkbox_group
druid.grid
- druid.locale
+ druid.input
+ druid.lang_text
druid.progress
druid.radio_group
druid.scroll
@@ -53,8 +54,8 @@
druid.timer
component
druid
- helper
- druid.progress_rich
+ druid_event
+ druid.helper
druid_instance
@@ -65,12 +66,23 @@
Module druid
Druid UI Library.
- Powerful Defold component based UI library. Use standart
+
+
Powerful Defold component based UI library. Use standart
components or make your own game-specific to make amazing
- GUI in your games.
+ GUI in your games.
+
Contains the several basic components and examples
to how to do your custom complex components to
- separate UI game logic to small files
+ separate UI game logic to small files
+
+
+
+require ("druid.druid" )
+function init(self)
+ self.druid = druid.new(self)
+end
+
+
@@ -100,7 +112,7 @@
Register external druid component.
After register you can create the component with
- druid_instance:new_{name}. For example `druid:new_button(...)`
+ druidinstance:new {name}. For example druid:new_button(...)
Parameters:
@@ -159,7 +171,7 @@
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:09:38
+
Last updated 2020-02-24 00:03:02
diff --git a/docs/modules/druid.progress_rich.html b/docs/modules/druid.input.html
similarity index 61%
rename from docs/modules/druid.progress_rich.html
rename to docs/modules/druid.input.html
index 335a6b3..da6d315 100644
--- a/docs/modules/druid.progress_rich.html
+++ b/docs/modules/druid.input.html
@@ -4,7 +4,7 @@
Defold Druid UI Library
-
+
@@ -44,7 +44,8 @@
druid.checkbox
druid.checkbox_group
druid.grid
- druid.locale
+ druid.input
+ druid.lang_text
druid.progress
druid.radio_group
druid.scroll
@@ -53,8 +54,8 @@
druid.timer
component
druid
- helper
- druid.progress_rich
+ druid_event
+ druid.helper
druid_instance
@@ -62,24 +63,22 @@
-
Module druid.progress_rich
-
Component for rich progress component
-
+
Module druid.input
+
Component to handle hover node interaction
+
+
+
@@ -91,11 +90,11 @@
-
- set_to(self, value)
+
+ hover:init(self, node, on_hover_callback)
- Instant fill progress bar to value
+ Component init function
Parameters:
@@ -104,60 +103,39 @@
table
Component instance
- value
- number
- Progress bar value, from 0 to 1
+ node
+ node
+ Gui node
-
-
-
-
-
-
-
-
-
- empty(self)
-
-
- Empty a progress bar
-
-
- Parameters:
-
- self
- table
- Component instance
-
-
-
-
-
-
-
-
-
-
- to(self, to[, callback])
-
-
- Start animation of a progress bar
-
-
- Parameters:
-
- self
- table
- Component instance
-
- to
- number
- value between 0..1
-
- callback
+ on_hover_callback
function
- Callback on animation ends
- (optional )
+ Hover callback
+
+
+
+
+
+
+
+
+
+
+ button:set_click_zone(self, zone)
+
+
+ Strict button click area. Useful for
+ no click events outside stencil node
+
+
+ Parameters:
+
+ self
+ table
+ Component instance
+
+ zone
+ node
+ Gui node
@@ -173,7 +151,7 @@
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:09:38
+
Last updated 2020-02-24 00:03:02
diff --git a/docs/modules/druid.locale.html b/docs/modules/druid.lang_text.html
similarity index 87%
rename from docs/modules/druid.locale.html
rename to docs/modules/druid.lang_text.html
index cd07ef0..9f52f6b 100644
--- a/docs/modules/druid.locale.html
+++ b/docs/modules/druid.lang_text.html
@@ -4,7 +4,7 @@
Defold Druid UI Library
-
+
@@ -44,7 +44,8 @@
druid.checkbox
druid.checkbox_group
druid.grid
- druid.locale
+ druid.input
+ druid.lang_text
druid.progress
druid.radio_group
druid.scroll
@@ -53,8 +54,8 @@
druid.timer
component
druid
- helper
- druid.progress_rich
+ druid_event
+ druid.helper
druid_instance
@@ -62,10 +63,12 @@
-
Module druid.locale
+
Module druid.lang_text
Component to handle all GUI texts
Good working with localization system
-
+
+
+
@@ -115,7 +118,7 @@
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:09:38
+
Last updated 2020-02-24 00:03:02
diff --git a/docs/modules/druid.progress.html b/docs/modules/druid.progress.html
index c133fb8..e8e1115 100644
--- a/docs/modules/druid.progress.html
+++ b/docs/modules/druid.progress.html
@@ -4,7 +4,7 @@
Defold Druid UI Library
-
+
@@ -44,7 +44,8 @@
druid.checkbox
druid.checkbox_group
druid.grid
- druid.locale
+ druid.input
+ druid.lang_text
druid.progress
druid.radio_group
druid.scroll
@@ -53,8 +54,8 @@
druid.timer
component
druid
- helper
- druid.progress_rich
+ druid_event
+ druid.helper
druid_instance
@@ -64,7 +65,9 @@
Module druid.progress
Basic progress bar component
-
+
+
+
@@ -293,7 +296,7 @@
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:09:38
+
Last updated 2020-02-24 00:03:02
diff --git a/docs/modules/druid.radio_group.html b/docs/modules/druid.radio_group.html
index e4db277..5d71a85 100644
--- a/docs/modules/druid.radio_group.html
+++ b/docs/modules/druid.radio_group.html
@@ -4,7 +4,7 @@
Defold Druid UI Library
-
+
@@ -40,7 +40,8 @@
druid.checkbox
druid.checkbox_group
druid.grid
- druid.locale
+ druid.input
+ druid.lang_text
druid.progress
druid.radio_group
druid.scroll
@@ -49,8 +50,8 @@
druid.timer
component
druid
- helper
- druid.progress_rich
+ druid_event
+ druid.helper
druid_instance
@@ -60,7 +61,9 @@
Module druid.radio_group
Radio group module
-
+
+
+
@@ -74,7 +77,7 @@
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:09:38
+
Last updated 2020-02-24 00:03:02
diff --git a/docs/modules/druid.scroll.html b/docs/modules/druid.scroll.html
index c91a211..551ceb5 100644
--- a/docs/modules/druid.scroll.html
+++ b/docs/modules/druid.scroll.html
@@ -4,7 +4,7 @@
Defold Druid UI Library
-
+
@@ -44,7 +44,8 @@
druid.checkbox
druid.checkbox_group
druid.grid
- druid.locale
+ druid.input
+ druid.lang_text
druid.progress
druid.radio_group
druid.scroll
@@ -53,8 +54,8 @@
druid.timer
component
druid
- helper
- druid.progress_rich
+ druid_event
+ druid.helper
druid_instance
@@ -64,7 +65,9 @@
Module druid.scroll
Component to handle scroll content
-
+
+
+
@@ -273,7 +276,7 @@
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:09:38
+
Last updated 2020-02-24 00:03:02
diff --git a/docs/modules/druid.slider.html b/docs/modules/druid.slider.html
index 4a71669..a4abba6 100644
--- a/docs/modules/druid.slider.html
+++ b/docs/modules/druid.slider.html
@@ -4,7 +4,7 @@
Defold Druid UI Library
-
+
@@ -40,7 +40,8 @@
druid.checkbox
druid.checkbox_group
druid.grid
- druid.locale
+ druid.input
+ druid.lang_text
druid.progress
druid.radio_group
druid.scroll
@@ -49,8 +50,8 @@
druid.timer
component
druid
- helper
- druid.progress_rich
+ druid_event
+ druid.helper
druid_instance
@@ -60,7 +61,9 @@
Module druid.slider
Druid slider component
-
+
+
+
@@ -74,7 +77,7 @@
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:09:38
+
Last updated 2020-02-24 00:03:02
diff --git a/docs/modules/druid.text.html b/docs/modules/druid.text.html
index c35de59..6df4131 100644
--- a/docs/modules/druid.text.html
+++ b/docs/modules/druid.text.html
@@ -4,7 +4,7 @@
Defold Druid UI Library
-
+
@@ -44,7 +44,8 @@
druid.checkbox
druid.checkbox_group
druid.grid
- druid.locale
+ druid.input
+ druid.lang_text
druid.progress
druid.radio_group
druid.scroll
@@ -53,8 +54,8 @@
druid.timer
component
druid
- helper
- druid.progress_rich
+ druid_event
+ druid.helper
druid_instance
@@ -65,7 +66,9 @@
Module druid.text
Component to handle all GUI texts
Good working with localization system
-
+
+
+
@@ -232,7 +235,7 @@
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:09:38
+
Last updated 2020-02-24 00:03:02
diff --git a/docs/modules/druid.timer.html b/docs/modules/druid.timer.html
index afc6f94..8fef622 100644
--- a/docs/modules/druid.timer.html
+++ b/docs/modules/druid.timer.html
@@ -4,7 +4,7 @@
Defold Druid UI Library
-
+
@@ -44,7 +44,8 @@
druid.checkbox
druid.checkbox_group
druid.grid
- druid.locale
+ druid.input
+ druid.lang_text
druid.progress
druid.radio_group
druid.scroll
@@ -53,8 +54,8 @@
druid.timer
component
druid
- helper
- druid.progress_rich
+ druid_event
+ druid.helper
druid_instance
@@ -64,7 +65,9 @@
Module druid.timer
Component to handle GUI timers
-
+
+
+
@@ -176,7 +179,7 @@
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:09:38
+
Last updated 2020-02-24 00:03:02
diff --git a/docs/modules/const.html b/docs/modules/druid_event.html
similarity index 52%
rename from docs/modules/const.html
rename to docs/modules/druid_event.html
index 0b50a56..dc54081 100644
--- a/docs/modules/const.html
+++ b/docs/modules/druid_event.html
@@ -4,7 +4,7 @@
Defold Druid UI Library
-
+
@@ -32,8 +32,7 @@
Contents
@@ -45,7 +44,8 @@
druid.checkbox
druid.checkbox_group
druid.grid
- druid.locale
+ druid.input
+ druid.lang_text
druid.progress
druid.radio_group
druid.scroll
@@ -53,11 +53,9 @@
druid.text
druid.timer
component
- const
druid
- helper
- helper.formats
- druid.progress_rich
+ druid_event
+ druid.helper
druid_instance
@@ -65,23 +63,26 @@
-
Module const
-
Druid constants
-
+
Module druid_event
+
Lua event small library
+
+
+
-
+
-
-
@@ -89,21 +90,22 @@
-
+
-
- pivots
+
+ event:subscribe(callback)
+ Subscribe callback on event
-
- Fields:
+ Parameters:
- test
- test
+ callback
+ function
+ Callback itself
@@ -112,18 +114,41 @@
-
-
-
-
-
- ON_MESSAGE
+
+ event:unsubscribe(callback)
- Interests
+ Unsubscribe callback on event
+ Parameters:
+
+ callback
+ function
+ Callback itself
+
+
+
+
+
+
+
+
+
+
+ event:trigger(...)
+
+
+ Trigger the event and call all subscribed callbacks
+
+
+ Parameters:
+
+ ...
+ All event params
+
+
@@ -137,7 +162,7 @@
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:01:14
+
Last updated 2020-02-24 00:03:02
diff --git a/docs/modules/druid_instance.html b/docs/modules/druid_instance.html
index fc11032..732fba4 100644
--- a/docs/modules/druid_instance.html
+++ b/docs/modules/druid_instance.html
@@ -4,7 +4,7 @@
Defold Druid UI Library
-
+
@@ -44,7 +44,8 @@
druid.checkbox
druid.checkbox_group
druid.grid
- druid.locale
+ druid.input
+ druid.lang_text
druid.progress
druid.radio_group
druid.scroll
@@ -53,8 +54,8 @@
druid.timer
component
druid
- helper
- druid.progress_rich
+ druid_event
+ druid.helper
druid_instance
@@ -71,8 +72,9 @@
druid.button
druid.blocker
druid.back_handler
+ druid.input
druid.text
- druid.locale
+ druid.lang_text
druid.timer
druid.progress
druid.grid
@@ -123,12 +125,16 @@
Create back_handler basic component
+ druid:new_hover(...)
+ Create hover basic component
+
+
druid:new_text(...)
Create text basic component
- druid:new_locale(...)
- Create locale basic component
+ druid:new_lang_text(...)
+ Create lang_text basic component
druid:new_timer(...)
@@ -155,6 +161,10 @@
Create checkbox basic component
+ druid:new_input(...)
+ Create input basic component
+
+
druid:new_checkbox_group(...)
Create checkbox_group basic component
@@ -162,10 +172,6 @@
druid:new_radio_group(...)
Create radio_group basic component
-
- druid:new_progress_rich(...)
- Create progress_rich basic component
-
@@ -231,7 +237,7 @@
Remove component from druid instance.
- Component `on_remove` function will be invoked, if exist.
+ Component on_remove
function will be invoked, if exist.
Parameters:
@@ -280,7 +286,7 @@
action_id
hash
- Action_id from on_input
+ Actionid from on input
action
table
@@ -305,7 +311,7 @@
message_id
hash
- Message_id from on_message
+ Messageid from on message
message
table
@@ -402,6 +408,33 @@
+
+
+
+ druid:new_hover(...)
+
+
+ Create hover basic component
+
+
+ Parameters:
+
+ ...
+ args
+ hover init args
+
+
+
+ Returns:
+
+
+ Component
+ hover component
+
+
+
+
+
@@ -431,18 +464,18 @@
-
- druid:new_locale(...)
+
+ druid:new_lang_text(...)
- Create locale basic component
+ Create lang_text basic component
Parameters:
...
args
- locale init args
+ lang_text init args
@@ -450,7 +483,7 @@
Component
- locale component
+ lang_text component
@@ -618,6 +651,33 @@
+
+
+
+ druid:new_input(...)
+
+
+ Create input basic component
+
+
+ Parameters:
+
+ ...
+ args
+ input init args
+
+
+
+ Returns:
+
+
+ Component
+ input component
+
+
+
+
+
@@ -672,33 +732,6 @@
-
-
-
- druid:new_progress_rich(...)
-
-
- Create progress_rich basic component
-
-
- Parameters:
-
- ...
- args
- progress_rich init args
-
-
-
- Returns:
-
-
- Component
- progress_rich component
-
-
-
-
-
@@ -707,7 +740,7 @@
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:09:38
+
Last updated 2020-02-24 00:03:02
diff --git a/docs/modules/helper.formats.html b/docs/modules/helper.formats.html
deleted file mode 100644
index 59952c4..0000000
--- a/docs/modules/helper.formats.html
+++ /dev/null
@@ -1,191 +0,0 @@
-
-
-
-
- Defold Druid UI Library
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Druid
-
-
-
-
Contents
-
-
-
-
Modules
-
-
-
-
-
-
-
Module helper.formats
-
Druid module with utils on string formats
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- add_prefix_zeros(num, count)
-
-
- Return number with zero number prefix
-
-
- Parameters:
-
- num
- number
- Number for conversion
-
- count
- number
- Count of numerals
-
-
-
- Returns:
-
-
- string with need count of zero (1,3) -> 001
-
-
-
-
-
-
-
-
- second_string_min(sec)
-
-
- Convert seconds to string minutes:seconds
-
-
- Parameters:
-
- sec
- number
- Seconds
-
-
-
- Returns:
-
-
- string minutes:seconds
-
-
-
-
-
-
-
-
- second_string_min(s, tab)
-
-
- Interpolate string with named Parameters in Table
-
-
- Parameters:
-
- s
- string
- Target string
-
- tab
- table
- Table with parameters
-
-
-
- Returns:
-
-
- string with replaced parameters
-
-
-
-
-
-
-
-
-
-
-
-
-
generated by LDoc 1.4.6
-
Last updated 2020-02-07 01:01:59
-
-
-
-
diff --git a/druid/base/back_handler.lua b/druid/base/back_handler.lua
index 67078c5..2431f80 100644
--- a/druid/base/back_handler.lua
+++ b/druid/base/back_handler.lua
@@ -1,6 +1,7 @@
--- Component to handle back key (android, backspace)
-- @module druid.back_handler
+local Event = require("druid.event")
local const = require("druid.const")
local component = require("druid.component")
@@ -13,9 +14,10 @@ local M = component.create("back_handler", { const.ON_INPUT })
-- @tparam callback callback On back button
-- @tparam[opt] params Callback argument
function M.init(self, callback, params)
- self.event = const.ACTION_BACK
self.callback = callback
self.params = params
+
+ self.on_back = Event(callback)
end
@@ -24,11 +26,12 @@ end
-- @tparam string action_id on_input action id
-- @tparam table action on_input action
function M.on_input(self, action_id, action)
- if action[const.RELEASED] then
- self.callback(self:get_context(), self.params)
+ if action_id == const.ACTION_BACK and action[const.RELEASED] then
+ self.on_back:trigger(self:get_context(), self.params)
+ return true
end
- return true
+ return false
end
diff --git a/druid/base/blocker.lua b/druid/base/blocker.lua
index 5c48263..303d703 100644
--- a/druid/base/blocker.lua
+++ b/druid/base/blocker.lua
@@ -1,20 +1,27 @@
--- Component to block input on specify zone (node)
-- @module druid.blocker
+local Event = require("druid.event")
local const = require("druid.const")
local helper = require("druid.helper")
local component = require("druid.component")
-local M = component.create("blocker", { const.ON_SWIPE })
+local M = component.create("blocker", { const.ON_INPUT_HIGH })
function M.init(self, node)
self.node = self:get_node(node)
- self.event = const.ACTION_TOUCH
+
+ self.on_click = Event()
+ self.on_enable_change = Event()
end
function M.on_input(self, action_id, action)
+ if action_id ~= const.ACTION_TOUCH then
+ return false
+ end
+
if not helper.is_enabled(self.node) then
return false
end
@@ -27,4 +34,14 @@ function M.on_input(self, action_id, action)
end
+function M.set_enabled(self, state)
+
+end
+
+
+function M.is_enabled(self, state)
+
+end
+
+
return M
diff --git a/druid/base/button.lua b/druid/base/button.lua
index 5367a57..8733a39 100644
--- a/druid/base/button.lua
+++ b/druid/base/button.lua
@@ -1,11 +1,36 @@
--- Component to handle basic GUI button
-- @module druid.button
--- TODO: Add button mode:
--- Long tap
--- Repeated tap
--- Double tap?
+--- Button gui component
+--@class druid
+--- Component events
+-- @table Events
+-- @tfield druid_event on_click On release button callback
+-- @tfield druid_event on_repeated_click On repeated action button callback
+-- @tfield druid_event on_long_click On long tap button callback
+-- @tfield druid_event on_double_click On double tap button callback
+
+--- Component fields
+-- @table Fields
+-- @tfield node node Trigger node
+-- @tfield[opt=node] node anim_node Animation node
+-- @tfield vector3 scale_from Initial scale of anim_node
+-- @tfield vector3 pos Initial pos of anim_node
+-- @tfield any params Params to click callbacks
+-- @tfield boolean hover_anim Is hover anim enabled
+-- @tfield druid.hover hover Druid hover logic component
+-- @tfield[opt] node click_zone Restriction zone
+
+--- Component style params
+-- @table Style
+-- @tfield function on_click (self, node)
+-- @tfield function on_click_disabled (self, node)
+-- @tfield function on_hover (self, node, hover_state)
+-- @tfield function on_set_enabled (self, node, enabled_state)
+-- @tfield bool IS_HOVER
+
+local Event = require("druid.event")
local const = require("druid.const")
local helper = require("druid.helper")
local component = require("druid.component")
@@ -13,53 +38,94 @@ local component = require("druid.component")
local M = component.create("button", { const.ON_INPUT })
---- Component init function
--- @function button:init
--- @tparam table self Component instance
--- @tparam node node Gui node
--- @tparam function callback Button callback
--- @tparam[opt] table params Button callback params
--- @tparam[opt] node anim_node Button anim node (node, if not provided)
--- @tparam[opt] string event Button react event, const.ACTION_TOUCH by default
-function M.init(self, node, callback, params, anim_node, event)
- assert(callback, "Button should have callback. To block input on zone use blocker component")
+local function is_input_match(self, action_id)
+ if action_id == const.ACTION_TOUCH then
+ return true
+ end
- self.style = self:get_style()
- self.node = self:get_node(node)
+ if self.key_trigger and action_id == self.key_trigger then
+ return true
+ end
- -- TODO: match event inside on_input?
- self.event = const.ACTION_TOUCH
- self.anim_node = anim_node and helper:get_node(anim_node) or self.node
- -- TODO: rename to start_scale
- self.scale_from = gui.get_scale(self.anim_node)
- self.pos = gui.get_position(self.anim_node)
- self.callback = callback
- self.params = params
- self.hover_anim = self.style.IS_HOVER
- self.click_zone = nil
+ return false
end
-local function set_hover(self, state)
- if self._is_hovered ~= state then
- if self.style.on_hover then
- self.style.on_hover(self, self.anim_node, state)
- end
- self._is_hovered = state
+local function on_button_hover(self, hover_state)
+ if not self.style.on_hover then
+ return
end
+
+ self.style.on_hover(self, self.anim_node, hover_state)
+end
+
+
+local function on_button_click(self)
+ if self.style.on_click then
+ self.style.on_click(self, self.anim_node)
+ end
+ self.click_in_row = 1
+ self.on_click:trigger(self:get_context(), self.params, self)
+end
+
+
+local function on_button_repeated_click(self)
+ if not self.is_repeated_started then
+ self.click_in_row = 0
+ self.is_repeated_started = true
+ end
+
+ if self.style.on_click then
+ self.style.on_click(self, self.anim_node)
+ end
+ self.click_in_row = self.click_in_row + 1
+ self.on_repeated_click:trigger(self:get_context(), self.params, self)
+end
+
+
+local function on_button_long_click(self)
+ if self.style.on_click then
+ self.style.on_click(self, self.anim_node)
+ end
+ self.click_in_row = 1
+ self.on_long_click:trigger(self:get_context(), self.params, self)
+end
+
+
+local function on_button_double_click(self)
+ if self.style.on_click then
+ self.style.on_click(self, self.anim_node)
+ end
+ self.click_in_row = self.click_in_row + 1
+ self.on_double_click:trigger(self:get_context(), self.params, self)
end
local function on_button_release(self)
+ if self.is_repeated_started then
+ return false
+ end
+
if not self.disabled then
- if not self.stub and self.can_action then
+ if self.can_action then
self.can_action = false
- if self.style.on_click then
- self.style.on_click(self, self.anim_node)
+
+ local time = socket.gettime()
+ local is_long_click = (time - self.last_pressed_time) > self.style.LONGTAP_TIME
+ is_long_click = is_long_click and self.on_long_click:is_exist()
+
+ local is_double_click = (time - self.last_released_time) < self.style.DOUBLETAP_TIME
+ is_double_click = is_double_click and self.on_double_click:is_exist()
+
+ if is_long_click then
+ on_button_long_click(self)
+ elseif is_double_click then
+ on_button_double_click(self)
+ else
+ on_button_click(self)
end
- self.callback(self:get_context(), self.params, self)
- else
- set_hover(self, false)
+
+ self.last_released_time = time
end
return true
else
@@ -71,53 +137,98 @@ local function on_button_release(self)
end
+--- Component init function
+-- @function button:init
+-- @tparam table self Component instance
+-- @tparam node node Gui node
+-- @tparam function callback Button callback
+-- @tparam[opt] table params Button callback params
+-- @tparam[opt] node anim_node Button anim node (node, if not provided)
+-- @tparam[opt] string event Button react event, const.ACTION_TOUCH by default
+function M.init(self, node, callback, params, anim_node, event)
+ self.druid = self:get_druid()
+ self.style = self:get_style()
+ self.node = self:get_node(node)
+
+ self.anim_node = anim_node and helper:get_node(anim_node) or self.node
+ -- TODO: rename to start_scale
+ self.scale_from = gui.get_scale(self.anim_node)
+ self.params = params
+ self.hover_anim = self.style.IS_HOVER
+ self.hover = self.druid:new_hover(node, on_button_hover)
+ self.click_zone = nil
+ self.is_repeated_started = false
+ self.last_pressed_time = 0
+ self.last_released_time = 0
+ self.click_in_row = 0
+ self.key_trigger = nil
+
+ -- Event stubs
+ self.on_click = Event(callback)
+ self.on_repeated_click = Event()
+ self.on_long_click = Event()
+ self.on_double_click = Event()
+end
+
+
function M.on_input(self, action_id, action)
+ if not is_input_match(self, action_id) then
+ return false
+ end
+
if not helper.is_enabled(self.node) then
return false
end
- local is_pick = gui.pick_node(self.node, action.x, action.y)
- if self.click_zone then
- is_pick = is_pick and gui.pick_node(self.click_zone, action.x, action.y)
+ local is_pick = true
+ local is_key_trigger = (action_id == self.key_trigger)
+ if not is_key_trigger then
+ is_pick = gui.pick_node(self.node, action.x, action.y)
+ if self.click_zone then
+ is_pick = is_pick and gui.pick_node(self.click_zone, action.x, action.y)
+ end
end
if not is_pick then
-- Can't interact, if touch outside of button
self.can_action = false
- set_hover(self, false)
return false
end
+ if is_key_trigger then
+ self.hover:set_hover(not action.released)
+ end
+
if action.pressed then
-- Can interact if start touch on the button
self.can_action = true
- self.repeated_counter = 0
+ self.is_repeated_started = false
+ self.last_pressed_time = socket.gettime()
return true
end
+ -- While hold button, repeat rate pick from input.repeat_interval
+ if action.repeated then
+ if not self.disabled and self.on_repeated_click:is_exist() and self.can_action then
+ on_button_repeated_click(self)
+ return true
+ end
+ end
+
if action.released then
- set_hover(self, false)
return on_button_release(self)
- else
- set_hover(self, true)
end
return not self.disabled
end
-function M.on_swipe(self)
- -- unhover button if start swipe
+function M.on_input_interrupt(self)
self.can_action = false
- set_hover(self, false)
end
function M.set_enabled(self, state)
- -- if self.disabled == state then
- -- return
- -- end
-
self.disabled = not state
if self.style.on_set_enabled then
self.style.on_set_enabled(self, self.node, state)
@@ -145,6 +256,23 @@ end
-- @tparam node zone Gui node
function M.set_click_zone(self, zone)
self.click_zone = self:get_node(zone)
+ self.hover:set_click_zone(zone)
+end
+
+
+--- Set key-code to trigger this button
+-- @function button:set_key_trigger
+-- @tparam hash key The action_id of the key
+function M.set_key_trigger(self, key)
+ self.key_trigger = hash(key)
+end
+
+
+--- Get key-code to trigger this button
+-- @function button:get_key_trigger
+-- @treturn hash The action_id of the key
+function M.get_key_trigger(self)
+ return self.key_trigger
end
diff --git a/druid/base/checkbox.lua b/druid/base/checkbox.lua
index 707e6ea..723decd 100644
--- a/druid/base/checkbox.lua
+++ b/druid/base/checkbox.lua
@@ -1,6 +1,7 @@
--- Druid checkbox component
-- @module druid.checkbox
+local Event = require("druid.event")
local component = require("druid.component")
local M = component.create("checkbox")
@@ -17,7 +18,7 @@ function M.set_state(self, state, is_silence)
end
if not is_silence and self.callback then
- self.callback(self:get_context(), state)
+ self.on_change_state:trigger(self:get_context(), state)
end
end
@@ -41,6 +42,8 @@ function M.init(self, node, callback, click_node)
self.button = self.druid:new_button(self.click_node or self.node, on_click)
M.set_state(self, false, true)
+
+ self.on_change_state = Event(callback)
end
diff --git a/druid/base/checkbox_group.lua b/druid/base/checkbox_group.lua
index 90f9481..3f5ed11 100644
--- a/druid/base/checkbox_group.lua
+++ b/druid/base/checkbox_group.lua
@@ -1,18 +1,12 @@
--- Checkboux group module
-- @module druid.checkbox_group
+local Event = require("druid.event")
local component = require("druid.component")
local M = component.create("checkbox_group")
-local function on_checkbox_click(self, index)
- if self.callback then
- self.callback(self:get_context(), index)
- end
-end
-
-
function M.set_state(self, indexes)
for i = 1, #indexes do
if self.checkboxes[i] then
@@ -36,12 +30,13 @@ end
function M.init(self, nodes, callback, click_nodes)
self.druid = self:get_druid()
self.checkboxes = {}
- self.callback = callback
+
+ self.on_checkbox_click = Event(callback)
for i = 1, #nodes do
local click_node = click_nodes and click_nodes[i] or nil
local checkbox = self.druid:new_checkbox(nodes[i], function()
- on_checkbox_click(self, i)
+ self.on_checkbox_click:trigger(self:get_context(), i)
end, click_node)
table.insert(self.checkboxes, checkbox)
diff --git a/druid/base/grid.lua b/druid/base/grid.lua
index 6ba4e7e..31ad635 100644
--- a/druid/base/grid.lua
+++ b/druid/base/grid.lua
@@ -2,6 +2,7 @@
-- Grid can anchor your elements, get content size and other
-- @module druid.grid
+local Event = require("druid.event")
local component = require("druid.component")
local M = component.create("grid")
@@ -17,6 +18,11 @@ function M.init(self, parent, element, in_row)
self.node_size = gui.get_size(self:get_node(element))
self.border = vmath.vector4(0)
self.border_offset = vmath.vector3(0)
+
+ self.on_add_item = Event()
+ self.on_remove_item = Event()
+ self.on_clear = Event()
+ self.on_update_positions = Event()
end
@@ -59,6 +65,8 @@ local function update_pos(self)
local node = self.nodes[i]
gui.set_position(node, get_pos(self, i))
end
+
+ self.on_update_positions:trigger(self:get_context())
end
@@ -82,6 +90,8 @@ function M.add(self, item, index)
local pos = get_pos(self, index)
check_border(self, pos)
update_pos(self)
+
+ self.on_add_item:trigger(self:get_context(), item, index)
end
diff --git a/druid/base/hover.lua b/druid/base/hover.lua
new file mode 100644
index 0000000..a535af9
--- /dev/null
+++ b/druid/base/hover.lua
@@ -0,0 +1,77 @@
+--- Component to handle hover node interaction
+-- @module druid.input
+
+local Event = require("druid.event")
+local const = require("druid.const")
+local helper = require("druid.helper")
+local component = require("druid.component")
+
+local M = component.create("hover", { const.ON_INPUT })
+
+
+--- Component init function
+-- @function hover:init
+-- @tparam table self Component instance
+-- @tparam node node Gui node
+-- @tparam function on_hover_callback Hover callback
+function M.init(self, node, on_hover_callback)
+ self.style = self:get_style()
+ self.node = self:get_node(node)
+
+ self._is_hovered = false
+
+ self.on_hover = Event(on_hover_callback)
+end
+
+
+function M.set_hover(self, state)
+ if self._is_hovered ~= state then
+ self._is_hovered = state
+ self.on_hover:trigger(self:get_context(), state)
+ end
+end
+
+
+function M.on_input(self, action_id, action)
+ if action_id ~= const.ACTION_TOUCH then
+ return
+ end
+
+ if not helper.is_enabled(self.node) then
+ return false
+ end
+
+ local is_pick = gui.pick_node(self.node, action.x, action.y)
+ if self.click_zone then
+ is_pick = is_pick and gui.pick_node(self.click_zone, action.x, action.y)
+ end
+
+ if not is_pick then
+ M.set_hover(self, false)
+ return false
+ end
+
+ if action.released then
+ M.set_hover(self, false)
+ else
+ M.set_hover(self, true)
+ end
+end
+
+
+function M.on_input_interrupt(self)
+ M.set_hover(self, false)
+end
+
+
+--- Strict button click area. Useful for
+-- no click events outside stencil node
+-- @function button:set_click_zone
+-- @tparam table self Component instance
+-- @tparam node zone Gui node
+function M.set_click_zone(self, zone)
+ self.click_zone = self:get_node(zone)
+end
+
+
+return M
diff --git a/druid/base/input.lua b/druid/base/input.lua
new file mode 100644
index 0000000..3b05fb8
--- /dev/null
+++ b/druid/base/input.lua
@@ -0,0 +1,15 @@
+--- Druid input text component
+-- @local unimplemented
+-- @module druid.input
+
+local component = require("druid.component")
+
+local M = component.create("input")
+
+
+function M.init(self, node, callback, click_node)
+ self.style = self:get_style()
+end
+
+
+return M
diff --git a/druid/base/locale.lua b/druid/base/lang_text.lua
similarity index 90%
rename from druid/base/locale.lua
rename to druid/base/lang_text.lua
index d419f01..760190e 100644
--- a/druid/base/locale.lua
+++ b/druid/base/lang_text.lua
@@ -1,12 +1,12 @@
--- Component to handle all GUI texts
-- Good working with localization system
--- @module druid.locale
+-- @module druid.lang_text
local const = require("druid.const")
local settings = require("druid.system.settings")
local component = require("druid.component")
-local M = component.create("locale", { const.ON_CHANGE_LANGUAGE })
+local M = component.create("lang_text", { const.ON_CHANGE_LANGUAGE })
function M.init(self, node, lang_id, no_adjust)
diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua
index a00459a..193a089 100644
--- a/druid/base/scroll.lua
+++ b/druid/base/scroll.lua
@@ -1,11 +1,12 @@
--- Component to handle scroll content
-- @module druid.scroll
+local Event = require("druid.event")
local helper = require("druid.helper")
local const = require("druid.const")
local component = require("druid.component")
-local M = component.create("scroll", { const.ON_UPDATE, const.ON_SWIPE })
+local M = component.create("scroll", { const.ON_UPDATE, const.ON_INPUT_HIGH })
-- Global on all scrolls
@@ -41,14 +42,21 @@ function M.init(self, scroll_parent, input_zone, border)
}
self:set_border(border)
+
+ self.on_scroll = Event()
+ self.on_scroll_to = Event()
+ self.on_point_scroll = Event()
end
local function set_pos(self, pos)
- self.pos.x = pos.x
- self.pos.y = pos.y
+ if self.pos.x ~= pos.x or self.pos.y ~= pos.y then
+ self.pos.x = pos.x
+ self.pos.y = pos.y
+ gui.set_position(self.node, self.pos)
- gui.set_position(self.node, self.pos)
+ self.on_scroll:trigger(self:get_context(), self.pos)
+ end
end
@@ -337,6 +345,8 @@ function M.scroll_to(self, point, is_instant)
set_pos(self, target)
end)
end
+
+ self.on_scroll_to:trigger(self:get_context(), point, is_instant)
end
@@ -351,8 +361,8 @@ function M.scroll_to_index(self, index, skip_cb)
if self.selected ~= index then
self.selected = index
- if not skip_cb and self.on_point_callback then
- self.on_point_callback(self:get_context(), index, self.points[index])
+ if not skip_cb then
+ self.on_point_scroll:trigger(self:get_context(), index, self.points[index])
end
end
@@ -395,7 +405,7 @@ end
-- @tparam table self Component instance
-- @tparam function callback Callback on scroll to point of interest
function M.on_point_move(self, callback)
- self.on_point_callback = callback
+ self.on_point_scroll:subscribe(callback)
end
diff --git a/druid/base/slider.lua b/druid/base/slider.lua
index 5b8d691..6fd3f9f 100644
--- a/druid/base/slider.lua
+++ b/druid/base/slider.lua
@@ -1,17 +1,16 @@
--- Druid slider component
-- @module druid.slider
+local Event = require("druid.event")
local helper = require("druid.helper")
local const = require("druid.const")
local component = require("druid.component")
-local M = component.create("slider", { const.ON_SWIPE })
+local M = component.create("slider", { const.ON_INPUT_HIGH })
local function on_change_value(self)
- if self.callback then
- self.callback(self:get_context(), self.value)
- end
+ self.on_change_value:trigger(self:get_context(), self.value)
end
@@ -26,7 +25,8 @@ function M.init(self, node, end_pos, callback)
self.dist = self.end_pos - self.start_pos
self.is_drag = false
self.value = 0
- self.callback = callback
+
+ self.on_change_value = Event(callback)
assert(self.dist.x == 0 or self.dist.y == 0, "Slider for now can be only vertical or horizontal")
end
diff --git a/druid/base/text.lua b/druid/base/text.lua
index 72307d8..2cee229 100644
--- a/druid/base/text.lua
+++ b/druid/base/text.lua
@@ -2,6 +2,7 @@
-- Good working with localization system
-- @module druid.text
+local Event = require("druid.event")
local const = require("druid.const")
local component = require("druid.component")
@@ -25,6 +26,10 @@ function M.init(self, node, value, no_adjust)
self.is_no_adjust = no_adjust
self.last_color = gui.get_color(self.node)
+ self.on_set_text = Event()
+ self.on_update_text_scale = Event()
+ self.on_set_pivot = Event()
+
self:set_to(value or 0)
return self
end
@@ -47,6 +52,8 @@ local function update_text_area_size(self)
local new_scale = vmath.vector3(scale_modifier, scale_modifier, cur_scale.z)
gui.set_scale(self.node, new_scale)
self.scale = new_scale
+
+ self.on_update_text_scale:trigger(self:get_context(), new_scale)
end
@@ -58,6 +65,8 @@ function M.set_to(self, set_to)
self.last_value = set_to
gui.set_text(self.node, set_to)
+ self.on_set_text:trigger(self:get_context(), set_to)
+
if not self.is_no_adjust then
update_text_area_size(self)
end
@@ -114,6 +123,8 @@ function M.set_pivot(self, pivot)
self.pos = self.pos + pos_offset
gui.set_position(self.node, self.pos)
+
+ self.on_set_pivot:trigger(self:get_context(), pivot)
end
diff --git a/druid/base/timer.lua b/druid/base/timer.lua
index efd8fc9..8fecf86 100644
--- a/druid/base/timer.lua
+++ b/druid/base/timer.lua
@@ -1,6 +1,7 @@
--- Component to handle GUI timers
-- @module druid.timer
+local Event = require("druid.event")
local const = require("druid.const")
local formats = require("druid.helper.formats")
local helper = require("druid.helper")
@@ -13,16 +14,19 @@ function M.init(self, node, seconds_from, seconds_to, callback)
self.node = self:get_node(node)
seconds_from = math.max(seconds_from, 0)
seconds_to = math.max(seconds_to or 0, 0)
- callback = callback or const.EMPTY_FUNCTION
+
+ self.on_tick = Event()
+ self.on_set_enabled = Event()
+ self.on_timer_end = Event(callback)
self:set_to(seconds_from)
self:set_interval(seconds_from, seconds_to)
- self.callback = callback
if seconds_to - seconds_from == 0 then
self:set_state(false)
- self.callback(self:get_context(), self)
+ self.on_timer_end:trigger(self:get_context(), self)
end
+
return self
end
@@ -43,6 +47,8 @@ end
-- @tparam boolean is_on Timer enable state
function M.set_state(self, is_on)
self.is_on = is_on
+
+ self.on_set_enabled:trigger(self:get_context(), is_on)
end
@@ -73,9 +79,12 @@ function M.update(self, dt)
self.temp = self.temp - dist
self.value = helper.step(self.value, self.target, 1)
M.set_to(self, self.value)
+
+ self.on_tick:trigger(self:get_context(), self.value)
+
if self.value == self.target then
self:set_state(false)
- self.callback(self:get_context(), self)
+ self.on_timer_end:trigger(self:get_context(), self)
end
end
end
diff --git a/druid/component.lua b/druid/component.lua
index 8b9caf5..bc49060 100644
--- a/druid/component.lua
+++ b/druid/component.lua
@@ -9,26 +9,6 @@ local class = require("druid.system.middleclass")
local Component = class("druid.component")
---- Setup component context and his style table
--- @function component:setup_component
--- @tparam context table Druid context. Usually it is self of script
--- @tparam style table Druid style module
--- @treturn Component Component itself
-function Component.setup_component(self, context, style)
- self._meta = {
- template = nil,
- context = nil,
- nodes = nil,
- style = nil,
- }
-
- self:set_context(context)
- self:set_style(style)
-
- return self
-end
-
-
--- Get current component style table
-- @function component:get_style
-- @treturn table Component style table
@@ -136,6 +116,26 @@ function Component.get_druid(self)
end
+--- Setup component context and his style table
+-- @function component:setup_component
+-- @tparam context table Druid context. Usually it is self of script
+-- @tparam style table Druid style module
+-- @treturn Component Component itself
+function Component.setup_component(self, context, style)
+ self._meta = {
+ template = nil,
+ context = nil,
+ nodes = nil,
+ style = nil,
+ }
+
+ self:set_context(context)
+ self:set_style(style)
+
+ return self
+end
+
+
--- Basic constructor of component. It will call automaticaly
-- by `Component.static.create`
-- @function component:initialize
diff --git a/druid/const.lua b/druid/const.lua
index ace87b6..fd2c121 100644
--- a/druid/const.lua
+++ b/druid/const.lua
@@ -19,14 +19,13 @@ M.ZERO = "0"
M.ALL = "all"
---- Interests
+--- Component Interests
M.ON_MESSAGE = hash("on_message")
M.ON_UPDATE = hash("on_update")
-
-
--- Input
-M.ON_SWIPE = hash("on_swipe")
+M.ON_INPUT_HIGH = hash("on_input_high")
M.ON_INPUT = hash("on_input")
+M.ON_CHANGE_LANGUAGE = hash("on_change_language")
+M.ON_LAYOUT_CHANGED = hash("on_layout_changed")
M.PIVOTS = {
@@ -42,43 +41,21 @@ M.PIVOTS = {
}
-M.SIDE = {
- X = "x",
- Y = "y"
-}
-
-
-M.UI_INPUT = {
- [M.ON_SWIPE] = true,
- [M.ON_INPUT] = true
-}
-
--- UI messages
-M.ON_CHANGE_LANGUAGE = hash("on_change_language")
-M.ON_LAYOUT_CHANGED = hash("on_layout_changed")
-
-
M.SPECIFIC_UI_MESSAGES = {
[M.ON_CHANGE_LANGUAGE] = "on_change_language",
[M.ON_LAYOUT_CHANGED] = "on_layout_changed"
}
--- Basic druid components
-M.COMPONENTS = {
- BUTTON = "button",
- BLOCKER = "blocker",
- BACK_HANDLER = "back_handler",
- TEXT = "text",
- LOCALE = "locale",
- TIMER = "timer",
- PROGRESS = "progress",
- GRID = "grid",
- SCROLL = "scroll",
- SLIDER = "slider",
- CHECKBOX = "checkbox",
- CHECKBOX_GROUP = "checkbox_group",
- RADIO_GROUP = "radio_group",
+M.UI_INPUT = {
+ [M.ON_INPUT_HIGH] = true,
+ [M.ON_INPUT] = true
+}
+
+
+M.SIDE = {
+ X = "x",
+ Y = "y"
}
diff --git a/druid/druid.lua b/druid/druid.lua
index 0003720..0716805 100644
--- a/druid/druid.lua
+++ b/druid/druid.lua
@@ -7,6 +7,11 @@
-- to how to do your custom complex components to
-- separate UI game logic to small files
--
+-- require("druid.druid")
+-- function init(self)
+-- self.druid = druid.new(self)
+-- end
+--
-- @module druid
local const = require("druid.const")
diff --git a/druid/event.lua b/druid/event.lua
new file mode 100644
index 0000000..1d6c289
--- /dev/null
+++ b/druid/event.lua
@@ -0,0 +1,71 @@
+--- Lua event small library
+-- @module druid_event
+
+local class = require("druid.system.middleclass")
+
+-- @class DruidEvent
+local M = class("druid.event")
+
+
+--- Event constructur
+-- @function Event
+-- @tparam function initial_callback Subscribe the callback on new event, if callback exist
+function M.initialize(self, initial_callback)
+ self._callbacks = {}
+
+ if initial_callback then
+ self:subscribe(initial_callback)
+ end
+end
+
+
+--- Subscribe callback on event
+-- @function event:subscribe
+-- @tparam function callback Callback itself
+function M.subscribe(self, callback)
+ assert(type(self) == "table", "You should subscribe to event with : syntax")
+ assert(type(callback) == "function", "Callback should be function")
+
+ table.insert(self._callbacks, callback)
+end
+
+
+--- Unsubscribe callback on event
+-- @function event:unsubscribe
+-- @tparam function callback Callback itself
+function M.unsubscribe(self, callback)
+ for i = 1, #self._callbacks do
+ if self._callbacks[i] == callback then
+ table.remove(self._callbacks, i)
+ return
+ end
+ end
+end
+
+
+--- Return true, if event have at lease one handler
+-- @function event:is_exist
+-- @treturn boolean True if event have handlers
+function M.is_exist(self)
+ return #self._callbacks > 0
+end
+
+
+--- Clear the all event handlers
+-- @function event:clear
+function M.clear(self)
+ self._callbacks = {}
+end
+
+
+--- Trigger the event and call all subscribed callbacks
+-- @function event:trigger
+-- @param ... All event params
+function M.trigger(self, ...)
+ for i = 1, #self._callbacks do
+ self._callbacks[i](...)
+ end
+end
+
+
+return M
diff --git a/druid/rich/progress_rich.lua b/druid/rich/progress_rich.lua
deleted file mode 100644
index fe39a9b..0000000
--- a/druid/rich/progress_rich.lua
+++ /dev/null
@@ -1,72 +0,0 @@
---- Component for rich progress component
--- @module druid.progress_rich
-
-local component = require("druid.component")
-
-local M = component.create("progress_rich")
-
-
-function M.init(self, name, red, green, key)
- self.druid = self:get_druid()
- self.style = self:get_style()
- self.red = self.druid:new_progress(red, key)
- self.green = self.druid:new_progress(green, key)
- self.fill = self.druid:new_progress(name, key)
-end
-
-
---- Instant fill progress bar to value
--- @function progress_rich:set_to
--- @tparam table self Component instance
--- @tparam number value Progress bar value, from 0 to 1
-function M.set_to(self, value)
- self.red:set_to(value)
- self.green:set_to(value)
- self.fill:set_to(value)
-end
-
-
---- Empty a progress bar
--- @function progress_rich:empty
--- @tparam table self Component instance
-function M.empty(self)
- self.red:empty()
- self.green:empty()
- self.fill:empty()
-end
-
-
---- Start animation of a progress bar
--- @function progress_rich:to
--- @tparam table self Component instance
--- @tparam number to value between 0..1
--- @tparam[opt] function callback Callback on animation ends
-function M.to(self, to, callback)
- if self.timer then
- timer.cancel(self.timer)
- self.timer = nil
- end
-
- if self.fill.last_value < to then
- self.red:to(self.fill.last_value)
- self.green:to(to, function()
- self.timer = timer.delay(self.style.DELAY, false, function()
- self.red:to(to)
- self.fill:to(to, callback)
- end)
- end)
- end
-
- if self.fill.last_value > to then
- self.green:to(self.red.last_value)
- self.fill:to(to, function()
- self.timer = timer.delay(self.style.DELAY, false, function()
- self.green:to(to)
- self.red:to(to, callback)
- end)
- end)
- end
-end
-
-
-return M
diff --git a/druid/styles/bounce/anims.lua b/druid/styles/default/anims.lua
similarity index 100%
rename from druid/styles/bounce/anims.lua
rename to druid/styles/default/anims.lua
diff --git a/druid/styles/bounce/style.lua b/druid/styles/default/style.lua
similarity index 94%
rename from druid/styles/bounce/style.lua
rename to druid/styles/default/style.lua
index e9d93bf..430c0fb 100644
--- a/druid/styles/bounce/style.lua
+++ b/druid/styles/default/style.lua
@@ -1,5 +1,5 @@
local settings = require("druid.system.settings")
-local anims = require("druid.styles.bounce.anims")
+local anims = require("druid.styles.default.anims")
local M = {}
@@ -12,6 +12,8 @@ M["button"] = {
BTN_SOUND_DISABLED = "click",
DISABLED_COLOR = vmath.vector4(0, 0, 0, 1),
ENABLED_COLOR = vmath.vector4(1),
+ LONGTAP_TIME = 0.4,
+ DOUBLETAP_TIME = 0.4,
IS_HOVER = true,
on_hover = function(self, node, state)
diff --git a/druid/styles/empty/style.lua b/druid/styles/empty/style.lua
index 2ef9698..27a9a43 100644
--- a/druid/styles/empty/style.lua
+++ b/druid/styles/empty/style.lua
@@ -6,6 +6,8 @@ M["button"] = {
BTN_SOUND_DISABLED = "click",
DISABLED_COLOR = vmath.vector4(0, 0, 0, 1),
ENABLED_COLOR = vmath.vector4(1),
+ LONGTAP_TIME = 0.4,
+ DOUBLETAP_TIME = 0.4,
IS_HOVER = false,
}
diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua
index 4a524fe..1a217ca 100644
--- a/druid/system/druid_instance.lua
+++ b/druid/system/druid_instance.lua
@@ -4,8 +4,9 @@
-- @see druid.button
-- @see druid.blocker
-- @see druid.back_handler
+-- @see druid.input
-- @see druid.text
--- @see druid.locale
+-- @see druid.lang_text
-- @see druid.timer
-- @see druid.progress
-- @see druid.grid
@@ -23,8 +24,9 @@ local class = require("druid.system.middleclass")
local button = require("druid.base.button")
local blocker = require("druid.base.blocker")
local back_handler = require("druid.base.back_handler")
+local hover = require("druid.base.hover")
local text = require("druid.base.text")
-local locale = require("druid.base.locale")
+local lang_text = require("druid.base.lang_text")
local timer = require("druid.base.timer")
local progress = require("druid.base.progress")
local grid = require("druid.base.grid")
@@ -33,9 +35,8 @@ local slider = require("druid.base.slider")
local checkbox = require("druid.base.checkbox")
local checkbox_group = require("druid.base.checkbox_group")
local radio_group = require("druid.base.radio_group")
--- local input - require("druid.base.input")
+local input = require("druid.base.input")
-- local infinity_scroll = require("druid.base.infinity_scroll")
-local progress_rich = require("druid.rich.progress_rich")
-- @classmod Druid
local Druid = class("druid.druid_instance")
@@ -81,29 +82,24 @@ local function create(self, instance_class)
end
-local function notify_input_on_swipe(self)
- if self.components[const.ON_INPUT] then
- local len = #self.components[const.ON_INPUT]
- for i = len, 1, -1 do
- local comp = self.components[const.ON_INPUT][i]
- if comp.on_swipe then
- comp:on_swipe()
+local function process_input(action_id, action, components, is_input_consumed)
+ if not components then
+ return is_input_consumed
+ end
+
+ for i = #components, 1, -1 do
+ local component = components[i]
+
+ if not is_input_consumed then
+ is_input_consumed = component:on_input(action_id, action)
+ else
+ if component.on_input_interrupt then
+ component:on_input_interrupt()
end
end
end
-end
-
-local function match_event(action_id, events)
- if type(events) == const.TABLE then
- for i = 1, #events do
- if action_id == events[i] then
- return true
- end
- end
- else
- return action_id == events
- end
+ return is_input_consumed
end
@@ -181,33 +177,15 @@ end
-- @tparam hash action_id Action_id from on_input
-- @tparam table action Action from on_input
function Druid.on_input(self, action_id, action)
- -- TODO: расписать отличия ON_SWIPE и ON_INPUT
- -- Почему-то некоторые используют ON_SWIPE, а логичнее ON_INPUT? (blocker, slider)
- local components = self.components[const.ON_SWIPE]
- if components then
- local result
- for i = #components, 1, -1 do
- local v = components[i]
- result = result or v:on_input(action_id, action)
- end
- if result then
- notify_input_on_swipe(self)
- return true
- end
- end
+ local is_input_consumed = false
- components = self.components[const.ON_INPUT]
- if components then
- for i = #components, 1, -1 do
- local v = components[i]
- if match_event(action_id, v.event) and v:on_input(action_id, action) then
- return true
- end
- end
- return false
- end
+ is_input_consumed = process_input(action_id, action,
+ self.components[const.ON_INPUT_HIGH], is_input_consumed)
- return false
+ is_input_consumed = process_input(action_id, action,
+ self.components[const.ON_INPUT], is_input_consumed)
+
+ return is_input_consumed
end
@@ -262,6 +240,15 @@ function Druid.new_back_handler(self, ...)
end
+--- Create hover basic component
+-- @function druid:new_hover
+-- @tparam args ... hover init args
+-- @treturn Component hover component
+function Druid.new_hover(self, ...)
+ return Druid.create(self, hover, ...)
+end
+
+
--- Create text basic component
-- @function druid:new_text
-- @tparam args ... text init args
@@ -271,12 +258,12 @@ function Druid.new_text(self, ...)
end
---- Create locale basic component
--- @function druid:new_locale
--- @tparam args ... locale init args
--- @treturn Component locale component
-function Druid.new_locale(self, ...)
- return Druid.create(self, locale, ...)
+--- Create lang_text basic component
+-- @function druid:new_lang_text
+-- @tparam args ... lang_text init args
+-- @treturn Component lang_text component
+function Druid.new_lang_text(self, ...)
+ return Druid.create(self, lang_text, ...)
end
@@ -334,6 +321,15 @@ function Druid.new_checkbox(self, ...)
end
+--- Create input basic component
+-- @function druid:new_input
+-- @tparam args ... input init args
+-- @treturn Component input component
+function Druid.new_input(self, ...)
+ return Druid.create(self, input, ...)
+end
+
+
--- Create checkbox_group basic component
-- @function druid:new_checkbox_group
-- @tparam args ... checkbox_group init args
@@ -352,13 +348,4 @@ function Druid.new_radio_group(self, ...)
end
---- Create progress_rich basic component
--- @function druid:new_progress_rich
--- @tparam args ... progress_rich init args
--- @treturn Component progress_rich component
-function Druid.new_progress_rich(self, ...)
- return Druid.create(self, progress_rich, ...)
-end
-
-
return Druid
diff --git a/example/kenney/gui/main/main.gui b/example/kenney/gui/main/main.gui
index 0d74dfd..be9af76 100644
--- a/example/kenney/gui/main/main.gui
+++ b/example/kenney/gui/main/main.gui
@@ -3981,6 +3981,1075 @@ nodes {
text_leading: 1.0
text_tracking: 0.0
}
+nodes {
+ position {
+ x: 1200.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 1.0
+ y: 1.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_BOX
+ blend_mode: BLEND_MODE_ALPHA
+ texture: "kenney/empty"
+ id: "button_page"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_CENTER
+ adjust_mode: ADJUST_MODE_STRETCH
+ parent: "C_Anchor"
+ layer: ""
+ inherit_alpha: true
+ slice9 {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 0.0
+ }
+ clipping_mode: CLIPPING_MODE_NONE
+ clipping_visible: true
+ clipping_inverted: false
+ alpha: 1.0
+ template_node_child: false
+ size_mode: SIZE_MODE_AUTO
+}
+nodes {
+ position {
+ x: -200.0
+ y: 280.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_TEMPLATE
+ id: "button_usual"
+ parent: "button_page"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ template: "/example/kenney/templates/button.gui"
+ template_node_child: false
+}
+nodes {
+ position {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 130.0
+ y: 60.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_BOX
+ blend_mode: BLEND_MODE_ALPHA
+ texture: "kenney/button_blue"
+ id: "button_usual/button"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_CENTER
+ adjust_mode: ADJUST_MODE_FIT
+ parent: "button_usual"
+ layer: ""
+ inherit_alpha: true
+ slice9 {
+ x: 15.0
+ y: 15.0
+ z: 15.0
+ w: 15.0
+ }
+ clipping_mode: CLIPPING_MODE_NONE
+ clipping_visible: true
+ clipping_inverted: false
+ alpha: 1.0
+ template_node_child: true
+ size_mode: SIZE_MODE_MANUAL
+}
+nodes {
+ position {
+ x: 0.0
+ y: 7.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 0.7
+ y: 0.7
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_TEXT
+ blend_mode: BLEND_MODE_ALPHA
+ text: "Usual"
+ font: "game"
+ id: "button_usual/text"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_CENTER
+ outline {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ shadow {
+ x: 0.101960786
+ y: 0.2
+ z: 0.6
+ w: 1.0
+ }
+ adjust_mode: ADJUST_MODE_FIT
+ line_break: false
+ parent: "button_usual/button"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ outline_alpha: 0.0
+ shadow_alpha: 0.78
+ overridden_fields: 8
+ template_node_child: true
+ text_leading: 1.0
+ text_tracking: 0.0
+}
+nodes {
+ position {
+ x: -200.0
+ y: 180.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_TEMPLATE
+ id: "button_custom_style"
+ parent: "button_page"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ template: "/example/kenney/templates/button.gui"
+ template_node_child: false
+}
+nodes {
+ position {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 130.0
+ y: 60.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_BOX
+ blend_mode: BLEND_MODE_ALPHA
+ texture: "kenney/button_blue"
+ id: "button_custom_style/button"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_CENTER
+ adjust_mode: ADJUST_MODE_FIT
+ parent: "button_custom_style"
+ layer: ""
+ inherit_alpha: true
+ slice9 {
+ x: 15.0
+ y: 15.0
+ z: 15.0
+ w: 15.0
+ }
+ clipping_mode: CLIPPING_MODE_NONE
+ clipping_visible: true
+ clipping_inverted: false
+ alpha: 1.0
+ template_node_child: true
+ size_mode: SIZE_MODE_MANUAL
+}
+nodes {
+ position {
+ x: 0.0
+ y: 7.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 0.5
+ y: 0.5
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_TEXT
+ blend_mode: BLEND_MODE_ALPHA
+ text: "Custom Style"
+ font: "game"
+ id: "button_custom_style/text"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_CENTER
+ outline {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ shadow {
+ x: 0.101960786
+ y: 0.2
+ z: 0.6
+ w: 1.0
+ }
+ adjust_mode: ADJUST_MODE_FIT
+ line_break: false
+ parent: "button_custom_style/button"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ outline_alpha: 0.0
+ shadow_alpha: 0.78
+ overridden_fields: 3
+ overridden_fields: 8
+ template_node_child: true
+ text_leading: 1.0
+ text_tracking: 0.0
+}
+nodes {
+ position {
+ x: -200.0
+ y: 80.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_TEMPLATE
+ id: "button_long_tap"
+ parent: "button_page"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ template: "/example/kenney/templates/button.gui"
+ template_node_child: false
+}
+nodes {
+ position {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 130.0
+ y: 60.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_BOX
+ blend_mode: BLEND_MODE_ALPHA
+ texture: "kenney/button_blue"
+ id: "button_long_tap/button"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_CENTER
+ adjust_mode: ADJUST_MODE_FIT
+ parent: "button_long_tap"
+ layer: ""
+ inherit_alpha: true
+ slice9 {
+ x: 15.0
+ y: 15.0
+ z: 15.0
+ w: 15.0
+ }
+ clipping_mode: CLIPPING_MODE_NONE
+ clipping_visible: true
+ clipping_inverted: false
+ alpha: 1.0
+ template_node_child: true
+ size_mode: SIZE_MODE_MANUAL
+}
+nodes {
+ position {
+ x: 0.0
+ y: 7.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 0.5
+ y: 0.7
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_TEXT
+ blend_mode: BLEND_MODE_ALPHA
+ text: "Long tap"
+ font: "game"
+ id: "button_long_tap/text"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_CENTER
+ outline {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ shadow {
+ x: 0.101960786
+ y: 0.2
+ z: 0.6
+ w: 1.0
+ }
+ adjust_mode: ADJUST_MODE_FIT
+ line_break: false
+ parent: "button_long_tap/button"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ outline_alpha: 0.0
+ shadow_alpha: 0.78
+ overridden_fields: 3
+ overridden_fields: 8
+ template_node_child: true
+ text_leading: 1.0
+ text_tracking: 0.0
+}
+nodes {
+ position {
+ x: -200.0
+ y: -20.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_TEMPLATE
+ id: "button_repeated_tap"
+ parent: "button_page"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ template: "/example/kenney/templates/button.gui"
+ template_node_child: false
+}
+nodes {
+ position {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 130.0
+ y: 60.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_BOX
+ blend_mode: BLEND_MODE_ALPHA
+ texture: "kenney/button_blue"
+ id: "button_repeated_tap/button"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_CENTER
+ adjust_mode: ADJUST_MODE_FIT
+ parent: "button_repeated_tap"
+ layer: ""
+ inherit_alpha: true
+ slice9 {
+ x: 15.0
+ y: 15.0
+ z: 15.0
+ w: 15.0
+ }
+ clipping_mode: CLIPPING_MODE_NONE
+ clipping_visible: true
+ clipping_inverted: false
+ alpha: 1.0
+ template_node_child: true
+ size_mode: SIZE_MODE_MANUAL
+}
+nodes {
+ position {
+ x: 0.0
+ y: 7.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 0.5
+ y: 0.7
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_TEXT
+ blend_mode: BLEND_MODE_ALPHA
+ text: "Repeated"
+ font: "game"
+ id: "button_repeated_tap/text"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_CENTER
+ outline {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ shadow {
+ x: 0.101960786
+ y: 0.2
+ z: 0.6
+ w: 1.0
+ }
+ adjust_mode: ADJUST_MODE_FIT
+ line_break: false
+ parent: "button_repeated_tap/button"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ outline_alpha: 0.0
+ shadow_alpha: 0.78
+ overridden_fields: 3
+ overridden_fields: 8
+ template_node_child: true
+ text_leading: 1.0
+ text_tracking: 0.0
+}
+nodes {
+ position {
+ x: -200.0
+ y: -120.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_TEMPLATE
+ id: "button_double_tap"
+ parent: "button_page"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ template: "/example/kenney/templates/button.gui"
+ template_node_child: false
+}
+nodes {
+ position {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 130.0
+ y: 60.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_BOX
+ blend_mode: BLEND_MODE_ALPHA
+ texture: "kenney/button_blue"
+ id: "button_double_tap/button"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_CENTER
+ adjust_mode: ADJUST_MODE_FIT
+ parent: "button_double_tap"
+ layer: ""
+ inherit_alpha: true
+ slice9 {
+ x: 15.0
+ y: 15.0
+ z: 15.0
+ w: 15.0
+ }
+ clipping_mode: CLIPPING_MODE_NONE
+ clipping_visible: true
+ clipping_inverted: false
+ alpha: 1.0
+ template_node_child: true
+ size_mode: SIZE_MODE_MANUAL
+}
+nodes {
+ position {
+ x: 0.0
+ y: 7.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 0.5
+ y: 0.7
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_TEXT
+ blend_mode: BLEND_MODE_ALPHA
+ text: "Double tap"
+ font: "game"
+ id: "button_double_tap/text"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_CENTER
+ outline {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ shadow {
+ x: 0.101960786
+ y: 0.2
+ z: 0.6
+ w: 1.0
+ }
+ adjust_mode: ADJUST_MODE_FIT
+ line_break: false
+ parent: "button_double_tap/button"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ outline_alpha: 0.0
+ shadow_alpha: 0.78
+ overridden_fields: 3
+ overridden_fields: 8
+ template_node_child: true
+ text_leading: 1.0
+ text_tracking: 0.0
+}
+nodes {
+ position {
+ x: -200.0
+ y: -220.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_TEMPLATE
+ id: "button_key_trigger"
+ parent: "button_page"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ template: "/example/kenney/templates/button.gui"
+ template_node_child: false
+}
+nodes {
+ position {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 130.0
+ y: 60.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_BOX
+ blend_mode: BLEND_MODE_ALPHA
+ texture: "kenney/button_blue"
+ id: "button_key_trigger/button"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_CENTER
+ adjust_mode: ADJUST_MODE_FIT
+ parent: "button_key_trigger"
+ layer: ""
+ inherit_alpha: true
+ slice9 {
+ x: 15.0
+ y: 15.0
+ z: 15.0
+ w: 15.0
+ }
+ clipping_mode: CLIPPING_MODE_NONE
+ clipping_visible: true
+ clipping_inverted: false
+ alpha: 1.0
+ template_node_child: true
+ size_mode: SIZE_MODE_MANUAL
+}
+nodes {
+ position {
+ x: 0.0
+ y: 7.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 0.5
+ y: 0.7
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_TEXT
+ blend_mode: BLEND_MODE_ALPHA
+ text: "Press Space"
+ font: "game"
+ id: "button_key_trigger/text"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_CENTER
+ outline {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ shadow {
+ x: 0.101960786
+ y: 0.2
+ z: 0.6
+ w: 1.0
+ }
+ adjust_mode: ADJUST_MODE_FIT
+ line_break: false
+ parent: "button_key_trigger/button"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ outline_alpha: 0.0
+ shadow_alpha: 0.78
+ overridden_fields: 3
+ overridden_fields: 8
+ template_node_child: true
+ text_leading: 1.0
+ text_tracking: 0.0
+}
+nodes {
+ position {
+ x: 1800.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 1.0
+ y: 1.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_BOX
+ blend_mode: BLEND_MODE_ALPHA
+ texture: "kenney/empty"
+ id: "scroll_page"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_CENTER
+ adjust_mode: ADJUST_MODE_STRETCH
+ parent: "C_Anchor"
+ layer: ""
+ inherit_alpha: true
+ slice9 {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 0.0
+ }
+ clipping_mode: CLIPPING_MODE_NONE
+ clipping_visible: true
+ clipping_inverted: false
+ alpha: 1.0
+ template_node_child: false
+ size_mode: SIZE_MODE_AUTO
+}
nodes {
position {
x: 0.0
diff --git a/example/kenney/gui/main/main.gui_script b/example/kenney/gui/main/main.gui_script
index 0f9fed2..bd472e3 100644
--- a/example/kenney/gui/main/main.gui_script
+++ b/example/kenney/gui/main/main.gui_script
@@ -1,14 +1,18 @@
local druid = require("druid.druid")
local empty_style = require("druid.styles.empty.style")
-local bounce_style = require("druid.styles.bounce.style")
+local default_style = require("druid.styles.default.style")
local main_page = require("example.kenney.page.main")
local text_page = require("example.kenney.page.texts")
+local button_page = require("example.kenney.page.button")
+local scroll_page = require("example.kenney.page.scroll")
local pages = {
"main_page",
- "texts_page"
+ "texts_page",
+ "button_page",
+ "scroll_page",
}
local function on_control_button(self, delta)
@@ -29,18 +33,23 @@ end
local function init_top_panel(self)
self.druid:new_button("button_left/button", on_control_button, -1)
self.druid:new_button("button_right/button", on_control_button, 1)
- self.header = self.druid:new_locale("text_header", "main_page")
+ self.header = self.druid:new_lang_text("text_header", "main_page")
end
function init(self)
- druid.set_default_style(bounce_style)
+ druid.set_default_style(default_style)
self.druid = druid.new(self)
init_top_panel(self)
- self.page = 1
+ self.page = 3
main_page.setup_page(self)
text_page.setup_page(self)
+ button_page.setup_page(self)
+ scroll_page.setup_page(self)
+
+ -- Refresh state
+ on_control_button(self, 0)
end
diff --git a/example/kenney/lang.lua b/example/kenney/lang.lua
index 43f0f91..c7eb298 100644
--- a/example/kenney/lang.lua
+++ b/example/kenney/lang.lua
@@ -5,6 +5,8 @@ local M = {}
local en = {
main_page = "Main page",
texts_page = "Text page",
+ button_page = "Button page",
+ scroll_page = "Scroll page",
ui_section_button = "Button",
ui_section_text = "Text",
ui_section_timer = "Timer",
@@ -19,6 +21,8 @@ local en = {
local ru = {
main_page = "Основное",
texts_page = "Текст",
+ button_page = "Кнопки",
+ scroll_page = "Скролл",
ui_section_button = "Кнопка",
ui_section_text = "Текст",
ui_section_timer = "Таймер",
diff --git a/example/kenney/page/button.lua b/example/kenney/page/button.lua
new file mode 100644
index 0000000..3ff56ff
--- /dev/null
+++ b/example/kenney/page/button.lua
@@ -0,0 +1,51 @@
+local sprite_change_style = {}
+
+local M = {}
+
+
+local function usual_callback()
+ print("Usual callback")
+end
+
+local function long_tap_callback()
+ print("Long tap callback")
+end
+
+local function repeated_callback(self, params, button)
+ print("Repeated callback", button.click_in_row)
+end
+
+local function double_tap_callback(self, params, button)
+ print("Double tap callback", button.click_in_row)
+end
+
+
+local function setup_buttons(self)
+ self.druid:new_button("button_usual/button", usual_callback)
+
+ local custom_style = self.druid:new_button("button_custom_style/button", usual_callback)
+ custom_style:set_style(sprite_change_style)
+ -- HOVER_IMAGE and DEFAULT_IMAGE - from our custom style params
+ custom_style.HOVER_IMAGE = "button_yellow"
+ custom_style.DEFAULT_IMAGE = "button_blue"
+
+ self.druid:new_button("button_long_tap/button", usual_callback)
+ .on_long_click:subscribe(long_tap_callback)
+ self.druid:new_button("button_repeated_tap/button", usual_callback)
+ .on_repeated_click:subscribe(repeated_callback)
+ self.druid:new_button("button_double_tap/button", usual_callback)
+ .on_double_click:subscribe(double_tap_callback)
+
+ local button_space = self.druid:new_button("button_key_trigger/button", usual_callback)
+ button_space:set_key_trigger("key_space")
+ button_space.on_long_click:subscribe(long_tap_callback)
+ button_space.on_double_click:subscribe(double_tap_callback)
+end
+
+
+function M.setup_page(self)
+ setup_buttons(self)
+end
+
+
+return M
diff --git a/example/kenney/page/main.lua b/example/kenney/page/main.lua
index cefd09d..e4d719f 100644
--- a/example/kenney/page/main.lua
+++ b/example/kenney/page/main.lua
@@ -26,16 +26,16 @@ end
local function setup_texts(self)
- self.druid:new_locale("text_button", "ui_section_button")
- self.druid:new_locale("text_text", "ui_section_text")
- self.druid:new_locale("text_timer", "ui_section_timer")
- self.druid:new_locale("text_progress", "ui_section_progress")
- self.druid:new_locale("text_slider", "ui_section_slider")
- self.druid:new_locale("text_radio", "ui_section_radio")
- self.druid:new_locale("text_checkbox", "ui_section_checkbox")
+ self.druid:new_lang_text("text_button", "ui_section_button")
+ self.druid:new_lang_text("text_text", "ui_section_text")
+ self.druid:new_lang_text("text_timer", "ui_section_timer")
+ self.druid:new_lang_text("text_progress", "ui_section_progress")
+ self.druid:new_lang_text("text_slider", "ui_section_slider")
+ self.druid:new_lang_text("text_radio", "ui_section_radio")
+ self.druid:new_lang_text("text_checkbox", "ui_section_checkbox")
- self.druid:new_locale("text_translated", "ui_text_example")
- self.druid:new_locale("text_button_lang", "ui_text_change_lang")
+ self.druid:new_lang_text("text_translated", "ui_text_example")
+ self.druid:new_lang_text("text_button_lang", "ui_text_change_lang")
self.druid:new_text("text_simple", "Simple")
end
diff --git a/example/kenney/page/scroll.lua b/example/kenney/page/scroll.lua
new file mode 100644
index 0000000..8f56646
--- /dev/null
+++ b/example/kenney/page/scroll.lua
@@ -0,0 +1,8 @@
+local M = {}
+
+
+function M.setup_page(self)
+end
+
+
+return M
diff --git a/example/kenney/page/texts.lua b/example/kenney/page/texts.lua
index c1386ce..d1d459d 100644
--- a/example/kenney/page/texts.lua
+++ b/example/kenney/page/texts.lua
@@ -19,7 +19,7 @@ local function setup_texts(self)
self.druid:new_text("text_multiline", "Simple multiline text with smth")
local anchoring = self.druid:new_text("text_anchoring", "Anchoring")
self.druid:new_text("text_no_adjust", "Without adjust size", true)
- self.druid:new_locale("text_locale", "ui_text_example")
+ self.druid:new_lang_text("text_locale", "ui_text_example")
local big_text = "Check max size"
local width = self.druid:new_text("text_max_width", big_text)
diff --git a/game.project b/game.project
index c918863..6e20bc6 100644
--- a/game.project
+++ b/game.project
@@ -17,3 +17,6 @@ include_dirs = druid
[graphics]
texture_profiles = /example/res/custom.texture_profiles
+[input]
+gamepads = /builtins/input/default.gamepadsc
+
diff --git a/input/game.input_binding b/input/game.input_binding
index 4d43ca9..8700888 100644
--- a/input/game.input_binding
+++ b/input/game.input_binding
@@ -6,6 +6,10 @@ key_trigger {
input: KEY_BACK
action: "back"
}
+key_trigger {
+ input: KEY_SPACE
+ action: "key_space"
+}
mouse_trigger {
input: MOUSE_BUTTON_1
action: "touch"
diff --git a/liveupdate.settings b/liveupdate.settings
new file mode 100644
index 0000000..10a44f5
--- /dev/null
+++ b/liveupdate.settings
@@ -0,0 +1,6 @@
+[liveupdate]
+mode = Zip
+zip-filepath = /Users/insality/code/defold/defold-eva/dist
+supported-versions = "1.0.0"
+publickey = /Users/insality/code/provisions/liveupdate/public.der
+privatekey = /Users/insality/code/provisions/liveupdate/private.der
\ No newline at end of file