mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 18:37:44 +02:00
Merge pull request #94 from Insality/feature/93-name-refactor
Renamed class functions
This commit is contained in:
commit
327bc48086
@ -13,14 +13,14 @@ local Event = require("druid.event")
|
|||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
local M = component.create("back_handler", { const.ON_INPUT })
|
local BackHandler = component.create("back_handler", { const.ON_INPUT })
|
||||||
|
|
||||||
|
|
||||||
--- Component init function
|
--- Component init function
|
||||||
-- @function back_handler:init
|
-- @function back_handler:init
|
||||||
-- @tparam callback callback On back button
|
-- @tparam callback callback On back button
|
||||||
-- @tparam[opt] params Callback argument
|
-- @tparam[opt] params Callback argument
|
||||||
function M.init(self, callback, params)
|
function BackHandler:init(callback, params)
|
||||||
self.params = params
|
self.params = params
|
||||||
|
|
||||||
self.on_back = Event(callback)
|
self.on_back = Event(callback)
|
||||||
@ -31,7 +31,7 @@ end
|
|||||||
-- @function back_handler:on_input
|
-- @function back_handler:on_input
|
||||||
-- @tparam string action_id on_input action id
|
-- @tparam string action_id on_input action id
|
||||||
-- @tparam table action on_input action
|
-- @tparam table action on_input action
|
||||||
function M.on_input(self, action_id, action)
|
function BackHandler:on_input(action_id, action)
|
||||||
if not action[const.RELEASED] then
|
if not action[const.RELEASED] then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -45,4 +45,4 @@ function M.on_input(self, action_id, action)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return BackHandler
|
||||||
|
@ -14,13 +14,13 @@ local Event = require("druid.event")
|
|||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
local M = component.create("blocker", { const.ON_INPUT })
|
local Blocker = component.create("blocker", { const.ON_INPUT })
|
||||||
|
|
||||||
|
|
||||||
--- Component init function
|
--- Component init function
|
||||||
-- @function blocker:init
|
-- @function blocker:init
|
||||||
-- @tparam node node Gui node
|
-- @tparam node node Gui node
|
||||||
function M.init(self, node)
|
function Blocker:init(node)
|
||||||
self.node = self:get_node(node)
|
self.node = self:get_node(node)
|
||||||
|
|
||||||
self.on_click = Event()
|
self.on_click = Event()
|
||||||
@ -28,7 +28,7 @@ function M.init(self, node)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.on_input(self, action_id, action)
|
function Blocker:on_input(action_id, action)
|
||||||
if action_id ~= const.ACTION_TOUCH and
|
if action_id ~= const.ACTION_TOUCH and
|
||||||
action_id ~= const.ACTION_MULTITOUCH and
|
action_id ~= const.ACTION_MULTITOUCH and
|
||||||
action_id ~= nil then
|
action_id ~= nil then
|
||||||
@ -50,7 +50,7 @@ end
|
|||||||
--- Set enabled blocker component state
|
--- Set enabled blocker component state
|
||||||
-- @function blocker:set_enabled
|
-- @function blocker:set_enabled
|
||||||
-- @tparam bool state Enabled state
|
-- @tparam bool state Enabled state
|
||||||
function M.set_enabled(self, state)
|
function Blocker:set_enabled(state)
|
||||||
gui.set_enabled(self.node, state)
|
gui.set_enabled(self.node, state)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -58,9 +58,9 @@ end
|
|||||||
--- Return blocked enabled state
|
--- Return blocked enabled state
|
||||||
-- @function blocker:is_enabled
|
-- @function blocker:is_enabled
|
||||||
-- @treturn bool True, if blocker is enabled
|
-- @treturn bool True, if blocker is enabled
|
||||||
function M.is_enabled(self, state)
|
function Blocker:is_enabled(state)
|
||||||
return gui.is_enabled(self.node)
|
return gui.is_enabled(self.node)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return Blocker
|
||||||
|
@ -26,7 +26,7 @@ local const = require("druid.const")
|
|||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
local M = component.create("button", { const.ON_INPUT })
|
local Button = component.create("button", { const.ON_INPUT })
|
||||||
|
|
||||||
|
|
||||||
local function is_input_match(self, action_id)
|
local function is_input_match(self, action_id)
|
||||||
@ -141,7 +141,7 @@ end
|
|||||||
-- @tfield function on_hover (self, node, hover_state)
|
-- @tfield function on_hover (self, node, hover_state)
|
||||||
-- @tfield function on_mouse_hover (self, node, hover_state)
|
-- @tfield function on_mouse_hover (self, node, hover_state)
|
||||||
-- @tfield function on_set_enabled (self, node, enabled_state)
|
-- @tfield function on_set_enabled (self, node, enabled_state)
|
||||||
function M.on_style_change(self, style)
|
function Button:on_style_change(style)
|
||||||
self.style = {}
|
self.style = {}
|
||||||
self.style.LONGTAP_TIME = style.LONGTAP_TIME or 0.4
|
self.style.LONGTAP_TIME = style.LONGTAP_TIME or 0.4
|
||||||
self.style.AUTOHOLD_TRIGGER = style.AUTOHOLD_TRIGGER or 0.8
|
self.style.AUTOHOLD_TRIGGER = style.AUTOHOLD_TRIGGER or 0.8
|
||||||
@ -161,7 +161,7 @@ end
|
|||||||
-- @tparam function callback Button callback
|
-- @tparam function callback Button callback
|
||||||
-- @tparam[opt] table params Button callback params
|
-- @tparam[opt] table params Button callback params
|
||||||
-- @tparam[opt] node anim_node Button anim node (node, if not provided)
|
-- @tparam[opt] node anim_node Button anim node (node, if not provided)
|
||||||
function M.init(self, node, callback, params, anim_node)
|
function Button:init(node, callback, params, anim_node)
|
||||||
self.druid = self:get_druid()
|
self.druid = self:get_druid()
|
||||||
self.node = self:get_node(node)
|
self.node = self:get_node(node)
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ function M.init(self, node, callback, params, anim_node)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.on_input(self, action_id, action)
|
function Button:on_input(action_id, action)
|
||||||
if not is_input_match(self, action_id) then
|
if not is_input_match(self, action_id) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -257,7 +257,7 @@ function M.on_input(self, action_id, action)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.on_input_interrupt(self)
|
function Button:on_input_interrupt()
|
||||||
self.can_action = false
|
self.can_action = false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ end
|
|||||||
-- @function button:set_enabled
|
-- @function button:set_enabled
|
||||||
-- @tparam bool state Enabled state
|
-- @tparam bool state Enabled state
|
||||||
-- @treturn druid.button Current button instance
|
-- @treturn druid.button Current button instance
|
||||||
function M.set_enabled(self, state)
|
function Button:set_enabled(state)
|
||||||
self.disabled = not state
|
self.disabled = not state
|
||||||
self.hover:set_enabled(state)
|
self.hover:set_enabled(state)
|
||||||
self.style.on_set_enabled(self, self.node, state)
|
self.style.on_set_enabled(self, self.node, state)
|
||||||
@ -278,7 +278,7 @@ end
|
|||||||
--- Return button enabled state
|
--- Return button enabled state
|
||||||
-- @function button:is_enabled
|
-- @function button:is_enabled
|
||||||
-- @treturn bool True, if button is enabled
|
-- @treturn bool True, if button is enabled
|
||||||
function M.is_enabled(self)
|
function Button:is_enabled()
|
||||||
return not self.disabled
|
return not self.disabled
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ end
|
|||||||
-- @function button:set_click_zone
|
-- @function button:set_click_zone
|
||||||
-- @tparam node zone Gui node
|
-- @tparam node zone Gui node
|
||||||
-- @treturn druid.button Current button instance
|
-- @treturn druid.button Current button instance
|
||||||
function M.set_click_zone(self, zone)
|
function Button:set_click_zone(zone)
|
||||||
self.click_zone = self:get_node(zone)
|
self.click_zone = self:get_node(zone)
|
||||||
self.hover:set_click_zone(zone)
|
self.hover:set_click_zone(zone)
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ end
|
|||||||
-- @function button:set_key_trigger
|
-- @function button:set_key_trigger
|
||||||
-- @tparam hash key The action_id of the key
|
-- @tparam hash key The action_id of the key
|
||||||
-- @treturn druid.button Current button instance
|
-- @treturn druid.button Current button instance
|
||||||
function M.set_key_trigger(self, key)
|
function Button:set_key_trigger(key)
|
||||||
self.key_trigger = hash(key)
|
self.key_trigger = hash(key)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -310,9 +310,9 @@ end
|
|||||||
--- Get key-code to trigger this button
|
--- Get key-code to trigger this button
|
||||||
-- @function button:get_key_trigger
|
-- @function button:get_key_trigger
|
||||||
-- @treturn hash The action_id of the key
|
-- @treturn hash The action_id of the key
|
||||||
function M.get_key_trigger(self)
|
function Button:get_key_trigger()
|
||||||
return self.key_trigger
|
return self.key_trigger
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return Button
|
||||||
|
@ -27,7 +27,7 @@ local const = require("druid.const")
|
|||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
local M = component.create("drag", { const.ON_INPUT_HIGH })
|
local Drag = component.create("drag", { const.ON_INPUT_HIGH })
|
||||||
|
|
||||||
|
|
||||||
local function start_touch(self, touch)
|
local function start_touch(self, touch)
|
||||||
@ -129,7 +129,7 @@ end
|
|||||||
-- or create your own style
|
-- or create your own style
|
||||||
-- @table Style
|
-- @table Style
|
||||||
-- @tfield[opt=10] number DRAG_DEADZONE Distance in pixels to start dragging
|
-- @tfield[opt=10] number DRAG_DEADZONE Distance in pixels to start dragging
|
||||||
function M.on_style_change(self, style)
|
function Drag:on_style_change(style)
|
||||||
self.style = {}
|
self.style = {}
|
||||||
self.style.DRAG_DEADZONE = style.DRAG_DEADZONE or 10
|
self.style.DRAG_DEADZONE = style.DRAG_DEADZONE or 10
|
||||||
end
|
end
|
||||||
@ -139,7 +139,7 @@ end
|
|||||||
-- @tparam node node GUI node to detect dragging
|
-- @tparam node node GUI node to detect dragging
|
||||||
-- @tparam function on_drag_callback Callback for on_drag_event(self, dx, dy)
|
-- @tparam function on_drag_callback Callback for on_drag_event(self, dx, dy)
|
||||||
-- @function drag:init
|
-- @function drag:init
|
||||||
function M.init(self, node, on_drag_callback)
|
function Drag:init(node, on_drag_callback)
|
||||||
self.node = self:get_node(node)
|
self.node = self:get_node(node)
|
||||||
|
|
||||||
self.dx = 0
|
self.dx = 0
|
||||||
@ -163,14 +163,14 @@ function M.init(self, node, on_drag_callback)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.on_input_interrupt(self)
|
function Drag:on_input_interrupt()
|
||||||
if self.is_drag or self.is_touch then
|
if self.is_drag or self.is_touch then
|
||||||
end_touch(self)
|
end_touch(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.on_input(self, action_id, action)
|
function Drag:on_input(action_id, action)
|
||||||
if action_id ~= const.ACTION_TOUCH and action_id ~= const.ACTION_MULTITOUCH then
|
if action_id ~= const.ACTION_TOUCH and action_id ~= const.ACTION_MULTITOUCH then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -243,9 +243,9 @@ end
|
|||||||
-- restrict events outside stencil node
|
-- restrict events outside stencil node
|
||||||
-- @function drag:set_click_zone
|
-- @function drag:set_click_zone
|
||||||
-- @tparam node zone Gui node
|
-- @tparam node zone Gui node
|
||||||
function M.set_click_zone(self, zone)
|
function Drag:set_click_zone(zone)
|
||||||
self.click_zone = self:get_node(zone)
|
self.click_zone = self:get_node(zone)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return Drag
|
||||||
|
@ -11,14 +11,14 @@ local const = require("druid.const")
|
|||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
local M = component.create("hover", { const.ON_INPUT })
|
local Hover = component.create("hover", { const.ON_INPUT })
|
||||||
|
|
||||||
|
|
||||||
--- Component init function
|
--- Component init function
|
||||||
-- @function hover:init
|
-- @function hover:init
|
||||||
-- @tparam node node Gui node
|
-- @tparam node node Gui node
|
||||||
-- @tparam function on_hover_callback Hover callback
|
-- @tparam function on_hover_callback Hover callback
|
||||||
function M.init(self, node, on_hover_callback)
|
function Hover:init(node, on_hover_callback)
|
||||||
self.node = self:get_node(node)
|
self.node = self:get_node(node)
|
||||||
|
|
||||||
self._is_hovered = false
|
self._is_hovered = false
|
||||||
@ -31,7 +31,7 @@ function M.init(self, node, on_hover_callback)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.on_input(self, action_id, action)
|
function Hover:on_input(action_id, action)
|
||||||
if action_id ~= const.ACTION_TOUCH and action_id ~= nil then
|
if action_id ~= const.ACTION_TOUCH and action_id ~= nil then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -49,7 +49,7 @@ function M.on_input(self, action_id, action)
|
|||||||
is_pick = is_pick and gui.pick_node(self.click_zone, action.x, action.y)
|
is_pick = is_pick and gui.pick_node(self.click_zone, action.x, action.y)
|
||||||
end
|
end
|
||||||
|
|
||||||
local hover_function = action_id and M.set_hover or M.set_mouse_hover
|
local hover_function = action_id and self.set_hover or self.set_mouse_hover
|
||||||
|
|
||||||
if not is_pick then
|
if not is_pick then
|
||||||
hover_function(self, false)
|
hover_function(self, false)
|
||||||
@ -64,7 +64,7 @@ function M.on_input(self, action_id, action)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.on_input_interrupt(self)
|
function Hover:on_input_interrupt()
|
||||||
self:set_hover(false)
|
self:set_hover(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ end
|
|||||||
--- Set hover state
|
--- Set hover state
|
||||||
-- @function hover:set_hover
|
-- @function hover:set_hover
|
||||||
-- @tparam bool state The hover state
|
-- @tparam bool state The hover state
|
||||||
function M.set_hover(self, state)
|
function Hover:set_hover(state)
|
||||||
if self._is_hovered ~= state then
|
if self._is_hovered ~= state then
|
||||||
self._is_hovered = state
|
self._is_hovered = state
|
||||||
self.on_hover:trigger(self:get_context(), state)
|
self.on_hover:trigger(self:get_context(), state)
|
||||||
@ -82,7 +82,7 @@ end
|
|||||||
--- Set mouse hover state
|
--- Set mouse hover state
|
||||||
-- @function hover:set_mouse_hover
|
-- @function hover:set_mouse_hover
|
||||||
-- @tparam bool state The mouse hover state
|
-- @tparam bool state The mouse hover state
|
||||||
function M.set_mouse_hover(self, state)
|
function Hover:set_mouse_hover(state)
|
||||||
if self._is_mouse_hovered ~= state then
|
if self._is_mouse_hovered ~= state then
|
||||||
self._is_mouse_hovered = state
|
self._is_mouse_hovered = state
|
||||||
self.on_mouse_hover:trigger(self:get_context(), state)
|
self.on_mouse_hover:trigger(self:get_context(), state)
|
||||||
@ -94,7 +94,7 @@ end
|
|||||||
-- no click events outside stencil node
|
-- no click events outside stencil node
|
||||||
-- @function hover:set_click_zone
|
-- @function hover:set_click_zone
|
||||||
-- @tparam node zone Gui node
|
-- @tparam node zone Gui node
|
||||||
function M.set_click_zone(self, zone)
|
function Hover:set_click_zone(zone)
|
||||||
self.click_zone = self:get_node(zone)
|
self.click_zone = self:get_node(zone)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ end
|
|||||||
-- any hover events
|
-- any hover events
|
||||||
-- @function hover:set_enabled
|
-- @function hover:set_enabled
|
||||||
-- @tparam bool state The hover enabled state
|
-- @tparam bool state The hover enabled state
|
||||||
function M.set_enabled(self, state)
|
function Hover:set_enabled(state)
|
||||||
self._is_enabled = state
|
self._is_enabled = state
|
||||||
|
|
||||||
if not state then
|
if not state then
|
||||||
@ -121,9 +121,9 @@ end
|
|||||||
--- Return current hover enabled state
|
--- Return current hover enabled state
|
||||||
-- @function hover:is_enabled
|
-- @function hover:is_enabled
|
||||||
-- @treturn bool The hover enabled state
|
-- @treturn bool The hover enabled state
|
||||||
function M.is_enabled(self)
|
function Hover:is_enabled()
|
||||||
return self._is_enabled
|
return self._is_enabled
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return Hover
|
||||||
|
@ -17,7 +17,7 @@ local const = require("druid.const")
|
|||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
local M = component.create("swipe", { const.ON_INPUT })
|
local Swipe = component.create("swipe", { const.ON_INPUT })
|
||||||
|
|
||||||
|
|
||||||
local function start_swipe(self, action)
|
local function start_swipe(self, action)
|
||||||
@ -69,7 +69,7 @@ end
|
|||||||
-- @tfield[opt=0.4] number SWIPE_TIME Maximum time for swipe trigger
|
-- @tfield[opt=0.4] number SWIPE_TIME Maximum time for swipe trigger
|
||||||
-- @tfield[opt=50] number SWIPE_THRESHOLD Minimum distance for swipe trigger
|
-- @tfield[opt=50] number SWIPE_THRESHOLD Minimum distance for swipe trigger
|
||||||
-- @tfield[opt=false] bool SWIPE_TRIGGER_ON_MOVE If true, trigger on swipe moving, not only release action
|
-- @tfield[opt=false] bool SWIPE_TRIGGER_ON_MOVE If true, trigger on swipe moving, not only release action
|
||||||
function M.on_style_change(self, style)
|
function Swipe:on_style_change(style)
|
||||||
self.style = {}
|
self.style = {}
|
||||||
self.style.SWIPE_TIME = style.SWIPE_TIME or 0.4
|
self.style.SWIPE_TIME = style.SWIPE_TIME or 0.4
|
||||||
self.style.SWIPE_THRESHOLD = style.SWIPE_THRESHOLD or 50
|
self.style.SWIPE_THRESHOLD = style.SWIPE_THRESHOLD or 50
|
||||||
@ -81,7 +81,7 @@ end
|
|||||||
-- @function swipe:init
|
-- @function swipe:init
|
||||||
-- @tparam node node Gui node
|
-- @tparam node node Gui node
|
||||||
-- @tparam function on_swipe_callback Swipe callback for on_swipe_end event
|
-- @tparam function on_swipe_callback Swipe callback for on_swipe_end event
|
||||||
function M.init(self, node, on_swipe_callback)
|
function Swipe:init(node, on_swipe_callback)
|
||||||
self._trigger_on_move = self.style.SWIPE_TRIGGER_ON_MOVE
|
self._trigger_on_move = self.style.SWIPE_TRIGGER_ON_MOVE
|
||||||
self.node = self:get_node(node)
|
self.node = self:get_node(node)
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ function M.init(self, node, on_swipe_callback)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.on_input(self, action_id, action)
|
function Swipe:on_input(action_id, action)
|
||||||
if action_id ~= const.ACTION_TOUCH then
|
if action_id ~= const.ACTION_TOUCH then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -126,7 +126,7 @@ function M.on_input(self, action_id, action)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.on_input_interrupt(self)
|
function Swipe:on_input_interrupt()
|
||||||
reset_swipe(self)
|
reset_swipe(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -135,9 +135,9 @@ end
|
|||||||
-- restrict events outside stencil node
|
-- restrict events outside stencil node
|
||||||
-- @function swipe:set_click_zone
|
-- @function swipe:set_click_zone
|
||||||
-- @tparam node zone Gui node
|
-- @tparam node zone Gui node
|
||||||
function M.set_click_zone(self, zone)
|
function Swipe:set_click_zone(zone)
|
||||||
self.click_zone = self:get_node(zone)
|
self.click_zone = self:get_node(zone)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return Swipe
|
||||||
|
@ -24,7 +24,7 @@ local Event = require("druid.event")
|
|||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
local M = component.create("text", { const.ON_LAYOUT_CHANGE })
|
local Text = component.create("text", { const.ON_LAYOUT_CHANGE })
|
||||||
|
|
||||||
|
|
||||||
local function update_text_size(self)
|
local function update_text_size(self)
|
||||||
@ -81,7 +81,7 @@ end
|
|||||||
-- @tparam node node Gui text node
|
-- @tparam node node Gui text node
|
||||||
-- @tparam[opt] string value Initial text. Default value is node text from GUI scene.
|
-- @tparam[opt] string value Initial text. Default value is node text from GUI scene.
|
||||||
-- @tparam[opt] bool no_adjust If true, text will be not auto-adjust size
|
-- @tparam[opt] bool no_adjust If true, text will be not auto-adjust size
|
||||||
function M.init(self, node, value, no_adjust)
|
function Text:init(node, value, no_adjust)
|
||||||
self.node = self:get_node(node)
|
self.node = self:get_node(node)
|
||||||
self.pos = gui.get_position(self.node)
|
self.pos = gui.get_position(self.node)
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ function M.init(self, node, value, no_adjust)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.on_layout_change(self)
|
function Text:on_layout_change()
|
||||||
self:set_to(self.last_value)
|
self:set_to(self.last_value)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ end
|
|||||||
--- Calculate text width with font with respect to trailing space
|
--- Calculate text width with font with respect to trailing space
|
||||||
-- @function text:get_text_width
|
-- @function text:get_text_width
|
||||||
-- @tparam[opt] string text
|
-- @tparam[opt] string text
|
||||||
function M.get_text_width(self, text)
|
function Text:get_text_width(text)
|
||||||
text = text or self.last_value
|
text = text or self.last_value
|
||||||
local font = gui.get_font(self.node)
|
local font = gui.get_font(self.node)
|
||||||
local scale = gui.get_scale(self.node)
|
local scale = gui.get_scale(self.node)
|
||||||
@ -136,7 +136,7 @@ end
|
|||||||
--- Set text to text field
|
--- Set text to text field
|
||||||
-- @function text:set_to
|
-- @function text:set_to
|
||||||
-- @tparam string set_to Text for node
|
-- @tparam string set_to Text for node
|
||||||
function M.set_to(self, set_to)
|
function Text:set_to(set_to)
|
||||||
self.last_value = set_to
|
self.last_value = set_to
|
||||||
gui.set_text(self.node, set_to)
|
gui.set_text(self.node, set_to)
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ end
|
|||||||
--- Set color
|
--- Set color
|
||||||
-- @function text:set_color
|
-- @function text:set_color
|
||||||
-- @tparam vector4 color Color for node
|
-- @tparam vector4 color Color for node
|
||||||
function M.set_color(self, color)
|
function Text:set_color(color)
|
||||||
self.color = color
|
self.color = color
|
||||||
gui.set_color(self.node, color)
|
gui.set_color(self.node, color)
|
||||||
end
|
end
|
||||||
@ -160,7 +160,7 @@ end
|
|||||||
--- Set alpha
|
--- Set alpha
|
||||||
-- @function text:set_alpha
|
-- @function text:set_alpha
|
||||||
-- @tparam number alpha Alpha for node
|
-- @tparam number alpha Alpha for node
|
||||||
function M.set_alpha(self, alpha)
|
function Text:set_alpha(alpha)
|
||||||
self.color.w = alpha
|
self.color.w = alpha
|
||||||
gui.set_color(self.node, self.color)
|
gui.set_color(self.node, self.color)
|
||||||
end
|
end
|
||||||
@ -169,7 +169,7 @@ end
|
|||||||
--- Set scale
|
--- Set scale
|
||||||
-- @function text:set_scale
|
-- @function text:set_scale
|
||||||
-- @tparam vector3 scale Scale for node
|
-- @tparam vector3 scale Scale for node
|
||||||
function M.set_scale(self, scale)
|
function Text:set_scale(scale)
|
||||||
self.last_scale = scale
|
self.last_scale = scale
|
||||||
gui.set_scale(self.node, scale)
|
gui.set_scale(self.node, scale)
|
||||||
end
|
end
|
||||||
@ -179,7 +179,7 @@ end
|
|||||||
-- his text area
|
-- his text area
|
||||||
-- @function text:set_pivot
|
-- @function text:set_pivot
|
||||||
-- @tparam gui.pivot pivot Gui pivot constant
|
-- @tparam gui.pivot pivot Gui pivot constant
|
||||||
function M.set_pivot(self, pivot)
|
function Text:set_pivot(pivot)
|
||||||
local prev_pivot = gui.get_pivot(self.node)
|
local prev_pivot = gui.get_pivot(self.node)
|
||||||
local prev_offset = const.PIVOTS[prev_pivot]
|
local prev_offset = const.PIVOTS[prev_pivot]
|
||||||
|
|
||||||
@ -202,9 +202,9 @@ end
|
|||||||
--- Return true, if text with line break
|
--- Return true, if text with line break
|
||||||
-- @function text:is_multiline
|
-- @function text:is_multiline
|
||||||
-- @treturn bool Is text node with line break
|
-- @treturn bool Is text node with line break
|
||||||
function M.is_multiline(self)
|
function Text:is_multiline()
|
||||||
return gui.get_line_break(self.node)
|
return gui.get_line_break(self.node)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return Text
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
local class = require("druid.system.middleclass")
|
local class = require("druid.system.middleclass")
|
||||||
|
|
||||||
-- @class DruidEvent
|
-- @class DruidEvent
|
||||||
local M = class("druid.event")
|
local Event = class("druid.event")
|
||||||
|
|
||||||
|
|
||||||
--- Event constructur
|
--- Event constructur
|
||||||
-- @function Event
|
-- @function Event
|
||||||
-- @tparam function initial_callback Subscribe the callback on new event, if callback exist
|
-- @tparam function initial_callback Subscribe the callback on new event, if callback exist
|
||||||
function M.initialize(self, initial_callback)
|
function Event:initialize(initial_callback)
|
||||||
self._callbacks = {}
|
self._callbacks = {}
|
||||||
|
|
||||||
if initial_callback then
|
if initial_callback then
|
||||||
@ -22,7 +22,7 @@ end
|
|||||||
--- Subscribe callback on event
|
--- Subscribe callback on event
|
||||||
-- @function event:subscribe
|
-- @function event:subscribe
|
||||||
-- @tparam function callback Callback itself
|
-- @tparam function callback Callback itself
|
||||||
function M.subscribe(self, callback)
|
function Event:subscribe(callback)
|
||||||
assert(type(self) == "table", "You should subscribe to event with : syntax")
|
assert(type(self) == "table", "You should subscribe to event with : syntax")
|
||||||
assert(type(callback) == "function", "Callback should be function")
|
assert(type(callback) == "function", "Callback should be function")
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ end
|
|||||||
--- Unsubscribe callback on event
|
--- Unsubscribe callback on event
|
||||||
-- @function event:unsubscribe
|
-- @function event:unsubscribe
|
||||||
-- @tparam function callback Callback itself
|
-- @tparam function callback Callback itself
|
||||||
function M.unsubscribe(self, callback)
|
function Event:unsubscribe(callback)
|
||||||
for i = 1, #self._callbacks do
|
for i = 1, #self._callbacks do
|
||||||
if self._callbacks[i] == callback then
|
if self._callbacks[i] == callback then
|
||||||
table.remove(self._callbacks, i)
|
table.remove(self._callbacks, i)
|
||||||
@ -48,14 +48,14 @@ end
|
|||||||
--- Return true, if event have at lease one handler
|
--- Return true, if event have at lease one handler
|
||||||
-- @function event:is_exist
|
-- @function event:is_exist
|
||||||
-- @treturn bool True if event have handlers
|
-- @treturn bool True if event have handlers
|
||||||
function M.is_exist(self)
|
function Event:is_exist()
|
||||||
return #self._callbacks > 0
|
return #self._callbacks > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Clear the all event handlers
|
--- Clear the all event handlers
|
||||||
-- @function event:clear
|
-- @function event:clear
|
||||||
function M.clear(self)
|
function Event:clear()
|
||||||
self._callbacks = {}
|
self._callbacks = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -63,11 +63,11 @@ end
|
|||||||
--- Trigger the event and call all subscribed callbacks
|
--- Trigger the event and call all subscribed callbacks
|
||||||
-- @function event:trigger
|
-- @function event:trigger
|
||||||
-- @param ... All event params
|
-- @param ... All event params
|
||||||
function M.trigger(self, ...)
|
function Event:trigger(...)
|
||||||
for i = 1, #self._callbacks do
|
for i = 1, #self._callbacks do
|
||||||
self._callbacks[i](...)
|
self._callbacks[i](...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return Event
|
||||||
|
@ -15,11 +15,11 @@ local const = require("druid.const")
|
|||||||
local Event = require("druid.event")
|
local Event = require("druid.event")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
local M = component.create("checkbox", { const.ON_LAYOUT_CHANGE })
|
local Checkbox = component.create("checkbox", { const.ON_LAYOUT_CHANGE })
|
||||||
|
|
||||||
|
|
||||||
local function on_click(self)
|
local function on_click(self)
|
||||||
M.set_state(self, not self.state)
|
self:set_state(not self.state)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ end
|
|||||||
-- or create your own style
|
-- or create your own style
|
||||||
-- @table Style
|
-- @table Style
|
||||||
-- @tfield function on_change_state (self, node, state)
|
-- @tfield function on_change_state (self, node, state)
|
||||||
function M.on_style_change(self, style)
|
function Checkbox:on_style_change(style)
|
||||||
self.style = {}
|
self.style = {}
|
||||||
|
|
||||||
self.style.on_change_state = style.on_change_state or function(_, node, state)
|
self.style.on_change_state = style.on_change_state or function(_, node, state)
|
||||||
@ -42,19 +42,19 @@ end
|
|||||||
-- @tparam node node Gui node
|
-- @tparam node node Gui node
|
||||||
-- @tparam function callback Checkbox callback
|
-- @tparam function callback Checkbox callback
|
||||||
-- @tparam[opt=node] node click node Trigger node, by default equals to node
|
-- @tparam[opt=node] node click node Trigger node, by default equals to node
|
||||||
function M.init(self, node, callback, click_node)
|
function Checkbox:init(node, callback, click_node)
|
||||||
self.druid = self:get_druid()
|
self.druid = self:get_druid()
|
||||||
self.node = self:get_node(node)
|
self.node = self:get_node(node)
|
||||||
self.click_node = self:get_node(click_node)
|
self.click_node = self:get_node(click_node)
|
||||||
|
|
||||||
self.button = self.druid:new_button(self.click_node or self.node, on_click)
|
self.button = self.druid:new_button(self.click_node or self.node, on_click)
|
||||||
M.set_state(self, false, true)
|
self:set_state(false, true)
|
||||||
|
|
||||||
self.on_change_state = Event(callback)
|
self.on_change_state = Event(callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.on_layout_change(self)
|
function Checkbox:on_layout_change()
|
||||||
self:set_state(self.state, true)
|
self:set_state(self.state, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ end
|
|||||||
-- @function checkbox:set_state
|
-- @function checkbox:set_state
|
||||||
-- @tparam bool state Checkbox state
|
-- @tparam bool state Checkbox state
|
||||||
-- @tparam bool is_silent Don't trigger on_change_state if true
|
-- @tparam bool is_silent Don't trigger on_change_state if true
|
||||||
function M.set_state(self, state, is_silent)
|
function Checkbox:set_state(state, is_silent)
|
||||||
self.state = state
|
self.state = state
|
||||||
self.style.on_change_state(self, self.node, state)
|
self.style.on_change_state(self, self.node, state)
|
||||||
|
|
||||||
@ -76,9 +76,9 @@ end
|
|||||||
--- Return checkbox state
|
--- Return checkbox state
|
||||||
-- @function checkbox:get_state
|
-- @function checkbox:get_state
|
||||||
-- @treturn bool Checkbox state
|
-- @treturn bool Checkbox state
|
||||||
function M.get_state(self)
|
function Checkbox:get_state()
|
||||||
return self.state
|
return self.state
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return Checkbox
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
local Event = require("druid.event")
|
local Event = require("druid.event")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
local M = component.create("checkbox_group")
|
local CheckboxGroup = component.create("checkbox_group")
|
||||||
|
|
||||||
|
|
||||||
--- Component init function
|
--- Component init function
|
||||||
@ -20,7 +20,7 @@ local M = component.create("checkbox_group")
|
|||||||
-- @tparam node[] node Array of gui node
|
-- @tparam node[] node Array of gui node
|
||||||
-- @tparam function callback Checkbox callback
|
-- @tparam function callback Checkbox callback
|
||||||
-- @tparam[opt=node] node[] click node Array of trigger nodes, by default equals to nodes
|
-- @tparam[opt=node] node[] click node Array of trigger nodes, by default equals to nodes
|
||||||
function M.init(self, nodes, callback, click_nodes)
|
function CheckboxGroup:init(nodes, callback, click_nodes)
|
||||||
self.druid = self:get_druid()
|
self.druid = self:get_druid()
|
||||||
self.checkboxes = {}
|
self.checkboxes = {}
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ end
|
|||||||
--- Set checkbox group state
|
--- Set checkbox group state
|
||||||
-- @function checkbox_group:set_state
|
-- @function checkbox_group:set_state
|
||||||
-- @tparam bool[] indexes Array of checkbox state
|
-- @tparam bool[] indexes Array of checkbox state
|
||||||
function M.set_state(self, indexes)
|
function CheckboxGroup:set_state(indexes)
|
||||||
for i = 1, #indexes do
|
for i = 1, #indexes do
|
||||||
if self.checkboxes[i] then
|
if self.checkboxes[i] then
|
||||||
self.checkboxes[i]:set_state(indexes[i], true)
|
self.checkboxes[i]:set_state(indexes[i], true)
|
||||||
@ -52,7 +52,7 @@ end
|
|||||||
--- Return checkbox group state
|
--- Return checkbox group state
|
||||||
-- @function checkbox_group:get_state
|
-- @function checkbox_group:get_state
|
||||||
-- @treturn bool[] Array if checkboxes state
|
-- @treturn bool[] Array if checkboxes state
|
||||||
function M.get_state(self)
|
function CheckboxGroup:get_state()
|
||||||
local result = {}
|
local result = {}
|
||||||
|
|
||||||
for i = 1, #self.checkboxes do
|
for i = 1, #self.checkboxes do
|
||||||
@ -63,4 +63,4 @@ function M.get_state(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return CheckboxGroup
|
||||||
|
@ -1,64 +1,64 @@
|
|||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
local M = component.create("my_component_name", { const.ON_UPDATE })
|
local Component = component.create("my_component_name", { const.ON_UPDATE })
|
||||||
|
|
||||||
|
|
||||||
-- Component constructor
|
-- Component constructor
|
||||||
function M.init(self, ...)
|
function Component:init(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Call only if exist interest: const.ON_UPDATE
|
-- Call only if exist interest: const.ON_UPDATE
|
||||||
function M.update(self, dt)
|
function Component:update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Call only if exist interest: const.ON_INPUT or const.ON_INPUT_HIGH
|
-- Call only if exist interest: const.ON_INPUT or const.ON_INPUT_HIGH
|
||||||
function M.on_input(self, action_id, action)
|
function Component:on_input(action_id, action)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Call on component creation and on component:set_style() function
|
-- Call on component creation and on component:set_style() function
|
||||||
function M.on_style_change(self, style)
|
function Component:on_style_change(style)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Call only if exist interest: const.ON_MESSAGE
|
-- Call only if exist interest: const.ON_MESSAGE
|
||||||
function M.on_message(self, message_id, message, sender)
|
function Component:on_message(message_id, message, sender)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Call only if component with ON_LANGUAGE_CHANGE interest
|
-- Call only if component with ON_LANGUAGE_CHANGE interest
|
||||||
function M.on_language_change(self)
|
function Component:on_language_change()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Call only if component with ON_LAYOUT_CHANGE interest
|
-- Call only if component with ON_LAYOUT_CHANGE interest
|
||||||
function M.on_layout_change(self)
|
function Component:on_layout_change()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Call, if input was capturing before this component
|
-- Call, if input was capturing before this component
|
||||||
-- Example: scroll is start scrolling, so you need unhover button
|
-- Example: scroll is start scrolling, so you need unhover button
|
||||||
function M.on_input_interrupt(self)
|
function Component:on_input_interrupt()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Call, if game lost focus. Need ON_FOCUS_LOST intereset
|
-- Call, if game lost focus. Need ON_FOCUS_LOST intereset
|
||||||
function M.on_focus_lost(self)
|
function Component:on_focus_lost()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Call, if game gained focus. Need ON_FOCUS_GAINED intereset
|
-- Call, if game gained focus. Need ON_FOCUS_GAINED intereset
|
||||||
function M.on_focus_gained(self)
|
function Component:on_focus_gained()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Call on component remove or on druid:final
|
-- Call on component remove or on druid:final
|
||||||
function M.on_remove(self)
|
function Component:on_remove()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return Component
|
||||||
|
@ -25,6 +25,7 @@ local component = require("druid.component")
|
|||||||
|
|
||||||
local DynamicGrid = component.create("dynamic_grid", { const.ON_LAYOUT_CHANGE })
|
local DynamicGrid = component.create("dynamic_grid", { const.ON_LAYOUT_CHANGE })
|
||||||
|
|
||||||
|
|
||||||
local SIDE_VECTORS = {
|
local SIDE_VECTORS = {
|
||||||
LEFT = vmath.vector3(-1, 0, 0),
|
LEFT = vmath.vector3(-1, 0, 0),
|
||||||
RIGHT = vmath.vector3(1, 0, 0),
|
RIGHT = vmath.vector3(1, 0, 0),
|
||||||
|
@ -27,7 +27,7 @@ local const = require("druid.const")
|
|||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
local utf8 = require("druid.system.utf8")
|
local utf8 = require("druid.system.utf8")
|
||||||
|
|
||||||
local M = component.create("input", { const.ON_INPUT, const.ON_FOCUS_LOST })
|
local Input = component.create("input", { const.ON_INPUT, const.ON_FOCUS_LOST })
|
||||||
|
|
||||||
|
|
||||||
--- Mask text by replacing every character with a mask character
|
--- Mask text by replacing every character with a mask character
|
||||||
@ -97,7 +97,7 @@ end
|
|||||||
-- @tfield function on_unselect (self, button_node) Callback on input field unselecting
|
-- @tfield function on_unselect (self, button_node) Callback on input field unselecting
|
||||||
-- @tfield function on_input_wrong (self, button_node) Callback on wrong user input
|
-- @tfield function on_input_wrong (self, button_node) Callback on wrong user input
|
||||||
-- @tfield table button_style Custom button style for input node
|
-- @tfield table button_style Custom button style for input node
|
||||||
function M.on_style_change(self, style)
|
function Input:on_style_change(style)
|
||||||
self.style = {}
|
self.style = {}
|
||||||
|
|
||||||
self.style.IS_LONGTAP_ERASE = style.IS_LONGTAP_ERASE or false
|
self.style.IS_LONGTAP_ERASE = style.IS_LONGTAP_ERASE or false
|
||||||
@ -115,7 +115,7 @@ function M.on_style_change(self, style)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.init(self, click_node, text_node, keyboard_type)
|
function Input:init(click_node, text_node, keyboard_type)
|
||||||
self.druid = self:get_druid(self)
|
self.druid = self:get_druid(self)
|
||||||
self.text = self.druid:new_text(text_node)
|
self.text = self.druid:new_text(text_node)
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ function M.init(self, click_node, text_node, keyboard_type)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.on_input(self, action_id, action)
|
function Input:on_input(action_id, action)
|
||||||
if self.selected then
|
if self.selected then
|
||||||
local input_text = nil
|
local input_text = nil
|
||||||
if action_id == const.ACTION_TEXT then
|
if action_id == const.ACTION_TEXT then
|
||||||
@ -213,12 +213,12 @@ function M.on_input(self, action_id, action)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.on_focus_lost(self)
|
function Input:on_focus_lost()
|
||||||
unselect(self)
|
unselect(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.on_input_interrupt(self)
|
function Input:on_input_interrupt()
|
||||||
-- unselect(self)
|
-- unselect(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ end
|
|||||||
--- Set text for input field
|
--- Set text for input field
|
||||||
-- @function input:set_text
|
-- @function input:set_text
|
||||||
-- @tparam string input_text The string to apply for input field
|
-- @tparam string input_text The string to apply for input field
|
||||||
function M.set_text(self, input_text)
|
function Input:set_text(input_text)
|
||||||
-- Case when update with marked text
|
-- Case when update with marked text
|
||||||
if input_text then
|
if input_text then
|
||||||
self.value = input_text
|
self.value = input_text
|
||||||
@ -273,7 +273,7 @@ end
|
|||||||
--- Return current input field text
|
--- Return current input field text
|
||||||
-- @function input:get_text
|
-- @function input:get_text
|
||||||
-- @treturn string The current input field text
|
-- @treturn string The current input field text
|
||||||
function M.get_text(self)
|
function Input:get_text()
|
||||||
return self.value .. self.marked_value
|
return self.value .. self.marked_value
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ end
|
|||||||
-- @function input:set_max_length
|
-- @function input:set_max_length
|
||||||
-- @tparam number max_length Maximum length for input text field
|
-- @tparam number max_length Maximum length for input text field
|
||||||
-- @treturn druid.input Current input instance
|
-- @treturn druid.input Current input instance
|
||||||
function M.set_max_length(self, max_length)
|
function Input:set_max_length(max_length)
|
||||||
self.max_length = max_length
|
self.max_length = max_length
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -295,7 +295,7 @@ end
|
|||||||
-- @function input:set_allowerd_characters
|
-- @function input:set_allowerd_characters
|
||||||
-- @tparam string characters Regulax exp. for validate user input
|
-- @tparam string characters Regulax exp. for validate user input
|
||||||
-- @treturn druid.input Current input instance
|
-- @treturn druid.input Current input instance
|
||||||
function M.set_allowed_characters(self, characters)
|
function Input:set_allowed_characters(characters)
|
||||||
self.allowed_characters = characters
|
self.allowed_characters = characters
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -303,10 +303,10 @@ end
|
|||||||
|
|
||||||
--- Reset current input selection and return previous value
|
--- Reset current input selection and return previous value
|
||||||
-- @function input:reset_changes
|
-- @function input:reset_changes
|
||||||
function M.reset_changes(self)
|
function Input:reset_changes()
|
||||||
self:set_text(self.previous_value)
|
self:set_text(self.previous_value)
|
||||||
unselect(self)
|
unselect(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return Input
|
||||||
|
@ -15,7 +15,7 @@ local const = require("druid.const")
|
|||||||
local settings = require("druid.system.settings")
|
local settings = require("druid.system.settings")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
local M = component.create("lang_text", { const.ON_LANGUAGE_CHANGE })
|
local LangText = component.create("lang_text", { const.ON_LANGUAGE_CHANGE })
|
||||||
|
|
||||||
|
|
||||||
--- Component init function
|
--- Component init function
|
||||||
@ -23,7 +23,7 @@ local M = component.create("lang_text", { const.ON_LANGUAGE_CHANGE })
|
|||||||
-- @tparam node node The text node
|
-- @tparam node node The text node
|
||||||
-- @tparam string locale_id Default locale id
|
-- @tparam string locale_id Default locale id
|
||||||
-- @tparam bool no_adjust If true, will not correct text size
|
-- @tparam bool no_adjust If true, will not correct text size
|
||||||
function M.init(self, node, locale_id, no_adjust)
|
function LangText:init(node, locale_id, no_adjust)
|
||||||
self.druid = self:get_druid()
|
self.druid = self:get_druid()
|
||||||
self.text = self.druid:new_text(node, locale_id, no_adjust)
|
self.text = self.druid:new_text(node, locale_id, no_adjust)
|
||||||
self.last_locale_args = {}
|
self.last_locale_args = {}
|
||||||
@ -36,9 +36,9 @@ function M.init(self, node, locale_id, no_adjust)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.on_language_change(self)
|
function LangText:on_language_change()
|
||||||
if self.last_locale then
|
if self.last_locale then
|
||||||
M.translate(self, self.last_locale, unpack(self.last_locale_args))
|
self:translate(self.last_locale, unpack(self.last_locale_args))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ end
|
|||||||
--- Setup raw text to lang_text component
|
--- Setup raw text to lang_text component
|
||||||
-- @function lang_text:set_to
|
-- @function lang_text:set_to
|
||||||
-- @tparam string text Text for text node
|
-- @tparam string text Text for text node
|
||||||
function M.set_to(self, text)
|
function LangText:set_to(text)
|
||||||
self.last_locale = false
|
self.last_locale = false
|
||||||
self.text:set_to(text)
|
self.text:set_to(text)
|
||||||
self.on_change:trigger()
|
self.on_change:trigger()
|
||||||
@ -56,11 +56,11 @@ end
|
|||||||
--- Translate the text by locale_id
|
--- Translate the text by locale_id
|
||||||
-- @function lang_text:translate
|
-- @function lang_text:translate
|
||||||
-- @tparam string locale_id Locale id
|
-- @tparam string locale_id Locale id
|
||||||
function M.translate(self, locale_id, ...)
|
function LangText:translate(locale_id, ...)
|
||||||
self.last_locale_args = {...}
|
self.last_locale_args = {...}
|
||||||
self.last_locale = locale_id or self.last_locale
|
self.last_locale = locale_id or self.last_locale
|
||||||
self.text:set_to(settings.get_text(self.last_locale, ...))
|
self.text:set_to(settings.get_text(self.last_locale, ...))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return LangText
|
||||||
|
@ -20,7 +20,7 @@ local const = require("druid.const")
|
|||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
local M = component.create("progress", { const.ON_UPDATE, const.ON_LAYOUT_CHANGE })
|
local Progress = component.create("progress", { const.ON_UPDATE, const.ON_LAYOUT_CHANGE })
|
||||||
|
|
||||||
|
|
||||||
local function check_steps(self, from, to, exactly)
|
local function check_steps(self, from, to, exactly)
|
||||||
@ -71,7 +71,7 @@ end
|
|||||||
-- @table Style
|
-- @table Style
|
||||||
-- @tfield[opt=5] number SPEED Progress bas fill rate. More -> faster
|
-- @tfield[opt=5] number SPEED Progress bas fill rate. More -> faster
|
||||||
-- @tfield[opt=0.005] number MIN_DELTA Minimum step to fill progress bar
|
-- @tfield[opt=0.005] number MIN_DELTA Minimum step to fill progress bar
|
||||||
function M.on_style_change(self, style)
|
function Progress:on_style_change(style)
|
||||||
self.style = {}
|
self.style = {}
|
||||||
self.style.SPEED = style.SPEED or 5
|
self.style.SPEED = style.SPEED or 5
|
||||||
self.style.MIN_DELTA = style.MIN_DELTA or 0.005
|
self.style.MIN_DELTA = style.MIN_DELTA or 0.005
|
||||||
@ -83,7 +83,7 @@ end
|
|||||||
-- @tparam string|node node Progress bar fill node or node name
|
-- @tparam string|node node Progress bar fill node or node name
|
||||||
-- @tparam string key Progress bar direction: const.SIDE.X or const.SIDE.Y
|
-- @tparam string key Progress bar direction: const.SIDE.X or const.SIDE.Y
|
||||||
-- @tparam[opt=1] number init_value Initial value of progress bar
|
-- @tparam[opt=1] number init_value Initial value of progress bar
|
||||||
function M.init(self, node, key, init_value)
|
function Progress:init(node, key, init_value)
|
||||||
assert(key == const.SIDE.X or const.SIDE.Y, "Progress bar key should be 'x' or 'y'")
|
assert(key == const.SIDE.X or const.SIDE.Y, "Progress bar key should be 'x' or 'y'")
|
||||||
|
|
||||||
self.prop = hash("scale."..key)
|
self.prop = hash("scale."..key)
|
||||||
@ -106,12 +106,12 @@ function M.init(self, node, key, init_value)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.on_layout_change(self)
|
function Progress:on_layout_change()
|
||||||
self:set_to(self.last_value)
|
self:set_to(self.last_value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.update(self, dt)
|
function Progress:update(dt)
|
||||||
if self.target then
|
if self.target then
|
||||||
local prev_value = self.last_value
|
local prev_value = self.last_value
|
||||||
local step = math.abs(self.last_value - self.target) * (self.style.SPEED*dt)
|
local step = math.abs(self.last_value - self.target) * (self.style.SPEED*dt)
|
||||||
@ -133,14 +133,14 @@ end
|
|||||||
|
|
||||||
--- Fill a progress bar and stop progress animation
|
--- Fill a progress bar and stop progress animation
|
||||||
-- @function progress:fill
|
-- @function progress:fill
|
||||||
function M.fill(self)
|
function Progress:fill()
|
||||||
set_bar_to(self, 1, true)
|
set_bar_to(self, 1, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Empty a progress bar
|
--- Empty a progress bar
|
||||||
-- @function progress:empty
|
-- @function progress:empty
|
||||||
function M.empty(self)
|
function Progress:empty()
|
||||||
set_bar_to(self, 0, true)
|
set_bar_to(self, 0, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -148,14 +148,14 @@ end
|
|||||||
--- Instant fill progress bar to value
|
--- Instant fill progress bar to value
|
||||||
-- @function progress:set_to
|
-- @function progress:set_to
|
||||||
-- @tparam number to Progress bar value, from 0 to 1
|
-- @tparam number to Progress bar value, from 0 to 1
|
||||||
function M.set_to(self, to)
|
function Progress:set_to(to)
|
||||||
set_bar_to(self, to)
|
set_bar_to(self, to)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Return current progress bar value
|
--- Return current progress bar value
|
||||||
-- @function progress:get
|
-- @function progress:get
|
||||||
function M.get(self)
|
function Progress:get()
|
||||||
return self.last_value
|
return self.last_value
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ end
|
|||||||
-- @tparam number[] steps Array of progress bar values
|
-- @tparam number[] steps Array of progress bar values
|
||||||
-- @tparam function callback Callback on intersect step value
|
-- @tparam function callback Callback on intersect step value
|
||||||
-- @usage progress:set_steps({0, 0.3, 0.6, 1}, function(self, step) end)
|
-- @usage progress:set_steps({0, 0.3, 0.6, 1}, function(self, step) end)
|
||||||
function M.set_steps(self, steps, callback)
|
function Progress:set_steps(steps, callback)
|
||||||
self.steps = steps
|
self.steps = steps
|
||||||
self.step_callback = callback
|
self.step_callback = callback
|
||||||
end
|
end
|
||||||
@ -175,7 +175,7 @@ end
|
|||||||
-- @function progress:to
|
-- @function progress:to
|
||||||
-- @tparam number to value between 0..1
|
-- @tparam number to value between 0..1
|
||||||
-- @tparam[opt] function callback Callback on animation ends
|
-- @tparam[opt] function callback Callback on animation ends
|
||||||
function M.to(self, to, callback)
|
function Progress:to(to, callback)
|
||||||
to = helper.clamp(to, 0, 1)
|
to = helper.clamp(to, 0, 1)
|
||||||
-- cause of float error
|
-- cause of float error
|
||||||
local value = helper.round(to, 5)
|
local value = helper.round(to, 5)
|
||||||
@ -190,4 +190,4 @@ function M.to(self, to, callback)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return Progress
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
local Event = require("druid.event")
|
local Event = require("druid.event")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
local M = component.create("radio_group")
|
local RadioGroup = component.create("radio_group")
|
||||||
|
|
||||||
|
|
||||||
local function on_checkbox_click(self, index)
|
local function on_checkbox_click(self, index)
|
||||||
@ -29,7 +29,7 @@ end
|
|||||||
-- @tparam node[] node Array of gui node
|
-- @tparam node[] node Array of gui node
|
||||||
-- @tparam function callback Radio callback
|
-- @tparam function callback Radio callback
|
||||||
-- @tparam[opt=node] node[] click node Array of trigger nodes, by default equals to nodes
|
-- @tparam[opt=node] node[] click node Array of trigger nodes, by default equals to nodes
|
||||||
function M.init(self, nodes, callback, click_nodes)
|
function RadioGroup:init(nodes, callback, click_nodes)
|
||||||
self.druid = self:get_druid()
|
self.druid = self:get_druid()
|
||||||
self.checkboxes = {}
|
self.checkboxes = {}
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ end
|
|||||||
--- Set radio group state
|
--- Set radio group state
|
||||||
-- @function radio_group:set_state
|
-- @function radio_group:set_state
|
||||||
-- @tparam number index Index in radio group
|
-- @tparam number index Index in radio group
|
||||||
function M.set_state(self, index)
|
function RadioGroup:set_state(index)
|
||||||
on_checkbox_click(self, index)
|
on_checkbox_click(self, index)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ end
|
|||||||
--- Return radio group state
|
--- Return radio group state
|
||||||
-- @function radio_group:get_state
|
-- @function radio_group:get_state
|
||||||
-- @treturn number Index in radio group
|
-- @treturn number Index in radio group
|
||||||
function M.get_state(self)
|
function RadioGroup:get_state()
|
||||||
local result = -1
|
local result = -1
|
||||||
|
|
||||||
for i = 1, #self.checkboxes do
|
for i = 1, #self.checkboxes do
|
||||||
@ -71,4 +71,4 @@ function M.get_state(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return RadioGroup
|
||||||
|
@ -22,7 +22,7 @@ local helper = require("druid.helper")
|
|||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
local M = component.create("slider", { const.ON_INPUT_HIGH, const.ON_LAYOUT_CHANGE })
|
local Slider = component.create("slider", { const.ON_INPUT_HIGH, const.ON_LAYOUT_CHANGE })
|
||||||
|
|
||||||
|
|
||||||
local function on_change_value(self)
|
local function on_change_value(self)
|
||||||
@ -41,7 +41,7 @@ end
|
|||||||
-- @tparam node node Gui pin node
|
-- @tparam node node Gui pin node
|
||||||
-- @tparam vector3 end_pos The end position of slider
|
-- @tparam vector3 end_pos The end position of slider
|
||||||
-- @tparam[opt] function callback On slider change callback
|
-- @tparam[opt] function callback On slider change callback
|
||||||
function M.init(self, node, end_pos, callback)
|
function Slider:init(node, end_pos, callback)
|
||||||
self.node = self:get_node(node)
|
self.node = self:get_node(node)
|
||||||
|
|
||||||
self.start_pos = gui.get_position(self.node)
|
self.start_pos = gui.get_position(self.node)
|
||||||
@ -59,12 +59,12 @@ function M.init(self, node, end_pos, callback)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.on_layout_change(self)
|
function Slider:on_layout_change()
|
||||||
self:set(self.value, true)
|
self:set(self.value, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.on_input(self, action_id, action)
|
function Slider:on_input(action_id, action)
|
||||||
if action_id ~= const.ACTION_TOUCH then
|
if action_id ~= const.ACTION_TOUCH then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -133,7 +133,7 @@ end
|
|||||||
-- @function slider:set
|
-- @function slider:set
|
||||||
-- @tparam number value Value from 0 to 1
|
-- @tparam number value Value from 0 to 1
|
||||||
-- @tparam[opt] bool is_silent Don't trigger event if true
|
-- @tparam[opt] bool is_silent Don't trigger event if true
|
||||||
function M.set(self, value, is_silent)
|
function Slider:set(value, is_silent)
|
||||||
value = helper.clamp(value, 0, 1)
|
value = helper.clamp(value, 0, 1)
|
||||||
set_position(self, value)
|
set_position(self, value)
|
||||||
self.value = value
|
self.value = value
|
||||||
@ -148,9 +148,9 @@ end
|
|||||||
-- @function slider:set_steps
|
-- @function slider:set_steps
|
||||||
-- @tparam number[] steps Array of steps
|
-- @tparam number[] steps Array of steps
|
||||||
-- @usage slider:set_steps({0, 0.2, 0.6, 1})
|
-- @usage slider:set_steps({0, 0.2, 0.6, 1})
|
||||||
function M.set_steps(self, steps)
|
function Slider:set_steps(steps)
|
||||||
self.steps = steps
|
self.steps = steps
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return Slider
|
||||||
|
@ -22,7 +22,7 @@ local formats = require("druid.helper.formats")
|
|||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
local M = component.create("timer", { const.ON_UPDATE })
|
local Timer = component.create("timer", { const.ON_UPDATE })
|
||||||
|
|
||||||
|
|
||||||
--- Component init function
|
--- Component init function
|
||||||
@ -31,7 +31,7 @@ local M = component.create("timer", { const.ON_UPDATE })
|
|||||||
-- @tparam number seconds_from Start timer value in seconds
|
-- @tparam number seconds_from Start timer value in seconds
|
||||||
-- @tparam[opt=0] number seconds_to End timer value in seconds
|
-- @tparam[opt=0] number seconds_to End timer value in seconds
|
||||||
-- @tparam[opt] function callback Function on timer end
|
-- @tparam[opt] function callback Function on timer end
|
||||||
function M.init(self, node, seconds_from, seconds_to, callback)
|
function Timer:init(node, seconds_from, seconds_to, callback)
|
||||||
self.node = self:get_node(node)
|
self.node = self:get_node(node)
|
||||||
seconds_from = math.max(seconds_from, 0)
|
seconds_from = math.max(seconds_from, 0)
|
||||||
seconds_to = math.max(seconds_to or 0, 0)
|
seconds_to = math.max(seconds_to or 0, 0)
|
||||||
@ -52,7 +52,7 @@ function M.init(self, node, seconds_from, seconds_to, callback)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.update(self, dt)
|
function Timer:update(dt)
|
||||||
if not self.is_on then
|
if not self.is_on then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -63,7 +63,7 @@ function M.update(self, dt)
|
|||||||
if self.temp > dist then
|
if self.temp > dist then
|
||||||
self.temp = self.temp - dist
|
self.temp = self.temp - dist
|
||||||
self.value = helper.step(self.value, self.target, 1)
|
self.value = helper.step(self.value, self.target, 1)
|
||||||
M.set_to(self, self.value)
|
self:set_to(self.value)
|
||||||
|
|
||||||
self.on_tick:trigger(self:get_context(), self.value)
|
self.on_tick:trigger(self:get_context(), self.value)
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ end
|
|||||||
--- Set text to text field
|
--- Set text to text field
|
||||||
-- @function timer:set_to
|
-- @function timer:set_to
|
||||||
-- @tparam number set_to Value in seconds
|
-- @tparam number set_to Value in seconds
|
||||||
function M.set_to(self, set_to)
|
function Timer:set_to(set_to)
|
||||||
self.last_value = set_to
|
self.last_value = set_to
|
||||||
gui.set_text(self.node, formats.second_string_min(set_to))
|
gui.set_text(self.node, formats.second_string_min(set_to))
|
||||||
end
|
end
|
||||||
@ -86,7 +86,7 @@ end
|
|||||||
--- Called when update
|
--- Called when update
|
||||||
-- @function timer:set_state
|
-- @function timer:set_state
|
||||||
-- @tparam bool is_on Timer enable state
|
-- @tparam bool is_on Timer enable state
|
||||||
function M.set_state(self, is_on)
|
function Timer:set_state(is_on)
|
||||||
self.is_on = is_on
|
self.is_on = is_on
|
||||||
|
|
||||||
self.on_set_enabled:trigger(self:get_context(), is_on)
|
self.on_set_enabled:trigger(self:get_context(), is_on)
|
||||||
@ -97,14 +97,14 @@ end
|
|||||||
-- @function timer:set_interval
|
-- @function timer:set_interval
|
||||||
-- @tparam number from Start time in seconds
|
-- @tparam number from Start time in seconds
|
||||||
-- @tparam number to Target time in seconds
|
-- @tparam number to Target time in seconds
|
||||||
function M.set_interval(self, from, to)
|
function Timer:set_interval(from, to)
|
||||||
self.from = from
|
self.from = from
|
||||||
self.value = from
|
self.value = from
|
||||||
self.temp = 0
|
self.temp = 0
|
||||||
self.target = to
|
self.target = to
|
||||||
M.set_state(self, true)
|
self:set_state(true)
|
||||||
M.set_to(self, from)
|
self:set_to(from)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return Timer
|
||||||
|
@ -137,7 +137,7 @@ end
|
|||||||
-- @function druid:initialize
|
-- @function druid:initialize
|
||||||
-- @tparam context table Druid context. Usually it is self of script
|
-- @tparam context table Druid context. Usually it is self of script
|
||||||
-- @tparam style table Druid style module
|
-- @tparam style table Druid style module
|
||||||
function Druid.initialize(self, context, style)
|
function Druid:initialize(context, style)
|
||||||
self._context = context
|
self._context = context
|
||||||
self._style = style or settings.default_style
|
self._style = style or settings.default_style
|
||||||
self._deleted = false
|
self._deleted = false
|
||||||
@ -156,7 +156,7 @@ end
|
|||||||
-- @function druid:create
|
-- @function druid:create
|
||||||
-- @tparam Component component Component module
|
-- @tparam Component component Component module
|
||||||
-- @tparam args ... Other component params to pass it to component:init function
|
-- @tparam args ... Other component params to pass it to component:init function
|
||||||
function Druid.create(self, component, ...)
|
function Druid:create(component, ...)
|
||||||
local instance = create(self, component)
|
local instance = create(self, component)
|
||||||
|
|
||||||
if instance.init then
|
if instance.init then
|
||||||
@ -170,7 +170,7 @@ end
|
|||||||
--- Call on final function on gui_script. It will call on_remove
|
--- Call on final function on gui_script. It will call on_remove
|
||||||
-- on all druid components
|
-- on all druid components
|
||||||
-- @function druid:final
|
-- @function druid:final
|
||||||
function Druid.final(self)
|
function Druid:final()
|
||||||
local components = self.components[const.ALL]
|
local components = self.components[const.ALL]
|
||||||
|
|
||||||
for i = #components, 1, -1 do
|
for i = #components, 1, -1 do
|
||||||
@ -189,7 +189,7 @@ end
|
|||||||
-- Component `on_remove` function will be invoked, if exist.
|
-- Component `on_remove` function will be invoked, if exist.
|
||||||
-- @function druid:remove
|
-- @function druid:remove
|
||||||
-- @tparam Component component Component instance
|
-- @tparam Component component Component instance
|
||||||
function Druid.remove(self, component)
|
function Druid:remove(component)
|
||||||
if self._is_input_processing then
|
if self._is_input_processing then
|
||||||
table.insert(self._late_remove, component)
|
table.insert(self._late_remove, component)
|
||||||
return
|
return
|
||||||
@ -232,7 +232,7 @@ end
|
|||||||
--- Druid update function
|
--- Druid update function
|
||||||
-- @function druid:update
|
-- @function druid:update
|
||||||
-- @tparam number dt Delta time
|
-- @tparam number dt Delta time
|
||||||
function Druid.update(self, dt)
|
function Druid:update(dt)
|
||||||
local components = self.components[const.ON_UPDATE]
|
local components = self.components[const.ON_UPDATE]
|
||||||
for i = 1, #components do
|
for i = 1, #components do
|
||||||
components[i]:update(dt)
|
components[i]:update(dt)
|
||||||
@ -244,7 +244,7 @@ end
|
|||||||
-- @function druid:on_input
|
-- @function druid:on_input
|
||||||
-- @tparam hash action_id Action_id from on_input
|
-- @tparam hash action_id Action_id from on_input
|
||||||
-- @tparam table action Action from on_input
|
-- @tparam table action Action from on_input
|
||||||
function Druid.on_input(self, action_id, action)
|
function Druid:on_input(action_id, action)
|
||||||
self._is_input_processing = true
|
self._is_input_processing = true
|
||||||
|
|
||||||
local is_input_consumed = false
|
local is_input_consumed = false
|
||||||
@ -273,7 +273,7 @@ end
|
|||||||
-- @tparam hash message_id Message_id from on_message
|
-- @tparam hash message_id Message_id from on_message
|
||||||
-- @tparam table message Message from on_message
|
-- @tparam table message Message from on_message
|
||||||
-- @tparam hash sender Sender from on_message
|
-- @tparam hash sender Sender from on_message
|
||||||
function Druid.on_message(self, message_id, message, sender)
|
function Druid:on_message(message_id, message, sender)
|
||||||
local specific_ui_message = const.SPECIFIC_UI_MESSAGES[message_id]
|
local specific_ui_message = const.SPECIFIC_UI_MESSAGES[message_id]
|
||||||
|
|
||||||
if specific_ui_message then
|
if specific_ui_message then
|
||||||
@ -296,7 +296,7 @@ end
|
|||||||
--- Druid on focus lost interest function.
|
--- Druid on focus lost interest function.
|
||||||
-- This one called by on_window_callback by global window listener
|
-- This one called by on_window_callback by global window listener
|
||||||
-- @function druid:on_focus_lost
|
-- @function druid:on_focus_lost
|
||||||
function Druid.on_focus_lost(self)
|
function Druid:on_focus_lost()
|
||||||
local components = self.components[const.ON_FOCUS_LOST]
|
local components = self.components[const.ON_FOCUS_LOST]
|
||||||
for i = 1, #components do
|
for i = 1, #components do
|
||||||
components[i]:on_focus_lost()
|
components[i]:on_focus_lost()
|
||||||
@ -307,7 +307,7 @@ end
|
|||||||
--- Druid on focus gained interest function.
|
--- Druid on focus gained interest function.
|
||||||
-- This one called by on_window_callback by global window listener
|
-- This one called by on_window_callback by global window listener
|
||||||
-- @function druid:on_focus_gained
|
-- @function druid:on_focus_gained
|
||||||
function Druid.on_focus_gained(self)
|
function Druid:on_focus_gained()
|
||||||
local components = self.components[const.ON_FOCUS_GAINED]
|
local components = self.components[const.ON_FOCUS_GAINED]
|
||||||
for i = 1, #components do
|
for i = 1, #components do
|
||||||
components[i]:on_focus_gained()
|
components[i]:on_focus_gained()
|
||||||
@ -318,7 +318,7 @@ end
|
|||||||
--- Druid on layout change function.
|
--- Druid on layout change function.
|
||||||
-- Called on update gui layout
|
-- Called on update gui layout
|
||||||
-- @function druid:on_layout_change
|
-- @function druid:on_layout_change
|
||||||
function Druid.on_layout_change(self)
|
function Druid:on_layout_change()
|
||||||
local components = self.components[const.ON_LAYOUT_CHANGE]
|
local components = self.components[const.ON_LAYOUT_CHANGE]
|
||||||
for i = 1, #components do
|
for i = 1, #components do
|
||||||
components[i]:on_layout_change()
|
components[i]:on_layout_change()
|
||||||
@ -330,7 +330,7 @@ end
|
|||||||
-- This one called by global gruid.on_language_change, but can be
|
-- This one called by global gruid.on_language_change, but can be
|
||||||
-- call manualy to update all translations
|
-- call manualy to update all translations
|
||||||
-- @function druid.on_language_change
|
-- @function druid.on_language_change
|
||||||
function Druid.on_language_change(self)
|
function Druid:on_language_change()
|
||||||
local components = self.components[const.ON_LANGUAGE_CHANGE]
|
local components = self.components[const.ON_LANGUAGE_CHANGE]
|
||||||
for i = 1, #components do
|
for i = 1, #components do
|
||||||
components[i]:on_language_change()
|
components[i]:on_language_change()
|
||||||
@ -342,7 +342,7 @@ end
|
|||||||
-- @function druid:new_button
|
-- @function druid:new_button
|
||||||
-- @tparam args ... button init args
|
-- @tparam args ... button init args
|
||||||
-- @treturn Component button component
|
-- @treturn Component button component
|
||||||
function Druid.new_button(self, ...)
|
function Druid:new_button(...)
|
||||||
return Druid.create(self, button, ...)
|
return Druid.create(self, button, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -351,7 +351,7 @@ end
|
|||||||
-- @function druid:new_blocker
|
-- @function druid:new_blocker
|
||||||
-- @tparam args ... blocker init args
|
-- @tparam args ... blocker init args
|
||||||
-- @treturn Component blocker component
|
-- @treturn Component blocker component
|
||||||
function Druid.new_blocker(self, ...)
|
function Druid:new_blocker(...)
|
||||||
return Druid.create(self, blocker, ...)
|
return Druid.create(self, blocker, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -360,7 +360,7 @@ end
|
|||||||
-- @function druid:new_back_handler
|
-- @function druid:new_back_handler
|
||||||
-- @tparam args ... back_handler init args
|
-- @tparam args ... back_handler init args
|
||||||
-- @treturn Component back_handler component
|
-- @treturn Component back_handler component
|
||||||
function Druid.new_back_handler(self, ...)
|
function Druid:new_back_handler(...)
|
||||||
return Druid.create(self, back_handler, ...)
|
return Druid.create(self, back_handler, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -369,7 +369,7 @@ end
|
|||||||
-- @function druid:new_hover
|
-- @function druid:new_hover
|
||||||
-- @tparam args ... hover init args
|
-- @tparam args ... hover init args
|
||||||
-- @treturn Component hover component
|
-- @treturn Component hover component
|
||||||
function Druid.new_hover(self, ...)
|
function Druid:new_hover(...)
|
||||||
return Druid.create(self, hover, ...)
|
return Druid.create(self, hover, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -378,7 +378,7 @@ end
|
|||||||
-- @function druid:new_text
|
-- @function druid:new_text
|
||||||
-- @tparam args ... text init args
|
-- @tparam args ... text init args
|
||||||
-- @treturn Component text component
|
-- @treturn Component text component
|
||||||
function Druid.new_text(self, ...)
|
function Druid:new_text(...)
|
||||||
return Druid.create(self, text, ...)
|
return Druid.create(self, text, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -388,7 +388,7 @@ end
|
|||||||
-- @tparam args ... grid init args
|
-- @tparam args ... grid init args
|
||||||
-- @treturn Component grid component
|
-- @treturn Component grid component
|
||||||
-- @deprecated
|
-- @deprecated
|
||||||
function Druid.new_grid(self, ...)
|
function Druid:new_grid(...)
|
||||||
helper.deprecated("The druid:new_grid is deprecated. Please use druid:new_static_grid instead")
|
helper.deprecated("The druid:new_grid is deprecated. Please use druid:new_static_grid instead")
|
||||||
return Druid.create(self, static_grid, ...)
|
return Druid.create(self, static_grid, ...)
|
||||||
end
|
end
|
||||||
@ -398,7 +398,7 @@ end
|
|||||||
-- @function druid:new_static_grid
|
-- @function druid:new_static_grid
|
||||||
-- @tparam args ... grid init args
|
-- @tparam args ... grid init args
|
||||||
-- @treturn Component grid component
|
-- @treturn Component grid component
|
||||||
function Druid.new_static_grid(self, ...)
|
function Druid:new_static_grid(...)
|
||||||
return Druid.create(self, static_grid, ...)
|
return Druid.create(self, static_grid, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -407,7 +407,7 @@ end
|
|||||||
-- @function druid:new_scroll
|
-- @function druid:new_scroll
|
||||||
-- @tparam args ... scroll init args
|
-- @tparam args ... scroll init args
|
||||||
-- @treturn Component scroll component
|
-- @treturn Component scroll component
|
||||||
function Druid.new_scroll(self, ...)
|
function Druid:new_scroll(...)
|
||||||
return Druid.create(self, scroll, ...)
|
return Druid.create(self, scroll, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -416,7 +416,7 @@ end
|
|||||||
-- @function druid:new_swipe
|
-- @function druid:new_swipe
|
||||||
-- @tparam args ... swipe init args
|
-- @tparam args ... swipe init args
|
||||||
-- @treturn Component swipe component
|
-- @treturn Component swipe component
|
||||||
function Druid.new_swipe(self, ...)
|
function Druid:new_swipe(...)
|
||||||
return Druid.create(self, swipe, ...)
|
return Druid.create(self, swipe, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -425,7 +425,7 @@ end
|
|||||||
-- @function druid:new_drag
|
-- @function druid:new_drag
|
||||||
-- @tparam args ... drag init args
|
-- @tparam args ... drag init args
|
||||||
-- @treturn Componetn drag component
|
-- @treturn Componetn drag component
|
||||||
function Druid.new_drag(self, ...)
|
function Druid:new_drag(...)
|
||||||
return Druid.create(self, drag, ...)
|
return Druid.create(self, drag, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -434,7 +434,7 @@ end
|
|||||||
-- @function druid:new_dynamic_grid
|
-- @function druid:new_dynamic_grid
|
||||||
-- @tparam args ... grid init args
|
-- @tparam args ... grid init args
|
||||||
-- @treturn Component grid component
|
-- @treturn Component grid component
|
||||||
function Druid.new_dynamic_grid(self, ...)
|
function Druid:new_dynamic_grid(...)
|
||||||
-- return helper.extended_component("dynamic_grid")
|
-- return helper.extended_component("dynamic_grid")
|
||||||
return Druid.create(self, dynamic_grid, ...)
|
return Druid.create(self, dynamic_grid, ...)
|
||||||
end
|
end
|
||||||
@ -444,7 +444,7 @@ end
|
|||||||
-- @function druid:new_lang_text
|
-- @function druid:new_lang_text
|
||||||
-- @tparam args ... lang_text init args
|
-- @tparam args ... lang_text init args
|
||||||
-- @treturn Component lang_text component
|
-- @treturn Component lang_text component
|
||||||
function Druid.new_lang_text(self, ...)
|
function Druid:new_lang_text(...)
|
||||||
-- return helper.extended_component("lang_text")
|
-- return helper.extended_component("lang_text")
|
||||||
return Druid.create(self, lang_text, ...)
|
return Druid.create(self, lang_text, ...)
|
||||||
end
|
end
|
||||||
@ -454,7 +454,7 @@ end
|
|||||||
-- @function druid:new_slider
|
-- @function druid:new_slider
|
||||||
-- @tparam args ... slider init args
|
-- @tparam args ... slider init args
|
||||||
-- @treturn Component slider component
|
-- @treturn Component slider component
|
||||||
function Druid.new_slider(self, ...)
|
function Druid:new_slider(...)
|
||||||
-- return helper.extended_component("slider")
|
-- return helper.extended_component("slider")
|
||||||
return Druid.create(self, slider, ...)
|
return Druid.create(self, slider, ...)
|
||||||
end
|
end
|
||||||
@ -464,7 +464,7 @@ end
|
|||||||
-- @function druid:new_checkbox
|
-- @function druid:new_checkbox
|
||||||
-- @tparam args ... checkbox init args
|
-- @tparam args ... checkbox init args
|
||||||
-- @treturn Component checkbox component
|
-- @treturn Component checkbox component
|
||||||
function Druid.new_checkbox(self, ...)
|
function Druid:new_checkbox(...)
|
||||||
-- return helper.extended_component("checkbox")
|
-- return helper.extended_component("checkbox")
|
||||||
return Druid.create(self, checkbox, ...)
|
return Druid.create(self, checkbox, ...)
|
||||||
end
|
end
|
||||||
@ -474,7 +474,7 @@ end
|
|||||||
-- @function druid:new_input
|
-- @function druid:new_input
|
||||||
-- @tparam args ... input init args
|
-- @tparam args ... input init args
|
||||||
-- @treturn Component input component
|
-- @treturn Component input component
|
||||||
function Druid.new_input(self, ...)
|
function Druid:new_input(...)
|
||||||
-- return helper.extended_component("input")
|
-- return helper.extended_component("input")
|
||||||
return Druid.create(self, input, ...)
|
return Druid.create(self, input, ...)
|
||||||
end
|
end
|
||||||
@ -484,7 +484,7 @@ end
|
|||||||
-- @function druid:new_checkbox_group
|
-- @function druid:new_checkbox_group
|
||||||
-- @tparam args ... checkbox_group init args
|
-- @tparam args ... checkbox_group init args
|
||||||
-- @treturn Component checkbox_group component
|
-- @treturn Component checkbox_group component
|
||||||
function Druid.new_checkbox_group(self, ...)
|
function Druid:new_checkbox_group(...)
|
||||||
-- return helper.extended_component("checkbox_group")
|
-- return helper.extended_component("checkbox_group")
|
||||||
return Druid.create(self, checkbox_group, ...)
|
return Druid.create(self, checkbox_group, ...)
|
||||||
end
|
end
|
||||||
@ -494,7 +494,7 @@ end
|
|||||||
-- @function druid:new_radio_group
|
-- @function druid:new_radio_group
|
||||||
-- @tparam args ... radio_group init args
|
-- @tparam args ... radio_group init args
|
||||||
-- @treturn Component radio_group component
|
-- @treturn Component radio_group component
|
||||||
function Druid.new_radio_group(self, ...)
|
function Druid:new_radio_group(...)
|
||||||
-- return helper.extended_component("radio_group")
|
-- return helper.extended_component("radio_group")
|
||||||
return Druid.create(self, radio_group, ...)
|
return Druid.create(self, radio_group, ...)
|
||||||
end
|
end
|
||||||
@ -504,7 +504,7 @@ end
|
|||||||
-- @function druid:new_timer
|
-- @function druid:new_timer
|
||||||
-- @tparam args ... timer init args
|
-- @tparam args ... timer init args
|
||||||
-- @treturn Component timer component
|
-- @treturn Component timer component
|
||||||
function Druid.new_timer(self, ...)
|
function Druid:new_timer(...)
|
||||||
-- return helper.extended_component("timer")
|
-- return helper.extended_component("timer")
|
||||||
return Druid.create(self, timer, ...)
|
return Druid.create(self, timer, ...)
|
||||||
end
|
end
|
||||||
@ -514,7 +514,7 @@ end
|
|||||||
-- @function druid:new_progress
|
-- @function druid:new_progress
|
||||||
-- @tparam args ... progress init args
|
-- @tparam args ... progress init args
|
||||||
-- @treturn Component progress component
|
-- @treturn Component progress component
|
||||||
function Druid.new_progress(self, ...)
|
function Druid:new_progress(...)
|
||||||
-- return helper.extended_component("progress")
|
-- return helper.extended_component("progress")
|
||||||
return Druid.create(self, progress, ...)
|
return Druid.create(self, progress, ...)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user