Update annotations: swipe, text, checkbox, checkbox_group, druid_instance

This commit is contained in:
Insality
2020-10-12 00:03:58 +03:00
parent 248b9c30f9
commit bea8e3b329
6 changed files with 203 additions and 223 deletions

View File

@@ -1,17 +1,20 @@
--- Druid checkbox component
-- @module druid.checkbox
-- @module Checkbox
-- @within BaseComponent
-- @alias druid.checkbox
--- Component events
-- @table Events
-- @tfield druid_event on_change_state On change state callback
--- On change state callback(self, state)
-- @tfield druid_event on_change_state
--- Visual node
-- @tfield node node
--- Button trigger node
-- @tfield[opt=node] node click_node
--- Button component from click_node
-- @tfield Button button
--- Component fields
-- @table Fields
-- @tfield node node Visual node
-- @tfield[opt=node] node click_node Button trigger node
-- @tfield druid.button button Button component from click_node
local const = require("druid.const")
local Event = require("druid.event")
@@ -28,9 +31,9 @@ end
--- Component style params.
-- You can override this component styles params in druid styles table
-- or create your own style
-- @table Style
-- @table style
-- @tfield function on_change_state (self, node, state)
function Checkbox:on_style_change(style)
function Checkbox.on_style_change(self, style)
self.style = {}
self.style.on_change_state = style.on_change_state or function(_, node, state)
@@ -40,11 +43,11 @@ end
--- Component init function
-- @function checkbox:init
-- @tparam Checkbox self
-- @tparam node node Gui node
-- @tparam function callback Checkbox callback
-- @tparam[opt=node] node click node Trigger node, by default equals to node
function Checkbox:init(node, callback, click_node)
-- @tparam[opt=node] node click_node Trigger node, by default equals to node
function Checkbox.init(self, node, callback, click_node)
self.druid = self:get_druid()
self.node = self:get_node(node)
self.click_node = self:get_node(click_node)
@@ -56,16 +59,16 @@ function Checkbox:init(node, callback, click_node)
end
function Checkbox:on_layout_change()
function Checkbox.on_layout_change(self)
self:set_state(self.state, true)
end
--- Set checkbox state
-- @function checkbox:set_state
-- @tparam Checkbox self
-- @tparam bool state Checkbox state
-- @tparam bool is_silent Don't trigger on_change_state if true
function Checkbox:set_state(state, is_silent)
function Checkbox.set_state(self, state, is_silent)
self.state = state
self.style.on_change_state(self, self.node, state)
@@ -76,9 +79,9 @@ end
--- Return checkbox state
-- @function checkbox:get_state
-- @tparam Checkbox self
-- @treturn bool Checkbox state
function Checkbox:get_state()
function Checkbox.get_state(self)
return self.state
end

View File

@@ -1,15 +1,14 @@
--- Checkbox group module
-- @module druid.checkbox_group
-- @module CheckboxGroup
-- @within BaseComponent
-- @alias druid.checkbox_group
--- Component events
-- @table Events
-- @tfield druid_event on_checkbox_click On any checkbox click
--- On any checkbox click callback(self, index)
-- @tfield druid_event on_checkbox_click
--- Array of checkbox components
-- @tfield table checkboxes
--- Component fields
-- @table Fields
-- @tfield table checkboxes Array of checkbox components
local Event = require("druid.event")
local component = require("druid.component")
@@ -18,11 +17,11 @@ local CheckboxGroup = component.create("checkbox_group")
--- Component init function
-- @function checkbox_group:init
-- @tparam node[] node Array of gui node
-- @tparam CheckboxGroup self
-- @tparam node[] nodes Array of gui node
-- @tparam function callback Checkbox callback
-- @tparam[opt=node] node[] click node Array of trigger nodes, by default equals to nodes
function CheckboxGroup:init(nodes, callback, click_nodes)
-- @tparam[opt=node] node[] click_nodes Array of trigger nodes, by default equals to nodes
function CheckboxGroup.init(self, nodes, callback, click_nodes)
self.druid = self:get_druid()
self.checkboxes = {}
@@ -40,9 +39,9 @@ end
--- Set checkbox group state
-- @function checkbox_group:set_state
-- @tparam CheckboxGroup self
-- @tparam bool[] indexes Array of checkbox state
function CheckboxGroup:set_state(indexes)
function CheckboxGroup.set_state(self, indexes)
for i = 1, #indexes do
if self.checkboxes[i] then
self.checkboxes[i]:set_state(indexes[i], true)
@@ -52,9 +51,9 @@ end
--- Return checkbox group state
-- @function checkbox_group:get_state
-- @tparam CheckboxGroup self
-- @treturn bool[] Array if checkboxes state
function CheckboxGroup:get_state()
function CheckboxGroup.get_state(self)
local result = {}
for i = 1, #self.checkboxes do