mirror of
https://github.com/Insality/druid
synced 2025-09-27 18:12:21 +02:00
Update docs, annotations and style for checkbox
This commit is contained in:
@@ -44,10 +44,11 @@ end
|
||||
--- Set checkbox group state
|
||||
-- @tparam CheckboxGroup self
|
||||
-- @tparam bool[] indexes Array of checkbox state
|
||||
function CheckboxGroup.set_state(self, indexes)
|
||||
-- @tparam boolean is_instant If instant state change
|
||||
function CheckboxGroup.set_state(self, indexes, is_instant)
|
||||
for i = 1, #indexes do
|
||||
if self.checkboxes[i] then
|
||||
self.checkboxes[i]:set_state(indexes[i], true)
|
||||
self.checkboxes[i]:set_state(indexes[i], true, is_instant)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -19,9 +19,9 @@ local component = require("druid.component")
|
||||
local RadioGroup = component.create("radio_group")
|
||||
|
||||
|
||||
local function on_checkbox_click(self, index)
|
||||
local function on_checkbox_click(self, index, is_instant)
|
||||
for i = 1, #self.checkboxes do
|
||||
self.checkboxes[i]:set_state(i == index, true)
|
||||
self.checkboxes[i]:set_state(i == index, true, is_instant)
|
||||
end
|
||||
|
||||
self.on_radio_click:trigger(self:get_context(), index)
|
||||
@@ -53,8 +53,9 @@ end
|
||||
--- Set radio group state
|
||||
-- @tparam RadioGroup self
|
||||
-- @tparam number index Index in radio group
|
||||
function RadioGroup.set_state(self, index)
|
||||
on_checkbox_click(self, index)
|
||||
-- @tparam boolean is_instant If is instant state change
|
||||
function RadioGroup.set_state(self, index, is_instant)
|
||||
on_checkbox_click(self, index, is_instant)
|
||||
end
|
||||
|
||||
|
||||
|
@@ -88,9 +88,15 @@ M["progress"] = {
|
||||
|
||||
|
||||
M["checkbox"] = {
|
||||
on_change_state = function(self, node, state)
|
||||
on_change_state = function(self, node, state, is_instant)
|
||||
local target = state and 1 or 0
|
||||
gui.animate(node, "color.w", target, gui.EASING_OUTSINE, 0.1)
|
||||
if not is_instant then
|
||||
gui.animate(node, "color.w", target, gui.EASING_OUTSINE, 0.1)
|
||||
else
|
||||
local color = gui.get_color(node)
|
||||
color.w = target
|
||||
gui.set_color(node, color)
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user