From aac80795b9af5dbd2d9a7fb01bc66a18daa4e7b4 Mon Sep 17 00:00:00 2001 From: Insality Date: Fri, 7 Feb 2020 01:36:11 +0300 Subject: [PATCH 01/20] Add alpha_todo fur alpha release --- alpha_todo.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 alpha_todo.txt diff --git a/alpha_todo.txt b/alpha_todo.txt new file mode 100644 index 0000000..6073ea5 --- /dev/null +++ b/alpha_todo.txt @@ -0,0 +1,22 @@ +Simple to-do for Druid Alpha 2.0 + +- custom input settings (name of touch, text, etc) +- refactor on_swipe. To on_scroll? Add input priority +- remove button event and match_event from druid +- add docs for all components +- button polish, actions +- ability to relocalize all locale text nodes +- better name for locale component? lang? lang_text? +- better scroll size management, check different cases. So implicit now +- better grid + scroll management +- add druid settings (add auto_focus input and other stuff) +- better default style, add template for custom style +- add template for user components +- add good examples with template and/or nodes (basic component no use any of them) +- add docs folder for every component with gifs? Solutions +- add init/remove stuff for every style in component. How to set custom sprites for button states? +- better callbacks for every components +- separate custom data and predefined fields in components? +- try use final druid in real project (FI uses custom druid) +- better name for slider component? +- add text component for alpha release \ No newline at end of file From b198e095603443b11977ea9f13b07912dc19e210 Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 22 Feb 2020 14:44:01 +0300 Subject: [PATCH 02/20] Add functions stubs --- README.md | 2 +- alpha_todo.txt | 37 +++++++++++++++++++---------- druid/base/button.lua | 42 +++++++++++++++++++++++++++++---- druid/base/input.lua | 15 ++++++++++++ druid/system/druid_instance.lua | 2 +- 5 files changed, 78 insertions(+), 20 deletions(-) create mode 100644 druid/base/input.lua diff --git a/README.md b/README.md index da5806f..298b34e 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 ``` diff --git a/alpha_todo.txt b/alpha_todo.txt index 6073ea5..65da880 100644 --- a/alpha_todo.txt +++ b/alpha_todo.txt @@ -1,22 +1,33 @@ -Simple to-do for Druid Alpha 2.0 +Simple to-do for Druid Alpha 0.2.0 -- custom input settings (name of touch, text, etc) -- refactor on_swipe. To on_scroll? Add input priority + +-- High - remove button event and match_event from druid -- add docs for all components -- button polish, actions -- ability to relocalize all locale text nodes +- add hover component +- add druid events/triggers? better callback system - better name for locale component? lang? lang_text? - better scroll size management, check different cases. So implicit now - better grid + scroll management +- button polish, actions +- button add key trigger +- add text component for alpha release +- refactor on_swipe. To on_scroll? Add input priority - add druid settings (add auto_focus input and other stuff) -- better default style, add template for custom style -- add template for user components -- add good examples with template and/or nodes (basic component no use any of them) -- add docs folder for every component with gifs? Solutions - add init/remove stuff for every style in component. How to set custom sprites for button states? - better callbacks for every components -- separate custom data and predefined fields in components? -- try use final druid in real project (FI uses custom druid) +- better default style, add template for custom style +- add docs for all components +- add docs folder for every component with gifs? Solutions - better name for slider component? -- add text component for alpha release \ No newline at end of file +- separate custom data and predefined fields in components? +- unify component api (get/set/to and other general stuff) +- compare with gooey + + +-- Low +- add code template and example for user components +- custom input settings (name of touch, text, etc) +- ability to relocalize all locale text nodes +- 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?) +- Druid store assest - separate repository with rich components diff --git a/druid/base/button.lua b/druid/base/button.lua index 5367a57..95add22 100644 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -1,11 +1,6 @@ --- Component to handle basic GUI button -- @module druid.button --- TODO: Add button mode: --- Long tap --- Repeated tap --- Double tap? - local const = require("druid.const") local helper = require("druid.helper") local component = require("druid.component") @@ -148,4 +143,41 @@ function M.set_click_zone(self, zone) end +-- TODO: implement them all! +--- Set key-code to trigger this button +function M.set_key_trigger(self, key) + +end + + +--- Get key-code to trigger this button +function M.get_key_trigger(self) + +end + + +--- Set usual button callback +function M.set_callback(self, callback) + +end + + +--- Repeat callback always, while holding button +function M.set_hold_callback(self, callback) + +end + + +--- Get doubletap callback on this button +function M.set_double_tap_callback(self, callback) + +end + + +--- Single callbacka after long_tap. No usual callback invoked +function M.set_long_tap_callback(self, callback) + +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/system/druid_instance.lua b/druid/system/druid_instance.lua index 4a524fe..d3800ae 100644 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -33,7 +33,7 @@ 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") From 0dd37a03cd39ff8dba84db847a57ff2e85382261 Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 22 Feb 2020 14:49:22 +0300 Subject: [PATCH 03/20] Add simple druid event library --- druid/event.lua | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 druid/event.lua diff --git a/druid/event.lua b/druid/event.lua new file mode 100644 index 0000000..f84ac00 --- /dev/null +++ b/druid/event.lua @@ -0,0 +1,37 @@ +--- Lua event small library + +local class = require("druid.system.middleclass") + +local M = class("druid.event") + + +function M.initialize(self) + self._callbacks = {} +end + + +function M.subscribe(self, callback) + assert(type(callback) == "function", "Callback should be function") + + table.insert(self._callbacks, callback) +end + + +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 + + +function M.trigger(self, ...) + for i = 1, #self._callbacks do + self._callbacks[i](...) + end +end + + +return M From 3e30fd44172fb9ef617ebfc93eda5747015ea75d Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 22 Feb 2020 15:09:29 +0300 Subject: [PATCH 04/20] Remove match_event from druid, add hover component --- druid/base/back_handler.lua | 6 +-- druid/base/blocker.lua | 5 ++- druid/base/button.lua | 6 ++- druid/base/hover.lua | 76 +++++++++++++++++++++++++++++++++ druid/system/druid_instance.lua | 37 +++++++++------- 5 files changed, 109 insertions(+), 21 deletions(-) create mode 100644 druid/base/hover.lua diff --git a/druid/base/back_handler.lua b/druid/base/back_handler.lua index 67078c5..70cd190 100644 --- a/druid/base/back_handler.lua +++ b/druid/base/back_handler.lua @@ -13,7 +13,6 @@ 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 end @@ -24,11 +23,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 + if action_id == const.ACTION_BACK and action[const.RELEASED] then self.callback(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..54d41b3 100644 --- a/druid/base/blocker.lua +++ b/druid/base/blocker.lua @@ -10,11 +10,14 @@ local M = component.create("blocker", { const.ON_SWIPE }) function M.init(self, node) self.node = self:get_node(node) - self.event = const.ACTION_TOUCH 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 diff --git a/druid/base/button.lua b/druid/base/button.lua index 95add22..85d68dd 100644 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -22,8 +22,6 @@ function M.init(self, node, callback, params, anim_node, event) self.style = self:get_style() self.node = self:get_node(node) - -- 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) @@ -67,6 +65,10 @@ 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 diff --git a/druid/base/hover.lua b/druid/base/hover.lua new file mode 100644 index 0000000..0015f35 --- /dev/null +++ b/druid/base/hover.lua @@ -0,0 +1,76 @@ +--- 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() + if on_hover_callback then + self.on_hover:subscribe(on_hover_callback) + end +end + + +local function set_hover(self, state) + if self._is_hovered ~= state then + self._is_hovered = state + self.on_hover:trigger(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 not is_pick then + set_hover(self, false) + return false + end + + if action.released then + set_hover(self, false) + else + set_hover(self, true) + end +end + + +function M.on_swipe(self) + 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/system/druid_instance.lua b/druid/system/druid_instance.lua index d3800ae..9907edd 100644 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -4,6 +4,7 @@ -- @see druid.button -- @see druid.blocker -- @see druid.back_handler +-- @see druid.input -- @see druid.text -- @see druid.locale -- @see druid.timer @@ -23,6 +24,7 @@ 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 timer = require("druid.base.timer") @@ -33,7 +35,7 @@ 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") @@ -94,19 +96,6 @@ local function notify_input_on_swipe(self) 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 -end - - --- Druid class constructor -- @function druid:initialize -- @tparam context table Druid context. Usually it is self of script @@ -200,7 +189,7 @@ function Druid.on_input(self, action_id, action) 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 + if v:on_input(action_id, action) then return true end end @@ -262,6 +251,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 @@ -334,6 +332,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 From 2c0b100ab7e4fdea95ac50850694f4cab16452c8 Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 22 Feb 2020 15:19:18 +0300 Subject: [PATCH 05/20] Move hover logic from button to hover component --- druid/base/button.lua | 33 +++++++++++---------------------- druid/base/hover.lua | 5 +++-- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/druid/base/button.lua b/druid/base/button.lua index 85d68dd..36bc2d4 100644 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -8,6 +8,14 @@ local component = require("druid.component") local M = component.create("button", { const.ON_INPUT }) +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 + --- Component init function -- @function button:init -- @tparam table self Component instance @@ -19,6 +27,7 @@ local M = component.create("button", { const.ON_INPUT }) function M.init(self, node, callback, params, anim_node, event) assert(callback, "Button should have callback. To block input on zone use blocker component") + self.druid = self:get_druid() self.style = self:get_style() self.node = self:get_node(node) @@ -29,20 +38,12 @@ function M.init(self, node, callback, params, anim_node, event) self.callback = callback self.params = params self.hover_anim = self.style.IS_HOVER + self.hover = self.druid:new_hover(node, self, on_button_hover) + self.click_zone = nil 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 - end -end - - local function on_button_release(self) if not self.disabled then if not self.stub and self.can_action then @@ -51,8 +52,6 @@ local function on_button_release(self) self.style.on_click(self, self.anim_node) end self.callback(self:get_context(), self.params, self) - else - set_hover(self, false) end return true else @@ -81,7 +80,6 @@ function M.on_input(self, action_id, action) if not is_pick then -- Can't interact, if touch outside of button self.can_action = false - set_hover(self, false) return false end @@ -93,10 +91,7 @@ function M.on_input(self, action_id, action) end if action.released then - set_hover(self, false) return on_button_release(self) - else - set_hover(self, true) end return not self.disabled @@ -104,17 +99,11 @@ end function M.on_swipe(self) - -- unhover button if start swipe 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) diff --git a/druid/base/hover.lua b/druid/base/hover.lua index 0015f35..dbf5016 100644 --- a/druid/base/hover.lua +++ b/druid/base/hover.lua @@ -14,11 +14,12 @@ local M = component.create("hover", { const.ON_INPUT }) -- @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) +function M.init(self, node, context, on_hover_callback) self.style = self:get_style() self.node = self:get_node(node) self._is_hovered = false + self.context = context self.on_hover = Event() if on_hover_callback then self.on_hover:subscribe(on_hover_callback) @@ -29,7 +30,7 @@ end local function set_hover(self, state) if self._is_hovered ~= state then self._is_hovered = state - self.on_hover:trigger(state) + self.on_hover:trigger(self.context, state) end end From 640753c080343d6a5795f7434bd02368d073853e Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 22 Feb 2020 15:24:52 +0300 Subject: [PATCH 06/20] Rename locale -> lang_text --- alpha_todo.txt | 8 +++-- druid/base/button.lua | 39 ++++++++++++------------ druid/base/{locale.lua => lang_text.lua} | 4 +-- druid/system/druid_instance.lua | 16 +++++----- example/kenney/gui/main/main.gui_script | 2 +- example/kenney/page/main.lua | 18 +++++------ example/kenney/page/texts.lua | 2 +- 7 files changed, 46 insertions(+), 43 deletions(-) rename druid/base/{locale.lua => lang_text.lua} (90%) diff --git a/alpha_todo.txt b/alpha_todo.txt index 65da880..e5c646a 100644 --- a/alpha_todo.txt +++ b/alpha_todo.txt @@ -2,9 +2,9 @@ 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 ++ 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 scroll size management, check different cases. So implicit now - better grid + scroll management @@ -22,6 +22,7 @@ Simple to-do for Druid Alpha 0.2.0 - separate custom data and predefined fields in components? - unify component api (get/set/to and other general stuff) - compare with gooey +- button and hover click restriction zone? -- Low @@ -31,3 +32,4 @@ Simple to-do for Druid Alpha 0.2.0 - 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?) - Druid store assest - separate repository with rich components +- ability to control buttons via controller. Select it by cursor (d-pad) diff --git a/druid/base/button.lua b/druid/base/button.lua index 36bc2d4..d0de518 100644 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -16,6 +16,26 @@ local function on_button_hover(self, hover_state) self.style.on_hover(self, self.anim_node, hover_state) end + +local function on_button_release(self) + if not self.disabled then + if not self.stub and self.can_action then + self.can_action = false + if self.style.on_click then + self.style.on_click(self, self.anim_node) + end + self.callback(self:get_context(), self.params, self) + end + return true + else + if self.style.on_click_disabled then + self.style.on_click_disabled(self, self.anim_node) + end + return false + end +end + + --- Component init function -- @function button:init -- @tparam table self Component instance @@ -44,25 +64,6 @@ function M.init(self, node, callback, params, anim_node, event) end -local function on_button_release(self) - if not self.disabled then - if not self.stub and self.can_action then - self.can_action = false - if self.style.on_click then - self.style.on_click(self, self.anim_node) - end - self.callback(self:get_context(), self.params, self) - end - return true - else - if self.style.on_click_disabled then - self.style.on_click_disabled(self, self.anim_node) - end - return false - end -end - - function M.on_input(self, action_id, action) if action_id ~= const.ACTION_TOUCH then return false 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/system/druid_instance.lua b/druid/system/druid_instance.lua index 9907edd..08e790a 100644 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -6,7 +6,7 @@ -- @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 @@ -26,7 +26,7 @@ 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") @@ -269,12 +269,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 diff --git a/example/kenney/gui/main/main.gui_script b/example/kenney/gui/main/main.gui_script index 0f9fed2..357e8b3 100644 --- a/example/kenney/gui/main/main.gui_script +++ b/example/kenney/gui/main/main.gui_script @@ -29,7 +29,7 @@ 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 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/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) From 3ae5011bde462c24fc199163da66bda808113fe4 Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 22 Feb 2020 15:44:20 +0300 Subject: [PATCH 07/20] Liveupdate 165 fixes --- alpha_todo.txt | 18 +++++++++--------- liveupdate.settings | 6 ++++++ 2 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 liveupdate.settings diff --git a/alpha_todo.txt b/alpha_todo.txt index e5c646a..ac659ed 100644 --- a/alpha_todo.txt +++ b/alpha_todo.txt @@ -5,24 +5,24 @@ Simple to-do for Druid Alpha 0.2.0 + 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 scroll size management, check different cases. So implicit now -- better grid + scroll management -- button polish, actions -- button add key trigger -- add text component for alpha release ++ better name for locale component? lang? lang_text? ++ better name for slider component? Slider is ok - refactor on_swipe. To on_scroll? Add input priority -- add druid settings (add auto_focus input and other stuff) +- separate custom data and predefined fields in components? - add init/remove stuff for every style in component. How to set custom sprites for button states? +- button add key trigger +- button polish, actions +- add druid settings (add auto_focus input and other stuff) - better callbacks for every components - better default style, add template for custom style - add docs for all components - add docs folder for every component with gifs? Solutions -- better name for slider component? -- separate custom data and predefined fields in components? - unify component api (get/set/to and other general stuff) +- add text component for alpha release - compare with gooey - button and hover click restriction zone? +- better scroll size management, check different cases. So implicit now +- better grid + scroll management -- Low 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 From 44016bc4f3fac5e3e84e9ea8e4c21836b397c07e Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 22 Feb 2020 23:54:26 +0300 Subject: [PATCH 08/20] Remove progress_rich component, move it to separate repository (druid-assets) --- druid/rich/progress_rich.lua | 72 --------------------------------- druid/system/druid_instance.lua | 10 ----- 2 files changed, 82 deletions(-) delete mode 100644 druid/rich/progress_rich.lua 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/system/druid_instance.lua b/druid/system/druid_instance.lua index 08e790a..684c515 100644 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -37,7 +37,6 @@ local checkbox_group = require("druid.base.checkbox_group") local radio_group = require("druid.base.radio_group") 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") @@ -359,13 +358,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 From c2b65eb4e20b22db8719b245854629b11fe379aa Mon Sep 17 00:00:00 2001 From: Insality Date: Sun, 23 Feb 2020 12:17:25 +0300 Subject: [PATCH 09/20] Input priority little rework? Remove on_swipe --- README.md | 8 ++--- alpha_todo.txt | 20 ++++++------ druid/base/blocker.lua | 2 +- druid/base/button.lua | 9 +++++- druid/base/hover.lua | 2 +- druid/base/scroll.lua | 2 +- druid/base/slider.lua | 2 +- druid/const.lua | 49 ++++++++---------------------- druid/system/druid_instance.lua | 54 ++++++++++++++------------------- 9 files changed, 61 insertions(+), 87 deletions(-) diff --git a/README.md b/README.md index 298b34e..60931e1 100644 --- a/README.md +++ b/README.md @@ -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 index ac659ed..aae9b80 100644 --- a/alpha_todo.txt +++ b/alpha_todo.txt @@ -7,29 +7,29 @@ Simple to-do for Druid Alpha 0.2.0 + 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? - add init/remove stuff for every style in component. How to set custom sprites for button states? +- unify component api (get/set/to and other general stuff) +- add druid settings (add auto_focus input and other stuff) - button add key trigger - button polish, actions -- add druid settings (add auto_focus input and other stuff) -- better callbacks for every components -- better default style, add template for custom style -- add docs for all components -- add docs folder for every component with gifs? Solutions -- unify component api (get/set/to and other general stuff) -- add text component for alpha release -- compare with gooey - button and hover click restriction zone? +- 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 -- Low - add code template and example for user components - custom input settings (name of touch, text, etc) -- ability to relocalize all locale text nodes - 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?) -- Druid store assest - separate repository with rich components +- ability to relocalize all locale text nodes - ability to control buttons via controller. Select it by cursor (d-pad) diff --git a/druid/base/blocker.lua b/druid/base/blocker.lua index 54d41b3..d03fc3f 100644 --- a/druid/base/blocker.lua +++ b/druid/base/blocker.lua @@ -5,7 +5,7 @@ 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) diff --git a/druid/base/button.lua b/druid/base/button.lua index d0de518..618663f 100644 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -1,6 +1,7 @@ --- Component to handle basic GUI button -- @module druid.button +local Event = require("druid.event") local const = require("druid.const") local helper = require("druid.helper") local component = require("druid.component") @@ -60,6 +61,12 @@ function M.init(self, node, callback, params, anim_node, event) self.hover_anim = self.style.IS_HOVER self.hover = self.druid:new_hover(node, self, on_button_hover) + -- Event stubs + self.on_click = Event() + self.on_hold_click = Event() + self.on_long_click = Event() + self.on_double_click = Event() + self.click_zone = nil end @@ -99,7 +106,7 @@ function M.on_input(self, action_id, action) end -function M.on_swipe(self) +function M.on_input_interrupt(self) self.can_action = false end diff --git a/druid/base/hover.lua b/druid/base/hover.lua index dbf5016..71a15bc 100644 --- a/druid/base/hover.lua +++ b/druid/base/hover.lua @@ -59,7 +59,7 @@ function M.on_input(self, action_id, action) end -function M.on_swipe(self) +function M.on_input_interrupt(self) set_hover(self, false) end diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index a00459a..b5382ca 100644 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -5,7 +5,7 @@ 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 diff --git a/druid/base/slider.lua b/druid/base/slider.lua index 5b8d691..80a8534 100644 --- a/druid/base/slider.lua +++ b/druid/base/slider.lua @@ -5,7 +5,7 @@ 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) 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/system/druid_instance.lua b/druid/system/druid_instance.lua index 684c515..1a217ca 100644 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -82,16 +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 + + return is_input_consumed end @@ -169,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 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 From cb6fd3038a68f3bb59e26d4329dc8c43646450cc Mon Sep 17 00:00:00 2001 From: Insality Date: Sun, 23 Feb 2020 13:00:59 +0300 Subject: [PATCH 10/20] Add examples to component docs --- alpha_todo.txt | 3 ++- config.ld | 6 +++++- druid/base/button.lua | 11 +++++++++++ druid/druid.lua | 5 +++++ druid/event.lua | 2 ++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/alpha_todo.txt b/alpha_todo.txt index aae9b80..552c412 100644 --- a/alpha_todo.txt +++ b/alpha_todo.txt @@ -8,7 +8,7 @@ Simple to-do for Druid Alpha 0.2.0 + 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 ++ refactor on_swipe. To on_scroll? Add input priority - separate custom data and predefined fields in components? - add init/remove stuff for every style in component. How to set custom sprites for button states? - unify component api (get/set/to and other general stuff) @@ -24,6 +24,7 @@ Simple to-do for Druid Alpha 0.2.0 - compare with gooey - add docs for all components - add docs folder for every component with gifs? Solutions +- remove component autoremove all children component -- Low diff --git a/config.ld b/config.ld index 43d3a05..b9a95cd 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=true 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/druid/base/button.lua b/druid/base/button.lua index 618663f..22f55b2 100644 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -1,6 +1,17 @@ --- Component to handle basic GUI button -- @module druid.button +--- Component events +-- @tfield druid_event on_click +-- @tfield druid_event on_hold_click +-- @tfield druid_event on_long_click +-- @tfield druid_event on_double_click +-- @table events + +--- Component fields +-- @tfield node Main node +-- @table fields + local Event = require("druid.event") local const = require("druid.const") local helper = require("druid.helper") 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 index f84ac00..baccb8e 100644 --- a/druid/event.lua +++ b/druid/event.lua @@ -1,7 +1,9 @@ --- Lua event small library +-- @module druid_event local class = require("druid.system.middleclass") +-- @class DruidEvent local M = class("druid.event") From 5c576e6059e8498f54d606dbe25f9a95c85736f8 Mon Sep 17 00:00:00 2001 From: Insality Date: Sun, 23 Feb 2020 13:01:15 +0300 Subject: [PATCH 11/20] Update ldoc --- docs/index.html | 25 +- docs/{ldoc_pale.css => ldoc_fixed.css} | 14 +- docs/modules/component.html | 544 ++++++------ docs/modules/druid.back_handler.html | 19 +- docs/modules/druid.blocker.html | 19 +- docs/modules/druid.button.html | 265 +++++- docs/modules/druid.checkbox.html | 19 +- docs/modules/druid.checkbox_group.html | 19 +- docs/modules/druid.grid.html | 18 +- .../{helper.html => druid.helper.html} | 154 +++- docs/modules/druid.html | 94 ++- ...id.progress_rich.html => druid.input.html} | 86 +- ...druid.locale.html => druid.lang_text.html} | 21 +- docs/modules/druid.progress.html | 183 +++-- docs/modules/druid.radio_group.html | 19 +- docs/modules/druid.scroll.html | 177 ++-- docs/modules/druid.slider.html | 19 +- docs/modules/druid.text.html | 69 +- docs/modules/druid.timer.html | 55 +- docs/modules/{const.html => druid_event.html} | 86 +- docs/modules/druid_instance.html | 775 +++++++++--------- docs/modules/helper.formats.html | 191 ----- 22 files changed, 1493 insertions(+), 1378 deletions(-) rename docs/{ldoc_pale.css => ldoc_fixed.css} (95%) rename docs/modules/{helper.html => druid.helper.html} (70%) rename docs/modules/{druid.progress_rich.html => druid.input.html} (61%) rename docs/modules/{druid.locale.html => druid.lang_text.html} (87%) rename docs/modules/{const.html => druid_event.html} (56%) delete mode 100644 docs/modules/helper.formats.html diff --git a/docs/index.html b/docs/index.html index 193baec..45b2665 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-23 13:01:03
    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..d0b3851 100644 --- a/docs/modules/component.html +++ b/docs/modules/component.html @@ -4,7 +4,7 @@ Defold Druid UI Library - + @@ -38,23 +38,24 @@

    Modules

    @@ -64,59 +65,58 @@

    Module component

    Basic class for all Druid components.

    -

    - To create you component, use `component.create`

    +

    To create you component, use component.create

    Functions

    - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + +
    setup_component(table, table)Setup component context and his style table
    get_style()Get current component style table
    set_style(style)Set current component style table
    get_template()Get current component template name
    set_template(template)Set current component template name
    get_nodes()Get current component nodes
    set_nodes(nodes)Set current component nodesComponent.create(name, interest)Create new component.
    get_context() Get current component context
    set_context(context)Set current component contextget_druid()Return druid with context of calling component.
    get_interests() Get current component interests
    get_druid()Return druid with context of calling component.get_nodes()Get current component nodes
    Component.create(name, interest)Create new component.get_style()Get current component style table
    get_template()Get current component template name
    set_context(context)Set current component context
    set_nodes(nodes)Set current component nodes
    set_style(style)Set current component style table
    set_template(template)Set current component template name
    setup_component(table, table)Setup component context and his style table
    @@ -127,6 +127,237 @@

    Functions

    +
    + + Component.create(name, interest) +
    +
    + Create new component. It will inheritance from basic + druid component. + + +

    Parameters:

    +
      +
    • name + string + Component name +
    • +
    • interest + table + List of component's interest +
    • +
    + + + + + +
    +
    + + get_context() +
    +
    + Get current component context + + + +

    Returns:

    +
      + + table + Component context +
    + + + + +
    +
    + + get_druid() +
    +
    + Return druid with context of calling component. + Use it to create component inside of other components. + + + +

    Returns:

    +
      + + Druid + Druid instance with component context +
    + + + + +
    +
    + + get_interests() +
    +
    + Get current component interests + + + +

    Returns:

    +
      + + table + List of component interests +
    + + + + +
    +
    + + get_nodes() +
    +
    + Get current component nodes + + + +

    Returns:

    +
      + + table + Component nodes table +
    + + + + +
    +
    + + get_style() +
    +
    + Get current component style table + + + +

    Returns:

    +
      + + table + Component style table +
    + + + + +
    +
    + + get_template() +
    +
    + Get current component template name + + + +

    Returns:

    +
      + + string + Component template name +
    + + + + +
    +
    + + set_context(context) +
    +
    + Set current component context + + +

    Parameters:

    +
      +
    • context + table + Druid context. Usually it is self of script +
    • +
    + + + + + +
    +
    + + set_nodes(nodes) +
    +
    + Set current component nodes + + +

    Parameters:

    +
      +
    • nodes + table + Component nodes table +
    • +
    + + + + + +
    +
    + + set_style(style) +
    +
    + Set current component style table + + +

    Parameters:

    +
      +
    • style + table + Druid style module +
    • +
    + + + + + +
    +
    + + set_template(template) +
    +
    + Set current component template name + + +

    Parameters:

    +
      +
    • template + string + Component template name +
    • +
    + + + + + +
    setup_component(table, table) @@ -157,237 +388,6 @@ - -
    - - get_style() -
    -
    - Get current component style table - - - -

    Returns:

    -
      - - table - Component style table -
    - - - - -
    -
    - - set_style(style) -
    -
    - Set current component style table - - -

    Parameters:

    -
      -
    • style - table - Druid style module -
    • -
    - - - - - -
    -
    - - get_template() -
    -
    - Get current component template name - - - -

    Returns:

    -
      - - string - Component template name -
    - - - - -
    -
    - - set_template(template) -
    -
    - Set current component template name - - -

    Parameters:

    -
      -
    • template - string - Component template name -
    • -
    - - - - - -
    -
    - - get_nodes() -
    -
    - Get current component nodes - - - -

    Returns:

    -
      - - table - Component nodes table -
    - - - - -
    -
    - - set_nodes(nodes) -
    -
    - Set current component nodes - - -

    Parameters:

    -
      -
    • nodes - table - Component nodes table -
    • -
    - - - - - -
    -
    - - get_context() -
    -
    - Get current component context - - - -

    Returns:

    -
      - - table - Component context -
    - - - - -
    -
    - - set_context(context) -
    -
    - Set current component context - - -

    Parameters:

    -
      -
    • context - table - Druid context. Usually it is self of script -
    • -
    - - - - - -
    -
    - - get_interests() -
    -
    - Get current component interests - - - -

    Returns:

    -
      - - table - List of component interests -
    - - - - -
    -
    - - get_druid() -
    -
    - Return druid with context of calling component. - Use it to create component inside of other components. - - - -

    Returns:

    -
      - - Druid - Druid instance with component context -
    - - - - -
    -
    - - Component.create(name, interest) -
    -
    - Create new component. It will inheritance from basic - druid component. - - -

    Parameters:

    -
      -
    • name - string - Component name -
    • -
    • interest - table - List of component's interest -
    • -
    - - - - -
    @@ -396,7 +396,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-07 01:09:38 +Last updated 2020-02-23 13:01:03
    diff --git a/docs/modules/druid.back_handler.html b/docs/modules/druid.back_handler.html index c0b420f..66881c1 100644 --- a/docs/modules/druid.back_handler.html +++ b/docs/modules/druid.back_handler.html @@ -4,7 +4,7 @@ Defold Druid UI Library - + @@ -38,23 +38,24 @@

    Modules

    @@ -64,7 +65,9 @@

    Module druid.back_handler

    Component to handle back key (android, backspace)

    -

    +

    + +

    Functions

    @@ -148,7 +151,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-07 01:09:38 +Last updated 2020-02-23 13:01:03
    diff --git a/docs/modules/druid.blocker.html b/docs/modules/druid.blocker.html index e1924ab..cd46818 100644 --- a/docs/modules/druid.blocker.html +++ b/docs/modules/druid.blocker.html @@ -4,7 +4,7 @@ Defold Druid UI Library - + @@ -34,23 +34,24 @@

    Modules

    @@ -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-23 13:01:03
    diff --git a/docs/modules/druid.button.html b/docs/modules/druid.button.html index 7e0edbc..4108eb2 100644 --- a/docs/modules/druid.button.html +++ b/docs/modules/druid.button.html @@ -4,7 +4,7 @@ Defold Druid UI Library - + @@ -33,28 +33,30 @@

    Contents

    Modules

    @@ -64,23 +66,56 @@

    Module druid.button

    Component to handle basic GUI button

    -

    +

    + +

    Functions

    - - - - + + + + + + + + + + + + + + + + + + + + + + + + +
    init(self, node, callback[, params[, anim_node[, event]]])Component init function
    disable_animation(self) Disable all button animations
    get_key_trigger(self)Get key-code to trigger this button
    init(self, node, callback[, params[, anim_node[, event]]])Component init function
    set_callback(self, callback)Set usual button callback
    set_click_zone(self, zone) Strict button click area.
    set_double_tap_callback(self, callback)Get doubletap callback on this button
    set_hold_callback(self, callback)Repeat callback always, while holding button
    set_long_tap_callback(self, callback)Single callbacka after long_tap.
    +

    Tables

    + + + + + + + + +
    eventsComponent events
    fieldsComponent fields

    @@ -90,6 +125,49 @@

    Functions

    +
    + + disable_animation(self) +
    +
    + Disable all button animations + + +

    Parameters:

    +
      +
    • self + table + Component instance +
    • +
    + + + + + +
    +
    + + get_key_trigger(self) +
    +
    + Get key-code to trigger this button + + +

    Parameters:

    +
      +
    • self + + + +
    • +
    + + + + + +
    init(self, node, callback[, params[, anim_node[, event]]]) @@ -135,18 +213,24 @@
    - - disable_animation(self) + + set_callback(self, callback)
    - Disable all button animations + Set usual button callback

    Parameters:

    • self - table - Component instance + + + +
    • +
    • callback + + +
    @@ -180,6 +264,153 @@ +
    +
    + + set_double_tap_callback(self, callback) +
    +
    + Get doubletap callback on this button + + +

    Parameters:

    +
      +
    • self + + + +
    • +
    • callback + + + +
    • +
    + + + + + +
    +
    + + set_hold_callback(self, callback) +
    +
    + Repeat callback always, while holding button + + +

    Parameters:

    +
      +
    • self + + + +
    • +
    • callback + + + +
    • +
    + + + + + +
    +
    + + set_long_tap_callback(self, callback) +
    +
    + Single callbacka after long_tap. No usual callback invoked + + +

    Parameters:

    +
      +
    • self + + + +
    • +
    • callback + + + +
    • +
    + + + + + +
    +
    +

    Tables

    + +
    +
    + + events +
    +
    + Component events + + +

    Fields:

    +
      +
    • on_click + druid_event + + + +
    • +
    • on_hold_click + druid_event + + + +
    • +
    • on_long_click + druid_event + + + +
    • +
    • on_double_click + druid_event + + + +
    • +
    + + + + + +
    +
    + + fields +
    +
    + Component fields + + +

    Fields:

    +
      +
    • Main + node + node +
    • +
    + + + + +
    @@ -188,7 +419,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-07 01:09:38 +Last updated 2020-02-23 13:01:03
    diff --git a/docs/modules/druid.checkbox.html b/docs/modules/druid.checkbox.html index 51a2f75..e3b8461 100644 --- a/docs/modules/druid.checkbox.html +++ b/docs/modules/druid.checkbox.html @@ -4,7 +4,7 @@ Defold Druid UI Library - + @@ -34,23 +34,24 @@

    Modules

    @@ -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-23 13:01:03
    diff --git a/docs/modules/druid.checkbox_group.html b/docs/modules/druid.checkbox_group.html index 0071b08..6a20fe6 100644 --- a/docs/modules/druid.checkbox_group.html +++ b/docs/modules/druid.checkbox_group.html @@ -4,7 +4,7 @@ Defold Druid UI Library - + @@ -34,23 +34,24 @@

    Modules

    @@ -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-23 13:01:03
    diff --git a/docs/modules/druid.grid.html b/docs/modules/druid.grid.html index 9321a7f..ad0f258 100644 --- a/docs/modules/druid.grid.html +++ b/docs/modules/druid.grid.html @@ -4,7 +4,7 @@ Defold Druid UI Library - + @@ -34,23 +34,24 @@

    Modules

    @@ -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-23 13:01:03
    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..820aaec 100644 --- a/docs/modules/helper.html +++ b/docs/modules/druid.helper.html @@ -4,7 +4,7 @@ Defold Druid UI Library - + @@ -38,23 +38,24 @@

    Modules

    @@ -62,20 +63,30 @@
    -

    Module helper

    +

    Module druid.helper

    Text node or icon node can be nil

    -

    +

    + +

    Functions

    + + + + - - + + + + + +
    centrate_icon_with_text([icon_node[, text_node[, margin=0]]])Center two nodes.
    centrate_text_with_icon([text_node][, icon_node], margin) Center two nodes.
    centrate_icon_with_text([icon_node[, text_node[, margin=0]]])Center two nodes.get_pivot_offset(pivot)Get node offset for given gui pivot
    is_enabled(node)Check if node is enabled in gui hierarchy.
    @@ -86,39 +97,6 @@

    Functions

    -
    - - centrate_text_with_icon([text_node][, icon_node], margin) -
    -
    - Center two nodes. - Nodes will be center around 0 x position - text_node will be first (at left side) - - -

    Parameters:

    -
      -
    • text_node - text - Gui text node - (optional) -
    • -
    • icon_node - box - Gui box node - (optional) -
    • -
    • margin - number - Offset between nodes -
    • -
    - - - - - -
    centrate_icon_with_text([icon_node[, text_node[, margin=0]]]) @@ -152,6 +130,94 @@ + +
    + + centrate_text_with_icon([text_node][, icon_node], margin) +
    +
    + Center two nodes. + Nodes will be center around 0 x position + text_node will be first (at left side) + + +

    Parameters:

    +
      +
    • text_node + text + Gui text node + (optional) +
    • +
    • icon_node + box + Gui box node + (optional) +
    • +
    • margin + number + Offset between nodes +
    • +
    + + + + + +
    +
    + + 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 +
    + + + + +
    +
    + + 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 +
    + + + +
    @@ -160,7 +226,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-07 01:09:38 +Last updated 2020-02-23 13:01:03
    diff --git a/docs/modules/druid.html b/docs/modules/druid.html index 18bfff8..eef8815 100644 --- a/docs/modules/druid.html +++ b/docs/modules/druid.html @@ -4,7 +4,7 @@ Defold Druid UI Library - + @@ -38,23 +38,24 @@

    Modules

    @@ -65,25 +66,36 @@

    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
    +
    +

    Functions

    - - - - + + + +
    register(name, module)Register external druid component.
    new(context[, style]) Create Druid instance.
    register(name, module)Register external druid component.

    @@ -93,33 +105,6 @@

    Functions

    -
    - - register(name, module) -
    -
    - Register external druid component. - After register you can create the component with - druid_instance:new_{name}. For example `druid:new_button(...)` - - -

    Parameters:

    -
      -
    • name - string - module name -
    • -
    • module - table - lua table with component -
    • -
    - - - - - -
    new(context[, style]) @@ -151,6 +136,33 @@ + +
    + + register(name, module) +
    +
    + Register external druid component. + After register you can create the component with + druidinstance:new{name}. For example druid:new_button(...) + + +

    Parameters:

    +
      +
    • name + string + module name +
    • +
    • module + table + lua table with component +
    • +
    + + + + +
    @@ -159,7 +171,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-07 01:09:38 +Last updated 2020-02-23 13:01:03
    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..234ed47 100644 --- a/docs/modules/druid.progress_rich.html +++ b/docs/modules/druid.input.html @@ -4,7 +4,7 @@ Defold Druid UI Library - + @@ -38,23 +38,24 @@

    Modules

    @@ -62,24 +63,22 @@
    -

    Module druid.progress_rich

    -

    Component for rich progress component

    -

    +

    Module druid.input

    +

    Component to handle hover node interaction

    +

    + +

    Functions

    - - + + - - - - - - + +
    set_to(self, value)Instant fill progress bar to valuebutton:set_click_zone(self, zone)Strict button click area.
    empty(self)Empty a progress bar
    to(self, to[, callback])Start animation of a progress barhover:init(self, node, on_hover_callback)Component init function
    @@ -91,11 +90,12 @@
    - - set_to(self, value) + + button:set_click_zone(self, zone)
    - Instant fill progress bar to value + Strict button click area. Useful for + no click events outside stencil node

    Parameters:

    @@ -104,9 +104,9 @@ table Component instance -
  • value - number - Progress bar value, from 0 to 1 +
  • zone + node + Gui node
  • @@ -116,11 +116,11 @@
    - - empty(self) + + hover:init(self, node, on_hover_callback)
    - Empty a progress bar + Component init function

    Parameters:

    @@ -129,35 +129,13 @@ table Component instance - - - - - - -
    -
    - - to(self, to[, callback]) -
    -
    - Start animation of a progress bar - - -

    Parameters:

    -
      -
    • self - table - Component instance +
    • node + node + Gui node
    • -
    • to - number - value between 0..1 -
    • -
    • callback +
    • on_hover_callback function - Callback on animation ends - (optional) + Hover callback
    @@ -173,7 +151,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-07 01:09:38 +Last updated 2020-02-23 13:01:03
    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..7eefddd 100644 --- a/docs/modules/druid.locale.html +++ b/docs/modules/druid.lang_text.html @@ -4,7 +4,7 @@ Defold Druid UI Library - + @@ -38,23 +38,24 @@

    Modules

    @@ -62,10 +63,12 @@
    -

    Module druid.locale

    +

    Module druid.lang_text

    Component to handle all GUI texts Good working with localization system

    -

    +

    + +

    Functions

    @@ -115,7 +118,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-07 01:09:38 +Last updated 2020-02-23 13:01:03
    diff --git a/docs/modules/druid.progress.html b/docs/modules/druid.progress.html index c133fb8..a505c5a 100644 --- a/docs/modules/druid.progress.html +++ b/docs/modules/druid.progress.html @@ -4,7 +4,7 @@ Defold Druid UI Library - + @@ -38,23 +38,24 @@

    Modules

    @@ -64,36 +65,38 @@

    Module druid.progress

    Basic progress bar component

    -

    +

    + +

    Functions

    - - + + - - - - - - - - + + + + + + + + @@ -106,6 +109,69 @@

    Functions

    +
    + + empty(self) +
    +
    + Empty a progress bar + + +

    Parameters:

    +
      +
    • self + table + Component instance +
    • +
    + + + + + +
    +
    + + empty(self) +
    +
    + Fill a progress bar and stop progress animation + + +

    Parameters:

    +
      +
    • self + table + Component instance +
    • +
    + + + + + +
    +
    + + get(self) +
    +
    + Return current progress bar value + + +

    Parameters:

    +
      +
    • self + table + Component instance +
    • +
    + + + + + +
    init(self, node, key, init_value) @@ -140,11 +206,11 @@
    - - empty(self) + + set_steps(self, steps, callback)
    - Fill a progress bar and stop progress animation + Set points on progress bar to fire the callback

    Parameters:

    @@ -153,26 +219,13 @@ table Component instance - - - - - - -
    -
    - - empty(self) -
    -
    - Empty a progress bar - - -

    Parameters:

    -
      -
    • self +
    • steps table - Component instance + Array of progress bar values +
    • +
    • callback + function + Callback on intersect step value
    @@ -205,56 +258,6 @@ -
    -
    - - get(self) -
    -
    - Return current progress bar value - - -

    Parameters:

    -
      -
    • self - table - Component instance -
    • -
    - - - - - -
    -
    - - set_steps(self, steps, callback) -
    -
    - Set points on progress bar to fire the callback - - -

    Parameters:

    -
      -
    • self - table - Component instance -
    • -
    • steps - table - Array of progress bar values -
    • -
    • callback - function - Callback on intersect step value -
    • -
    - - - - -
    @@ -293,7 +296,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-07 01:09:38 +Last updated 2020-02-23 13:01:03
    diff --git a/docs/modules/druid.radio_group.html b/docs/modules/druid.radio_group.html index e4db277..95f1c32 100644 --- a/docs/modules/druid.radio_group.html +++ b/docs/modules/druid.radio_group.html @@ -4,7 +4,7 @@ Defold Druid UI Library - + @@ -34,23 +34,24 @@

    Modules

    @@ -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-23 13:01:03
    diff --git a/docs/modules/druid.scroll.html b/docs/modules/druid.scroll.html index c91a211..c12e1aa 100644 --- a/docs/modules/druid.scroll.html +++ b/docs/modules/druid.scroll.html @@ -4,7 +4,7 @@ Defold Druid UI Library - + @@ -38,23 +38,24 @@

    Modules

    @@ -64,35 +65,37 @@

    Module druid.scroll

    Component to handle scroll content

    -

    +

    + +

    Functions

    init(self, node, key, init_value)Component init functionempty(self)Empty a progress bar
    empty(self) Fill a progress bar and stop progress animation
    empty(self)Empty a progress bar
    set_to(self, to)Instant fill progress bar to value
    get(self) Return current progress bar value
    init(self, node, key, init_value)Component init function
    set_steps(self, steps, callback) Set points on progress bar to fire the callback
    set_to(self, to)Instant fill progress bar to value
    to(self, to[, callback]) Start animation of a progress bar
    - - - - - - - - - - - - + + + + + + + + + + + +
    scroll_to(vector3[, is_instant])Start scroll to target point
    init(self, index[, skip_cb]) Scroll to item in scroll by point index
    set_points(self, points)Set points of interest.
    set_inert(self, state)Enable or disable scroll inert.
    on_point_move(self, callback) Set the callback on scrolling to point (if exist)
    scroll_to(vector3[, is_instant])Start scroll to target point
    set_border(self, border) Set the scroll possibly area
    set_inert(self, state)Enable or disable scroll inert.
    set_points(self, points)Set points of interest.

    @@ -102,6 +105,61 @@

    Functions

    +
    + + init(self, index[, skip_cb]) +
    +
    + Scroll to item in scroll by point index + + +

    Parameters:

    +
      +
    • self + table + Component instance +
    • +
    • index + number + Point index +
    • +
    • skip_cb + boolean + If true, skip the point callback + (optional) +
    • +
    + + + + + +
    +
    + + on_point_move(self, callback) +
    +
    + Set the callback on scrolling to point (if exist) + + +

    Parameters:

    +
      +
    • self + table + Component instance +
    • +
    • callback + function + Callback on scroll to point of interest +
    • +
    + + + + + +
    scroll_to(vector3[, is_instant]) @@ -134,11 +192,11 @@
    - - init(self, index[, skip_cb]) + + set_border(self, border)
    - Scroll to item in scroll by point index + Set the scroll possibly area

    Parameters:

    @@ -147,40 +205,9 @@ table Component instance -
  • index - number - Point index -
  • -
  • skip_cb - boolean - If true, skip the point callback - (optional) -
  • - - - - - - -
    -
    - - set_points(self, points) -
    -
    - Set points of interest. - Scroll will always centered on closer points - - -

    Parameters:

    -
      -
    • self - table - Component instance -
    • -
    • points - table - Array of vector3 points +
    • border + vmath.vector3 + Size of scrolling area
    @@ -217,11 +244,12 @@
    - - on_point_move(self, callback) + + set_points(self, points)
    - Set the callback on scrolling to point (if exist) + Set points of interest. + Scroll will always centered on closer points

    Parameters:

    @@ -230,34 +258,9 @@ table Component instance -
  • callback - function - Callback on scroll to point of interest -
  • - - - - - - -
    -
    - - set_border(self, border) -
    -
    - Set the scroll possibly area - - -

    Parameters:

    -
      -
    • self +
    • points table - Component instance -
    • -
    • border - vmath.vector3 - Size of scrolling area + Array of vector3 points
    @@ -273,7 +276,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-07 01:09:38 +Last updated 2020-02-23 13:01:03
    diff --git a/docs/modules/druid.slider.html b/docs/modules/druid.slider.html index 4a71669..fb5dc21 100644 --- a/docs/modules/druid.slider.html +++ b/docs/modules/druid.slider.html @@ -4,7 +4,7 @@ Defold Druid UI Library - + @@ -34,23 +34,24 @@

    Modules

    @@ -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-23 13:01:03
    diff --git a/docs/modules/druid.text.html b/docs/modules/druid.text.html index c35de59..a1ec437 100644 --- a/docs/modules/druid.text.html +++ b/docs/modules/druid.text.html @@ -4,7 +4,7 @@ Defold Druid UI Library - + @@ -38,23 +38,24 @@

    Modules

    @@ -65,30 +66,32 @@

    Module druid.text

    Component to handle all GUI texts Good working with localization system

    -

    +

    + +

    Functions

    - - + + - - + + - - + +
    set_to(self, set_to)Set text to text fieldset_alpha(self, alpha)Set alpha
    set_color(self, color) Set color
    set_alpha(self, alpha)Set alphaset_pivot(self, pivot)Set text pivot.
    set_scale(self, scale) Set scale
    set_pivot(self, pivot)Set text pivot.set_to(self, set_to)Set text to text field
    @@ -100,11 +103,11 @@
    - - set_to(self, set_to) + + set_alpha(self, alpha)
    - Set text to text field + Set alpha

    Parameters:

    @@ -113,9 +116,9 @@ table Component instance -
  • set_to - string - Text for node +
  • alpha + number + Alpha for node
  • @@ -150,11 +153,12 @@
    - - set_alpha(self, alpha) + + set_pivot(self, pivot)
    - Set alpha + Set text pivot. Text will re-anchor inside + his text area

    Parameters:

    @@ -163,9 +167,9 @@ table Component instance -
  • alpha - number - Alpha for node +
  • pivot + gui.pivot + Gui pivot constant
  • @@ -200,12 +204,11 @@
    - - set_pivot(self, pivot) + + set_to(self, set_to)
    - Set text pivot. Text will re-anchor inside - his text area + Set text to text field

    Parameters:

    @@ -214,9 +217,9 @@ table Component instance -
  • pivot - gui.pivot - Gui pivot constant +
  • set_to + string + Text for node
  • @@ -232,7 +235,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-07 01:09:38 +Last updated 2020-02-23 13:01:03
    diff --git a/docs/modules/druid.timer.html b/docs/modules/druid.timer.html index afc6f94..afa6a7a 100644 --- a/docs/modules/druid.timer.html +++ b/docs/modules/druid.timer.html @@ -4,7 +4,7 @@ Defold Druid UI Library - + @@ -38,23 +38,24 @@

    Modules

    @@ -64,22 +65,24 @@

    Module druid.timer

    Component to handle GUI timers

    -

    +

    + +

    Functions

    - - + + - - + +
    set_to(self, set_to)Set text to text fieldset_interval(self, from, to)Set time interval
    set_state(self, is_on) Called when update
    set_interval(self, from, to)Set time intervalset_to(self, set_to)Set text to text field
    @@ -91,11 +94,11 @@
    - - set_to(self, set_to) + + set_interval(self, from, to)
    - Set text to text field + Set time interval

    Parameters:

    @@ -104,9 +107,13 @@ table Component instance -
  • set_to +
  • from number - Value in seconds + Start time in seconds +
  • +
  • to + number + Target time in seconds
  • @@ -141,11 +148,11 @@
    - - set_interval(self, from, to) + + set_to(self, set_to)
    - Set time interval + Set text to text field

    Parameters:

    @@ -154,13 +161,9 @@ table Component instance -
  • from +
  • set_to number - Start time in seconds -
  • -
  • to - number - Target time in seconds + Value in seconds
  • @@ -176,7 +179,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-07 01:09:38 +Last updated 2020-02-23 13:01:03
    diff --git a/docs/modules/const.html b/docs/modules/druid_event.html similarity index 56% rename from docs/modules/const.html rename to docs/modules/druid_event.html index 0b50a56..f6bda44 100644 --- a/docs/modules/const.html +++ b/docs/modules/druid_event.html @@ -4,7 +4,7 @@ Defold Druid UI Library - + @@ -30,34 +30,28 @@
  • Index
  • -

    Contents

    -

    Modules

    @@ -65,79 +59,25 @@
    -

    Module const

    -

    Druid constants

    -

    +

    Module druid_event

    +

    Lua event small library

    +

    + +

    -

    Tables

    - - - - - -
    pivots
    -

    Fields

    - - - - - -
    ON_MESSAGEInterests


    -

    Tables

    - -
    -
    - - pivots -
    -
    - - - -

    Fields:

    -
      -
    • test - test -
    • -
    - - - - - -
    -
    -

    Fields

    - -
    -
    - - ON_MESSAGE -
    -
    - Interests - - - - - - - -
    -
    generated by LDoc 1.4.6 -Last updated 2020-02-07 01:01:14 +Last updated 2020-02-23 13:01:03
    diff --git a/docs/modules/druid_instance.html b/docs/modules/druid_instance.html index fc11032..719a0ca 100644 --- a/docs/modules/druid_instance.html +++ b/docs/modules/druid_instance.html @@ -4,7 +4,7 @@ Defold Druid UI Library - + @@ -38,23 +38,24 @@

    Modules

    @@ -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
  • @@ -86,69 +88,25 @@

    Functions

    - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - + + @@ -159,12 +117,60 @@ + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    druid:initialize(table, table)Druid class constructor
    druid:create(component, ...) Create new druid component
    druid:remove(component)Remove component from druid instance.
    druid:update(dt)Druid update function
    druid:on_input(action_id, action)Druid on_input function
    druid:on_message(message_id, message, sender)Druid on_message function
    druid:new_button(...)Create button basic component
    druid:new_blocker(...)Create blocker basic componentdruid:initialize(table, table)Druid class constructor
    druid:new_back_handler(...) Create back_handler basic component
    druid:new_text(...)Create text basic componentdruid:new_blocker(...)Create blocker basic component
    druid:new_locale(...)Create locale basic component
    druid:new_timer(...)Create timer basic component
    druid:new_progress(...)Create progress basic component
    druid:new_grid(...)Create grid basic component
    druid:new_scroll(...)Create scroll basic component
    druid:new_slider(...)Create slider basic componentdruid:new_button(...)Create button basic component
    druid:new_checkbox(...)Create checkbox_group basic component
    druid:new_grid(...)Create grid basic component
    druid:new_hover(...)Create hover basic component
    druid:new_input(...)Create input basic component
    druid:new_lang_text(...)Create lang_text basic component
    druid:new_progress(...)Create progress basic component
    druid:new_radio_group(...) Create radio_group basic component
    druid:new_progress_rich(...)Create progress_rich basic componentdruid:new_scroll(...)Create scroll basic component
    druid:new_slider(...)Create slider basic component
    druid:new_text(...)Create text basic component
    druid:new_timer(...)Create timer basic component
    druid:on_input(action_id, action)Druid on_input function
    druid:on_message(message_id, message, sender)Druid on_message function
    druid:remove(component)Remove component from druid instance.
    druid:update(dt)Druid update function
    @@ -175,31 +181,6 @@

    Functions

    -
    - - druid:initialize(table, table) -
    -
    - Druid class constructor - - -

    Parameters:

    -
      -
    • table - style - Druid style module -
    • -
    • table - style - Druid style module -
    • -
    - - - - - -
    druid:create(component, ...) @@ -226,19 +207,22 @@
    - - druid:remove(component) + + druid:initialize(table, table)
    - Remove component from druid instance. - Component `on_remove` function will be invoked, if exist. + Druid class constructor

    Parameters:

      -
    • component - Component - Component instance +
    • table + style + Druid style module +
    • +
    • table + style + Druid style module
    @@ -248,93 +232,18 @@
    - - druid:update(dt) + + druid:new_back_handler(...)
    - Druid update function - - -

    Parameters:

    -
      -
    • dt - number - Delta time -
    • -
    - - - - - -
    -
    - - druid:on_input(action_id, action) -
    -
    - Druid on_input function - - -

    Parameters:

    -
      -
    • action_id - hash - Action_id from on_input -
    • -
    • action - table - Action from on_input -
    • -
    - - - - - -
    -
    - - druid:on_message(message_id, message, sender) -
    -
    - Druid on_message function - - -

    Parameters:

    -
      -
    • message_id - hash - Message_id from on_message -
    • -
    • message - table - Message from on_message -
    • -
    • sender - hash - Sender from on_message -
    • -
    - - - - - -
    -
    - - druid:new_button(...) -
    -
    - Create button basic component + Create back_handler basic component

    Parameters:

    • ... args - button init args + back_handler init args
    @@ -342,7 +251,7 @@
      Component - button component + back_handler component
    @@ -377,18 +286,18 @@
    - - druid:new_back_handler(...) + + druid:new_button(...)
    - Create back_handler basic component + Create button basic component

    Parameters:

    • ... args - back_handler init args + button init args
    @@ -396,196 +305,7 @@
      Component - back_handler component -
    - - - - -
    -
    - - druid:new_text(...) -
    -
    - Create text basic component - - -

    Parameters:

    -
      -
    • ... - args - text init args -
    • -
    - -

    Returns:

    -
      - - Component - text component -
    - - - - -
    -
    - - druid:new_locale(...) -
    -
    - Create locale basic component - - -

    Parameters:

    -
      -
    • ... - args - locale init args -
    • -
    - -

    Returns:

    -
      - - Component - locale component -
    - - - - -
    -
    - - druid:new_timer(...) -
    -
    - Create timer basic component - - -

    Parameters:

    -
      -
    • ... - args - timer init args -
    • -
    - -

    Returns:

    -
      - - Component - timer component -
    - - - - -
    -
    - - druid:new_progress(...) -
    -
    - Create progress basic component - - -

    Parameters:

    -
      -
    • ... - args - progress init args -
    • -
    - -

    Returns:

    -
      - - Component - progress component -
    - - - - -
    -
    - - druid:new_grid(...) -
    -
    - Create grid basic component - - -

    Parameters:

    -
      -
    • ... - args - grid init args -
    • -
    - -

    Returns:

    -
      - - Component - grid component -
    - - - - -
    -
    - - druid:new_scroll(...) -
    -
    - Create scroll basic component - - -

    Parameters:

    -
      -
    • ... - args - scroll init args -
    • -
    - -

    Returns:

    -
      - - Component - scroll component -
    - - - - -
    -
    - - druid:new_slider(...) -
    -
    - Create slider basic component - - -

    Parameters:

    -
      -
    • ... - args - slider init args -
    • -
    - -

    Returns:

    -
      - - Component - slider component + button component
    @@ -645,6 +365,141 @@ +
    +
    + + druid:new_grid(...) +
    +
    + Create grid basic component + + +

    Parameters:

    +
      +
    • ... + args + grid init args +
    • +
    + +

    Returns:

    +
      + + Component + grid component +
    + + + + +
    +
    + + druid:new_hover(...) +
    +
    + Create hover basic component + + +

    Parameters:

    +
      +
    • ... + args + hover init args +
    • +
    + +

    Returns:

    +
      + + Component + hover component +
    + + + + +
    +
    + + druid:new_input(...) +
    +
    + Create input basic component + + +

    Parameters:

    +
      +
    • ... + args + input init args +
    • +
    + +

    Returns:

    +
      + + Component + input component +
    + + + + +
    +
    + + druid:new_lang_text(...) +
    +
    + Create lang_text basic component + + +

    Parameters:

    +
      +
    • ... + args + lang_text init args +
    • +
    + +

    Returns:

    +
      + + Component + lang_text component +
    + + + + +
    +
    + + druid:new_progress(...) +
    +
    + Create progress basic component + + +

    Parameters:

    +
      +
    • ... + args + progress init args +
    • +
    + +

    Returns:

    +
      + + Component + progress component +
    + + + +
    @@ -674,18 +529,18 @@
    - - druid:new_progress_rich(...) + + druid:new_scroll(...)
    - Create progress_rich basic component + Create scroll basic component

    Parameters:

    • ... args - progress_rich init args + scroll init args
    @@ -693,12 +548,190 @@
      Component - progress_rich component + scroll component
    +
    +
    + + druid:new_slider(...) +
    +
    + Create slider basic component + + +

    Parameters:

    +
      +
    • ... + args + slider init args +
    • +
    + +

    Returns:

    +
      + + Component + slider component +
    + + + + +
    +
    + + druid:new_text(...) +
    +
    + Create text basic component + + +

    Parameters:

    +
      +
    • ... + args + text init args +
    • +
    + +

    Returns:

    +
      + + Component + text component +
    + + + + +
    +
    + + druid:new_timer(...) +
    +
    + Create timer basic component + + +

    Parameters:

    +
      +
    • ... + args + timer init args +
    • +
    + +

    Returns:

    +
      + + Component + timer component +
    + + + + +
    +
    + + druid:on_input(action_id, action) +
    +
    + Druid on_input function + + +

    Parameters:

    +
      +
    • action_id + hash + Actionid from oninput +
    • +
    • action + table + Action from on_input +
    • +
    + + + + + +
    +
    + + druid:on_message(message_id, message, sender) +
    +
    + Druid on_message function + + +

    Parameters:

    +
      +
    • message_id + hash + Messageid from onmessage +
    • +
    • message + table + Message from on_message +
    • +
    • sender + hash + Sender from on_message +
    • +
    + + + + + +
    +
    + + druid:remove(component) +
    +
    + Remove component from druid instance. + Component on_remove function will be invoked, if exist. + + +

    Parameters:

    +
      +
    • component + Component + Component instance +
    • +
    + + + + + +
    +
    + + druid:update(dt) +
    +
    + Druid update function + + +

    Parameters:

    +
      +
    • dt + number + Delta time +
    • +
    + + + + +
    @@ -707,7 +740,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-07 01:09:38 +Last updated 2020-02-23 13:01:03
    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 - - - - -
    - -
    - -
    -
    -
    - - -
    - - - - - - -
    - -

    Module helper.formats

    -

    Druid module with utils on string formats

    -

    - - -

    Functions

    - - - - - - - - - - - - - -
    add_prefix_zeros(num, count)Return number with zero number prefix
    second_string_min(sec)Convert seconds to string minutes:seconds
    second_string_min(s, tab)Interpolate string with named Parameters in Table
    - -
    -
    - - -

    Functions

    - -
    -
    - - 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 -
    -
    - - From 822db35e84baf48e979cf11cc7868a7b6edf4bc0 Mon Sep 17 00:00:00 2001 From: Insality Date: Sun, 23 Feb 2020 22:57:44 +0300 Subject: [PATCH 12/20] Documentation experiments --- alpha_todo.txt | 6 +- config.ld | 2 +- docs/index.html | 2 +- docs/modules/component.html | 370 ++++++++--------- docs/modules/druid.back_handler.html | 8 +- docs/modules/druid.blocker.html | 8 +- docs/modules/druid.button.html | 249 ++++-------- docs/modules/druid.checkbox.html | 8 +- docs/modules/druid.checkbox_group.html | 8 +- docs/modules/druid.grid.html | 8 +- docs/modules/druid.helper.html | 112 +++--- docs/modules/druid.html | 70 ++-- docs/modules/druid.input.html | 68 ++-- docs/modules/druid.lang_text.html | 8 +- docs/modules/druid.progress.html | 176 ++++---- docs/modules/druid.radio_group.html | 8 +- docs/modules/druid.scroll.html | 166 ++++---- docs/modules/druid.slider.html | 8 +- docs/modules/druid.text.html | 58 +-- docs/modules/druid.timer.html | 44 +- docs/modules/druid_event.html | 93 ++++- docs/modules/druid_instance.html | 536 ++++++++++++------------- druid/base/button.lua | 62 ++- druid/component.lua | 40 +- druid/event.lua | 10 + 25 files changed, 1071 insertions(+), 1057 deletions(-) diff --git a/alpha_todo.txt b/alpha_todo.txt index 552c412..cff23aa 100644 --- a/alpha_todo.txt +++ b/alpha_todo.txt @@ -9,13 +9,15 @@ Simple to-do for Druid Alpha 0.2.0 + 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? ++ 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? -- unify component api (get/set/to and other general stuff) - 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 diff --git a/config.ld b/config.ld index b9a95cd..00b4508 100644 --- a/config.ld +++ b/config.ld @@ -3,7 +3,7 @@ title='Defold Druid UI Library' description='Documentation for Druid Library' file={"./druid"} package='druid' -sort=true +sort=false dir='./docs' style='!fixed' format='discount' diff --git a/docs/index.html b/docs/index.html index 45b2665..e865552 100644 --- a/docs/index.html +++ b/docs/index.html @@ -145,7 +145,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/component.html b/docs/modules/component.html index d0b3851..a05a234 100644 --- a/docs/modules/component.html +++ b/docs/modules/component.html @@ -38,15 +38,12 @@

    Modules

    @@ -70,54 +70,54 @@

    Functions

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Component.create(name, interest)Create new component.
    get_context()Get current component context
    get_druid()Return druid with context of calling component.
    get_interests()Get current component interests
    get_nodes()Get current component nodes
    get_style() Get current component style table
    get_template()Get current component template name
    set_context(context)Set current component context
    set_nodes(nodes)Set current component nodes
    set_style(style) Set current component style table
    get_template()Get current component template name
    set_template(template) Set current component template name
    get_nodes()Get current component nodes
    set_nodes(nodes)Set current component nodes
    get_context()Get current component context
    set_context(context)Set current component context
    get_interests()Get current component interests
    get_druid()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.

    @@ -128,23 +128,120 @@
    - - Component.create(name, interest) + + get_style()
    - Create new component. It will inheritance from basic - druid component. + Get current component style table + + + +

    Returns:

    +
      + + table + Component style table +
    + + + + +
    +
    + + set_style(style) +
    +
    + Set current component style table

    Parameters:

      -
    • name - string - Component name -
    • -
    • interest +
    • style table - List of component's interest + Druid style module +
    • +
    + + + + + +
    +
    + + get_template() +
    +
    + Get current component template name + + + +

    Returns:

    +
      + + string + Component template name +
    + + + + +
    +
    + + set_template(template) +
    +
    + Set current component template name + + +

    Parameters:

    +
      +
    • template + string + Component template name +
    • +
    + + + + + +
    +
    + + get_nodes() +
    +
    + Get current component nodes + + + +

    Returns:

    +
      + + table + Component nodes table +
    + + + + +
    +
    + + set_nodes(nodes) +
    +
    + Set current component nodes + + +

    Parameters:

    +
      +
    • nodes + table + Component nodes table
    @@ -174,21 +271,21 @@
    - - get_druid() + + set_context(context)
    - Return druid with context of calling component. - Use it to create component inside of other components. + Set current component context +

    Parameters:

    +
      +
    • context + table + Druid context. Usually it is self of script +
    • +
    -

    Returns:

    -
      - - Druid - Druid instance with component context -
    @@ -215,148 +312,25 @@
    - - get_nodes() + + get_druid()
    - Get current component nodes + Return druid with context of calling component. + Use it to create component inside of other components.

    Returns:

      - table - Component nodes table + Druid + Druid instance with component context
    -
    -
    - - get_style() -
    -
    - Get current component style table - - - -

    Returns:

    -
      - - table - Component style table -
    - - - - -
    -
    - - get_template() -
    -
    - Get current component template name - - - -

    Returns:

    -
      - - string - Component template name -
    - - - - -
    -
    - - set_context(context) -
    -
    - Set current component context - - -

    Parameters:

    -
      -
    • context - table - Druid context. Usually it is self of script -
    • -
    - - - - - -
    -
    - - set_nodes(nodes) -
    -
    - Set current component nodes - - -

    Parameters:

    -
      -
    • nodes - table - Component nodes table -
    • -
    - - - - - -
    -
    - - set_style(style) -
    -
    - Set current component style table - - -

    Parameters:

    -
      -
    • style - table - Druid style module -
    • -
    - - - - - -
    -
    - - set_template(template) -
    -
    - Set current component template name - - -

    Parameters:

    -
      -
    • template - string - Component template name -
    • -
    - - - - -
    @@ -388,6 +362,32 @@ +
    +
    + + Component.create(name, interest) +
    +
    + Create new component. It will inheritance from basic + druid component. + + +

    Parameters:

    +
      +
    • name + string + Component name +
    • +
    • interest + table + List of component's interest +
    • +
    + + + + +
    @@ -396,7 +396,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.back_handler.html b/docs/modules/druid.back_handler.html index 66881c1..66d587d 100644 --- a/docs/modules/druid.back_handler.html +++ b/docs/modules/druid.back_handler.html @@ -38,15 +38,12 @@

    Modules

    @@ -151,7 +151,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.blocker.html b/docs/modules/druid.blocker.html index cd46818..46ce82d 100644 --- a/docs/modules/druid.blocker.html +++ b/docs/modules/druid.blocker.html @@ -34,15 +34,12 @@

    Modules

    @@ -77,7 +77,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.button.html b/docs/modules/druid.button.html index 4108eb2..82fe0ef 100644 --- a/docs/modules/druid.button.html +++ b/docs/modules/druid.button.html @@ -39,15 +39,12 @@

    Modules

    @@ -73,49 +73,37 @@

    Functions

    - - - - - - - - - - + + - - - - - - - - - - + +
    disable_animation(self)Disable all button animations
    get_key_trigger(self)Get key-code to trigger this button
    init(self, node, callback[, params[, anim_node[, event]]]) Component init function
    set_callback(self, callback)Set usual button callbackdisable_animation(self)Disable all button animations
    set_click_zone(self, zone) Strict button click area.
    set_double_tap_callback(self, callback)Get doubletap callback on this button
    set_hold_callback(self, callback)Repeat callback always, while holding button
    set_long_tap_callback(self, callback)Single callbacka after long_tap.get_key_trigger(self)Get key-code to trigger this button

    Tables

    - + - + + + + +
    eventsEvents Component events
    fieldsFields Component fields
    StyleComponent style params

    @@ -125,49 +113,6 @@

    Functions

    -
    - - disable_animation(self) -
    -
    - Disable all button animations - - -

    Parameters:

    -
      -
    • self - table - Component instance -
    • -
    - - - - - -
    -
    - - get_key_trigger(self) -
    -
    - Get key-code to trigger this button - - -

    Parameters:

    -
      -
    • self - - - -
    • -
    - - - - - -
    init(self, node, callback[, params[, anim_node[, event]]]) @@ -213,24 +158,18 @@
    - - set_callback(self, callback) + + disable_animation(self)
    - Set usual button callback + Disable all button animations

    Parameters:

    • self - - - -
    • -
    • callback - - - + table + Component instance
    @@ -266,11 +205,11 @@
    - - set_double_tap_callback(self, callback) + + get_key_trigger(self)
    - Get doubletap callback on this button + Get key-code to trigger this button

    Parameters:

    @@ -279,65 +218,6 @@ - -
  • callback - - - -
  • - - - - - - -
    -
    - - set_hold_callback(self, callback) -
    -
    - Repeat callback always, while holding button - - -

    Parameters:

    -
      -
    • self - - - -
    • -
    • callback - - - -
    • -
    - - - - - -
    -
    - - set_long_tap_callback(self, callback) -
    -
    - Single callbacka after long_tap. No usual callback invoked - - -

    Parameters:

    -
      -
    • self - - - -
    • -
    • callback - - -
    @@ -351,8 +231,8 @@
    - - events + + Events
    Component events @@ -362,27 +242,19 @@
    • on_click druid_event - - - + On release button callback
    • -
    • on_hold_click +
    • 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
    @@ -392,8 +264,8 @@
    - - fields + + Fields
    Component fields @@ -401,9 +273,64 @@

    Fields:

      -
    • Main +
    • node 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_hover + function + (self, node, hover_state)
    @@ -419,7 +346,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.checkbox.html b/docs/modules/druid.checkbox.html index e3b8461..bfe3b2a 100644 --- a/docs/modules/druid.checkbox.html +++ b/docs/modules/druid.checkbox.html @@ -34,15 +34,12 @@

    Modules

    @@ -77,7 +77,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.checkbox_group.html b/docs/modules/druid.checkbox_group.html index 6a20fe6..e492ef9 100644 --- a/docs/modules/druid.checkbox_group.html +++ b/docs/modules/druid.checkbox_group.html @@ -34,15 +34,12 @@

    Modules

    @@ -77,7 +77,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.grid.html b/docs/modules/druid.grid.html index ad0f258..6914a07 100644 --- a/docs/modules/druid.grid.html +++ b/docs/modules/druid.grid.html @@ -34,15 +34,12 @@

    Modules

    @@ -75,7 +75,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.helper.html b/docs/modules/druid.helper.html index 820aaec..ae45827 100644 --- a/docs/modules/druid.helper.html +++ b/docs/modules/druid.helper.html @@ -38,15 +38,12 @@

    Modules

    @@ -72,22 +72,22 @@

    Functions

    - - - - - - + + + + + +
    centrate_icon_with_text([icon_node[, text_node[, margin=0]]])Center two nodes.
    centrate_text_with_icon([text_node][, icon_node], margin) Center two nodes.
    get_pivot_offset(pivot)Get node offset for given gui pivotcentrate_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

    @@ -97,6 +97,39 @@

    Functions

    +
    + + centrate_text_with_icon([text_node][, icon_node], margin) +
    +
    + Center two nodes. + Nodes will be center around 0 x position + text_node will be first (at left side) + + +

    Parameters:

    +
      +
    • text_node + text + Gui text node + (optional) +
    • +
    • icon_node + box + Gui box node + (optional) +
    • +
    • margin + number + Offset between nodes +
    • +
    + + + + + +
    centrate_icon_with_text([icon_node[, text_node[, margin=0]]]) @@ -132,33 +165,28 @@
    - - centrate_text_with_icon([text_node][, icon_node], margin) + + is_enabled(node)
    - Center two nodes. - Nodes will be center around 0 x position - text_node will be first (at left side) + Check if node is enabled in gui hierarchy. + Return false, if node or any his parent is disabled

    Parameters:

      -
    • text_node - text - Gui text node - (optional) -
    • -
    • icon_node - box - Gui box node - (optional) -
    • -
    • margin - number - Offset between nodes +
    • node + node + Gui node
    +

    Returns:

    +
      + + bool + Is enabled in hierarchy +
    @@ -190,34 +218,6 @@ -
    -
    - - 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 -
    - - - -
    @@ -226,7 +226,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.html b/docs/modules/druid.html index eef8815..66d2c54 100644 --- a/docs/modules/druid.html +++ b/docs/modules/druid.html @@ -38,15 +38,12 @@

    Modules

    @@ -88,14 +88,14 @@

    Functions

    - - - - + + + +
    new(context[, style])Create Druid instance.
    register(name, module) Register external druid component.
    new(context[, style])Create Druid instance.

    @@ -105,6 +105,33 @@

    Functions

    +
    + + register(name, module) +
    +
    + Register external druid component. + After register you can create the component with + druidinstance:new{name}. For example druid:new_button(...) + + +

    Parameters:

    +
      +
    • name + string + module name +
    • +
    • module + table + lua table with component +
    • +
    + + + + + +
    new(context[, style]) @@ -136,33 +163,6 @@ -
    -
    - - register(name, module) -
    -
    - Register external druid component. - After register you can create the component with - druidinstance:new{name}. For example druid:new_button(...) - - -

    Parameters:

    -
      -
    • name - string - module name -
    • -
    • module - table - lua table with component -
    • -
    - - - - -
    @@ -171,7 +171,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.input.html b/docs/modules/druid.input.html index 234ed47..3c37497 100644 --- a/docs/modules/druid.input.html +++ b/docs/modules/druid.input.html @@ -38,15 +38,12 @@

    Modules

    @@ -72,14 +72,14 @@

    Functions

    - - - - + + + +
    button:set_click_zone(self, zone)Strict button click area.
    hover:init(self, node, on_hover_callback) Component init function
    button:set_click_zone(self, zone)Strict button click area.

    @@ -89,32 +89,6 @@

    Functions

    -
    - - 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 -
    • -
    - - - - - -
    hover:init(self, node, on_hover_callback) @@ -143,6 +117,32 @@ + +
    + + 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 +
    • +
    + + + + +
    @@ -151,7 +151,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.lang_text.html b/docs/modules/druid.lang_text.html index 7eefddd..2c02a82 100644 --- a/docs/modules/druid.lang_text.html +++ b/docs/modules/druid.lang_text.html @@ -38,15 +38,12 @@

    Modules

    @@ -118,7 +118,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.progress.html b/docs/modules/druid.progress.html index a505c5a..2b0ede6 100644 --- a/docs/modules/druid.progress.html +++ b/docs/modules/druid.progress.html @@ -38,15 +38,12 @@

    Modules

    @@ -73,30 +73,30 @@

    Functions

    - - + + - - - - - - - - - - + + + + + + + + + + @@ -109,69 +109,6 @@

    Functions

    -
    - - empty(self) -
    -
    - Empty a progress bar - - -

    Parameters:

    -
      -
    • self - table - Component instance -
    • -
    - - - - - -
    -
    - - empty(self) -
    -
    - Fill a progress bar and stop progress animation - - -

    Parameters:

    -
      -
    • self - table - Component instance -
    • -
    - - - - - -
    -
    - - get(self) -
    -
    - Return current progress bar value - - -

    Parameters:

    -
      -
    • self - table - Component instance -
    • -
    - - - - - -
    init(self, node, key, init_value) @@ -206,11 +143,11 @@
    - - set_steps(self, steps, callback) + + empty(self)
    - Set points on progress bar to fire the callback + Fill a progress bar and stop progress animation

    Parameters:

    @@ -219,13 +156,26 @@ table Component instance -
  • steps + + + + + + +
  • +
    + + empty(self) +
    +
    + Empty a progress bar + + +

    Parameters:

    +
      +
    • self table - Array of progress bar values -
    • -
    • callback - function - Callback on intersect step value + Component instance
    @@ -258,6 +208,56 @@ +
    +
    + + get(self) +
    +
    + Return current progress bar value + + +

    Parameters:

    +
      +
    • self + table + Component instance +
    • +
    + + + + + +
    +
    + + set_steps(self, steps, callback) +
    +
    + Set points on progress bar to fire the callback + + +

    Parameters:

    +
      +
    • self + table + Component instance +
    • +
    • steps + table + Array of progress bar values +
    • +
    • callback + function + Callback on intersect step value +
    • +
    + + + + +
    @@ -296,7 +296,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.radio_group.html b/docs/modules/druid.radio_group.html index 95f1c32..082f70a 100644 --- a/docs/modules/druid.radio_group.html +++ b/docs/modules/druid.radio_group.html @@ -34,15 +34,12 @@

    Modules

    @@ -77,7 +77,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.scroll.html b/docs/modules/druid.scroll.html index c12e1aa..81b1019 100644 --- a/docs/modules/druid.scroll.html +++ b/docs/modules/druid.scroll.html @@ -38,15 +38,12 @@

    Modules

    @@ -72,29 +72,29 @@

    Functions

    empty(self)Empty a progress barinit(self, node, key, init_value)Component init function
    empty(self) Fill a progress bar and stop progress animation
    get(self)Return current progress bar value
    init(self, node, key, init_value)Component init function
    set_steps(self, steps, callback)Set points on progress bar to fire the callbackempty(self)Empty a progress bar
    set_to(self, to) Instant fill progress bar to value
    get(self)Return current progress bar value
    set_steps(self, steps, callback)Set points on progress bar to fire the callback
    to(self, to[, callback]) Start animation of a progress bar
    - - - - - - - - - - + + + + + + - - + + + + + +
    init(self, index[, skip_cb])Scroll to item in scroll by point index
    on_point_move(self, callback)Set the callback on scrolling to point (if exist)
    scroll_to(vector3[, is_instant]) Start scroll to target point
    set_border(self, border)Set the scroll possibly areainit(self, index[, skip_cb])Scroll to item in scroll by point index
    set_points(self, points)Set points of interest.
    set_inert(self, state) Enable or disable scroll inert.
    set_points(self, points)Set points of interest.on_point_move(self, callback)Set the callback on scrolling to point (if exist)
    set_border(self, border)Set the scroll possibly area
    @@ -105,61 +105,6 @@

    Functions

    -
    - - init(self, index[, skip_cb]) -
    -
    - Scroll to item in scroll by point index - - -

    Parameters:

    -
      -
    • self - table - Component instance -
    • -
    • index - number - Point index -
    • -
    • skip_cb - boolean - If true, skip the point callback - (optional) -
    • -
    - - - - - -
    -
    - - on_point_move(self, callback) -
    -
    - Set the callback on scrolling to point (if exist) - - -

    Parameters:

    -
      -
    • self - table - Component instance -
    • -
    • callback - function - Callback on scroll to point of interest -
    • -
    - - - - - -
    scroll_to(vector3[, is_instant]) @@ -192,11 +137,11 @@
    - - set_border(self, border) + + init(self, index[, skip_cb])
    - Set the scroll possibly area + Scroll to item in scroll by point index

    Parameters:

    @@ -205,9 +150,40 @@ table Component instance -
  • border - vmath.vector3 - Size of scrolling area +
  • index + number + Point index +
  • +
  • skip_cb + boolean + If true, skip the point callback + (optional) +
  • + + + + + + +
    +
    + + set_points(self, points) +
    +
    + Set points of interest. + Scroll will always centered on closer points + + +

    Parameters:

    +
      +
    • self + table + Component instance +
    • +
    • points + table + Array of vector3 points
    @@ -244,12 +220,11 @@
    - - set_points(self, points) + + on_point_move(self, callback)
    - Set points of interest. - Scroll will always centered on closer points + Set the callback on scrolling to point (if exist)

    Parameters:

    @@ -258,9 +233,34 @@ table Component instance -
  • points +
  • callback + function + Callback on scroll to point of interest +
  • + + + + + + +
    +
    + + set_border(self, border) +
    +
    + Set the scroll possibly area + + +

    Parameters:

    +
      +
    • self table - Array of vector3 points + Component instance +
    • +
    • border + vmath.vector3 + Size of scrolling area
    @@ -276,7 +276,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.slider.html b/docs/modules/druid.slider.html index fb5dc21..03e14f1 100644 --- a/docs/modules/druid.slider.html +++ b/docs/modules/druid.slider.html @@ -34,15 +34,12 @@

    Modules

    @@ -77,7 +77,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.text.html b/docs/modules/druid.text.html index a1ec437..41d09ef 100644 --- a/docs/modules/druid.text.html +++ b/docs/modules/druid.text.html @@ -38,15 +38,12 @@

    Modules

    @@ -74,24 +74,24 @@

    Functions

    - - + + - - + + - - + +
    set_alpha(self, alpha)Set alphaset_to(self, set_to)Set text to text field
    set_color(self, color) Set color
    set_pivot(self, pivot)Set text pivot.set_alpha(self, alpha)Set alpha
    set_scale(self, scale) Set scale
    set_to(self, set_to)Set text to text fieldset_pivot(self, pivot)Set text pivot.
    @@ -103,11 +103,11 @@
    - - set_alpha(self, alpha) + + set_to(self, set_to)
    - Set alpha + Set text to text field

    Parameters:

    @@ -116,9 +116,9 @@ table Component instance -
  • alpha - number - Alpha for node +
  • set_to + string + Text for node
  • @@ -153,12 +153,11 @@
    - - set_pivot(self, pivot) + + set_alpha(self, alpha)
    - Set text pivot. Text will re-anchor inside - his text area + Set alpha

    Parameters:

    @@ -167,9 +166,9 @@ table Component instance -
  • pivot - gui.pivot - Gui pivot constant +
  • alpha + number + Alpha for node
  • @@ -204,11 +203,12 @@
    - - set_to(self, set_to) + + set_pivot(self, pivot)
    - Set text to text field + Set text pivot. Text will re-anchor inside + his text area

    Parameters:

    @@ -217,9 +217,9 @@ table Component instance -
  • set_to - string - Text for node +
  • pivot + gui.pivot + Gui pivot constant
  • @@ -235,7 +235,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.timer.html b/docs/modules/druid.timer.html index afa6a7a..242b9b2 100644 --- a/docs/modules/druid.timer.html +++ b/docs/modules/druid.timer.html @@ -38,15 +38,12 @@

    Modules

    @@ -73,16 +73,16 @@

    Functions

    - - + + - - + +
    set_interval(self, from, to)Set time intervalset_to(self, set_to)Set text to text field
    set_state(self, is_on) Called when update
    set_to(self, set_to)Set text to text fieldset_interval(self, from, to)Set time interval
    @@ -94,11 +94,11 @@
    - - set_interval(self, from, to) + + set_to(self, set_to)
    - Set time interval + Set text to text field

    Parameters:

    @@ -107,13 +107,9 @@ table Component instance -
  • from +
  • set_to number - Start time in seconds -
  • -
  • to - number - Target time in seconds + Value in seconds
  • @@ -148,11 +144,11 @@
    - - set_to(self, set_to) + + set_interval(self, from, to)
    - Set text to text field + Set time interval

    Parameters:

    @@ -161,9 +157,13 @@ table Component instance -
  • set_to +
  • from number - Value in seconds + Start time in seconds +
  • +
  • to + number + Target time in seconds
  • @@ -179,7 +179,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid_event.html b/docs/modules/druid_event.html index f6bda44..37e3a1c 100644 --- a/docs/modules/druid_event.html +++ b/docs/modules/druid_event.html @@ -30,19 +30,20 @@
  • Index
  • +

    Contents

    +

    Modules

    @@ -66,18 +70,99 @@

    +

    Functions

    + + + + + + + + + + + + + +
    event:subscribe(callback)Subscribe callback on event
    event:unsubscribe(callback)Unsubscribe callback on event
    event:trigger(...)Trigger the event and call all subscribed callbacks


    +

    Functions

    + +
    +
    + + event:subscribe(callback) +
    +
    + Subscribe callback on event + + +

    Parameters:

    +
      +
    • callback + function + Callback itself +
    • +
    + + + + + +
    +
    + + event:unsubscribe(callback) +
    +
    + Unsubscribe callback on event + + +

    Parameters:

    +
      +
    • callback + function + Callback itself +
    • +
    + + + + + +
    +
    + + event:trigger(...) +
    +
    + Trigger the event and call all subscribed callbacks + + +

    Parameters:

    +
      +
    • ... + All event params +
    • +
    + + + + + +
    +
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid_instance.html b/docs/modules/druid_instance.html index 719a0ca..f3df01a 100644 --- a/docs/modules/druid_instance.html +++ b/docs/modules/druid_instance.html @@ -38,15 +38,12 @@

    Modules

    @@ -88,73 +88,21 @@

    Functions

    - - - - - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -165,12 +113,64 @@ - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    druid:create(component, ...)Create new druid component
    druid:initialize(table, table) Druid class constructor
    druid:new_back_handler(...)Create back_handler basic componentdruid:create(component, ...)Create new druid component
    druid:new_blocker(...)Create blocker basic componentdruid:remove(component)Remove component from druid instance.
    druid:new_button(...)Create button basic component
    druid:new_checkbox(...)Create checkbox basic component
    druid:new_checkbox_group(...)Create checkbox_group basic component
    druid:new_grid(...)Create grid basic component
    druid:new_hover(...)Create hover basic component
    druid:new_input(...)Create input basic component
    druid:new_lang_text(...)Create lang_text basic component
    druid:new_progress(...)Create progress basic component
    druid:new_radio_group(...)Create radio_group basic component
    druid:new_scroll(...)Create scroll basic component
    druid:new_slider(...)Create slider basic component
    druid:new_text(...)Create text basic component
    druid:new_timer(...)Create timer basic componentdruid:update(dt)Druid update function
    druid:on_input(action_id, action)Druid on_message function
    druid:remove(component)Remove component from druid instance.druid:new_button(...)Create button basic component
    druid:update(dt)Druid update functiondruid:new_blocker(...)Create blocker basic component
    druid:new_back_handler(...)Create back_handler basic component
    druid:new_hover(...)Create hover basic component
    druid:new_text(...)Create text basic component
    druid:new_lang_text(...)Create lang_text basic component
    druid:new_timer(...)Create timer basic component
    druid:new_progress(...)Create progress basic component
    druid:new_grid(...)Create grid basic component
    druid:new_scroll(...)Create scroll basic component
    druid:new_slider(...)Create slider basic component
    druid:new_checkbox(...)Create checkbox basic component
    druid:new_input(...)Create input basic component
    druid:new_checkbox_group(...)Create checkbox_group basic component
    druid:new_radio_group(...)Create radio_group basic component
    @@ -181,31 +181,6 @@

    Functions

    -
    - - druid:create(component, ...) -
    -
    - Create new druid component - - -

    Parameters:

    -
      -
    • component - Component - Component module -
    • -
    • ... - args - Other component params to pass it to component:init function -
    • -
    - - - - - -
    druid:initialize(table, table) @@ -232,18 +207,140 @@
    - - druid:new_back_handler(...) + + druid:create(component, ...)
    - Create back_handler basic component + Create new druid component + + +

    Parameters:

    +
      +
    • component + Component + Component module +
    • +
    • ... + args + Other component params to pass it to component:init function +
    • +
    + + + + + +
    +
    + + druid:remove(component) +
    +
    + Remove component from druid instance. + Component on_remove function will be invoked, if exist. + + +

    Parameters:

    +
      +
    • component + Component + Component instance +
    • +
    + + + + + +
    +
    + + druid:update(dt) +
    +
    + Druid update function + + +

    Parameters:

    +
      +
    • dt + number + Delta time +
    • +
    + + + + + +
    +
    + + druid:on_input(action_id, action) +
    +
    + Druid on_input function + + +

    Parameters:

    +
      +
    • action_id + hash + Actionid from oninput +
    • +
    • action + table + Action from on_input +
    • +
    + + + + + +
    +
    + + druid:on_message(message_id, message, sender) +
    +
    + Druid on_message function + + +

    Parameters:

    +
      +
    • message_id + hash + Messageid from onmessage +
    • +
    • message + table + Message from on_message +
    • +
    • sender + hash + Sender from on_message +
    • +
    + + + + + +
    +
    + + druid:new_button(...) +
    +
    + Create button basic component

    Parameters:

    • ... args - back_handler init args + button init args
    @@ -251,7 +348,7 @@
      Component - back_handler component + button component
    @@ -286,18 +383,18 @@
    - - druid:new_button(...) + + druid:new_back_handler(...)
    - Create button basic component + Create back_handler basic component

    Parameters:

    • ... args - button init args + back_handler init args
    @@ -305,88 +402,7 @@
      Component - button component -
    - - - - -
    -
    - - druid:new_checkbox(...) -
    -
    - Create checkbox basic component - - -

    Parameters:

    -
      -
    • ... - args - checkbox init args -
    • -
    - -

    Returns:

    -
      - - Component - checkbox component -
    - - - - -
    -
    - - druid:new_checkbox_group(...) -
    -
    - Create checkbox_group basic component - - -

    Parameters:

    -
      -
    • ... - args - checkbox_group init args -
    • -
    - -

    Returns:

    -
      - - Component - checkbox_group component -
    - - - - -
    -
    - - druid:new_grid(...) -
    -
    - Create grid basic component - - -

    Parameters:

    -
      -
    • ... - args - grid init args -
    • -
    - -

    Returns:

    -
      - - Component - grid component + back_handler component
    @@ -421,18 +437,18 @@
    - - druid:new_input(...) + + druid:new_text(...)
    - Create input basic component + Create text basic component

    Parameters:

    • ... args - input init args + text init args
    @@ -440,7 +456,7 @@
      Component - input component + text component
    @@ -473,6 +489,33 @@ +
    +
    + + druid:new_timer(...) +
    +
    + Create timer basic component + + +

    Parameters:

    +
      +
    • ... + args + timer init args +
    • +
    + +

    Returns:

    +
      + + Component + timer component +
    + + + +
    @@ -502,18 +545,18 @@
    - - druid:new_radio_group(...) + + druid:new_grid(...)
    - Create radio_group basic component + Create grid basic component

    Parameters:

    • ... args - radio_group init args + grid init args
    @@ -521,7 +564,7 @@
      Component - radio_group component + grid component
    @@ -583,18 +626,18 @@
    - - druid:new_text(...) + + druid:new_checkbox(...)
    - Create text basic component + Create checkbox basic component

    Parameters:

    • ... args - text init args + checkbox init args
    @@ -602,7 +645,7 @@
      Component - text component + checkbox component
    @@ -610,18 +653,18 @@
    - - druid:new_timer(...) + + druid:new_input(...)
    - Create timer basic component + Create input basic component

    Parameters:

    • ... args - timer init args + input init args
    @@ -629,7 +672,7 @@
      Component - timer component + input component
    @@ -637,97 +680,54 @@
    - - druid:on_input(action_id, action) + + druid:new_checkbox_group(...)
    - Druid on_input function + Create checkbox_group basic component

    Parameters:

      -
    • action_id - hash - Actionid from oninput -
    • -
    • action - table - Action from on_input +
    • ... + args + checkbox_group init args
    +

    Returns:

    +
      + + Component + checkbox_group component +
    - - druid:on_message(message_id, message, sender) + + druid:new_radio_group(...)
    - Druid on_message function + Create radio_group basic component

    Parameters:

      -
    • message_id - hash - Messageid from onmessage -
    • -
    • message - table - Message from on_message -
    • -
    • sender - hash - Sender from on_message +
    • ... + args + radio_group init args
    +

    Returns:

    +
      - - - -
    -
    - - druid:remove(component) -
    -
    - Remove component from druid instance. - Component on_remove function will be invoked, if exist. - - -

    Parameters:

    -
      -
    • component - Component - Component instance -
    • -
    - - - - - -
    -
    - - druid:update(dt) -
    -
    - Druid update function - - -

    Parameters:

    -
      -
    • dt - number - Delta time -
    • -
    - + Component + radio_group component + @@ -740,7 +740,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/druid/base/button.lua b/druid/base/button.lua index 22f55b2..34f8f37 100644 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -2,15 +2,27 @@ -- @module druid.button --- Component events --- @tfield druid_event on_click --- @tfield druid_event on_hold_click --- @tfield druid_event on_long_click --- @tfield druid_event on_double_click --- @table 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 --- @tfield node Main node --- @table 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_hover (self, node, hover_state) local Event = require("druid.event") local const = require("druid.const") @@ -36,7 +48,7 @@ local function on_button_release(self) if self.style.on_click then self.style.on_click(self, self.anim_node) end - self.callback(self:get_context(), self.params, self) + self.on_click:trigger(self:get_context(), self.params, self) end return true else @@ -66,19 +78,21 @@ function M.init(self, node, callback, params, anim_node, event) 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.hover = self.druid:new_hover(node, self, on_button_hover) + self.click_zone = nil -- Event stubs self.on_click = Event() - self.on_hold_click = Event() + self.on_repeated_click = Event() self.on_long_click = Event() self.on_double_click = Event() - self.click_zone = nil + if callback then + self.on_click:subscribe(callback) + end + end @@ -166,28 +180,4 @@ function M.get_key_trigger(self) end ---- Set usual button callback -function M.set_callback(self, callback) - -end - - ---- Repeat callback always, while holding button -function M.set_hold_callback(self, callback) - -end - - ---- Get doubletap callback on this button -function M.set_double_tap_callback(self, callback) - -end - - ---- Single callbacka after long_tap. No usual callback invoked -function M.set_long_tap_callback(self, callback) - -end - - return M 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/event.lua b/druid/event.lua index baccb8e..8b3350e 100644 --- a/druid/event.lua +++ b/druid/event.lua @@ -12,13 +12,20 @@ function M.initialize(self) 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 @@ -29,6 +36,9 @@ function M.unsubscribe(self, callback) 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](...) From a81d49de9d74ad7872d9e834651a8a69880835dc Mon Sep 17 00:00:00 2001 From: Insality Date: Mon, 24 Feb 2020 00:03:29 +0300 Subject: [PATCH 13/20] Rename bounce -> default style, start make new example pages --- docs/index.html | 2 +- docs/modules/component.html | 2 +- docs/modules/druid.back_handler.html | 2 +- docs/modules/druid.blocker.html | 2 +- docs/modules/druid.button.html | 16 +++++++++++++++- docs/modules/druid.checkbox.html | 2 +- docs/modules/druid.checkbox_group.html | 2 +- docs/modules/druid.grid.html | 2 +- docs/modules/druid.helper.html | 2 +- docs/modules/druid.html | 2 +- docs/modules/druid.input.html | 2 +- docs/modules/druid.lang_text.html | 2 +- docs/modules/druid.progress.html | 2 +- docs/modules/druid.radio_group.html | 2 +- docs/modules/druid.scroll.html | 2 +- docs/modules/druid.slider.html | 2 +- docs/modules/druid.text.html | 2 +- docs/modules/druid.timer.html | 2 +- docs/modules/druid_event.html | 2 +- docs/modules/druid_instance.html | 2 +- druid/base/button.lua | 6 ++++++ druid/styles/{bounce => default}/anims.lua | 0 druid/styles/{bounce => default}/style.lua | 2 +- example/kenney/gui/main/main.gui_script | 8 +++++--- example/kenney/lang.lua | 4 ++++ 25 files changed, 50 insertions(+), 24 deletions(-) rename druid/styles/{bounce => default}/anims.lua (100%) rename druid/styles/{bounce => default}/style.lua (97%) diff --git a/docs/index.html b/docs/index.html index e865552..8e850b0 100644 --- a/docs/index.html +++ b/docs/index.html @@ -145,7 +145,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 22:54:59 +Last updated 2020-02-24 00:03:02
    diff --git a/docs/modules/component.html b/docs/modules/component.html index a05a234..03ef47b 100644 --- a/docs/modules/component.html +++ b/docs/modules/component.html @@ -396,7 +396,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 22:54:59 +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 66d587d..2943f1f 100644 --- a/docs/modules/druid.back_handler.html +++ b/docs/modules/druid.back_handler.html @@ -151,7 +151,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 22:54:59 +Last updated 2020-02-24 00:03:02
    diff --git a/docs/modules/druid.blocker.html b/docs/modules/druid.blocker.html index 46ce82d..ad72a4e 100644 --- a/docs/modules/druid.blocker.html +++ b/docs/modules/druid.blocker.html @@ -77,7 +77,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 22:54:59 +Last updated 2020-02-24 00:03:02
    diff --git a/docs/modules/druid.button.html b/docs/modules/druid.button.html index 82fe0ef..886be31 100644 --- a/docs/modules/druid.button.html +++ b/docs/modules/druid.button.html @@ -328,9 +328,23 @@ 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 + + +
  • @@ -346,7 +360,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 22:54:59 +Last updated 2020-02-24 00:03:02
    diff --git a/docs/modules/druid.checkbox.html b/docs/modules/druid.checkbox.html index bfe3b2a..66054fe 100644 --- a/docs/modules/druid.checkbox.html +++ b/docs/modules/druid.checkbox.html @@ -77,7 +77,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 22:54:59 +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 e492ef9..1c40d26 100644 --- a/docs/modules/druid.checkbox_group.html +++ b/docs/modules/druid.checkbox_group.html @@ -77,7 +77,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 22:54:59 +Last updated 2020-02-24 00:03:02
    diff --git a/docs/modules/druid.grid.html b/docs/modules/druid.grid.html index 6914a07..69dee2b 100644 --- a/docs/modules/druid.grid.html +++ b/docs/modules/druid.grid.html @@ -75,7 +75,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 22:54:59 +Last updated 2020-02-24 00:03:02
    diff --git a/docs/modules/druid.helper.html b/docs/modules/druid.helper.html index ae45827..c81e977 100644 --- a/docs/modules/druid.helper.html +++ b/docs/modules/druid.helper.html @@ -226,7 +226,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 22:54:59 +Last updated 2020-02-24 00:03:02
    diff --git a/docs/modules/druid.html b/docs/modules/druid.html index 66d2c54..46038ef 100644 --- a/docs/modules/druid.html +++ b/docs/modules/druid.html @@ -171,7 +171,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 22:54:59 +Last updated 2020-02-24 00:03:02
    diff --git a/docs/modules/druid.input.html b/docs/modules/druid.input.html index 3c37497..da6d315 100644 --- a/docs/modules/druid.input.html +++ b/docs/modules/druid.input.html @@ -151,7 +151,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 22:54:59 +Last updated 2020-02-24 00:03:02
    diff --git a/docs/modules/druid.lang_text.html b/docs/modules/druid.lang_text.html index 2c02a82..9f52f6b 100644 --- a/docs/modules/druid.lang_text.html +++ b/docs/modules/druid.lang_text.html @@ -118,7 +118,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 22:54:59 +Last updated 2020-02-24 00:03:02
    diff --git a/docs/modules/druid.progress.html b/docs/modules/druid.progress.html index 2b0ede6..e8e1115 100644 --- a/docs/modules/druid.progress.html +++ b/docs/modules/druid.progress.html @@ -296,7 +296,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 22:54:59 +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 082f70a..5d71a85 100644 --- a/docs/modules/druid.radio_group.html +++ b/docs/modules/druid.radio_group.html @@ -77,7 +77,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 22:54:59 +Last updated 2020-02-24 00:03:02
    diff --git a/docs/modules/druid.scroll.html b/docs/modules/druid.scroll.html index 81b1019..551ceb5 100644 --- a/docs/modules/druid.scroll.html +++ b/docs/modules/druid.scroll.html @@ -276,7 +276,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 22:54:59 +Last updated 2020-02-24 00:03:02
    diff --git a/docs/modules/druid.slider.html b/docs/modules/druid.slider.html index 03e14f1..a4abba6 100644 --- a/docs/modules/druid.slider.html +++ b/docs/modules/druid.slider.html @@ -77,7 +77,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 22:54:59 +Last updated 2020-02-24 00:03:02
    diff --git a/docs/modules/druid.text.html b/docs/modules/druid.text.html index 41d09ef..6df4131 100644 --- a/docs/modules/druid.text.html +++ b/docs/modules/druid.text.html @@ -235,7 +235,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 22:54:59 +Last updated 2020-02-24 00:03:02
    diff --git a/docs/modules/druid.timer.html b/docs/modules/druid.timer.html index 242b9b2..8fef622 100644 --- a/docs/modules/druid.timer.html +++ b/docs/modules/druid.timer.html @@ -179,7 +179,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 22:54:59 +Last updated 2020-02-24 00:03:02
    diff --git a/docs/modules/druid_event.html b/docs/modules/druid_event.html index 37e3a1c..dc54081 100644 --- a/docs/modules/druid_event.html +++ b/docs/modules/druid_event.html @@ -162,7 +162,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 22:54:59 +Last updated 2020-02-24 00:03:02
    diff --git a/docs/modules/druid_instance.html b/docs/modules/druid_instance.html index f3df01a..732fba4 100644 --- a/docs/modules/druid_instance.html +++ b/docs/modules/druid_instance.html @@ -740,7 +740,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 22:54:59 +Last updated 2020-02-24 00:03:02
    diff --git a/druid/base/button.lua b/druid/base/button.lua index 34f8f37..bacc089 100644 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -1,6 +1,9 @@ --- Component to handle basic GUI button -- @module druid.button +--- Button gui component +--@class druid + --- Component events -- @table Events -- @tfield druid_event on_click On release button callback @@ -22,7 +25,10 @@ --- 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") 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 97% rename from druid/styles/bounce/style.lua rename to druid/styles/default/style.lua index e9d93bf..d9a7d46 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 = {} diff --git a/example/kenney/gui/main/main.gui_script b/example/kenney/gui/main/main.gui_script index 357e8b3..30fd8af 100644 --- a/example/kenney/gui/main/main.gui_script +++ b/example/kenney/gui/main/main.gui_script @@ -1,14 +1,16 @@ 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 pages = { "main_page", - "texts_page" + "texts_page", + "button_page", + "scroll_page", } local function on_control_button(self, delta) @@ -34,7 +36,7 @@ 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) 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 = "Таймер", From ac2bbc29d3812bb4bdb42e32947df67dac1cc213 Mon Sep 17 00:00:00 2001 From: Insality Date: Mon, 24 Feb 2020 09:34:16 +0300 Subject: [PATCH 14/20] Add druid events in components --- druid/base/back_handler.lua | 5 +- druid/base/blocker.lua | 14 + druid/base/button.lua | 9 +- druid/base/checkbox.lua | 5 +- druid/base/checkbox_group.lua | 13 +- druid/base/grid.lua | 10 + druid/base/hover.lua | 6 +- druid/base/slider.lua | 8 +- druid/base/text.lua | 11 + druid/base/timer.lua | 17 +- druid/event.lua | 9 +- example/kenney/gui/main/main.gui | 909 ++++++++++++++++++++++++ example/kenney/gui/main/main.gui_script | 4 + example/kenney/page/button.lua | 23 + example/kenney/page/scroll.lua | 8 + 15 files changed, 1019 insertions(+), 32 deletions(-) create mode 100644 example/kenney/page/button.lua create mode 100644 example/kenney/page/scroll.lua diff --git a/druid/base/back_handler.lua b/druid/base/back_handler.lua index 70cd190..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") @@ -15,6 +16,8 @@ local M = component.create("back_handler", { const.ON_INPUT }) function M.init(self, callback, params) self.callback = callback self.params = params + + self.on_back = Event(callback) end @@ -24,7 +27,7 @@ end -- @tparam table action on_input action function M.on_input(self, action_id, action) if action_id == const.ACTION_BACK and action[const.RELEASED] then - self.callback(self:get_context(), self.params) + self.on_back:trigger(self:get_context(), self.params) return true end diff --git a/druid/base/blocker.lua b/druid/base/blocker.lua index d03fc3f..303d703 100644 --- a/druid/base/blocker.lua +++ b/druid/base/blocker.lua @@ -1,6 +1,7 @@ --- 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") @@ -10,6 +11,9 @@ local M = component.create("blocker", { const.ON_INPUT_HIGH }) function M.init(self, node) self.node = self:get_node(node) + + self.on_click = Event() + self.on_enable_change = Event() end @@ -30,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 bacc089..a24d24d 100644 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -75,8 +75,6 @@ end -- @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") - self.druid = self:get_druid() self.style = self:get_style() self.node = self:get_node(node) @@ -90,15 +88,10 @@ function M.init(self, node, callback, params, anim_node, event) self.click_zone = nil -- Event stubs - self.on_click = Event() + self.on_click = Event(callback) self.on_repeated_click = Event() self.on_long_click = Event() self.on_double_click = Event() - - if callback then - self.on_click:subscribe(callback) - end - 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 index 71a15bc..42af7d4 100644 --- a/druid/base/hover.lua +++ b/druid/base/hover.lua @@ -20,10 +20,8 @@ function M.init(self, node, context, on_hover_callback) self._is_hovered = false self.context = context - self.on_hover = Event() - if on_hover_callback then - self.on_hover:subscribe(on_hover_callback) - end + + self.on_hover = Event(on_hover_callback) end diff --git a/druid/base/slider.lua b/druid/base/slider.lua index 80a8534..6fd3f9f 100644 --- a/druid/base/slider.lua +++ b/druid/base/slider.lua @@ -1,6 +1,7 @@ --- 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") @@ -9,9 +10,7 @@ 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/event.lua b/druid/event.lua index 8b3350e..d38761e 100644 --- a/druid/event.lua +++ b/druid/event.lua @@ -7,8 +7,15 @@ local class = require("druid.system.middleclass") local M = class("druid.event") -function M.initialize(self) +--- 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 diff --git a/example/kenney/gui/main/main.gui b/example/kenney/gui/main/main.gui index 0d74dfd..1ba3e11 100644 --- a/example/kenney/gui/main/main.gui +++ b/example/kenney/gui/main/main.gui @@ -3981,6 +3981,915 @@ 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: 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 30fd8af..8760379 100644 --- a/example/kenney/gui/main/main.gui_script +++ b/example/kenney/gui/main/main.gui_script @@ -5,6 +5,8 @@ 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", @@ -43,6 +45,8 @@ function init(self) self.page = 1 main_page.setup_page(self) text_page.setup_page(self) + button_page.setup_page(self) + scroll_page.setup_page(self) end diff --git a/example/kenney/page/button.lua b/example/kenney/page/button.lua new file mode 100644 index 0000000..308b1eb --- /dev/null +++ b/example/kenney/page/button.lua @@ -0,0 +1,23 @@ +local sprite_change_style = {} + +local M = {} + + +local function setup_buttons(self) + self.druid:new_button("button_usual/button") + + local custom_style = self.druid:new_button("button_custom_style/button") + 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" +end + + +function M.setup_page(self) + setup_buttons(self) +end + + +return M 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 From d28b77bc9a4f442faa77c32dc17723db32533a9d Mon Sep 17 00:00:00 2001 From: Insality Date: Mon, 24 Feb 2020 09:40:09 +0300 Subject: [PATCH 15/20] Hover context remove (get from get_context()) --- druid/base/button.lua | 2 +- druid/base/hover.lua | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/druid/base/button.lua b/druid/base/button.lua index a24d24d..4bcf9f6 100644 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -84,7 +84,7 @@ function M.init(self, node, callback, params, anim_node, event) 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, self, on_button_hover) + self.hover = self.druid:new_hover(node, on_button_hover) self.click_zone = nil -- Event stubs diff --git a/druid/base/hover.lua b/druid/base/hover.lua index 42af7d4..5f04feb 100644 --- a/druid/base/hover.lua +++ b/druid/base/hover.lua @@ -14,12 +14,11 @@ local M = component.create("hover", { const.ON_INPUT }) -- @tparam table self Component instance -- @tparam node node Gui node -- @tparam function on_hover_callback Hover callback -function M.init(self, node, context, on_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.context = context self.on_hover = Event(on_hover_callback) end @@ -28,7 +27,7 @@ end local function set_hover(self, state) if self._is_hovered ~= state then self._is_hovered = state - self.on_hover:trigger(self.context, state) + self.on_hover:trigger(self:get_context(), state) end end From b1fbb7c5bf08200e6d3f505e215aab9f4765e033 Mon Sep 17 00:00:00 2001 From: Insality Date: Mon, 24 Feb 2020 20:29:56 +0300 Subject: [PATCH 16/20] Add simple scroll events --- druid/base/scroll.lua | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index b5382ca..193a089 100644 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -1,6 +1,7 @@ --- 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") @@ -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 From 162bbd0ed982215e5a51515f4fb5f53150ec5fd3 Mon Sep 17 00:00:00 2001 From: Insality Date: Mon, 24 Feb 2020 23:36:44 +0300 Subject: [PATCH 17/20] Add more events on button (long_tap, repeated_tap, double_tap) --- druid/base/button.lua | 78 +++++++++++++++++++++++-- druid/event.lua | 15 +++++ druid/styles/default/style.lua | 2 + druid/styles/empty/style.lua | 2 + example/kenney/gui/main/main.gui_script | 5 +- example/kenney/page/button.lua | 30 +++++++++- 6 files changed, 122 insertions(+), 10 deletions(-) diff --git a/druid/base/button.lua b/druid/base/button.lua index 4bcf9f6..abe994f 100644 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -47,14 +47,67 @@ local function on_button_hover(self, 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 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.on_click:trigger(self:get_context(), self.params, self) + + self.last_released_time = time end return true else @@ -86,6 +139,10 @@ function M.init(self, node, callback, params, anim_node, event) 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 -- Event stubs self.on_click = Event(callback) @@ -118,10 +175,20 @@ function M.on_input(self, action_id, action) 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 + self.is_repeated_started = true + on_button_repeated_click(self) + return true + end + end + if action.released then return on_button_release(self) end @@ -166,7 +233,6 @@ function M.set_click_zone(self, zone) end --- TODO: implement them all! --- Set key-code to trigger this button function M.set_key_trigger(self, key) diff --git a/druid/event.lua b/druid/event.lua index d38761e..1d6c289 100644 --- a/druid/event.lua +++ b/druid/event.lua @@ -43,6 +43,21 @@ function M.unsubscribe(self, callback) 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 diff --git a/druid/styles/default/style.lua b/druid/styles/default/style.lua index d9a7d46..430c0fb 100644 --- a/druid/styles/default/style.lua +++ b/druid/styles/default/style.lua @@ -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/example/kenney/gui/main/main.gui_script b/example/kenney/gui/main/main.gui_script index 8760379..bd472e3 100644 --- a/example/kenney/gui/main/main.gui_script +++ b/example/kenney/gui/main/main.gui_script @@ -42,11 +42,14 @@ function init(self) 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/page/button.lua b/example/kenney/page/button.lua index 308b1eb..cdfad37 100644 --- a/example/kenney/page/button.lua +++ b/example/kenney/page/button.lua @@ -3,15 +3,39 @@ 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") + self.druid:new_button("button_usual/button", usual_callback) - local custom_style = self.druid:new_button("button_custom_style/button") + 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) end From 2d45573f02d9af4d0b8192677afda3075de46e91 Mon Sep 17 00:00:00 2001 From: Insality Date: Mon, 24 Feb 2020 23:56:57 +0300 Subject: [PATCH 18/20] Add key_trigger to the button --- druid/base/button.lua | 46 +++++++-- druid/base/hover.lua | 10 +- example/kenney/gui/main/main.gui | 160 +++++++++++++++++++++++++++++++ example/kenney/page/button.lua | 6 +- game.project | 3 + input/game.input_binding | 4 + 6 files changed, 216 insertions(+), 13 deletions(-) diff --git a/druid/base/button.lua b/druid/base/button.lua index abe994f..6edc540 100644 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -38,6 +38,19 @@ local component = require("druid.component") local M = component.create("button", { const.ON_INPUT }) +local function is_input_match(self, action_id) + if action_id == const.ACTION_TOUCH then + return true + end + + if self.key_trigger and action_id == self.key_trigger then + return true + end + + return false +end + + local function on_button_hover(self, hover_state) if not self.style.on_hover then return @@ -57,6 +70,11 @@ 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 @@ -143,6 +161,7 @@ function M.init(self, node, callback, params, anim_node, event) 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) @@ -153,17 +172,23 @@ end function M.on_input(self, action_id, action) - if action_id ~= const.ACTION_TOUCH then + if not is_input_match(self, action_id) then return false end + local is_key_trigger = (action_id == self.key_trigger) + 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 + + 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 @@ -172,6 +197,10 @@ function M.on_input(self, action_id, action) 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 @@ -183,7 +212,6 @@ function M.on_input(self, action_id, action) -- 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 - self.is_repeated_started = true on_button_repeated_click(self) return true end @@ -234,14 +262,18 @@ 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/hover.lua b/druid/base/hover.lua index 5f04feb..bf93a7b 100644 --- a/druid/base/hover.lua +++ b/druid/base/hover.lua @@ -24,7 +24,7 @@ function M.init(self, node, on_hover_callback) end -local function set_hover(self, state) +function M.set_hover(self, state) if self._is_hovered ~= state then self._is_hovered = state self.on_hover:trigger(self:get_context(), state) @@ -44,20 +44,20 @@ function M.on_input(self, action_id, action) local is_pick = gui.pick_node(self.node, action.x, action.y) if not is_pick then - set_hover(self, false) + M.set_hover(self, false) return false end if action.released then - set_hover(self, false) + M.set_hover(self, false) else - set_hover(self, true) + M.set_hover(self, true) end end function M.on_input_interrupt(self) - set_hover(self, false) + M.set_hover(self, false) end diff --git a/example/kenney/gui/main/main.gui b/example/kenney/gui/main/main.gui index 1ba3e11..be9af76 100644 --- a/example/kenney/gui/main/main.gui +++ b/example/kenney/gui/main/main.gui @@ -4835,6 +4835,166 @@ nodes { 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 diff --git a/example/kenney/page/button.lua b/example/kenney/page/button.lua index cdfad37..3ff56ff 100644 --- a/example/kenney/page/button.lua +++ b/example/kenney/page/button.lua @@ -29,13 +29,17 @@ local function setup_buttons(self) 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 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" From 09dbd66484892cf89c632d9871df18b2325866e5 Mon Sep 17 00:00:00 2001 From: Insality Date: Tue, 25 Feb 2020 00:13:54 +0300 Subject: [PATCH 19/20] Add click_zone to hover --- druid/base/button.lua | 1 + druid/base/hover.lua | 3 +++ 2 files changed, 4 insertions(+) diff --git a/druid/base/button.lua b/druid/base/button.lua index 6edc540..2b6e4bf 100644 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -258,6 +258,7 @@ 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 diff --git a/druid/base/hover.lua b/druid/base/hover.lua index bf93a7b..a535af9 100644 --- a/druid/base/hover.lua +++ b/druid/base/hover.lua @@ -42,6 +42,9 @@ function M.on_input(self, action_id, action) 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) From 5ea102d0aa898d80ecdfc5d8abf057d5e17063b7 Mon Sep 17 00:00:00 2001 From: Insality Date: Tue, 25 Feb 2020 00:26:53 +0300 Subject: [PATCH 20/20] To-do list changes --- alpha_todo.txt | 4 ++-- druid/base/button.lua | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/alpha_todo.txt b/alpha_todo.txt index cff23aa..fbbf68e 100644 --- a/alpha_todo.txt +++ b/alpha_todo.txt @@ -13,9 +13,9 @@ Simple to-do for Druid Alpha 0.2.0 - 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 add key trigger - button polish, actions -- button and hover click restriction zone? ++ button and hover click restriction zone? - unify component api (get/set/to and other general stuff) - better callbacks for every components diff --git a/druid/base/button.lua b/druid/base/button.lua index 2b6e4bf..8733a39 100644 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -176,14 +176,12 @@ function M.on_input(self, action_id, action) return false end - local is_key_trigger = (action_id == self.key_trigger) - if not helper.is_enabled(self.node) then return false end 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