From 24bb39481d991ef4a1290d14222b611af803fa9c Mon Sep 17 00:00:00 2001 From: Insality Date: Tue, 17 Oct 2023 23:18:25 +0300 Subject: [PATCH] Annotations update [4] --- docs/modules/BaseComponent.html | 2 +- docs/modules/DynamicGrid.html | 24 ++++++++++-------------- docs/modules/RichInput.html | 26 +++++++++++++++++++++++++- druid/annotations.lua | 13 +++++++------ druid/component.lua | 2 +- druid/custom/rich_input/rich_input.lua | 7 ++++++- druid/extended/dynamic_grid.lua | 8 ++++---- 7 files changed, 54 insertions(+), 28 deletions(-) diff --git a/docs/modules/BaseComponent.html b/docs/modules/BaseComponent.html index 52c4c3c..1c81617 100644 --- a/docs/modules/BaseComponent.html +++ b/docs/modules/BaseComponent.html @@ -598,7 +598,7 @@ self:set_nodes(nodes) BaseComponent
  • druid_style - table + table or nil Druid style module
  • diff --git a/docs/modules/DynamicGrid.html b/docs/modules/DynamicGrid.html index 331e65b..2f6677f 100644 --- a/docs/modules/DynamicGrid.html +++ b/docs/modules/DynamicGrid.html @@ -86,7 +86,7 @@ Return side vector to correct node shifting - add(self, node, index[, shift_policy=SHIFT.RIGHT[, is_instant=false]]) + add(self, node, index, shift_policy, is_instant) Add new node to the grid @@ -122,7 +122,7 @@ The DynamicGrid constructor - remove(self, index[, shift_policy=SHIFT.RIGHT[, is_instant=false]]) + remove(self, index, shift_policy, is_instant) Remove the item from the grid. @@ -213,7 +213,7 @@
    - add(self, node, index[, shift_policy=SHIFT.RIGHT[, is_instant=false]]) + add(self, node, index, shift_policy, is_instant)
    Add new node to the grid @@ -234,14 +234,12 @@ The node position. By default add as last node
  • shift_policy - number - How shift nodes, if required. See const.SHIFT - (default SHIFT.RIGHT) + number or nil + How shift nodes, if required. Default: const.SHIFT.RIGHT
  • is_instant - boolean + boolean or nil If true, update node positions instantly - (default false)
  • @@ -487,7 +485,7 @@
    - remove(self, index[, shift_policy=SHIFT.RIGHT[, is_instant=false]]) + remove(self, index, shift_policy, is_instant)
    Remove the item from the grid. Note that gui node will be not deleted @@ -504,14 +502,12 @@ The grid node index to remove
  • shift_policy - number - How shift nodes, if required. See const.SHIFT - (default SHIFT.RIGHT) + number or nil + How shift nodes, if required. Default: const.SHIFT.RIGHT
  • is_instant - boolean + boolean or nil If true, update node positions instantly - (default false)
  • diff --git a/docs/modules/RichInput.html b/docs/modules/RichInput.html index c9d71b2..4183c31 100644 --- a/docs/modules/RichInput.html +++ b/docs/modules/RichInput.html @@ -109,6 +109,10 @@ placeholder On input field text change to max length string callback(self, input_text) + + root + Root node +
    @@ -162,7 +166,7 @@ RichInput
  • placeholder_text - string + string or nil The placeholder text
  • @@ -255,6 +259,26 @@ +
    +
    + + root +
    +
    + Root node + + + + + + + +
    diff --git a/druid/annotations.lua b/druid/annotations.lua index 2ecb74d..5843e13 100644 --- a/druid/annotations.lua +++ b/druid/annotations.lua @@ -137,7 +137,7 @@ function druid__base_component.set_nodes(self, nodes) end --- Set current component style table. --- Invoke `on_style_change` on component, if exist. Component should handle their style changing and store all style params ---@param self druid.base_component @{BaseComponent} ----@param druid_style table Druid style module +---@param druid_style table|nil Druid style module ---@return druid.base_component @{BaseComponent} function druid__base_component.set_style(self, druid_style) end @@ -451,8 +451,8 @@ function druid__dynamic_grid._get_side_vector(self, side, is_forward) end ---@param self druid.dynamic_grid @{DynamicGrid} ---@param node node Gui node ---@param index number|nil The node position. By default add as last node ----@param shift_policy number How shift nodes, if required. See const.SHIFT ----@param is_instant boolean If true, update node positions instantly +---@param shift_policy number|nil How shift nodes, if required. Default: const.SHIFT.RIGHT +---@param is_instant boolean|nil If true, update node positions instantly function druid__dynamic_grid.add(self, node, index, shift_policy, is_instant) end --- Clear grid nodes array. @@ -505,8 +505,8 @@ function druid__dynamic_grid.init(self, parent) end --- Note that gui node will be not deleted ---@param self druid.dynamic_grid @{DynamicGrid} ---@param index number The grid node index to remove ----@param shift_policy number How shift nodes, if required. See const.SHIFT ----@param is_instant boolean If true, update node positions instantly +---@param shift_policy number|nil How shift nodes, if required. Default: const.SHIFT.RIGHT +---@param is_instant boolean|nil If true, update node positions instantly ---@return node The deleted gui node from grid function druid__dynamic_grid.remove(self, index, shift_policy, is_instant) end @@ -933,6 +933,7 @@ function druid__radio_group.set_state(self, index, is_instant) end ---@field druid druid_instance The component druid instance ---@field input druid.input On input field text change callback(self, input_text) ---@field placeholder druid.text On input field text change to max length string callback(self, input_text) +---@field root node Root node local druid__rich_input = {} --- The @{RichInput} constructor @@ -943,7 +944,7 @@ function druid__rich_input.init(self, template, nodes) end --- Set placeholder text ---@param self druid.rich_input @{RichInput} ----@param placeholder_text string The placeholder text +---@param placeholder_text string|nil The placeholder text function druid__rich_input.set_placeholder(self, placeholder_text) end diff --git a/druid/component.lua b/druid/component.lua index e9bcd43..ca6f89e 100644 --- a/druid/component.lua +++ b/druid/component.lua @@ -75,7 +75,7 @@ end -- Invoke `on_style_change` on component, if exist. Component should handle -- their style changing and store all style params -- @tparam BaseComponent self @{BaseComponent} --- @tparam table druid_style Druid style module +-- @tparam table|nil druid_style Druid style module -- @treturn BaseComponent @{BaseComponent} function BaseComponent.set_style(self, druid_style) self._meta.style = druid_style or {} diff --git a/druid/custom/rich_input/rich_input.lua b/druid/custom/rich_input/rich_input.lua index e932d7a..9adcc70 100644 --- a/druid/custom/rich_input/rich_input.lua +++ b/druid/custom/rich_input/rich_input.lua @@ -9,6 +9,9 @@ --- The component druid instance -- @tfield DruidInstance druid @{DruidInstance} +--- Root node +-- @tfield node root + --- On input field text change callback(self, input_text) -- @tfield Input input @{Input} @@ -69,6 +72,8 @@ function RichInput.init(self, template, nodes) self:set_template(template) self:set_nodes(nodes) self.druid = self:get_druid() + self.root = self:get_node(SCHEME.ROOT) + self.input = self.druid:new_input(self:get_node(SCHEME.BUTTON), self:get_node(SCHEME.INPUT)) self.cursor = self:get_node(SCHEME.CURSOR) @@ -85,7 +90,7 @@ end --- Set placeholder text -- @tparam RichInput self @{RichInput} --- @tparam string placeholder_text The placeholder text +-- @tparam string|nil placeholder_text The placeholder text function RichInput.set_placeholder(self, placeholder_text) self.placeholder:set_to(placeholder_text) return self diff --git a/druid/extended/dynamic_grid.lua b/druid/extended/dynamic_grid.lua index e1fb56d..3206020 100644 --- a/druid/extended/dynamic_grid.lua +++ b/druid/extended/dynamic_grid.lua @@ -141,8 +141,8 @@ end -- @tparam DynamicGrid self @{DynamicGrid} -- @tparam node node Gui node -- @tparam number|nil index The node position. By default add as last node --- @tparam[opt=SHIFT.RIGHT] number shift_policy How shift nodes, if required. See const.SHIFT --- @tparam[opt=false] boolean is_instant If true, update node positions instantly +-- @tparam number|nil shift_policy How shift nodes, if required. Default: const.SHIFT.RIGHT +-- @tparam boolean|nil is_instant If true, update node positions instantly function DynamicGrid.add(self, node, index, shift_policy, is_instant) shift_policy = shift_policy or const.SHIFT.RIGHT local delta = shift_policy -- -1 or 1 or 0 @@ -183,8 +183,8 @@ end --- Remove the item from the grid. Note that gui node will be not deleted -- @tparam DynamicGrid self @{DynamicGrid} -- @tparam number index The grid node index to remove --- @tparam[opt=SHIFT.RIGHT] number shift_policy How shift nodes, if required. See const.SHIFT --- @tparam[opt=false] boolean is_instant If true, update node positions instantly +-- @tparam number|nil shift_policy How shift nodes, if required. Default: const.SHIFT.RIGHT +-- @tparam boolean|nil is_instant If true, update node positions instantly -- @treturn node The deleted gui node from grid function DynamicGrid.remove(self, index, shift_policy, is_instant) shift_policy = shift_policy or const.SHIFT.RIGHT