Skip to content

Commit

Permalink
Update annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Insality committed Oct 15, 2024
1 parent 5848921 commit ea80c87
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 65 deletions.
103 changes: 103 additions & 0 deletions docs/modules/DataList.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ <h1>Module <code>DataList</code></h1>

<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#add">add(self, data, index, shift_policy)</a></td>
<td class="summary">Add element to DataList.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#clear">clear(self)</a></td>
<td class="summary">Clear the DataList and refresh visuals</td>
Expand Down Expand Up @@ -112,6 +116,14 @@ <h2><a href="#Functions">Functions</a></h2>
<td class="summary">Druid System on_remove function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#remove">remove(self, index, shift_policy)</a></td>
<td class="summary">Remove element from DataList.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#remove_by_data">remove_by_data(self, data, shift_policy)</a></td>
<td class="summary">Remove element from DataList by data value.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#scroll_to_index">scroll_to_index(self, index)</a></td>
<td class="summary">Instant scroll to element with passed index</td>
</tr>
Expand Down Expand Up @@ -167,6 +179,39 @@ <h2><a href="#Fields">Fields</a></h2>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>

<dl class="function">
<dt>
<a name = "add"></a>
<strong>add(self, data, index, shift_policy)</strong>
</dt>
<dd>
Add element to DataList. Currenly untested


<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DataList</span></span>
<a href="../modules/DataList.html#">DataList</a>
</li>
<li><span class="parameter">data</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>

</li>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>

</li>
<li><span class="parameter">shift_policy</span>
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
The constant from const.SHIFT.*
</li>
</ul>





</dd>
<dt>
<a name = "clear"></a>
<strong>clear(self)</strong>
Expand Down Expand Up @@ -347,6 +392,64 @@ <h3>Parameters:</h3>



</dd>
<dt>
<a name = "remove"></a>
<strong>remove(self, index, shift_policy)</strong>
</dt>
<dd>
Remove element from DataList. Currenly untested


<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DataList</span></span>
<a href="../modules/DataList.html#">DataList</a>
</li>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>

</li>
<li><span class="parameter">shift_policy</span>
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
The constant from const.SHIFT.*
</li>
</ul>





</dd>
<dt>
<a name = "remove_by_data"></a>
<strong>remove_by_data(self, data, shift_policy)</strong>
</dt>
<dd>
Remove element from DataList by data value. Currenly untested


<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DataList</span></span>
<a href="../modules/DataList.html#">DataList</a>
</li>
<li><span class="parameter">data</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>

</li>
<li><span class="parameter">shift_policy</span>
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
The constant from const.SHIFT.*
</li>
</ul>





</dd>
<dt>
<a name = "scroll_to_index"></a>
Expand Down
15 changes: 1 addition & 14 deletions docs/modules/RichText.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,7 @@ <h1>Module <code>RichText</code></h1>
<b># Overview #</b>
<p> This custom component is inspired by <a href="https://github.com/britzl/defold-richtext" target="_blank">defold-richtext</a> by britzl.
It uses a similar syntax for tags but currently supports fewer tags.
<p> All parameters for the Rich Text component are adjusted in the GUI scene.
<p> This component uses GUI component template. (/druid/custom/rich_text/rich_text.gui).
<p> You able to customize it or make your own with the next node scructure:
<p> root
<p> - text_prefab
<p> - icon_prefab
<p> <b># Rich Text Setup #</b>
<p> • Root node size: Set the maximum width and height of the text.
<p> • Root anchor: Define the alignment of the Rich Text inside the root node size area.
<p> • Text prefab: Configure all default text parameters for the text node.
<p> • Text prefab anchor: Set the anchor for each text node (adjust this only if animating text).
<p> • Icon prefab: Configure all default node parameters for the icon node.
<p> • Icon prefab anchor: Set the anchor for each icon node (adjust this only if animating the icon).
<p> Create Rich Text on your GUI Text Node. All properties of the text node will be used as default for the text.
<p> <b># Notes #</b>
<p> • Nested tags are supported
<p> <a href="https://insality.github.io/druid/druid/index.html?example=custom_rich_text" target="_blank"><b>Example Link</b></a></p>
Expand All @@ -119,7 +107,6 @@ <h3>Usage:</h3>
outline: vector4,
font: string,
image: druid.rich_text.image,
default_animation: string,
br: boolean,
nobr: boolean,
}
Expand Down
46 changes: 40 additions & 6 deletions druid/annotations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion druid/custom/rich_text/module/rt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down
27 changes: 1 addition & 26 deletions druid/custom/rich_text/rich_text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,7 @@
-- This custom component is inspired by <a href="https://github.com/britzl/defold-richtext" target="_blank">defold-richtext</a> 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
--
-- <b># Rich Text Setup #</b>
--
-- • 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.
--
-- <b># Notes #</b>
--
Expand Down Expand Up @@ -58,7 +34,6 @@
-- outline: vector4,
-- font: string,
-- image: druid.rich_text.image,
-- default_animation: string,
-- br: boolean,
-- nobr: boolean,
-- }
Expand Down
15 changes: 6 additions & 9 deletions druid/extended/data_list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions druid/extended/layout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 16 additions & 6 deletions utils/annotations_manual.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ea80c87

Please sign in to comment.