Update component docs

This commit is contained in:
Insality
2020-03-21 21:37:32 +03:00
parent b33efd692f
commit ca78b10794
20 changed files with 603 additions and 334 deletions

View File

@@ -1,32 +1,25 @@
--- Checkboux group module
--- Checkbox group module
-- @module druid.checkbox_group
--- Component events
-- @table Events
-- @tfield druid_event on_checkbox_click On any checkbox click
--- Component fields
-- @table Fields
-- @tfield table checkboxes Array of checkbox components
local Event = require("druid.event")
local component = require("druid.component")
local M = component.create("checkbox_group")
function M.set_state(self, indexes)
for i = 1, #indexes do
if self.checkboxes[i] then
self.checkboxes[i]:set_state(indexes[i], true)
end
end
end
function M.get_state(self)
local result = {}
for i = 1, #self.checkboxes do
table.insert(result, self.checkboxes[i]:get_state())
end
return result
end
--- Component init function
-- @function checkbox_group:init
-- @tparam node[] node 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 M.init(self, nodes, callback, click_nodes)
self.druid = self:get_druid()
self.checkboxes = {}
@@ -44,4 +37,30 @@ function M.init(self, nodes, callback, click_nodes)
end
--- Set checkbox group state
-- @function checkbox_group:set_state
-- @tparam bool[] state Array of checkbox state
function M.set_state(self, indexes)
for i = 1, #indexes do
if self.checkboxes[i] then
self.checkboxes[i]:set_state(indexes[i], true)
end
end
end
--- Return checkbox group state
-- @function checkbox_group:get_state
-- @treturn bool[] Array if checkboxes state
function M.get_state(self)
local result = {}
for i = 1, #self.checkboxes do
table.insert(result, self.checkboxes[i]:get_state())
end
return result
end
return M