From ea80c874f6c0ea175b317d01ac45c567db9179c7 Mon Sep 17 00:00:00 2001 From: Insality Date: Tue, 15 Oct 2024 19:43:36 +0300 Subject: [PATCH] Update annotations --- docs/modules/DataList.html | 103 +++++++++++++++++++++++++++ docs/modules/RichText.html | 15 +--- druid/annotations.lua | 46 ++++++++++-- druid/custom/rich_text/module/rt.lua | 1 - druid/custom/rich_text/rich_text.lua | 27 +------ druid/extended/data_list.lua | 15 ++-- druid/extended/layout.lua | 6 +- utils/annotations_manual.lua | 22 ++++-- 8 files changed, 170 insertions(+), 65 deletions(-) diff --git a/docs/modules/DataList.html b/docs/modules/DataList.html index 7dcbdbe..68df37a 100644 --- a/docs/modules/DataList.html +++ b/docs/modules/DataList.html @@ -83,6 +83,10 @@

Functions

+ + + + @@ -112,6 +116,14 @@ + + + + + + + + @@ -167,6 +179,39 @@

Functions

+
+ + add(self, data, index, shift_policy) +
+
+ Add element to DataList. Currenly untested + + +

Parameters:

+
    +
  • self + DataList + DataList +
  • +
  • data + table + +
  • +
  • index + number or nil + +
  • +
  • shift_policy + number or nil + The constant from const.SHIFT.* +
  • +
+ + + + + +
clear(self) @@ -347,6 +392,64 @@ + +
+ + remove(self, index, shift_policy) +
+
+ Remove element from DataList. Currenly untested + + +

Parameters:

+
    +
  • self + DataList + DataList +
  • +
  • index + number or nil + +
  • +
  • shift_policy + number or nil + The constant from const.SHIFT.* +
  • +
+ + + + + +
+
+ + remove_by_data(self, data, shift_policy) +
+
+ Remove element from DataList by data value. Currenly untested + + +

Parameters:

+
    +
  • self + DataList + DataList +
  • +
  • data + table + +
  • +
  • shift_policy + number or nil + The constant from const.SHIFT.* +
  • +
+ + + + +
diff --git a/docs/modules/RichText.html b/docs/modules/RichText.html index c72269b..ec185a8 100644 --- a/docs/modules/RichText.html +++ b/docs/modules/RichText.html @@ -81,19 +81,7 @@ # Overview #

This custom component is inspired by defold-richtext by britzl. It uses a similar syntax for tags but currently supports fewer tags. -

All parameters for the Rich Text component are adjusted in the GUI scene. -

This component uses GUI component template. (/druid/custom/rich_text/rich_text.gui). -

You able to customize it or make your own with the next node scructure: -

root -

- text_prefab -

- icon_prefab -

# Rich Text Setup # -

• Root node size: Set the maximum width and height of the text. -

• Root anchor: Define the alignment of the Rich Text inside the root node size area. -

• Text prefab: Configure all default text parameters for the text node. -

• Text prefab anchor: Set the anchor for each text node (adjust this only if animating text). -

• Icon prefab: Configure all default node parameters for the icon node. -

• Icon prefab anchor: Set the anchor for each icon node (adjust this only if animating the icon). +

Create Rich Text on your GUI Text Node. All properties of the text node will be used as default for the text.

# Notes #

• Nested tags are supported

Example Link

@@ -119,7 +107,6 @@ self.rich_text:set_text("Hello, Druid Rich Text!") outline: vector4, font: string, image: druid.rich_text.image, - default_animation: string, br: boolean, nobr: boolean, } diff --git a/druid/annotations.lua b/druid/annotations.lua index c8e29dd..3e8be27 100644 --- a/druid/annotations.lua +++ b/druid/annotations.lua @@ -321,6 +321,14 @@ function druid__checkbox_group.set_state(self, indexes, is_instant) end ---@field top_index number The current top index of visual elements local druid__data_list = {} +--- Add element to DataList. +--- Currenly untested +---@param self druid.data_list @{DataList} +---@param data table +---@param index number|nil +---@param shift_policy number|nil The constant from const.SHIFT.* +function druid__data_list.add(self, data, index, shift_policy) end + --- Clear the DataList and refresh visuals ---@param self druid.data_list @{DataList} function druid__data_list.clear(self) end @@ -356,6 +364,20 @@ function druid__data_list.init(self, scroll, grid, create_function) end ---@param self druid.data_list @{DataList} function druid__data_list.on_remove(self) end +--- Remove element from DataList. +--- Currenly untested +---@param self druid.data_list @{DataList} +---@param index number|nil +---@param shift_policy number|nil The constant from const.SHIFT.* +function druid__data_list.remove(self, index, shift_policy) end + +--- Remove element from DataList by data value. +--- Currenly untested +---@param self druid.data_list @{DataList} +---@param data table +---@param shift_policy number|nil The constant from const.SHIFT.* +function druid__data_list.remove_by_data(self, data, shift_policy) end + --- Instant scroll to element with passed index ---@param self druid.data_list @{DataList} ---@param index number @@ -1903,6 +1925,8 @@ function helper.table_to_string(t) end ---@field height number ---@field offset_x number|nil ---@field offset_y number|nil +---@field max_ascent number +---@field max_descent number ---@field node_size vector3|nil @For images only ---@class druid.rich_text.lines_metrics @@ -1967,12 +1991,22 @@ function helper.table_to_string(t) end ---@field max_descent number ---@class utf8 ----@field len fun(string: string): number ----@field sub fun(string: string, i: number, j: number): string ----@field gmatch fun(string: string, pattern: string): fun(): string ----@field gsub fun(string: string, pattern: string, repl: string, n: number): string ----@field char fun(...: number): string ----@field byte fun(string: string, i: number, j: number): number +---@field len fun(s: string):number +---@field sub fun(s: string, start_index: number, length: number) +---@field reverse fun() +---@field char fun() +---@field unicode fun() +---@field gensub fun() +---@field byte fun() +---@field find fun() +---@field match fun(s: string, m: string) +---@field gmatch fun(s: string, m: string) +---@field gsub fun() +---@field dump fun() +---@field format fun() +---@field lower fun() +---@field upper fun() +---@field rep fun() ---Add generics to some functions. diff --git a/druid/custom/rich_text/module/rt.lua b/druid/custom/rich_text/module/rt.lua index 74aa679..8baa48c 100755 --- a/druid/custom/rich_text/module/rt.lua +++ b/druid/custom/rich_text/module/rt.lua @@ -12,7 +12,6 @@ local utf8_lua = require("druid.system.utf8") local utf8 = utf8 or utf8_lua local VECTOR_ZERO = vmath.vector3(0) -local VECTOR_ONE = vmath.vector3(1) local COLOR_WHITE = vmath.vector4(1) local M = {} diff --git a/druid/custom/rich_text/rich_text.lua b/druid/custom/rich_text/rich_text.lua index 29bb098..b3d4973 100644 --- a/druid/custom/rich_text/rich_text.lua +++ b/druid/custom/rich_text/rich_text.lua @@ -6,31 +6,7 @@ -- This custom component is inspired by defold-richtext by britzl. -- It uses a similar syntax for tags but currently supports fewer tags. -- --- All parameters for the Rich Text component are adjusted in the GUI scene. --- --- This component uses GUI component template. (/druid/custom/rich_text/rich_text.gui). --- --- You able to customize it or make your own with the next node scructure: --- --- root --- --- - text_prefab --- --- - icon_prefab --- --- # Rich Text Setup # --- --- • Root node size: Set the maximum width and height of the text. --- --- • Root anchor: Define the alignment of the Rich Text inside the root node size area. --- --- • Text prefab: Configure all default text parameters for the text node. --- --- • Text prefab anchor: Set the anchor for each text node (adjust this only if animating text). --- --- • Icon prefab: Configure all default node parameters for the icon node. --- --- • Icon prefab anchor: Set the anchor for each icon node (adjust this only if animating the icon). +-- Create Rich Text on your GUI Text Node. All properties of the text node will be used as default for the text. -- -- # Notes # -- @@ -58,7 +34,6 @@ -- outline: vector4, -- font: string, -- image: druid.rich_text.image, --- default_animation: string, -- br: boolean, -- nobr: boolean, -- } diff --git a/druid/extended/data_list.lua b/druid/extended/data_list.lua index 17aba86..e28714f 100644 --- a/druid/extended/data_list.lua +++ b/druid/extended/data_list.lua @@ -115,9 +115,8 @@ end --- Add element to DataList. Currenly untested -- @tparam DataList self @{DataList} -- @tparam table data --- @tparam number index --- @tparam number shift_policy The constant from const.SHIFT.* --- @local +-- @tparam number|nil index +-- @tparam number|nil shift_policy The constant from const.SHIFT.* function DataList.add(self, data, index, shift_policy) index = index or #self._data + 1 shift_policy = shift_policy or const.SHIFT.RIGHT @@ -129,9 +128,8 @@ end --- Remove element from DataList. Currenly untested -- @tparam DataList self @{DataList} --- @tparam number index --- @tparam number shift_policy The constant from const.SHIFT.* --- @local +-- @tparam number|nil index +-- @tparam number|nil shift_policy The constant from const.SHIFT.* function DataList.remove(self, index, shift_policy) helper.remove_with_shift(self._data, index, shift_policy) self:_refresh() @@ -140,9 +138,8 @@ end --- Remove element from DataList by data value. Currenly untested -- @tparam DataList self @{DataList} --- @tparam tabe data --- @tparam number shift_policy The constant from const.SHIFT.* --- @local +-- @tparam table data +-- @tparam number|nil shift_policy The constant from const.SHIFT.* function DataList.remove_by_data(self, data, shift_policy) local index = helper.contains(self._data, data) if index then diff --git a/druid/extended/layout.lua b/druid/extended/layout.lua index d8ac732..7d2dc04 100644 --- a/druid/extended/layout.lua +++ b/druid/extended/layout.lua @@ -297,9 +297,9 @@ function M.clear_layout(self) end --- @private -- @tparam node node -- @treturn number, number +-- @local function M.get_node_size(node) if not gui.is_enabled(node, false) then return 0, 0 @@ -318,10 +318,10 @@ function M.get_node_size(node) end --- @private -- @tparam Layout self @{Layout} -- Calculate rows data for layout. Contains total width, height and rows info (width, height, count of elements in row) -- @treturn druid.layout.rows_data +-- @local function M.calculate_rows_data(self) local entities = self.entities local margin = self.margin @@ -401,11 +401,11 @@ function M.calculate_rows_data(self) return rows_data end --- @private -- @tparam node node -- @tparam number x -- @tparam number y -- @treturn node +-- @local function M:set_node_position(node, x, y) local position = gui.get_position(node) position.x = x diff --git a/utils/annotations_manual.lua b/utils/annotations_manual.lua index a72a32e..ab4169d 100644 --- a/utils/annotations_manual.lua +++ b/utils/annotations_manual.lua @@ -73,12 +73,22 @@ ---@field max_descent number ---@class utf8 ----@field len fun(string: string): number ----@field sub fun(string: string, i: number, j: number): string ----@field gmatch fun(string: string, pattern: string): fun(): string ----@field gsub fun(string: string, pattern: string, repl: string, n: number): string ----@field char fun(...: number): string ----@field byte fun(string: string, i: number, j: number): number +---@field len fun(s: string):number +---@field sub fun(s: string, start_index: number, length: number) +---@field reverse fun() +---@field char fun() +---@field unicode fun() +---@field gensub fun() +---@field byte fun() +---@field find fun() +---@field match fun(s: string, m: string) +---@field gmatch fun(s: string, m: string) +---@field gsub fun() +---@field dump fun() +---@field format fun() +---@field lower fun() +---@field upper fun() +---@field rep fun() ---Add generics to some functions.
add(self, data, index, shift_policy)Add element to DataList.
clear(self) Clear the DataList and refresh visualsDruid System on_remove function
remove(self, index, shift_policy)Remove element from DataList.
remove_by_data(self, data, shift_policy)Remove element from DataList by data value.
scroll_to_index(self, index) Instant scroll to element with passed index