mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 18:37:44 +02:00
Update style annotations
This commit is contained in:
parent
928a212527
commit
7ed7e8e798
@ -21,13 +21,6 @@
|
||||
-- @tfield druid.hover hover Druid hover logic component
|
||||
-- @tfield[opt] node click_zone Restriction zone
|
||||
|
||||
--- Component style params
|
||||
-- @table Style
|
||||
-- @tfield function on_click (self, node)
|
||||
-- @tfield function on_click_disabled (self, node)
|
||||
-- @tfield function on_hover (self, node, hover_state)
|
||||
-- @tfield function on_set_enabled (self, node, enabled_state)
|
||||
|
||||
local Event = require("druid.event")
|
||||
local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
@ -136,23 +129,29 @@ local function on_button_release(self)
|
||||
end
|
||||
|
||||
|
||||
--- Change style of component.
|
||||
-- This function can be called before component:init. This callback
|
||||
-- only for store component style params inside self context
|
||||
-- @function button:on_style_change
|
||||
-- @tparam table style The component style table
|
||||
--- Component style params.
|
||||
-- You can override this component styles params in druid styles table
|
||||
-- or create your own style
|
||||
-- @table Style
|
||||
-- @tfield[opt=0.4] number LONGTAP_TIME Minimum time to trigger on_hold_callback
|
||||
-- @tfield[opt=0.8] number AUTOHOLD_TRIGGER Maximum hold time to trigger button release while holding
|
||||
-- @tfield[opt=0.4] number DOUBLETAP_TIME Time between double taps
|
||||
-- @tfield function on_click (self, node)
|
||||
-- @tfield function on_click_disabled (self, node)
|
||||
-- @tfield function on_hover (self, node, hover_state)
|
||||
-- @tfield function on_mouse_hover (self, node, hover_state)
|
||||
-- @tfield function on_set_enabled (self, node, enabled_state)
|
||||
function M.on_style_change(self, style)
|
||||
self.style = {}
|
||||
self.style.HOVER_SCKCOLOR = style.HOVER_SCKCOLOR or vmath.vector4(1)
|
||||
self.style.LONGTAP_TIME = style.LONGTAP_TIME or 0.4
|
||||
self.style.AUTOHOLD_TRIGGER = style.AUTOHOLD_TRIGGER or 0.8
|
||||
self.style.DOUBLETAP_TIME = style.DOUBLETAP_TIME or 0.4
|
||||
|
||||
self.style.on_hover = style.on_hover or function(self, node, state) end
|
||||
self.style.on_mouse_hover = style.on_mouse_hover or function(self, node, state) end
|
||||
self.style.on_click = style.on_click or function(self, node) end
|
||||
self.style.on_click_disabled = style.on_click_disabled or function(self, node) end
|
||||
self.style.on_set_enabled = style.on_set_enabled or function(self, node, state) end
|
||||
self.style.on_click = style.on_click or function(_, node) end
|
||||
self.style.on_click_disabled = style.on_click_disabled or function(_, node) end
|
||||
self.style.on_mouse_hover = style.on_mouse_hover or function(_, node, state) end
|
||||
self.style.on_hover = style.on_hover or function(_, node, state) end
|
||||
self.style.on_set_enabled = style.on_set_enabled or function(_, node, state) end
|
||||
end
|
||||
|
||||
|
||||
|
@ -11,10 +11,6 @@
|
||||
-- @tfield[opt=node] node click_node Button trigger node
|
||||
-- @tfield druid.button button Button component from click_node
|
||||
|
||||
--- Component style params
|
||||
-- @table Style
|
||||
-- @tfield function on_change_state (self, node, state)
|
||||
|
||||
local Event = require("druid.event")
|
||||
local component = require("druid.component")
|
||||
|
||||
@ -26,15 +22,15 @@ local function on_click(self)
|
||||
end
|
||||
|
||||
|
||||
--- Change style of component.
|
||||
-- This function can be called before component:init. This callback
|
||||
-- only for store component style params inside self context
|
||||
-- @function checkbox:on_style_change
|
||||
-- @tparam table style The component style table
|
||||
--- Component style params.
|
||||
-- You can override this component styles params in druid styles table
|
||||
-- or create your own style
|
||||
-- @table Style
|
||||
-- @tfield function on_change_state (self, node, state)
|
||||
function M.on_style_change(self, style)
|
||||
self.style = {}
|
||||
|
||||
self.style.on_change_state = style.on_change_state or function(self, node, state)
|
||||
self.style.on_change_state = style.on_change_state or function(_, node, state)
|
||||
gui.set_enabled(node, state)
|
||||
end
|
||||
end
|
||||
|
@ -22,10 +22,6 @@
|
||||
-- @tfield number y Current touch y position
|
||||
-- @tfield vector3 touch_start_pos Touch start position
|
||||
|
||||
--- Component style params
|
||||
-- @table Style
|
||||
-- @tfield number DRAG_DEADZONE Distance in pixels to start dragging
|
||||
|
||||
local Event = require("druid.event")
|
||||
local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
@ -128,11 +124,11 @@ local function on_touch_release(self, action_id, action)
|
||||
end
|
||||
|
||||
|
||||
--- Change style of component.
|
||||
-- This function can be called before component:init. This callback
|
||||
-- only for store component style params inside self context
|
||||
-- @function drag:on_style_change
|
||||
-- @tparam table style The component style table
|
||||
--- Component style params.
|
||||
-- You can override this component styles params in druid styles table
|
||||
-- or create your own style
|
||||
-- @table Style
|
||||
-- @tfield[opt=10] number DRAG_DEADZONE Distance in pixels to start dragging
|
||||
function M.on_style_change(self, style)
|
||||
self.style = {}
|
||||
self.style.DRAG_DEADZONE = style.DRAG_DEADZONE or 10
|
||||
|
@ -22,15 +22,6 @@
|
||||
-- @tfield[opt] string allowerd_characters Pattern matching for user input
|
||||
-- @tfield number keyboard_type Gui keyboard type for input field
|
||||
|
||||
--- Component style params
|
||||
-- @table Style
|
||||
-- @tfield bool IS_LONGTAP_ERASE Is long tap will erase current input data
|
||||
-- @tfield string MASK_DEFAULT_CHAR Default character mask for password input
|
||||
-- @tfield function on_select (self, button_node) Callback on input field selecting
|
||||
-- @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 table button Custom button style for input node
|
||||
|
||||
local Event = require("druid.event")
|
||||
local const = require("druid.const")
|
||||
local component = require("druid.component")
|
||||
@ -96,11 +87,16 @@ local function clear_and_select(self)
|
||||
end
|
||||
|
||||
|
||||
--- Change style of component.
|
||||
-- This function can be called before component:init. This callback
|
||||
-- only for store component style params inside self context
|
||||
-- @function input:on_style_change
|
||||
-- @tparam table style The component style table
|
||||
--- Component style params.
|
||||
-- You can override this component styles params in druid styles table
|
||||
-- or create your own style
|
||||
-- @table Style
|
||||
-- @tfield[opt=false] bool IS_LONGTAP_ERASE Is long tap will erase current input data
|
||||
-- @tfield[opt=*] string MASK_DEFAULT_CHAR Default character mask for password input
|
||||
-- @tfield function on_select (self, button_node) Callback on input field selecting
|
||||
-- @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 table button_style Custom button style for input node
|
||||
function M.on_style_change(self, style)
|
||||
self.style = {}
|
||||
|
||||
@ -140,7 +136,7 @@ function M.init(self, click_node, text_node, keyboard_type)
|
||||
self.keyboard_type = keyboard_type or gui.KEYBOARD_TYPE_DEFAULT
|
||||
|
||||
self.button = self.druid:new_button(click_node, select)
|
||||
self.button:set_style(self.style)
|
||||
self.button:set_style(self.button_style)
|
||||
self.button.on_click_outside:subscribe(unselect)
|
||||
self.button.on_long_click:subscribe(clear_and_select)
|
||||
|
||||
|
@ -15,11 +15,6 @@
|
||||
-- @tfield number max_size Maximum size of progress bar
|
||||
-- @tfield vector4 slice Progress bar slice9 settings
|
||||
|
||||
--- Component style params
|
||||
-- @table Style
|
||||
-- @tfield number SPEED Progress bas fill rate. More -> faster
|
||||
-- @tfield number MIN_DELTA Minimum step to fill progress bar
|
||||
|
||||
local Event = require("druid.event")
|
||||
local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
@ -70,11 +65,12 @@ local function set_bar_to(self, set_to, is_silent)
|
||||
end
|
||||
|
||||
|
||||
--- Change style of component.
|
||||
-- This function can be called before component:init. This callback
|
||||
-- only for store component style params inside self context
|
||||
-- @function progress:on_style_change
|
||||
-- @tparam table style The component style table
|
||||
--- Component style params.
|
||||
-- You can override this component styles params in druid styles table
|
||||
-- or create your own style
|
||||
-- @table Style
|
||||
-- @tfield[opt=5] number SPEED Progress bas fill rate. More -> faster
|
||||
-- @tfield[opt=0.005] number MIN_DELTA Minimum step to fill progress bar
|
||||
function M.on_style_change(self, style)
|
||||
self.style = {}
|
||||
self.style.SPEED = style.SPEED or 5
|
||||
|
@ -27,18 +27,6 @@
|
||||
-- @tfield[opt] selected Current index of points of interests
|
||||
-- @tfield bool is_animate Flag, if scroll now animating by gui.animate
|
||||
|
||||
--- Component style params
|
||||
-- @table Style
|
||||
-- @tfield number FRICT_HOLD Multiplier for inertion, while touching
|
||||
-- @tfield number FRICT Multiplier for free inertion
|
||||
-- @tfield number INERT_THRESHOLD Scroll speed to stop inertion
|
||||
-- @tfield number INERT_SPEED Multiplier for inertion speed
|
||||
-- @tfield number POINTS_DEADZONE Speed to check points of interests in no_inertion mode
|
||||
-- @tfield number BACK_SPEED Scroll back returning lerp speed
|
||||
-- @tfield number ANIM_SPEED Scroll gui.animation speed for scroll_to function
|
||||
-- @tfield number EXTRA_STRECH_SIZE extra size in pixels outside of scroll (stretch effect)
|
||||
-- @tfield bool SMALL_CONTENT_SCROLL If true, content node with size less than view node size can be scrolled
|
||||
|
||||
local Event = require("druid.event")
|
||||
local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
@ -326,11 +314,19 @@ local function update_size(self)
|
||||
end
|
||||
|
||||
|
||||
--- Change style of component.
|
||||
-- This function can be called before component:init. This callback
|
||||
-- only for store component style params inside self context
|
||||
-- @function scroll:on_style_change
|
||||
-- @tparam table style The component style table
|
||||
--- Component style params.
|
||||
-- You can override this component styles params in druid styles table
|
||||
-- or create your own style
|
||||
-- @table Style
|
||||
-- @tfield[opt=0] number FRICT Multiplier for free inertion
|
||||
-- @tfield[opt=0] number FRICT_HOLD Multiplier for inertion, while touching
|
||||
-- @tfield[opt=3] number INERT_THRESHOLD Scroll speed to stop inertion
|
||||
-- @tfield[opt=30] number INERT_SPEED Multiplier for inertion speed
|
||||
-- @tfield[opt=20] number POINTS_DEADZONE Speed to check points of interests in no_inertion mode
|
||||
-- @tfield[opt=0.35] number BACK_SPEED Scroll back returning lerp speed
|
||||
-- @tfield[opt=0.2] number ANIM_SPEED Scroll gui.animation speed for scroll_to function
|
||||
-- @tfield[opt=0] number EXTRA_STRECH_SIZE extra size in pixels outside of scroll (stretch effect)
|
||||
-- @tfield[opt=false] bool SMALL_CONTENT_SCROLL If true, content node with size less than view node size can be scrolled
|
||||
function M.on_style_change(self, style)
|
||||
self.style = {}
|
||||
self.style.EXTRA_STRECH_SIZE = style.EXTRA_STRECH_SIZE or 0
|
||||
|
@ -12,12 +12,6 @@
|
||||
-- @table Events
|
||||
-- @tfield druid_event on_swipe Trigger on swipe event
|
||||
|
||||
--- Component style params
|
||||
-- @table Style
|
||||
-- @tfield number SWIPE_TIME Maximum time for swipe trigger
|
||||
-- @tfield number SWIPE_THRESHOLD Minimum distance for swipe trigger
|
||||
-- @tfield bool SWIPE_TRIGGER_ON_MOVE If true, trigger on swipe moving, not only release action
|
||||
|
||||
local Event = require("druid.event")
|
||||
local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
@ -48,6 +42,7 @@ local function check_swipe(self, action)
|
||||
if is_swipe then
|
||||
local is_x_swipe = math.abs(dx) >= math.abs(dy)
|
||||
local swipe_side = false
|
||||
|
||||
if is_x_swipe and dx > 0 then
|
||||
swipe_side = const.SWIPE.RIGHT
|
||||
end
|
||||
@ -67,15 +62,17 @@ local function check_swipe(self, action)
|
||||
end
|
||||
|
||||
|
||||
--- Change style of component.
|
||||
-- This function can be called before component:init. This callback
|
||||
-- only for store component style params inside self context
|
||||
-- @function swipe:on_style_change
|
||||
-- @tparam table style The component style table
|
||||
--- Component style params.
|
||||
-- You can override this component styles params in druid styles table
|
||||
-- or create your own style
|
||||
-- @table Style
|
||||
-- @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=false] bool SWIPE_TRIGGER_ON_MOVE If true, trigger on swipe moving, not only release action
|
||||
function M.on_style_change(self, style)
|
||||
self.style = {}
|
||||
self.style.SWIPE_THRESHOLD = style.SWIPE_THRESHOLD or 50
|
||||
self.style.SWIPE_TIME = style.SWIPE_TIME or 0.4
|
||||
self.style.SWIPE_THRESHOLD = style.SWIPE_THRESHOLD or 50
|
||||
self.style.SWIPE_TRIGGER_ON_MOVE = style.SWIPE_TRIGGER_ON_MOVE or false
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user