mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 10:27:47 +02:00
Update documentation
This commit is contained in:
parent
1e568c2fa6
commit
10c4ee2151
@ -15,15 +15,17 @@
|
|||||||
|
|
||||||
--- Component fields
|
--- Component fields
|
||||||
-- @table Fields
|
-- @table Fields
|
||||||
-- @tfield node node Scroll parent node
|
-- @tfield node view_node Scroll view node
|
||||||
-- @tfield node input_zone Scroll input node
|
-- @tfield node content_node Scroll content node
|
||||||
-- @tfield vector3 zone_size Current scroll content size
|
|
||||||
-- @tfield number soft_size Soft zone size from style table
|
|
||||||
-- @tfield vector3 center_offset Distance from node to node's center
|
|
||||||
-- @tfield bool is_inert Flag, if scroll now moving by inertion
|
-- @tfield bool is_inert Flag, if scroll now moving by inertion
|
||||||
-- @tfield vector3 inert Current inert speed
|
-- @tfield vector3 inertion Current inert speed
|
||||||
-- @tfield vector3 pos Current scroll posisition
|
-- @tfield vector3 position Current scroll posisition
|
||||||
-- @tfield vector3 target Current scroll target position
|
-- @tfield vector3 target_position Current scroll target position
|
||||||
|
-- @tfield vector4 available_pos Available position for content node: (min_x, max_y, max_x, min_y)
|
||||||
|
-- @tfield vector3 available_size Size of available positions: (width, height, 0)
|
||||||
|
-- @tfield druid.drag drag Drag component
|
||||||
|
-- @tfield[opt] selected Current index of points of interests
|
||||||
|
-- @tfield bool is_animate Flag, if scroll now animating by gui.animate
|
||||||
|
|
||||||
--- Component style params
|
--- Component style params
|
||||||
-- @table Style
|
-- @table Style
|
||||||
@ -31,10 +33,11 @@
|
|||||||
-- @tfield number FRICT Multiplier for free inertion
|
-- @tfield number FRICT Multiplier for free inertion
|
||||||
-- @tfield number INERT_THRESHOLD Scroll speed to stop inertion
|
-- @tfield number INERT_THRESHOLD Scroll speed to stop inertion
|
||||||
-- @tfield number INERT_SPEED Multiplier for inertion speed
|
-- @tfield number INERT_SPEED Multiplier for inertion speed
|
||||||
-- @tfield number DEADZONE Deadzone for start scrol in pixels
|
-- @tfield number POINTS_DEADZONE Speed to check points of interests in no_inertion mode
|
||||||
-- @tfield number SOFT_ZONE_SIZE Size of outside zone in pixels (for scroll back moving)
|
|
||||||
-- @tfield number BACK_SPEED Scroll back returning lerp speed
|
-- @tfield number BACK_SPEED Scroll back returning lerp speed
|
||||||
-- @tfield number ANIM_SPEED Scroll gui.animation speed for scroll_to function
|
-- @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 Event = require("druid.event")
|
||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
@ -174,11 +177,11 @@ local function check_points(self)
|
|||||||
|
|
||||||
local inert = self.inertion
|
local inert = self.inertion
|
||||||
if not self._is_inert then
|
if not self._is_inert then
|
||||||
if math.abs(inert.x) > self.style.DEADZONE then
|
if math.abs(inert.x) > self.style.POINTS_DEADZONE then
|
||||||
self:scroll_to_index(self.selected - helper.sign(inert.x))
|
self:scroll_to_index(self.selected - helper.sign(inert.x))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if math.abs(inert.y) > self.style.DEADZONE then
|
if math.abs(inert.y) > self.style.POINTS_DEADZONE then
|
||||||
self:scroll_to_index(self.selected + helper.sign(inert.y))
|
self:scroll_to_index(self.selected + helper.sign(inert.y))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -251,8 +254,8 @@ local function update_free_scroll(self, dt)
|
|||||||
-- Inertion friction
|
-- Inertion friction
|
||||||
self.inertion = self.inertion * self.style.FRICT
|
self.inertion = self.inertion * self.style.FRICT
|
||||||
|
|
||||||
|
check_soft_zone(self)
|
||||||
if self.position.x ~= target.x or self.position.y ~= target.y then
|
if self.position.x ~= target.x or self.position.y ~= target.y then
|
||||||
check_soft_zone(self)
|
|
||||||
set_scroll_position(self, target)
|
set_scroll_position(self, target)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -326,18 +329,18 @@ end
|
|||||||
-- @function scroll:init
|
-- @function scroll:init
|
||||||
-- @tparam node view_node GUI view scroll node
|
-- @tparam node view_node GUI view scroll node
|
||||||
-- @tparam node content_node GUI content scroll node
|
-- @tparam node content_node GUI content scroll node
|
||||||
function M.init(self, view_zone, content_zone)
|
function M.init(self, view_node, content_node)
|
||||||
self.druid = self:get_druid()
|
self.druid = self:get_druid()
|
||||||
self.style = self:get_style()
|
self.style = self:get_style()
|
||||||
|
|
||||||
self.view_node = self:get_node(view_zone)
|
self.view_node = self:get_node(view_node)
|
||||||
self.content_node = self:get_node(content_zone)
|
self.content_node = self:get_node(content_node)
|
||||||
|
|
||||||
self.position = gui.get_position(self.content_node)
|
self.position = gui.get_position(self.content_node)
|
||||||
self.target_position = vmath.vector3(self.position)
|
self.target_position = vmath.vector3(self.position)
|
||||||
self.inertion = vmath.vector3(0)
|
self.inertion = vmath.vector3(0)
|
||||||
|
|
||||||
self.drag = self.druid:new_drag(view_zone, on_scroll_drag)
|
self.drag = self.druid:new_drag(view_node, on_scroll_drag)
|
||||||
self.drag.on_touch_start:subscribe(on_touch_start)
|
self.drag.on_touch_start:subscribe(on_touch_start)
|
||||||
self.drag.on_touch_end:subscribe(on_touch_end)
|
self.drag.on_touch_end:subscribe(on_touch_end)
|
||||||
|
|
||||||
|
@ -44,24 +44,23 @@ M["button"] = {
|
|||||||
|
|
||||||
|
|
||||||
M["drag"] = {
|
M["drag"] = {
|
||||||
DRAG_DEADZONE = 10,
|
DRAG_DEADZONE = 10, -- Size in pixels of drag deadzone
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
M["scroll"] = {
|
M["scroll"] = {
|
||||||
ANIM_SPEED = 0.2, -- gui.animation speed to point
|
ANIM_SPEED = 0.2, -- gui.animation speed to point
|
||||||
SCROLL_WHEEL_SPEED = 10,
|
BACK_SPEED = 0.35, -- Lerp speed of return to soft position
|
||||||
DEADZONE = 20,
|
|
||||||
|
|
||||||
FRICT = 0.93, -- mult for free inert
|
FRICT = 0.93, -- mult for free inert
|
||||||
FRICT_HOLD = 0.79, -- mult. for inert, while touching
|
FRICT_HOLD = 0.79, -- mult. for inert, while touching
|
||||||
INERT_THRESHOLD = 2.5, -- speed to stop inertion
|
INERT_THRESHOLD = 2.5, -- speed to stop inertion
|
||||||
INERT_SPEED = 30, -- koef. of inert speed
|
INERT_SPEED = 30, -- koef. of inert speed
|
||||||
|
EXTRA_STRECH_SIZE = 100, -- extra size in pixels outside of scroll (stretch effect)
|
||||||
|
POINTS_DEADZONE = 20, -- Speed to check points of interests in no_inertion mode
|
||||||
|
|
||||||
BACK_SPEED = 0.35, -- Lerp speed of return to soft position
|
SCROLL_WHEEL_SPEED = 20,
|
||||||
|
|
||||||
EXTRA_STRECH_SIZE = 100, -- size of outside zone (back move)
|
SMALL_CONTENT_SCROLL = true, -- If true, content node with size less than view node size can be scrolled
|
||||||
SMALL_CONTENT_SCROLL = true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -71,11 +70,6 @@ M["progress"] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
M["progress_rich"] = {
|
|
||||||
DELAY = 1, -- delay in seconds before main fill
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
M["checkbox"] = {
|
M["checkbox"] = {
|
||||||
on_change_state = function(self, node, state)
|
on_change_state = function(self, node, state)
|
||||||
local target = state and 1 or 0
|
local target = state and 1 or 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user