From 3c9f539376c9c678dd9b5e9987900b7530c007c2 Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 5 Oct 2024 02:27:30 +0300 Subject: [PATCH] Update annotations --- druid/annotations.lua | 28 +++++++++++++++++++++++++--- druid/custom/rich_text/rich_text.lua | 14 +++++++++++++- druid/extended/data_list.lua | 6 ++++++ druid/extended/input.lua | 4 ++-- utils/annotations_manual.lua | 14 +++++++++++++- 5 files changed, 59 insertions(+), 7 deletions(-) diff --git a/druid/annotations.lua b/druid/annotations.lua index d6a453d..9ffadd0 100644 --- a/druid/annotations.lua +++ b/druid/annotations.lua @@ -312,11 +312,13 @@ function druid__checkbox_group.set_state(self, indexes, is_instant) end ---@class druid.data_list : druid.base_component ---@field grid druid.static_grid|druid.dynamic_grid The Druid Grid component +---@field last_index number The current last index of visual elements ---@field on_element_add druid.event On DataList visual element created Event callback(self, index, node, instance) ---@field on_element_remove druid.event On DataList visual element created Event callback(self, index) ---@field on_scroll_progress_change druid.event Event triggered when scroll progress is changed; event(self, progress_value) ---@field scroll druid.scroll The Druid scroll component ---@field scroll_progress number The current progress of scroll posititon +---@field top_index number The current top index of visual elements local druid__data_list = {} --- Clear the DataList and refresh visuals @@ -712,7 +714,7 @@ function druid__input.select(self) end --- Set cursor position in input field ---@param self druid.input @{Input} ---@param cursor_index number|nil Cursor index for cursor position, if nil - will be set to the end of the text ----@param start_index number|nils Start index for cursor position, if nil - will be set to the end of the text +---@param start_index number|nil Start index for cursor position, if nil - will be set to the end of the text ---@param end_index number|nil End index for cursor position, if nil - will be set to the start_index ---@return druid.input Current input instance function druid__input.select_cursor(self, cursor_index, start_index, end_index) end @@ -1024,7 +1026,10 @@ function druid__rich_input.set_text(self, text) end ---@class druid.rich_text : druid.base_component ---@field druid druid_instance The component druid instance +---@field icon_prefab node The icon prefab node +---@field root node The root node of the Rich Text ---@field style druid.rich_text.style Component style params. +---@field text_prefab node The text prefab node local druid__rich_text = {} --- Split a word into it's characters @@ -1040,6 +1045,11 @@ function druid__rich_text.clear() end ---@return druid.rich_text.lines_metrics function druid__rich_text.get_line_metric() end +--- Get current text +---@param self druid.rich_text @{RichText} +---@return string text +function druid__rich_text.get_text(self) end + --- Get all current words. ---@return table druid.rich_text.word[] function druid__rich_text.get_words() end @@ -1052,7 +1062,7 @@ function druid__rich_text.init(self, template, nodes) end --- Set text for Rich Text ---@param self druid.rich_text @{RichText} ----@param text string |nil The text to set +---@param text string|nil The text to set ---@return druid.rich_text.word[] words ---@return druid.rich_text.lines_metrics line_metrics function druid__rich_text.set_text(self, text) end @@ -1962,7 +1972,7 @@ function helper.table_to_string(t) end ---@field scale vector3 ---@field size vector3 ---@field metrics druid.rich_text.metrics ----@field pivot number @ The gui.PIVOT_* constant +---@field pivot userdata @ The gui.PIVOT_* constant ---@field text string ---@field shadow vector4 ---@field outline vector4 @@ -1972,6 +1982,9 @@ function helper.table_to_string(t) end ---@field anchor number ---@field br boolean ---@field nobr boolean +---@field source_text string +---@field image_color vector4 +---@field text_color vector4 ---@class druid.rich_text.image ---@field texture string @@ -1992,6 +2005,15 @@ function helper.table_to_string(t) end ---@field default_animation string ---@field node_prefab node ---@field text_prefab node +---@field text_scale vector3 +---@field adjust_scale number +---@field default_texture string +---@field node_scale vector3 +---@field is_multiline boolean +---@field text_leading number +---@field font hash +---@field width number +---@field height number ---@class GUITextMetrics ---@field width number diff --git a/druid/custom/rich_text/rich_text.lua b/druid/custom/rich_text/rich_text.lua index cf83f2a..48a5fd7 100644 --- a/druid/custom/rich_text/rich_text.lua +++ b/druid/custom/rich_text/rich_text.lua @@ -90,6 +90,15 @@ --- The component druid instance -- @tfield DruidInstance druid @{DruidInstance} +--- The root node of the Rich Text +-- @tfield node root + +--- The text prefab node +-- @tfield node text_prefab + +--- The icon prefab node +-- @tfield node icon_prefab + -- local component = require("druid.component") @@ -149,7 +158,7 @@ end --- Set text for Rich Text -- @tparam RichText self @{RichText} --- @tparam string text|nil The text to set +-- @tparam string|nil text The text to set -- @treturn druid.rich_text.word[] words -- @treturn druid.rich_text.lines_metrics line_metrics -- @usage @@ -210,6 +219,9 @@ function RichText.set_text(self, text) end +--- Get current text +-- @tparam RichText self @{RichText} +-- @treturn string text function RichText.get_text(self) return self._last_value end diff --git a/druid/extended/data_list.lua b/druid/extended/data_list.lua index 8052d82..c4a5f35 100644 --- a/druid/extended/data_list.lua +++ b/druid/extended/data_list.lua @@ -18,6 +18,12 @@ --- The current progress of scroll posititon -- @tfield number scroll_progress +--- The current top index of visual elements +-- @tfield number top_index + +--- The current last index of visual elements +-- @tfield number last_index + --- Event triggered when scroll progress is changed; event(self, progress_value) -- @tfield DruidEvent on_scroll_progress_change @{DruidEvent} diff --git a/druid/extended/input.lua b/druid/extended/input.lua index 4de1d8b..a48117f 100755 --- a/druid/extended/input.lua +++ b/druid/extended/input.lua @@ -303,7 +303,7 @@ function Input.on_input(self, action_id, action) return false end - return false + return self.is_selected end @@ -484,7 +484,7 @@ end --- Set cursor position in input field -- @tparam Input self @{Input} -- @tparam number|nil cursor_index Cursor index for cursor position, if nil - will be set to the end of the text --- @tparam number|nils start_index Start index for cursor position, if nil - will be set to the end of the text +-- @tparam number|nil start_index Start index for cursor position, if nil - will be set to the end of the text -- @tparam number|nil end_index End index for cursor position, if nil - will be set to the start_index -- @treturn druid.input Current input instance function Input.select_cursor(self, cursor_index, start_index, end_index) diff --git a/utils/annotations_manual.lua b/utils/annotations_manual.lua index d87b665..6f6547a 100644 --- a/utils/annotations_manual.lua +++ b/utils/annotations_manual.lua @@ -21,7 +21,7 @@ ---@field scale vector3 ---@field size vector3 ---@field metrics druid.rich_text.metrics ----@field pivot number @ The gui.PIVOT_* constant +---@field pivot userdata @ The gui.PIVOT_* constant ---@field text string ---@field shadow vector4 ---@field outline vector4 @@ -31,6 +31,9 @@ ---@field anchor number ---@field br boolean ---@field nobr boolean +---@field source_text string +---@field image_color vector4 +---@field text_color vector4 ---@class druid.rich_text.image ---@field texture string @@ -51,6 +54,15 @@ ---@field default_animation string ---@field node_prefab node ---@field text_prefab node +---@field text_scale vector3 +---@field adjust_scale number +---@field default_texture string +---@field node_scale vector3 +---@field is_multiline boolean +---@field text_leading number +---@field font hash +---@field width number +---@field height number ---@class GUITextMetrics ---@field width number