mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
Update docs, config generations, fix linter
This commit is contained in:
parent
2f5336fa4f
commit
5848921cba
7
.vscode/settings.json
vendored
7
.vscode/settings.json
vendored
@ -27,6 +27,11 @@
|
||||
"test/tests/*.lua",
|
||||
"utils/annotations_manual.lua"
|
||||
],
|
||||
"Lua.runtime.pathStrict": true,
|
||||
"Lua.diagnostics.libraryFiles": "Enable",
|
||||
"Lua.runtime.version": "Lua 5.1"
|
||||
"Lua.runtime.version": "Lua 5.1",
|
||||
"Lua.workspace.library": [
|
||||
"~/Library/Application Support/Code/User/globalStorage/astronachos.defold",
|
||||
"~/Library/Application Support/Code/User/workspaceStorage/72e25b7e0fdc873ee6f7baa61edbd6b1/astronachos.defold"
|
||||
]
|
||||
}
|
@ -17,9 +17,9 @@ Try the [**HTML5 version**](https://insality.github.io/druid/druid/) of the **Dr
|
||||
|
||||
To integrate the **Druid** extension into your own project, add this project as a [dependency](https://www.defold.com/manuals/libraries/) in your **Defold** game. Open your `game.project` file and add the following line to the dependencies field under the project section:
|
||||
|
||||
**Druid v0.11.0**
|
||||
**Druid v0.12.0**
|
||||
|
||||
> [https://github.com/Insality/druid/archive/refs/tags/0.11.0.zip](https://github.com/Insality/druid/archive/refs/tags/0.11.0.zip)
|
||||
> [https://github.com/Insality/druid/archive/refs/tags/0.12.0.zip](https://github.com/Insality/druid/archive/refs/tags/0.12.0.zip)
|
||||
|
||||
Here is a list of [all releases](https://github.com/Insality/druid/releases).
|
||||
|
||||
|
@ -4,7 +4,6 @@ description='Documentation for Druid Framework'
|
||||
file={"./druid",
|
||||
exclude = {
|
||||
"./druid/styles/",
|
||||
"./druid/system/middleclass.lua",
|
||||
"./druid/templates/",
|
||||
"./druid/annotations.lua",
|
||||
"./druid/custom/rich_text/module",
|
||||
|
@ -106,7 +106,7 @@ return AwesomeComponent
|
||||
<td class="summary">Context used as first arg in all Druid events</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_druid">get_druid(self)</a></td>
|
||||
<td class="name" nowrap><a href="#get_druid">get_druid(self, template, nodes)</a></td>
|
||||
<td class="summary">Get Druid instance for inner component creation.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -226,7 +226,7 @@ return AwesomeComponent
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_druid"></a>
|
||||
<strong>get_druid(self)</strong>
|
||||
<strong>get_druid(self, template, nodes)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Get Druid instance for inner component creation.
|
||||
@ -238,6 +238,14 @@ return AwesomeComponent
|
||||
<span class="types"><span class="type">BaseComponent</span></span>
|
||||
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
||||
</li>
|
||||
<li><span class="parameter">template</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
The template name
|
||||
</li>
|
||||
<li><span class="parameter">nodes</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a> or <span class="type">nil</span></span>
|
||||
The nodes table
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
|
@ -100,22 +100,10 @@
|
||||
<td class="summary">Return current data from DataList component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_first_index">get_first_index(self)</a></td>
|
||||
<td class="summary">Return first index from data.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_index">get_index(self, data)</a></td>
|
||||
<td class="summary">Return index for data value</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_last_index">get_last_index(self)</a></td>
|
||||
<td class="summary">Return last index from data</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_length">get_length(self)</a></td>
|
||||
<td class="summary">Return amount of data</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, scroll, grid, create_function)</a></td>
|
||||
<td class="summary">The <a href="../modules/DataList.html#">DataList</a> constructor</td>
|
||||
</tr>
|
||||
@ -131,6 +119,10 @@
|
||||
<td class="name" nowrap><a href="#set_data">set_data(self, data)</a></td>
|
||||
<td class="summary">Set new data set for DataList component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_use_cache">set_use_cache(self, is_use_cache)</a></td>
|
||||
<td class="summary">Set refresh function for DataList component</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Fields">Fields</a></h2>
|
||||
<table class="function_list">
|
||||
@ -140,7 +132,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#last_index">last_index</a></td>
|
||||
<td class="summary">The current visual last data index</td>
|
||||
<td class="summary">The current last index of visual elements</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_element_add">on_element_add</a></td>
|
||||
@ -164,7 +156,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#top_index">top_index</a></td>
|
||||
<td class="summary">The current visual top data index</td>
|
||||
<td class="summary">The current top index of visual elements</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@ -276,27 +268,6 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_first_index"></a>
|
||||
<strong>get_first_index(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Return first index from data. It not always equals to 1
|
||||
|
||||
|
||||
<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>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_index"></a>
|
||||
@ -322,48 +293,6 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_last_index"></a>
|
||||
<strong>get_last_index(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Return last index from data
|
||||
|
||||
|
||||
<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>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_length"></a>
|
||||
<strong>get_length(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Return amount of data
|
||||
|
||||
|
||||
<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>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
@ -474,6 +403,37 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_use_cache"></a>
|
||||
<strong>set_use_cache(self, is_use_cache)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set refresh function for DataList component
|
||||
|
||||
|
||||
<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">is_use_cache</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
Use cache version of DataList. Requires make setup of components in on_element_add callback and clean in on_element_remove
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">druid.data_list</span></span>
|
||||
Current DataList instance
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
|
||||
@ -504,7 +464,7 @@
|
||||
<strong>last_index</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The current visual last data index
|
||||
The current last index of visual elements
|
||||
|
||||
|
||||
<ul>
|
||||
@ -624,7 +584,7 @@
|
||||
<strong>top_index</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The current visual top data index
|
||||
The current top index of visual elements
|
||||
|
||||
|
||||
<ul>
|
||||
|
@ -134,11 +134,11 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_drag">on_drag</a></td>
|
||||
<td class="summary">on drag progress callback(self, dx, dy, total_x, total_y)</td>
|
||||
<td class="summary">on drag progress callback(self, dx, dy, total_x, total_y, touch)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_drag_end">on_drag_end</a></td>
|
||||
<td class="summary">Event on drag end callback(self, total_x, total_y)</td>
|
||||
<td class="summary">Event on drag end callback(self, total_x, total_y, touch)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_drag_start">on_drag_start</a></td>
|
||||
@ -428,7 +428,7 @@
|
||||
<strong>on_drag</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
on drag progress callback(self, dx, dy, total_x, total_y)
|
||||
on drag progress callback(self, dx, dy, total_x, total_y, touch)
|
||||
|
||||
|
||||
<ul>
|
||||
@ -448,7 +448,7 @@
|
||||
<strong>on_drag_end</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Event on drag end callback(self, total_x, total_y)
|
||||
Event on drag end callback(self, total_x, total_y, touch)
|
||||
|
||||
|
||||
<ul>
|
||||
|
@ -87,15 +87,23 @@
|
||||
<td class="summary">Clear the all event handlers</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#initialize">initialize(self, initial_callback)</a></td>
|
||||
<td class="name" nowrap><a href="#create">create(callback, callback_context)</a></td>
|
||||
<td class="summary">DruidEvent constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#is_empty">is_empty(self)</a></td>
|
||||
<td class="summary">Return true, if event not have handler</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#is_exist">is_exist(self)</a></td>
|
||||
<td class="summary">Return true, if event have at lease one handler</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#subscribe">subscribe(self, callback, context)</a></td>
|
||||
<td class="name" nowrap><a href="#is_subscribed">is_subscribed(self, callback, callback_context)</a></td>
|
||||
<td class="summary">Check is event subscribed.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#subscribe">subscribe(self, callback, callback_context)</a></td>
|
||||
<td class="summary">Subscribe callback on event</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -103,7 +111,7 @@
|
||||
<td class="summary">Trigger the event and call all subscribed callbacks</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#unsubscribe">unsubscribe(self, callback, context)</a></td>
|
||||
<td class="name" nowrap><a href="#unsubscribe">unsubscribe(self, callback, callback_context)</a></td>
|
||||
<td class="summary">Unsubscribe callback on event</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -141,8 +149,8 @@
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "initialize"></a>
|
||||
<strong>initialize(self, initial_callback)</strong>
|
||||
<a name = "create"></a>
|
||||
<strong>create(callback, callback_context)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
DruidEvent constructor
|
||||
@ -150,14 +158,14 @@
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">DruidEvent</span></span>
|
||||
<a href="../modules/DruidEvent.html#">DruidEvent</a>
|
||||
</li>
|
||||
<li><span class="parameter">initial_callback</span>
|
||||
<li><span class="parameter">callback</span>
|
||||
<span class="types"><span class="type">function</span> or <span class="type">nil</span></span>
|
||||
Subscribe the callback on new event, if callback exist
|
||||
</li>
|
||||
<li><span class="parameter">callback_context</span>
|
||||
<span class="types"><span class="type">any</span> or <span class="type">nil</span></span>
|
||||
Additional context as first param to callback call
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@ -167,7 +175,38 @@
|
||||
<ul>
|
||||
<pre class="example"><span class="keyword">local</span> Event = <span class="global">require</span>(<span class="string">"druid.event"</span>)
|
||||
...
|
||||
<span class="keyword">local</span> event = Event(initial_callback)</pre>
|
||||
<span class="keyword">local</span> event = Event(callback)</pre>
|
||||
</ul>
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "is_empty"></a>
|
||||
<strong>is_empty(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Return true, if event not have handler
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">DruidEvent</span></span>
|
||||
<a href="../modules/DruidEvent.html#">DruidEvent</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
True if event not have handlers
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
<h3>Usage:</h3>
|
||||
<ul>
|
||||
<pre class="example"><span class="keyword">local</span> is_long_click_handler_not_exists = button.on_long_click:is_empty()</pre>
|
||||
</ul>
|
||||
|
||||
</dd>
|
||||
@ -201,10 +240,45 @@
|
||||
<pre class="example"><span class="keyword">local</span> is_long_click_handler_exists = button.on_long_click:is_exist()</pre>
|
||||
</ul>
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "is_subscribed"></a>
|
||||
<strong>is_subscribed(self, callback, callback_context)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Check is event subscribed.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">DruidEvent</span></span>
|
||||
<a href="../modules/DruidEvent.html#">DruidEvent</a>
|
||||
</li>
|
||||
<li><span class="parameter">callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
Callback itself
|
||||
</li>
|
||||
<li><span class="parameter">callback_context</span>
|
||||
<span class="types"><span class="type">any</span> or <span class="type">nil</span></span>
|
||||
Additional context as first param to callback call
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">boolean,</span></span>
|
||||
number|nil @Is event subscribed, return index of callback in event as second param
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "subscribe"></a>
|
||||
<strong>subscribe(self, callback, context)</strong>
|
||||
<strong>subscribe(self, callback, callback_context)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Subscribe callback on event
|
||||
@ -220,12 +294,18 @@
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
Callback itself
|
||||
</li>
|
||||
<li><span class="parameter">context</span>
|
||||
<li><span class="parameter">callback_context</span>
|
||||
<span class="types"><span class="type">any</span> or <span class="type">nil</span></span>
|
||||
Additional context as first param to callback call, usually it's self
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
True if callback was subscribed
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
@ -274,7 +354,7 @@ event:trigger(<span class="string">"Param1"</span>, <span class="string">"Param2
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "unsubscribe"></a>
|
||||
<strong>unsubscribe(self, callback, context)</strong>
|
||||
<strong>unsubscribe(self, callback, callback_context)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Unsubscribe callback on event
|
||||
@ -290,7 +370,7 @@ event:trigger(<span class="string">"Param1"</span>, <span class="string">"Param2
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
Callback itself
|
||||
</li>
|
||||
<li><span class="parameter">context</span>
|
||||
<li><span class="parameter">callback_context</span>
|
||||
<span class="types"><span class="type">any</span> or <span class="type">nil</span></span>
|
||||
Additional context as first param to callback call
|
||||
</li>
|
||||
|
@ -142,10 +142,6 @@ end
|
||||
<td class="summary">Call this in gui_script final function.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new">new(self, component, ...)</a></td>
|
||||
<td class="summary">Create new component.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new_back_handler">new_back_handler(self, callback, params)</a></td>
|
||||
<td class="summary">Create <a href="../modules/BackHandler.html#">BackHandler</a> component</td>
|
||||
</tr>
|
||||
@ -182,7 +178,7 @@ end
|
||||
<td class="summary">Create <a href="../modules/Hotkey.html#">Hotkey</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new_hover">new_hover(self, node, on_hover_callback)</a></td>
|
||||
<td class="name" nowrap><a href="#new_hover">new_hover(self, node, on_hover_callback, on_mouse_hover_callback)</a></td>
|
||||
<td class="summary">Create <a href="../modules/Hover.html#">Hover</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -194,7 +190,7 @@ end
|
||||
<td class="summary">Create <a href="../modules/LangText.html#">LangText</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new_layout">new_layout(self, node, mode, on_size_changed_callback)</a></td>
|
||||
<td class="name" nowrap><a href="#new_layout">new_layout(self, node, mode)</a></td>
|
||||
<td class="summary">Create <a href="../modules/Layout.html#">Layout</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -286,41 +282,6 @@ end
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new"></a>
|
||||
<strong>new(self, component, ...)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create new component.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">DruidInstance</span></span>
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">component</span>
|
||||
<span class="types"><span class="type">BaseComponent</span></span>
|
||||
Component module
|
||||
</li>
|
||||
<li><span class="parameter">...</span>
|
||||
<span class="types"><span class="type">any</span></span>
|
||||
Other component params to pass it to component:init function
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">BaseComponent</span></span>
|
||||
Component instance
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_back_handler"></a>
|
||||
@ -411,7 +372,7 @@ end
|
||||
Button callback
|
||||
</li>
|
||||
<li><span class="parameter">params</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a> or <span class="type">nil</span></span>
|
||||
<span class="types"><span class="type">any</span> or <span class="type">nil</span></span>
|
||||
Button callback params
|
||||
</li>
|
||||
<li><span class="parameter">anim_node</span>
|
||||
@ -659,7 +620,7 @@ end
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_hover"></a>
|
||||
<strong>new_hover(self, node, on_hover_callback)</strong>
|
||||
<strong>new_hover(self, node, on_hover_callback, on_mouse_hover_callback)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create <a href="../modules/Hover.html#">Hover</a> component
|
||||
@ -679,6 +640,10 @@ end
|
||||
<span class="types"><span class="type">function</span> or <span class="type">nil</span></span>
|
||||
Hover callback
|
||||
</li>
|
||||
<li><span class="parameter">on_mouse_hover_callback</span>
|
||||
<span class="types"><span class="type">function</span> or <span class="type">nil</span></span>
|
||||
Mouse hover callback
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
@ -772,7 +737,7 @@ end
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_layout"></a>
|
||||
<strong>new_layout(self, node, mode, on_size_changed_callback)</strong>
|
||||
<strong>new_layout(self, node, mode)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create <a href="../modules/Layout.html#">Layout</a> component
|
||||
@ -792,10 +757,6 @@ end
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
The layout mode
|
||||
</li>
|
||||
<li><span class="parameter">on_size_changed_callback</span>
|
||||
<span class="types"><span class="type">function</span> or <span class="type">nil</span></span>
|
||||
The callback on window resize
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
@ -1244,6 +1205,12 @@ end
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
True if component was removed
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
@ -151,10 +151,18 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
<td class="summary">Check if device is native mobile (Android or iOS)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#helper.is_multitouch_supported">helper.is_multitouch_supported()</a></td>
|
||||
<td class="summary">Check if device is mobile and can support multitouch</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#helper.is_web">helper.is_web()</a></td>
|
||||
<td class="summary">Check if device is HTML5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#helper.is_web_mobile">helper.is_web_mobile()</a></td>
|
||||
<td class="summary">Check if device is HTML5 mobile</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#helper.lerp">helper.lerp(a, b, t)</a></td>
|
||||
<td class="summary">Lerp between two values</td>
|
||||
</tr>
|
||||
@ -658,6 +666,26 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "helper.is_multitouch_supported"></a>
|
||||
<strong>helper.is_multitouch_supported()</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Check if device is mobile and can support multitouch
|
||||
|
||||
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
Is multitouch supported
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "helper.is_web"></a>
|
||||
@ -678,6 +706,26 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "helper.is_web_mobile"></a>
|
||||
<strong>helper.is_web_mobile()</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Check if device is HTML5 mobile
|
||||
|
||||
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
Is web mobile
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "helper.lerp"></a>
|
||||
|
@ -117,8 +117,12 @@
|
||||
<td class="summary">Visual node</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_change_state">on_change_state</a></td>
|
||||
<td class="summary">On change state callback(self, state)</td>
|
||||
<td class="name" nowrap><a href="#on_hotkey_pressed">on_hotkey_pressed</a></td>
|
||||
<td class="summary">On hotkey released callback(self, argument)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_hotkey_released">on_hotkey_released</a></td>
|
||||
<td class="summary">On hotkey released callback(self, argument)</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@ -320,15 +324,35 @@
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "on_change_state"></a>
|
||||
<strong>on_change_state</strong>
|
||||
<a name = "on_hotkey_pressed"></a>
|
||||
<strong>on_hotkey_pressed</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
On change state callback(self, state)
|
||||
On hotkey released callback(self, argument)
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">on_change_state</span>
|
||||
<li><span class="parameter">on_hotkey_pressed</span>
|
||||
<span class="types"><span class="type">DruidEvent</span></span>
|
||||
<a href="../modules/DruidEvent.html#">DruidEvent</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "on_hotkey_released"></a>
|
||||
<strong>on_hotkey_released</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
On hotkey released callback(self, argument)
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">on_hotkey_released</span>
|
||||
<span class="types"><span class="type">DruidEvent</span></span>
|
||||
<a href="../modules/DruidEvent.html#">DruidEvent</a>
|
||||
</li>
|
||||
|
@ -33,6 +33,7 @@
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
<li><a href="#Tables">Tables</a></li>
|
||||
<li><a href="#Fields">Fields</a></li>
|
||||
</ul>
|
||||
|
||||
@ -82,7 +83,7 @@
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, on_hover_callback)</a></td>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, on_hover_callback, on_mouse_hover)</a></td>
|
||||
<td class="summary">The <a href="../modules/Hover.html#">Hover</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -114,8 +115,19 @@
|
||||
<td class="summary">Set mouse hover state</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Tables">Tables</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#style">style</a></td>
|
||||
<td class="summary">Component style params.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Fields">Fields</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#node">node</a></td>
|
||||
<td class="summary">Hover node</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_hover">on_hover</a></td>
|
||||
<td class="summary">On hover callback(self, state, hover_instance)</td>
|
||||
@ -135,7 +147,7 @@
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, node, on_hover_callback)</strong>
|
||||
<strong>init(self, node, on_hover_callback, on_mouse_hover)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The <a href="../modules/Hover.html#">Hover</a> constructor
|
||||
@ -148,13 +160,17 @@
|
||||
<a href="../modules/Hover.html#">Hover</a>
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
<span class="types"><a class="type" href="../modules/Hover.html#node">node</a></span>
|
||||
Gui node
|
||||
</li>
|
||||
<li><span class="parameter">on_hover_callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
Hover callback
|
||||
</li>
|
||||
<li><span class="parameter">on_mouse_hover</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
On mouse hover callback
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@ -259,7 +275,7 @@
|
||||
<a href="../modules/Hover.html#">Hover</a>
|
||||
</li>
|
||||
<li><span class="parameter">zone</span>
|
||||
<span class="types"><span class="type">node</span>, <a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
<span class="types"><a class="type" href="../modules/Hover.html#node">node</a>, <a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Gui node
|
||||
</li>
|
||||
</ul>
|
||||
@ -345,11 +361,64 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "style"></a>
|
||||
<strong>style</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Component style params.
|
||||
You can override this component styles params in druid styles table
|
||||
or create your own style
|
||||
|
||||
|
||||
<h3>Fields:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">ON_HOVER_CURSOR</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
Mouse hover style on node hover
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">ON_MOUSE_HOVER_CURSOR</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
Mouse hover style on node mouse hover
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "node"></a>
|
||||
<strong>node</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Hover node
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><a class="type" href="../modules/Hover.html#node">node</a></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "on_hover"></a>
|
||||
<strong>on_hover</strong>
|
||||
|
@ -93,10 +93,18 @@
|
||||
<td class="summary">Return current input field text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_text_selected_replaced">get_text_selected_replaced(self, text)</a></td>
|
||||
<td class="summary">Replace selected text with new text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, click_node, text_node, keyboard_type)</a></td>
|
||||
<td class="summary">The <a href="../modules/Input.html#">Input</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#move_selection">move_selection(self, delta, is_add_to_selection, is_move_to_end)</a></td>
|
||||
<td class="summary">Change cursor position by delta</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#reset_changes">reset_changes(self)</a></td>
|
||||
<td class="summary">Reset current input selection and return previous value</td>
|
||||
</tr>
|
||||
@ -105,6 +113,10 @@
|
||||
<td class="summary">Select input field.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#select_cursor">select_cursor(self, cursor_index, start_index, end_index)</a></td>
|
||||
<td class="summary">Set cursor position in input field</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_allowed_characters">set_allowed_characters(self, characters)</a></td>
|
||||
<td class="summary">Set allowed charaters for input field.</td>
|
||||
</tr>
|
||||
@ -139,6 +151,18 @@
|
||||
<td class="summary">Button component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#current_value">current_value</a></td>
|
||||
<td class="summary">Current input value with marked text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#cursor_index">cursor_index</a></td>
|
||||
<td class="summary">The cursor index.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#end_index">end_index</a></td>
|
||||
<td class="summary">Theselection end index.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#is_empty">is_empty</a></td>
|
||||
<td class="summary">Is current input is empty now</td>
|
||||
</tr>
|
||||
@ -151,6 +175,14 @@
|
||||
<td class="summary">Gui keyboard type for input field</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#marked_text_width">marked_text_width</a></td>
|
||||
<td class="summary">Marked text width</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#marked_value">marked_value</a></td>
|
||||
<td class="summary">Marked text for input field.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#max_length">max_length</a></td>
|
||||
<td class="summary">Max length for input text</td>
|
||||
</tr>
|
||||
@ -164,7 +196,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_input_select">on_input_select</a></td>
|
||||
<td class="summary">On input field select callback(self, button_node)</td>
|
||||
<td class="summary">On input field select callback(self, input_instance)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_input_text">on_input_text</a></td>
|
||||
@ -172,16 +204,36 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_input_unselect">on_input_unselect</a></td>
|
||||
<td class="summary">On input field unselect callback(self, input_text)</td>
|
||||
<td class="summary">On input field unselect callback(self, input_text, input_instance)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_input_wrong">on_input_wrong</a></td>
|
||||
<td class="summary">On trying user input with not allowed character callback(self, params, button_instance)</td>
|
||||
<td class="summary">On trying user input with not allowed character callback(self, params, input_text)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_select_cursor_change">on_select_cursor_change</a></td>
|
||||
<td class="summary">On cursor position change callback(self, cursor_index, start_index, end_index)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#previous_value">previous_value</a></td>
|
||||
<td class="summary">Previous input value</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#start_index">start_index</a></td>
|
||||
<td class="summary">The selection start index.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#text">text</a></td>
|
||||
<td class="summary">Text component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#text_width">text_width</a></td>
|
||||
<td class="summary">Text width</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#value">value</a></td>
|
||||
<td class="summary">Current input value</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
@ -217,6 +269,37 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_text_selected_replaced"></a>
|
||||
<strong>get_text_selected_replaced(self, text)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Replace selected text with new text
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Input</span></span>
|
||||
<a href="../modules/Input.html#">Input</a>
|
||||
</li>
|
||||
<li><span class="parameter">text</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
The text to replace selected text
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
New input text
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
@ -250,6 +333,39 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "move_selection"></a>
|
||||
<strong>move_selection(self, delta, is_add_to_selection, is_move_to_end)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Change cursor position by delta
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Input</span></span>
|
||||
<a href="../modules/Input.html#">Input</a>
|
||||
</li>
|
||||
<li><span class="parameter">delta</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
side for cursor position, -1 for left, 1 for right
|
||||
</li>
|
||||
<li><span class="parameter">is_add_to_selection</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
(Shift key)
|
||||
</li>
|
||||
<li><span class="parameter">is_move_to_end</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
(Ctrl key)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "reset_changes"></a>
|
||||
@ -267,6 +383,12 @@
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">druid.input</span></span>
|
||||
Current input instance
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
@ -292,6 +414,45 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "select_cursor"></a>
|
||||
<strong>select_cursor(self, cursor_index, start_index, end_index)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set cursor position in input field
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Input</span></span>
|
||||
<a href="../modules/Input.html#">Input</a>
|
||||
</li>
|
||||
<li><span class="parameter">cursor_index</span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Cursor index for cursor position, if nil - will be set to the end of the text
|
||||
</li>
|
||||
<li><span class="parameter">start_index</span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Start index for cursor position, if nil - will be set to the end of the text
|
||||
</li>
|
||||
<li><span class="parameter">end_index</span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
End index for cursor position, if nil - will be set to the start_index
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">druid.input</span></span>
|
||||
Current input instance
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_allowed_characters"></a>
|
||||
@ -432,10 +593,6 @@
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
If true, call unselect on select selected input. Default: false
|
||||
</li>
|
||||
<li><span class="parameter">NO_CONSUME_INPUT_WHILE_SELECTED</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
If true, will not consume input while input is selected. It's allow to interact with other components while input is selected (text input still captured). Default: false
|
||||
</li>
|
||||
<li><span class="parameter">on_select</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
(self, button_node) Callback on input field selecting
|
||||
@ -502,6 +659,66 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "current_value"></a>
|
||||
<strong>current_value</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Current input value with marked text
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">current_value</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "cursor_index"></a>
|
||||
<strong>cursor_index</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The cursor index. The index of letter cursor after. Leftmost cursor - 0
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">cursor_index</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "end_index"></a>
|
||||
<strong>end_index</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Theselection end index. The index of letter cursor before. Rightmost selection - #text
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">end_index</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "is_empty"></a>
|
||||
@ -562,6 +779,46 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "marked_text_width"></a>
|
||||
<strong>marked_text_width</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Marked text width
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">marked_text_width</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "marked_value"></a>
|
||||
<strong>marked_value</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Marked text for input field. Info: https://defold.com/manuals/input-key-and-text/#marked-text
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">marked_value</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "max_length"></a>
|
||||
@ -628,7 +885,7 @@
|
||||
<strong>on_input_select</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
On input field select callback(self, button_node)
|
||||
On input field select callback(self, input_instance)
|
||||
|
||||
|
||||
<ul>
|
||||
@ -668,7 +925,7 @@
|
||||
<strong>on_input_unselect</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
On input field unselect callback(self, input_text)
|
||||
On input field unselect callback(self, input_text, input_instance)
|
||||
|
||||
|
||||
<ul>
|
||||
@ -688,7 +945,7 @@
|
||||
<strong>on_input_wrong</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
On trying user input with not allowed character callback(self, params, button_instance)
|
||||
On trying user input with not allowed character callback(self, params, input_text)
|
||||
|
||||
|
||||
<ul>
|
||||
@ -702,6 +959,66 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "on_select_cursor_change"></a>
|
||||
<strong>on_select_cursor_change</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
On cursor position change callback(self, cursor_index, start_index, end_index)
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">on_select_cursor_change</span>
|
||||
<span class="types"><span class="type">DruidEvent</span></span>
|
||||
<a href="../modules/DruidEvent.html#">DruidEvent</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "previous_value"></a>
|
||||
<strong>previous_value</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Previous input value
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">previous_value</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "start_index"></a>
|
||||
<strong>start_index</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The selection start index. The index of letter cursor after. Leftmost selection - 0
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">start_index</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "text"></a>
|
||||
@ -722,6 +1039,46 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "text_width"></a>
|
||||
<strong>text_width</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Text width
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">text_width</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "value"></a>
|
||||
<strong>value</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Current input value
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">value</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
@ -32,7 +32,6 @@
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
<li><a href="#Fields">Fields</a></li>
|
||||
</ul>
|
||||
|
||||
@ -79,45 +78,6 @@
|
||||
<p> <a href="https://insality.github.io/druid/druid/index.html?example=general_layout" target="_blank"><b>Example Link</b></a></p>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#fit_into_node">fit_into_node(self, node)</a></td>
|
||||
<td class="summary">Set node for layout node to fit inside it.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#fit_into_size">fit_into_size(self, target_size)</a></td>
|
||||
<td class="summary">Set size for layout node to fit inside it</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#fit_into_window">fit_into_window(self)</a></td>
|
||||
<td class="summary">Set current size for layout node to fit inside it</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, mode, on_size_changed_callback)</a></td>
|
||||
<td class="summary">The <a href="../modules/Layout.html#">Layout</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_max_gui_upscale">set_max_gui_upscale(self, max_gui_upscale)</a></td>
|
||||
<td class="summary">Set max gui upscale for FIT adjust mode (or side).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_max_size">set_max_size(self, max_size)</a></td>
|
||||
<td class="summary">Set maximum size of layout node</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_min_size">set_min_size(self, min_size)</a></td>
|
||||
<td class="summary">Set minimal size of layout node</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_origin_position">set_origin_position(self, new_origin_position)</a></td>
|
||||
<td class="summary">Set new origin position of layout node.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_origin_size">set_origin_size(self, new_origin_size)</a></td>
|
||||
<td class="summary">Set new origin size of layout node.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Fields">Fields</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
@ -128,297 +88,12 @@
|
||||
<td class="name" nowrap><a href="#node">node</a></td>
|
||||
<td class="summary">Layout node</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_size_changed">on_size_changed</a></td>
|
||||
<td class="summary">On window resize callback(self, new_size)</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "fit_into_node"></a>
|
||||
<strong>fit_into_node(self, node)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set node for layout node to fit inside it. Pass nil to reset
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><a class="type" href="../modules/Layout.html#node">node</a> or <span class="type">nil</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "fit_into_size"></a>
|
||||
<strong>fit_into_size(self, target_size)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set size for layout node to fit inside it
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</li>
|
||||
<li><span class="parameter">target_size</span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "fit_into_window"></a>
|
||||
<strong>fit_into_window(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set current size for layout node to fit inside it
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, node, mode, on_size_changed_callback)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The <a href="../modules/Layout.html#">Layout</a> constructor
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><a class="type" href="../modules/Layout.html#node">node</a></span>
|
||||
Gui node
|
||||
</li>
|
||||
<li><span class="parameter">mode</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
The layout mode (from const.LAYOUT_MODE)
|
||||
</li>
|
||||
<li><span class="parameter">on_size_changed_callback</span>
|
||||
<span class="types"><span class="type">function</span> or <span class="type">nil</span></span>
|
||||
The callback on window resize
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_max_gui_upscale"></a>
|
||||
<strong>set_max_gui_upscale(self, max_gui_upscale)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set max gui upscale for FIT adjust mode (or side). It happens on bigger render gui screen
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</li>
|
||||
<li><span class="parameter">max_gui_upscale</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_max_size"></a>
|
||||
<strong>set_max_size(self, max_size)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set maximum size of layout node
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</li>
|
||||
<li><span class="parameter">max_size</span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_min_size"></a>
|
||||
<strong>set_min_size(self, min_size)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set minimal size of layout node
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</li>
|
||||
<li><span class="parameter">min_size</span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_origin_position"></a>
|
||||
<strong>set_origin_position(self, new_origin_position)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set new origin position of layout node. You should apply this on node movement
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</li>
|
||||
<li><span class="parameter">new_origin_position</span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_origin_size"></a>
|
||||
<strong>set_origin_size(self, new_origin_size)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set new origin size of layout node. You should apply this on node manual size change
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</li>
|
||||
<li><span class="parameter">new_origin_size</span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
|
||||
|
||||
<dl class="function">
|
||||
@ -461,26 +136,6 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "on_size_changed"></a>
|
||||
<strong>on_size_changed</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
On window resize callback(self, new_size)
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">on_size_changed</span>
|
||||
<span class="types"><span class="type">DruidEvent</span></span>
|
||||
<a href="../modules/DruidEvent.html#">DruidEvent</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
@ -84,20 +84,32 @@
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_text">get_text(self)</a></td>
|
||||
<td class="summary">GSet input field text</td>
|
||||
<td class="summary">Set input field text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, template, nodes)</a></td>
|
||||
<td class="summary">The <a href="../modules/RichInput.html#">RichInput</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#select">select(self)</a></td>
|
||||
<td class="summary">Select input field</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_allowed_characters">set_allowed_characters(self, characters)</a></td>
|
||||
<td class="summary">Set allowed charaters for input field.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_font">set_font(self, font)</a></td>
|
||||
<td class="summary">Set input field font</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_placeholder">set_placeholder(self, placeholder_text)</a></td>
|
||||
<td class="summary">Set placeholder text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_text">set_text(self, text)</a></td>
|
||||
<td class="summary">Set input field text</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Fields">Fields</a></h2>
|
||||
<table class="function_list">
|
||||
@ -135,7 +147,7 @@
|
||||
<strong>get_text(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
GSet input field text
|
||||
Set input field text
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@ -146,12 +158,6 @@
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
Current input text
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
@ -185,6 +191,27 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "select"></a>
|
||||
<strong>select(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Select input field
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">RichInput</span></span>
|
||||
<a href="../modules/RichInput.html#">RichInput</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_allowed_characters"></a>
|
||||
@ -218,6 +245,37 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_font"></a>
|
||||
<strong>set_font(self, font)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set input field font
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">RichInput</span></span>
|
||||
<a href="../modules/RichInput.html#">RichInput</a>
|
||||
</li>
|
||||
<li><span class="parameter">font</span>
|
||||
<span class="types"><span class="type">hash</span></span>
|
||||
The font hash
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">druid.input</span></span>
|
||||
Current input instance
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_placeholder"></a>
|
||||
@ -234,16 +292,41 @@
|
||||
<a href="../modules/RichInput.html#">RichInput</a>
|
||||
</li>
|
||||
<li><span class="parameter">placeholder_text</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
The placeholder text
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_text"></a>
|
||||
<strong>set_text(self, text)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set input field text
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">RichInput</span></span>
|
||||
<a href="../modules/RichInput.html#">RichInput</a>
|
||||
</li>
|
||||
<li><span class="parameter">text</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
The input text
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">RichInput</span></span>
|
||||
Current instance
|
||||
<span class="types"><span class="type">druid.input</span></span>
|
||||
Current input instance
|
||||
</ol>
|
||||
|
||||
|
||||
|
@ -150,6 +150,10 @@ type druid.rich_text.metrics = {
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#characters">characters(self, word)</a></td>
|
||||
<td class="summary">Split a word into it's characters</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#clear">clear()</a></td>
|
||||
<td class="summary">Clear all created words.</td>
|
||||
@ -159,11 +163,15 @@ type druid.rich_text.metrics = {
|
||||
<td class="summary">Get current line metrics</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_text">get_text(self)</a></td>
|
||||
<td class="summary">Get current text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_words">get_words()</a></td>
|
||||
<td class="summary">Get all current words.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, template, nodes)</a></td>
|
||||
<td class="name" nowrap><a href="#init">init(self, text_node, value)</a></td>
|
||||
<td class="summary">The <a href="../modules/RichText.html#">RichText</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -171,7 +179,7 @@ type druid.rich_text.metrics = {
|
||||
<td class="summary">Set text for Rich Text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#tagged">tagged(tag)</a></td>
|
||||
<td class="name" nowrap><a href="#tagged">tagged(self, tag)</a></td>
|
||||
<td class="summary">Get all words, which has a passed tag.</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -188,6 +196,18 @@ type druid.rich_text.metrics = {
|
||||
<td class="name" nowrap><a href="#druid">druid</a></td>
|
||||
<td class="summary">The component druid instance</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#icon_prefab">icon_prefab</a></td>
|
||||
<td class="summary">The icon prefab node</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#root">root</a></td>
|
||||
<td class="summary">The root node of the Rich Text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#text_prefab">text_prefab</a></td>
|
||||
<td class="summary">The text prefab node</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
@ -197,6 +217,37 @@ type druid.rich_text.metrics = {
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "characters"></a>
|
||||
<strong>characters(self, word)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Split a word into it's characters
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">RichText</span></span>
|
||||
<a href="../modules/RichText.html#">RichText</a>
|
||||
</li>
|
||||
<li><span class="parameter">word</span>
|
||||
<span class="types"><span class="type">druid.rich_text.word</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">druid.rich_text.word[]</span></span>
|
||||
characters
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "clear"></a>
|
||||
<strong>clear()</strong>
|
||||
@ -230,6 +281,33 @@ type druid.rich_text.metrics = {
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_text"></a>
|
||||
<strong>get_text(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Get current text
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">RichText</span></span>
|
||||
<a href="../modules/RichText.html#">RichText</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
text
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_words"></a>
|
||||
@ -253,7 +331,7 @@ type druid.rich_text.metrics = {
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, template, nodes)</strong>
|
||||
<strong>init(self, text_node, value)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The <a href="../modules/RichText.html#">RichText</a> constructor
|
||||
@ -265,13 +343,13 @@ type druid.rich_text.metrics = {
|
||||
<span class="types"><span class="type">RichText</span></span>
|
||||
<a href="../modules/RichText.html#">RichText</a>
|
||||
</li>
|
||||
<li><span class="parameter">template</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
The Rich Text template name
|
||||
<li><span class="parameter">text_node</span>
|
||||
<span class="types"><span class="type">node</span> or <a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
The text node to make Rich Text
|
||||
</li>
|
||||
<li><span class="parameter">nodes</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
||||
The node table, if prefab was copied by gui.clone_tree()
|
||||
<li><span class="parameter">value</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
The initial text value. Default will be gui.get_text(text_node)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@ -295,7 +373,7 @@ type druid.rich_text.metrics = {
|
||||
<a href="../modules/RichText.html#">RichText</a>
|
||||
</li>
|
||||
<li><span class="parameter">text</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
The text to set
|
||||
</li>
|
||||
</ul>
|
||||
@ -361,7 +439,7 @@ Words <nobr>inside tag</nobr> won't <span class="keyword">break</spa
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "tagged"></a>
|
||||
<strong>tagged(tag)</strong>
|
||||
<strong>tagged(self, tag)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Get all words, which has a passed tag.
|
||||
@ -369,6 +447,10 @@ Words <nobr>inside tag</nobr> won't <span class="keyword">break</spa
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">RichText</span></span>
|
||||
<a href="../modules/RichText.html#">RichText</a>
|
||||
</li>
|
||||
<li><span class="parameter">tag</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
|
||||
@ -444,6 +526,66 @@ Words <nobr>inside tag</nobr> won't <span class="keyword">break</spa
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "icon_prefab"></a>
|
||||
<strong>icon_prefab</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The icon prefab node
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">icon_prefab</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "root"></a>
|
||||
<strong>root</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The root node of the Rich Text
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">root</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "text_prefab"></a>
|
||||
<strong>text_prefab</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The text prefab node
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">text_prefab</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
@ -167,6 +167,14 @@
|
||||
<td class="name" nowrap><a href="#set_vertical_scroll">set_vertical_scroll(self, state)</a></td>
|
||||
<td class="summary">Lock or unlock vertical scroll</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_view_size">set_view_size(self, size)</a></td>
|
||||
<td class="summary">Set new scroll view size in case the node size was changed.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#update_view_size">update_view_size(self)</a></td>
|
||||
<td class="summary">Refresh scroll view size</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Tables">Tables</a></h2>
|
||||
<table class="function_list">
|
||||
@ -233,6 +241,10 @@
|
||||
<td class="name" nowrap><a href="#view_node">view_node</a></td>
|
||||
<td class="summary">Scroll view node</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#view_size">view_size</a></td>
|
||||
<td class="summary">Scroll view size</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
@ -733,6 +745,58 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_view_size"></a>
|
||||
<strong>set_view_size(self, size)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set new scroll view size in case the node size was changed.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Scroll</span></span>
|
||||
<a href="../modules/Scroll.html#">Scroll</a>
|
||||
</li>
|
||||
<li><span class="parameter">size</span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
The new size for view node
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">druid.scroll</span></span>
|
||||
Current scroll instance
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "update_view_size"></a>
|
||||
<strong>update_view_size(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Refresh scroll view size
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Scroll</span></span>
|
||||
<a href="../modules/Scroll.html#">Scroll</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
|
||||
@ -819,7 +883,7 @@
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">_is_inert</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
@ -1088,6 +1152,26 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "view_size"></a>
|
||||
<strong>view_size</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Scroll view size
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">view_size</span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
@ -86,10 +86,18 @@
|
||||
<td class="summary">The <a href="../modules/Slider.html#">Slider</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#is_enabled">is_enabled(self)</a></td>
|
||||
<td class="summary">Check if Slider component is enabled</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set">set(self, value, is_silent)</a></td>
|
||||
<td class="summary">Set value for slider</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_enabled">set_enabled(self, is_enabled)</a></td>
|
||||
<td class="summary">Set Slider input enabled or disabled</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_input_node">set_input_node(self, input_node)</a></td>
|
||||
<td class="summary">Set input zone for slider.</td>
|
||||
</tr>
|
||||
@ -177,6 +185,33 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "is_enabled"></a>
|
||||
<strong>is_enabled(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Check if Slider component is enabled
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Slider</span></span>
|
||||
<a href="../modules/Slider.html#">Slider</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set"></a>
|
||||
@ -206,6 +241,31 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_enabled"></a>
|
||||
<strong>set_enabled(self, is_enabled)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set Slider input enabled or disabled
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Slider</span></span>
|
||||
<a href="../modules/Slider.html#">Slider</a>
|
||||
</li>
|
||||
<li><span class="parameter">is_enabled</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_input_node"></a>
|
||||
@ -291,7 +351,7 @@
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">dist</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -154,9 +154,21 @@
|
||||
<td class="summary">Set new in_row elements for grid</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_item_size">set_item_size(self[, width[, height]])</a></td>
|
||||
<td class="summary">Set new node size for grid</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_items">set_items(self, nodes[, is_instant=false])</a></td>
|
||||
<td class="summary">Set new items to the grid.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_position_function">set_position_function(self, callback)</a></td>
|
||||
<td class="summary">Change set position function for grid nodes.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#sort_nodes">sort_nodes(self, comparator)</a></td>
|
||||
<td class="summary">Sort grid nodes by custom comparator function</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Tables">Tables</a></h2>
|
||||
<table class="function_list">
|
||||
@ -621,6 +633,73 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_item_size"></a>
|
||||
<strong>set_item_size(self[, width[, height]])</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set new node size for grid
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">StaticGrid</span></span>
|
||||
<a href="../modules/StaticGrid.html#">StaticGrid</a>
|
||||
</li>
|
||||
<li><span class="parameter">width</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
The new node width
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">height</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
The new node height
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">druid.static_grid</span></span>
|
||||
Current grid instance
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_items"></a>
|
||||
<strong>set_items(self, nodes[, is_instant=false])</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set new items to the grid. All previous items will be removed
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">StaticGrid</span></span>
|
||||
<a href="../modules/StaticGrid.html#">StaticGrid</a>
|
||||
</li>
|
||||
<li><span class="parameter">nodes</span>
|
||||
<span class="types"><span class="type">node[]</span></span>
|
||||
The new grid nodes
|
||||
</li>
|
||||
<li><span class="parameter">is_instant</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
If true, update node positions instantly
|
||||
(<em>default</em> false)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_position_function"></a>
|
||||
@ -653,6 +732,37 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "sort_nodes"></a>
|
||||
<strong>sort_nodes(self, comparator)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Sort grid nodes by custom comparator function
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">StaticGrid</span></span>
|
||||
<a href="../modules/StaticGrid.html#">StaticGrid</a>
|
||||
</li>
|
||||
<li><span class="parameter">comparator</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
The comparator function. (a, b) -> boolean
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">druid.static_grid</span></span>
|
||||
Current grid instance
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
|
||||
|
@ -105,6 +105,10 @@
|
||||
<td class="summary">Return current text adjust type</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_text_index_by_width">get_text_index_by_width(self, width)</a></td>
|
||||
<td class="summary">Get chars count by width</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_text_size">get_text_size(self, text)</a></td>
|
||||
<td class="summary">Calculate text width with font with respect to trailing space</td>
|
||||
</tr>
|
||||
@ -247,6 +251,37 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_text_index_by_width"></a>
|
||||
<strong>get_text_index_by_width(self, width)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Get chars count by width
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Text</span></span>
|
||||
<a href="../modules/Text.html#">Text</a>
|
||||
</li>
|
||||
<li><span class="parameter">width</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Chars count
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_text_size"></a>
|
||||
@ -263,8 +298,8 @@
|
||||
<a href="../modules/Text.html#">Text</a>
|
||||
</li>
|
||||
<li><span class="parameter">text</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
|nil
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@ -302,11 +337,11 @@
|
||||
</li>
|
||||
<li><span class="parameter">value</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Initial text. Default value is node text from GUI scene.
|
||||
Initial text. Default value is node text from GUI scene. Default: nil
|
||||
</li>
|
||||
<li><span class="parameter">adjust_type</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference. Default: downscale
|
||||
Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference. Default: DOWNSCALE
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@ -618,6 +653,14 @@
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
The default adjust type for any text component. Default: DOWNSCALE
|
||||
</li>
|
||||
<li><span class="parameter">ADJUST_STEPS</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Amount of iterations for text adjust by height. Default: 20
|
||||
</li>
|
||||
<li><span class="parameter">ADJUST_SCALE_DELTA</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Scale step on each height adjust step. Default: 0.02
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
@ -158,7 +158,7 @@
|
||||
Gui text node
|
||||
</li>
|
||||
<li><span class="parameter">seconds_from</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Start timer value in seconds
|
||||
</li>
|
||||
<li><span class="parameter">seconds_to</span>
|
||||
|
95
docs/modules/druid.extended.layout.html
Normal file
95
docs/modules/druid.extended.layout.html
Normal file
@ -0,0 +1,95 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>Defold Druid UI Framework</title>
|
||||
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>Druid</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
|
||||
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
|
||||
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
|
||||
<li><a href="../modules/Helper.html">Helper</a></li>
|
||||
<li><a href="../modules/Hotkey.html">Hotkey</a></li>
|
||||
<li><a href="../modules/Hover.html">Hover</a></li>
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
<li><a href="../modules/Slider.html">Slider</a></li>
|
||||
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
|
||||
<li><a href="../modules/Swipe.html">Swipe</a></li>
|
||||
<li><a href="../modules/Text.html">Text</a></li>
|
||||
<li><a href="../modules/Timer.html">Timer</a></li>
|
||||
<li><strong>druid.extended.layout</strong></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>druid.extended.layout</code></h1>
|
||||
<p>Druid layout module
|
||||
<p> <b># Overview #</b>
|
||||
<p> Layout component works like Dynamic Grid before - for aligning elements in a row or column.</p>
|
||||
<p> Works like a Figma layout.
|
||||
<p> <b># Notes</p>
|
||||
|
||||
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc TESTING</a></i>
|
||||
<i style="float:right;">Last updated 2015-01-01 12:00:00 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
93
docs/modules/druid.system.utf8.html
Normal file
93
docs/modules/druid.system.utf8.html
Normal file
@ -0,0 +1,93 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>Defold Druid UI Framework</title>
|
||||
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>Druid</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
|
||||
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
|
||||
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
|
||||
<li><a href="../modules/Helper.html">Helper</a></li>
|
||||
<li><a href="../modules/Hotkey.html">Hotkey</a></li>
|
||||
<li><a href="../modules/Hover.html">Hover</a></li>
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
<li><a href="../modules/Slider.html">Slider</a></li>
|
||||
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
|
||||
<li><a href="../modules/Swipe.html">Swipe</a></li>
|
||||
<li><a href="../modules/Text.html">Text</a></li>
|
||||
<li><a href="../modules/Timer.html">Timer</a></li>
|
||||
<li><strong>druid.system.utf8</strong></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>druid.system.utf8</code></h1>
|
||||
<p></p>
|
||||
<p></p>
|
||||
|
||||
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc TESTING</a></i>
|
||||
<i style="float:right;">Last updated 2015-01-01 12:00:00 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
@ -17,18 +17,11 @@ local component = require("druid.component")
|
||||
---@class component_name: druid.base_component
|
||||
local Component = component.create("component_name")
|
||||
|
||||
local SCHEME = {
|
||||
ROOT = "root",
|
||||
BUTTON = "button",
|
||||
}
|
||||
|
||||
function Component:init(template, nodes)
|
||||
self:set_template(template)
|
||||
self:set_nodes(nodes)
|
||||
self.root = self:get_node(SCHEME.ROOT)
|
||||
self.druid = self:get_druid()
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
self.root = self:get_node("root")
|
||||
|
||||
self.button = self.druid:new_button(SCHEME.BUTTON, function() end)
|
||||
self.button = self.druid:new_button("button", function() end)
|
||||
end
|
||||
|
||||
function Component:on_remove() end
|
||||
@ -45,16 +38,10 @@ local component = require("druid.component")
|
||||
|
||||
---@class component_name: druid.base_component
|
||||
local Component = component.create("component_name")
|
||||
local SCHEME = {
|
||||
ROOT = "root",
|
||||
BUTTON = "button",
|
||||
}
|
||||
|
||||
function Component:init(template, nodes)
|
||||
self:set_template(template)
|
||||
self:set_nodes(nodes)
|
||||
self.root = self:get_node(SCHEME.ROOT)
|
||||
self.druid = self:get_druid()
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
self.root = self:get_node("root")
|
||||
end
|
||||
|
||||
function Component:update(dt) end
|
||||
@ -92,7 +79,7 @@ local my_component = require("my.amazing.component")
|
||||
|
||||
function init(self)
|
||||
self.druid = druid.new(self)
|
||||
self.druid:new(my_component, "template_name", nodes)
|
||||
self.druid:new(my_component, "template_name")
|
||||
end
|
||||
```
|
||||
|
||||
@ -107,6 +94,7 @@ local druid = require("druid.druid")
|
||||
local my_component = require("my.amazing.component")
|
||||
|
||||
function init(self)
|
||||
-- Register makes a "druid:new_{component_name}" function available
|
||||
druid.register("my_component", my_component)
|
||||
end
|
||||
```
|
||||
@ -149,33 +137,6 @@ Available keywords:
|
||||
|
||||
uid Timer](01-components.md#timer) component.
|
||||
|
||||
## Best Practices for Custom Components
|
||||
|
||||
When working with each component, it's recommended to describe the component scheme in the following way:
|
||||
|
||||
```lua
|
||||
-- Component module
|
||||
local component = require("druid.component")
|
||||
|
||||
local M = component.create("your_component")
|
||||
|
||||
local SCHEME = {
|
||||
ROOT = "root",
|
||||
ITEM = "item",
|
||||
TITLE = "title"
|
||||
}
|
||||
|
||||
function M.init(self, template_name, node_table)
|
||||
self:set_template(template_name)
|
||||
self:set_nodes(node_table)
|
||||
|
||||
local root = self:get_node(SCHEME.ROOT)
|
||||
local druid = self:get_druid()
|
||||
|
||||
-- Create components inside this component using the inner druid instance
|
||||
end
|
||||
```
|
||||
|
||||
## The Power of Using Templates
|
||||
|
||||
With Druid, you can use a single component but create and customize templates for it. Templates only need to match the component scheme. For example, you can have a component named `player_panel` and two GUI templates named `player_panel` and `enemy_panel` with different layouts. The same component script can be used for both templates.
|
||||
|
@ -367,6 +367,12 @@ function druid__data_list.scroll_to_index(self, index) end
|
||||
---@return druid.data_list Current DataList instance
|
||||
function druid__data_list.set_data(self, data) end
|
||||
|
||||
--- Set refresh function for DataList component
|
||||
---@param self druid.data_list @{DataList}
|
||||
---@param is_use_cache boolean Use cache version of DataList. Requires make setup of components in on_element_add callback and clean in on_element_remove
|
||||
---@return druid.data_list Current DataList instance
|
||||
function druid__data_list.set_use_cache(self, is_use_cache) end
|
||||
|
||||
|
||||
---@class druid.drag : druid.base_component
|
||||
---@field can_x boolean Is drag component process vertical dragging.
|
||||
@ -374,8 +380,8 @@ function druid__data_list.set_data(self, data) end
|
||||
---@field is_drag boolean Is component now dragging
|
||||
---@field is_touch boolean Is component now touching
|
||||
---@field node node Drag node
|
||||
---@field on_drag druid.event on drag progress callback(self, dx, dy, total_x, total_y)
|
||||
---@field on_drag_end druid.event Event on drag end callback(self, total_x, total_y)
|
||||
---@field on_drag druid.event on drag progress callback(self, dx, dy, total_x, total_y, touch)
|
||||
---@field on_drag_end druid.event Event on drag end callback(self, total_x, total_y, touch)
|
||||
---@field on_drag_start druid.event Event on drag start callback(self, touch)
|
||||
---@field on_touch_end druid.event Event on touch end callback(self)
|
||||
---@field on_touch_start druid.event Event on touch start callback(self)
|
||||
@ -559,7 +565,8 @@ function druid__event.unsubscribe(self, callback, callback_context) end
|
||||
---@field button druid.button Button component from click_node
|
||||
---@field click_node node|nil Button trigger node
|
||||
---@field node node Visual node
|
||||
---@field on_change_state druid.event On change state callback(self, state)
|
||||
---@field on_hotkey_pressed druid.event On hotkey released callback(self, argument)
|
||||
---@field on_hotkey_released druid.event On hotkey released callback(self, argument)
|
||||
---@field style druid.hotkey.style Component style params.
|
||||
local druid__hotkey = {}
|
||||
|
||||
@ -803,67 +810,8 @@ function druid__lang_text.translate(self, locale_id, a, b, c, d, e, f, g) end
|
||||
---@class druid.layout : druid.base_component
|
||||
---@field mode string Current layout mode
|
||||
---@field node node Layout node
|
||||
---@field on_size_changed druid.event On window resize callback(self, new_size)
|
||||
local druid__layout = {}
|
||||
|
||||
--- Set node for layout node to fit inside it.
|
||||
--- Pass nil to reset
|
||||
---@param self druid.layout @{Layout}
|
||||
---@param node node|nil
|
||||
---@return druid.layout @{Layout}
|
||||
function druid__layout.fit_into_node(self, node) end
|
||||
|
||||
--- Set size for layout node to fit inside it
|
||||
---@param self druid.layout @{Layout}
|
||||
---@param target_size vector3
|
||||
---@return druid.layout @{Layout}
|
||||
function druid__layout.fit_into_size(self, target_size) end
|
||||
|
||||
--- Set current size for layout node to fit inside it
|
||||
---@param self druid.layout @{Layout}
|
||||
---@return druid.layout @{Layout}
|
||||
function druid__layout.fit_into_window(self) end
|
||||
|
||||
--- The @{Layout} constructor
|
||||
---@param self druid.layout @{Layout}
|
||||
---@param node node Gui node
|
||||
---@param mode string The layout mode (from const.LAYOUT_MODE)
|
||||
---@param on_size_changed_callback function|nil The callback on window resize
|
||||
function druid__layout.init(self, node, mode, on_size_changed_callback) end
|
||||
|
||||
--- Set max gui upscale for FIT adjust mode (or side).
|
||||
--- It happens on bigger render gui screen
|
||||
---@param self druid.layout @{Layout}
|
||||
---@param max_gui_upscale number
|
||||
---@return druid.layout @{Layout}
|
||||
function druid__layout.set_max_gui_upscale(self, max_gui_upscale) end
|
||||
|
||||
--- Set maximum size of layout node
|
||||
---@param self druid.layout @{Layout}
|
||||
---@param max_size vector3
|
||||
---@return druid.layout @{Layout}
|
||||
function druid__layout.set_max_size(self, max_size) end
|
||||
|
||||
--- Set minimal size of layout node
|
||||
---@param self druid.layout @{Layout}
|
||||
---@param min_size vector3
|
||||
---@return druid.layout @{Layout}
|
||||
function druid__layout.set_min_size(self, min_size) end
|
||||
|
||||
--- Set new origin position of layout node.
|
||||
--- You should apply this on node movement
|
||||
---@param self druid.layout @{Layout}
|
||||
---@param new_origin_position vector3
|
||||
---@return druid.layout @{Layout}
|
||||
function druid__layout.set_origin_position(self, new_origin_position) end
|
||||
|
||||
--- Set new origin size of layout node.
|
||||
--- You should apply this on node manual size change
|
||||
---@param self druid.layout @{Layout}
|
||||
---@param new_origin_size vector3
|
||||
---@return druid.layout @{Layout}
|
||||
function druid__layout.set_origin_size(self, new_origin_size) end
|
||||
|
||||
|
||||
---@class druid.pin_knob : druid.base_component
|
||||
---@field druid druid_instance The component druid instance
|
||||
@ -1056,9 +1004,9 @@ function druid__rich_text.get_words() end
|
||||
|
||||
--- The @{RichText} constructor
|
||||
---@param self druid.rich_text @{RichText}
|
||||
---@param template string The Rich Text template name
|
||||
---@param nodes table The node table, if prefab was copied by gui.clone_tree()
|
||||
function druid__rich_text.init(self, template, nodes) end
|
||||
---@param text_node node|string The text node to make Rich Text
|
||||
---@param value string|nil The initial text value. Default will be gui.get_text(text_node)
|
||||
function druid__rich_text.init(self, text_node, value) end
|
||||
|
||||
--- Set text for Rich Text
|
||||
---@param self druid.rich_text @{RichText}
|
||||
@ -1097,6 +1045,7 @@ local druid__rich_text__style = {}
|
||||
---@field style druid.scroll.style Component style params.
|
||||
---@field target_position vector3 Current scroll target position
|
||||
---@field view_node node Scroll view node
|
||||
---@field view_size vector3 Scroll view size
|
||||
local druid__scroll = {}
|
||||
|
||||
--- Bind the grid component (Static or Dynamic) to recalculate scroll size on grid changes
|
||||
@ -1205,6 +1154,10 @@ function druid__scroll.set_vertical_scroll(self, state) end
|
||||
---@return druid.scroll Current scroll instance
|
||||
function druid__scroll.set_view_size(self, size) end
|
||||
|
||||
--- Refresh scroll view size
|
||||
---@param self druid.scroll @{Scroll}
|
||||
function druid__scroll.update_view_size(self) end
|
||||
|
||||
|
||||
---@class druid.scroll.style
|
||||
---@field ANIM_SPEED number|nil Scroll gui.animation speed for scroll_to function. Default: 2
|
||||
@ -1550,7 +1503,7 @@ local druid__timer = {}
|
||||
--- The @{Timer} constructor
|
||||
---@param self druid.timer @{Timer}
|
||||
---@param node node Gui text node
|
||||
---@param seconds_from number Start timer value in seconds
|
||||
---@param seconds_from number|nil Start timer value in seconds
|
||||
---@param seconds_to number|nil End timer value in seconds
|
||||
---@param callback function|nil Function on timer end
|
||||
function druid__timer.init(self, node, seconds_from, seconds_to, callback) end
|
||||
@ -1579,14 +1532,6 @@ local druid_instance = {}
|
||||
---@param self druid_instance
|
||||
function druid_instance.final(self) end
|
||||
|
||||
--- Create new component.
|
||||
---@generic T
|
||||
---@param self druid_instance
|
||||
---@param component T Component module
|
||||
---@param ... any Other component params to pass it to component:init function
|
||||
---@return T Component instance
|
||||
function druid_instance.new(self, component, ...) end
|
||||
|
||||
--- Create @{BackHandler} component
|
||||
---@param self druid_instance
|
||||
---@param callback function|nil @The callback(self, custom_args) to call on back event
|
||||
@ -1683,9 +1628,8 @@ function druid_instance.new_lang_text(self, node, locale_id, adjust_type) end
|
||||
---@param self druid_instance
|
||||
---@param node string|node The_node id or gui.get_node(node_id).
|
||||
---@param mode string The layout mode
|
||||
---@param on_size_changed_callback function|nil The callback on window resize
|
||||
---@return druid.layout @{Layout} component
|
||||
function druid_instance.new_layout(self, node, mode, on_size_changed_callback) end
|
||||
function druid_instance.new_layout(self, node, mode) end
|
||||
|
||||
--- Create @{Progress} component
|
||||
---@param self druid_instance
|
||||
@ -1752,7 +1696,7 @@ function druid_instance.new_text(self, node, value, no_adjust) end
|
||||
--- Create @{Timer} component
|
||||
---@param self druid_instance
|
||||
---@param node string|node Gui text node
|
||||
---@param seconds_from number|nil Start timer value in seconds
|
||||
---@param seconds_from number Start timer value in seconds
|
||||
---@param seconds_to number|nil End timer value in seconds
|
||||
---@param callback function|nil Function on timer end
|
||||
---@return druid.timer @{Timer} component
|
||||
@ -2021,3 +1965,22 @@ function helper.table_to_string(t) end
|
||||
---@field height number
|
||||
---@field max_ascent number
|
||||
---@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
|
||||
|
||||
|
||||
---Add generics to some functions.
|
||||
|
||||
---Create new component.
|
||||
---@generic T: druid.base_component
|
||||
---@param self druid_instance
|
||||
---@param component T Component module
|
||||
---@param ... any Other component params to pass it to component:init function
|
||||
---@return T Component instance
|
||||
function druid_instance.new(self, component, ...) end
|
@ -344,10 +344,6 @@ function Button.on_input(self, action_id, action)
|
||||
return false
|
||||
end
|
||||
|
||||
if not self:is_enabled() then
|
||||
return false
|
||||
end
|
||||
|
||||
local is_consume = true
|
||||
local is_pick = true
|
||||
local is_key_trigger = (action_id == self.key_trigger)
|
||||
|
@ -22,10 +22,10 @@
|
||||
--- Event on drag start callback(self, touch)
|
||||
-- @tfield DruidEvent on_drag_start @{DruidEvent}
|
||||
|
||||
--- on drag progress callback(self, dx, dy, total_x, total_y)
|
||||
--- on drag progress callback(self, dx, dy, total_x, total_y, touch)
|
||||
-- @tfield DruidEvent on_drag Event @{DruidEvent}
|
||||
|
||||
--- Event on drag end callback(self, total_x, total_y)
|
||||
--- Event on drag end callback(self, total_x, total_y, touch)
|
||||
-- @tfield DruidEvent on_drag_end @{DruidEvent}
|
||||
|
||||
--- Is component now touching
|
||||
|
@ -50,6 +50,9 @@
|
||||
--- Scroll view node
|
||||
-- @tfield node view_node
|
||||
|
||||
--- Scroll view size
|
||||
-- @tfield vector3 view_size
|
||||
|
||||
--- Scroll content node
|
||||
-- @tfield node content_node
|
||||
|
||||
|
@ -211,6 +211,9 @@ local function update_text_with_trim(self, trim_postfix)
|
||||
text_length = text_length - 1
|
||||
new_text = utf8.sub(self.last_value, 1, text_length)
|
||||
text_width = self:get_text_size(new_text .. trim_postfix)
|
||||
if text_length == 0 then
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
gui.set_text(self.node, new_text .. trim_postfix)
|
||||
|
@ -227,7 +227,7 @@ function M._fill_properties(word, metrics, settings)
|
||||
else
|
||||
-- Text properties
|
||||
word.scale = settings.scale * word.relative_scale * settings.adjust_scale
|
||||
word.pivot = gui.PIVOT_W -- With this pivot adjustments works correctly, but with another some misalignment
|
||||
word.pivot = gui.PIVOT_SW -- With this pivot adjustments works more correctly than with other pivots
|
||||
word.size = vmath.vector3(metrics.width, metrics.height, 0)
|
||||
word.offset = vmath.vector3(metrics.offset_x, metrics.offset_y, 0)
|
||||
end
|
||||
|
@ -1,45 +0,0 @@
|
||||
fonts {
|
||||
name: "game"
|
||||
font: "/example/assets/fonts/game.font"
|
||||
}
|
||||
textures {
|
||||
name: "items"
|
||||
texture: "/example/assets/images/kenney.atlas"
|
||||
}
|
||||
nodes {
|
||||
size {
|
||||
x: 400.0
|
||||
y: 100.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
id: "root"
|
||||
inherit_alpha: true
|
||||
visible: false
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: -200.0
|
||||
}
|
||||
size {
|
||||
x: 400.0
|
||||
y: 100.0
|
||||
}
|
||||
type: TYPE_TEXT
|
||||
text: "Rich text"
|
||||
font: "game"
|
||||
id: "text_prefab"
|
||||
pivot: PIVOT_W
|
||||
parent: "root"
|
||||
inherit_alpha: true
|
||||
outline_alpha: 0.0
|
||||
shadow_alpha: 0.0
|
||||
}
|
||||
nodes {
|
||||
type: TYPE_BOX
|
||||
id: "icon_prefab"
|
||||
parent: "root"
|
||||
inherit_alpha: true
|
||||
size_mode: SIZE_MODE_AUTO
|
||||
}
|
||||
material: "/builtins/materials/gui.material"
|
||||
adjust_reference: ADJUST_REFERENCE_PARENT
|
@ -109,8 +109,8 @@ local RichText = component.create("rich_text")
|
||||
|
||||
--- The @{RichText} constructor
|
||||
-- @tparam RichText self @{RichText}
|
||||
-- @tparam string template The Rich Text template name
|
||||
-- @tparam table nodes The node table, if prefab was copied by gui.clone_tree()
|
||||
-- @tparam node|string text_node The text node to make Rich Text
|
||||
-- @tparam string|nil value The initial text value. Default will be gui.get_text(text_node)
|
||||
function RichText.init(self, text_node, value)
|
||||
self.root = self:get_node(text_node)
|
||||
self.text_prefab = self.root
|
||||
|
@ -25,35 +25,6 @@ end
|
||||
|
||||
function M.get_commands()
|
||||
return {
|
||||
{
|
||||
label = "Print GUI Scheme",
|
||||
|
||||
locations = { "Outline" },
|
||||
|
||||
query = {
|
||||
selection = {type = "outline", cardinality = "many"}
|
||||
},
|
||||
|
||||
active = function(opts)
|
||||
return true
|
||||
end,
|
||||
|
||||
run = function(opts)
|
||||
print("local SCHEME = {")
|
||||
|
||||
for i = 1, #opts.selection do
|
||||
local file = opts.selection[i]
|
||||
if editor.can_get(file, "id") then
|
||||
local id = editor.get(file, "id")
|
||||
print("\t" .. string.upper(id) .. " = \"" .. id .. "\",")
|
||||
end
|
||||
end
|
||||
|
||||
print("}")
|
||||
print("")
|
||||
end
|
||||
},
|
||||
|
||||
{
|
||||
label = "Assign layers",
|
||||
|
||||
|
@ -84,6 +84,8 @@ end
|
||||
|
||||
--- Set refresh function for DataList component
|
||||
-- @tparam DataList self @{DataList}
|
||||
-- @tparam boolean is_use_cache Use cache version of DataList. Requires make setup of components in on_element_add callback and clean in on_element_remove
|
||||
-- @treturn druid.data_list Current DataList instance
|
||||
function DataList.set_use_cache(self, is_use_cache)
|
||||
self._is_use_cache = is_use_cache
|
||||
return self
|
||||
@ -280,7 +282,7 @@ end
|
||||
function DataList._refresh(self)
|
||||
self.scroll:set_size(self.grid:get_size_for(#self._data))
|
||||
|
||||
local start_pos = -self.scroll.position
|
||||
local start_pos = -self.scroll.position --[[@as vector3]]
|
||||
local start_index = self.grid:get_index(start_pos)
|
||||
start_index = math.max(1, start_index)
|
||||
|
||||
|
@ -1,392 +0,0 @@
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class druid.figma_layout.row_data
|
||||
---@field width number
|
||||
---@field height number
|
||||
---@field count number
|
||||
|
||||
---@class druid.figma_layout.rows_data
|
||||
---@field total_width number
|
||||
---@field total_height number
|
||||
---@field nodes_width table<node, number>
|
||||
---@field nodes_height table<node, number>
|
||||
---@field rows druid.figma_layout.row_data[]>
|
||||
|
||||
---@class druid.figma_layout: druid.base_component
|
||||
local M = component.create("layout")
|
||||
|
||||
|
||||
--- The @{Layout} constructor
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @tparam node node Gui node
|
||||
-- @tparam string layout_type The layout mode (from const.LAYOUT_MODE)
|
||||
-- @tparam function|nil on_size_changed_callback The callback on window resize
|
||||
function M:init(node, layout_type)
|
||||
self.node = self:get_node(node)
|
||||
|
||||
print(self.node)
|
||||
self.is_dirty = true
|
||||
self.entities = {}
|
||||
self.margin = { x = 0, y = 0 }
|
||||
self.padding = gui.get_slice9(self.node)
|
||||
self.type = layout_type or "horizontal"
|
||||
self.is_resize_width = false
|
||||
self.is_resize_height = false
|
||||
self.is_justify = false
|
||||
end
|
||||
|
||||
|
||||
function M:update()
|
||||
if not self.is_dirty then
|
||||
return
|
||||
end
|
||||
|
||||
self:refresh_layout()
|
||||
end
|
||||
|
||||
|
||||
---@param margin_x number|nil
|
||||
---@param margin_y number|nil
|
||||
---@return druid.figma_layout
|
||||
function M:set_margin(margin_x, margin_y)
|
||||
self.margin.x = margin_x or self.margin.x
|
||||
self.margin.y = margin_y or self.margin.y
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
---@param padding vector4 The vector4 with padding values, where x - left, y - top, z - right, w - bottom
|
||||
function M:set_padding(padding)
|
||||
self.padding = padding
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
function M:set_dirty()
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
---@param is_justify boolean
|
||||
---@return druid.figma_layout
|
||||
function M:set_justify(is_justify)
|
||||
self.is_justify = is_justify
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
---@param type string The layout type: "horizontal", "vertical", "horizontal_wrap"
|
||||
function M:set_type(type)
|
||||
self.type = type
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
|
||||
---@param is_hug_width boolean
|
||||
---@param is_hug_height boolean
|
||||
---@return druid.figma_layout
|
||||
function M:set_hug_content(is_hug_width, is_hug_height)
|
||||
self.is_resize_width = is_hug_width or false
|
||||
self.is_resize_height = is_hug_height or false
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
---@param node_or_node_id string|node
|
||||
---@return druid.figma_layout
|
||||
function M:add(node_or_node_id)
|
||||
-- Acquire node from entity or by id
|
||||
local node = node_or_node_id
|
||||
if type(node_or_node_id) == "table" then
|
||||
assert(node_or_node_id.node, "The entity should have a node")
|
||||
node = node_or_node_id.node
|
||||
else
|
||||
---@cast node_or_node_id string|node
|
||||
node = self:get_node(node_or_node_id)
|
||||
end
|
||||
|
||||
---@cast node node
|
||||
table.insert(self.entities, node)
|
||||
gui.set_parent(node, self.node)
|
||||
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
---@return druid.figma_layout
|
||||
function M:refresh_layout()
|
||||
local layout_node = self.node
|
||||
|
||||
local entities = self.entities
|
||||
local type = self.type -- vertical, horizontal, horizontal_wrap
|
||||
local margin = self.margin -- {x: horizontal, y: vertical} in pixels, between elements
|
||||
local padding = self.padding -- {x: left, y: top, z: right, w: bottom} in pixels
|
||||
local is_justify = self.is_justify
|
||||
local size = gui.get_size(layout_node)
|
||||
local max_width = size.x - padding.x - padding.z
|
||||
local max_height = size.y - padding.y - padding.w
|
||||
local layout_pivot_offset = helper.get_pivot_offset(gui.get_pivot(layout_node)) -- {x: -0.5, y: -0.5} - is left bot, {x: 0.5, y: 0.5} - is right top
|
||||
|
||||
local rows_data = self:calculate_rows_data()
|
||||
local rows = rows_data.rows
|
||||
local row_index = 1
|
||||
local row = rows[row_index]
|
||||
|
||||
-- Current x and Current y is a top left corner of the node
|
||||
local current_x = -row.width * (0.5 + layout_pivot_offset.x)
|
||||
local current_y = rows_data.total_height * (0.5 - layout_pivot_offset.y)
|
||||
|
||||
if is_justify then
|
||||
if (type == "horizontal" or type == "horizontal_wrap") and row.count > 1 then
|
||||
current_x = -max_width * (0.5 + layout_pivot_offset.x)
|
||||
end
|
||||
if type == "vertical" then
|
||||
current_y = max_height * (0.5 - layout_pivot_offset.y)
|
||||
end
|
||||
end
|
||||
|
||||
for index = 1, #entities do
|
||||
local node = entities[index]
|
||||
local node_width = rows_data.nodes_width[node]
|
||||
local node_height = rows_data.nodes_height[node]
|
||||
local pivot_offset = helper.get_pivot_offset(gui.get_pivot(node))
|
||||
|
||||
if node_width > 0 and node_height > 0 then
|
||||
-- Calculate position for current node
|
||||
local position_x, position_y
|
||||
|
||||
if type == "horizontal" then
|
||||
position_x = current_x + node_width * (0.5 + pivot_offset.x)
|
||||
position_y = current_y - row.height * (0.5 - pivot_offset.y)
|
||||
|
||||
local node_margin = margin.x
|
||||
if is_justify and row.count > 1 then
|
||||
node_margin = (max_width - row.width) / (row.count - 1) + margin.x
|
||||
end
|
||||
current_x = current_x + node_width + node_margin
|
||||
end
|
||||
|
||||
if type == "vertical" then
|
||||
position_x = current_x + row.width * (0.5 - pivot_offset.x)
|
||||
position_y = current_y - node_height * (0.5 + pivot_offset.y)
|
||||
|
||||
local node_margin = margin.y
|
||||
if is_justify then
|
||||
node_margin = (max_height - rows_data.total_height) / (#rows - 1) + margin.y
|
||||
end
|
||||
|
||||
current_y = current_y - node_height - node_margin
|
||||
end
|
||||
|
||||
if type == "horizontal_wrap" then
|
||||
local width = row.width
|
||||
if is_justify and row.count > 0 then
|
||||
width = math.max(row.width, max_width)
|
||||
end
|
||||
local new_row_width = width * (0.5 - layout_pivot_offset.x)
|
||||
|
||||
-- Compare with eps due the float loss and element flickering
|
||||
if current_x + node_width - new_row_width > 0.0001 then
|
||||
if row_index < #rows then
|
||||
row_index = row_index + 1
|
||||
row = rows[row_index]
|
||||
end
|
||||
|
||||
current_x = -row.width * (0.5 + layout_pivot_offset.x)
|
||||
current_y = current_y - row.height - margin.y
|
||||
if is_justify and row.count > 1 then
|
||||
current_x = -max_width * (0.5 + layout_pivot_offset.x)
|
||||
end
|
||||
end
|
||||
|
||||
position_x = current_x + node_width * (0.5 + pivot_offset.x)
|
||||
position_y = current_y - row.height * (0.5 - pivot_offset.y)
|
||||
|
||||
local node_margin = margin.x
|
||||
if is_justify and row.count > 1 then
|
||||
node_margin = (max_width - row.width) / (row.count - 1) + margin.x
|
||||
end
|
||||
current_x = current_x + node_width + node_margin
|
||||
end
|
||||
|
||||
do -- Padding offset
|
||||
if layout_pivot_offset.x == -0.5 then
|
||||
position_x = position_x + padding.x
|
||||
end
|
||||
if layout_pivot_offset.y == 0.5 then
|
||||
position_y = position_y - padding.y
|
||||
end
|
||||
if layout_pivot_offset.x == 0.5 then
|
||||
position_x = position_x - padding.z
|
||||
end
|
||||
if layout_pivot_offset.y == -0.5 then
|
||||
position_y = position_y + padding.w
|
||||
end
|
||||
end
|
||||
|
||||
self:set_node_position(node, position_x, position_y)
|
||||
end
|
||||
end
|
||||
|
||||
if self.is_resize_width or self.is_resize_height then
|
||||
if self.is_resize_width then
|
||||
size.x = rows_data.total_width + padding.x + padding.z
|
||||
end
|
||||
if self.is_resize_height then
|
||||
size.y = rows_data.total_height + padding.y + padding.w
|
||||
end
|
||||
gui.set_size(layout_node, size)
|
||||
end
|
||||
|
||||
self.is_dirty = false
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
---@return druid.figma_layout
|
||||
function M:clear_layout()
|
||||
for index = #self.entities, 1, -1 do
|
||||
self.entities[index] = nil
|
||||
end
|
||||
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
---@param node node
|
||||
---@return number, number
|
||||
function M.get_node_size(node)
|
||||
if not gui.is_enabled(node, false) then
|
||||
return 0, 0
|
||||
end
|
||||
|
||||
local scale = gui.get_scale(node)
|
||||
|
||||
-- If node has text - get text size instead of node size
|
||||
if gui.get_text(node) then
|
||||
local text_metrics = helper.get_text_metrics_from_node(node)
|
||||
return text_metrics.width * scale.x, text_metrics.height * scale.y
|
||||
end
|
||||
|
||||
local size = gui.get_size(node)
|
||||
return size.x * scale.x, size.y * scale.y
|
||||
end
|
||||
|
||||
|
||||
---Calculate rows data for layout. Contains total width, height and rows info (width, height, count of elements in row)
|
||||
---@private
|
||||
---@return druid.figma_layout.rows_data
|
||||
function M:calculate_rows_data()
|
||||
local entities = self.entities
|
||||
local margin = self.margin
|
||||
local type = self.type
|
||||
local padding = self.padding
|
||||
|
||||
local size = gui.get_size(self.node)
|
||||
local max_width = size.x - padding.x - padding.z
|
||||
|
||||
-- Collect rows info about width, height and count of elements in row
|
||||
local current_row = { width = 0, height = 0, count = 0 }
|
||||
local rows_data = {
|
||||
total_width = 0,
|
||||
total_height = 0,
|
||||
nodes_width = {},
|
||||
nodes_height = {},
|
||||
rows = { current_row }
|
||||
}
|
||||
|
||||
for index = 1, #entities do
|
||||
local node = entities[index]
|
||||
local node_width = rows_data.nodes_width[node]
|
||||
local node_height = rows_data.nodes_height[node]
|
||||
|
||||
-- Get node size if it's not calculated yet
|
||||
if not node_width or not node_height then
|
||||
node_width, node_height = M.get_node_size(node)
|
||||
rows_data.nodes_width[node] = node_width
|
||||
rows_data.nodes_height[node] = node_height
|
||||
end
|
||||
|
||||
if node_width > 0 and node_height > 0 then
|
||||
if type == "horizontal" then
|
||||
current_row.width = current_row.width + node_width + margin.x
|
||||
current_row.height = math.max(current_row.height, node_height)
|
||||
current_row.count = current_row.count + 1
|
||||
end
|
||||
|
||||
if type == "vertical" then
|
||||
if current_row.count > 0 then
|
||||
current_row = { width = 0, height = 0, count = 0 }
|
||||
table.insert(rows_data.rows, current_row)
|
||||
end
|
||||
|
||||
current_row.width = math.max(current_row.width, node_width + margin.x)
|
||||
current_row.height = node_height
|
||||
current_row.count = current_row.count + 1
|
||||
end
|
||||
|
||||
if type == "horizontal_wrap" then
|
||||
if current_row.width + node_width > max_width and current_row.count > 0 then
|
||||
current_row = { width = 0, height = 0, count = 0 }
|
||||
table.insert(rows_data.rows, current_row)
|
||||
end
|
||||
|
||||
current_row.width = current_row.width + node_width + margin.x
|
||||
current_row.height = math.max(current_row.height, node_height)
|
||||
current_row.count = current_row.count + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Remove last margin of each row
|
||||
-- Calculate total width and height
|
||||
local rows_count = #rows_data.rows
|
||||
for index = 1, rows_count do
|
||||
local row = rows_data.rows[index]
|
||||
if row.width > 0 then
|
||||
row.width = row.width - margin.x
|
||||
end
|
||||
|
||||
rows_data.total_width = math.max(rows_data.total_width, row.width)
|
||||
rows_data.total_height = rows_data.total_height + row.height
|
||||
end
|
||||
|
||||
rows_data.total_height = rows_data.total_height + margin.y * (rows_count - 1)
|
||||
return rows_data
|
||||
end
|
||||
|
||||
|
||||
---@private
|
||||
---@param node node
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@return node
|
||||
function M:set_node_position(node, x, y)
|
||||
local position = gui.get_position(node)
|
||||
position.x = x
|
||||
position.y = y
|
||||
gui.set_position(node, position)
|
||||
|
||||
return node
|
||||
end
|
||||
|
||||
|
||||
return M
|
@ -27,7 +27,6 @@
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
local Event = require("druid.event")
|
||||
local const = require("druid.const")
|
||||
|
||||
local Hotkey = component.create("hotkey")
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
-- Copyright (c) 2021 Maksim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
|
||||
-- Copyright (c) 2024 Maksim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
|
||||
|
||||
--- Layout management on node
|
||||
--
|
||||
@ -13,205 +13,406 @@
|
||||
--- Current layout mode
|
||||
-- @tfield string mode
|
||||
|
||||
---On window resize callback(self, new_size)
|
||||
-- @tfield DruidEvent on_size_changed @{DruidEvent}
|
||||
|
||||
---
|
||||
|
||||
|
||||
local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
local Event = require("druid.event")
|
||||
|
||||
-- @class druid.layout.row_data
|
||||
-- @tfield width number
|
||||
-- @tfield height number
|
||||
-- @tfield count number
|
||||
|
||||
local Layout = component.create("layout")
|
||||
-- @class druid.layout.rows_data
|
||||
-- @tfield total_width number
|
||||
-- @tfield total_height number
|
||||
-- @tfield nodes_width table<node, number>
|
||||
-- @tfield nodes_height table<node, number>
|
||||
-- @tfield rows druid.layout.row_data[]>
|
||||
|
||||
-- @class druid.layout: druid.base_component
|
||||
local M = component.create("layout")
|
||||
|
||||
--- The @{Layout} constructor
|
||||
-- The @{Layout} constructor
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @tparam node node Gui node
|
||||
-- @tparam string mode The layout mode (from const.LAYOUT_MODE)
|
||||
-- @tparam string layout_type The layout mode (from const.LAYOUT_MODE)
|
||||
-- @tparam function|nil on_size_changed_callback The callback on window resize
|
||||
function Layout.init(self, node, mode, on_size_changed_callback)
|
||||
function M.init(self, node, layout_type)
|
||||
self.node = self:get_node(node)
|
||||
|
||||
self._min_size = nil
|
||||
self._max_size = nil
|
||||
self._current_size = vmath.vector3(0)
|
||||
self._inited = false
|
||||
self._max_gui_upscale = nil
|
||||
self._fit_node = nil
|
||||
|
||||
self._anchors = {}
|
||||
|
||||
self.mode = mode or const.LAYOUT_MODE.FIT
|
||||
|
||||
self.on_size_changed = Event(on_size_changed_callback)
|
||||
self.is_dirty = true
|
||||
self.entities = {}
|
||||
self.margin = { x = 0, y = 0 }
|
||||
self.padding = gui.get_slice9(self.node)
|
||||
self.type = layout_type or "horizontal"
|
||||
self.is_resize_width = false
|
||||
self.is_resize_height = false
|
||||
self.is_justify = false
|
||||
end
|
||||
|
||||
|
||||
function Layout.on_late_init(self)
|
||||
self._inited = true
|
||||
self.origin_size = self.origin_size or gui.get_size(self.node)
|
||||
self.fit_size = self.fit_size or vmath.vector3(self.origin_size)
|
||||
self.pivot = helper.get_pivot_offset(gui.get_pivot(self.node))
|
||||
self.origin_position = gui.get_position(self.node)
|
||||
self.position = vmath.vector3(self.origin_position)
|
||||
gui.set_size_mode(self.node, gui.SIZE_MODE_MANUAL)
|
||||
gui.set_adjust_mode(self.node, gui.ADJUST_FIT)
|
||||
self:on_window_resized()
|
||||
end
|
||||
|
||||
|
||||
function Layout.on_window_resized(self)
|
||||
if not self._inited then
|
||||
function M:update()
|
||||
if not self.is_dirty then
|
||||
return
|
||||
end
|
||||
|
||||
local x_koef, y_koef = helper.get_screen_aspect_koef()
|
||||
|
||||
local revert_scale = 1
|
||||
if self._max_gui_upscale then
|
||||
revert_scale = self._max_gui_upscale / helper.get_gui_scale()
|
||||
revert_scale = math.min(revert_scale, 1)
|
||||
end
|
||||
gui.set_scale(self.node, vmath.vector3(revert_scale))
|
||||
|
||||
if self._fit_node then
|
||||
self.fit_size = gui.get_size(self._fit_node)
|
||||
self.fit_size.x = self.fit_size.x / x_koef
|
||||
self.fit_size.y = self.fit_size.y / y_koef
|
||||
end
|
||||
|
||||
x_koef = self.fit_size.x / self.origin_size.x * x_koef
|
||||
y_koef = self.fit_size.y / self.origin_size.y * y_koef
|
||||
|
||||
local new_size = vmath.vector3(self.origin_size)
|
||||
|
||||
if self.mode == const.LAYOUT_MODE.STRETCH then
|
||||
new_size.x = new_size.x * x_koef / revert_scale
|
||||
new_size.y = new_size.y * y_koef / revert_scale
|
||||
end
|
||||
|
||||
if self.mode == const.LAYOUT_MODE.STRETCH_X then
|
||||
new_size.x = new_size.x * x_koef / revert_scale
|
||||
end
|
||||
|
||||
if self.mode == const.LAYOUT_MODE.STRETCH_Y then
|
||||
new_size.y = new_size.y * y_koef / revert_scale
|
||||
end
|
||||
|
||||
-- Fit to the stretched container (node size or other defined)
|
||||
if self.mode == const.LAYOUT_MODE.ZOOM_MIN then
|
||||
new_size = new_size * math.min(x_koef, y_koef)
|
||||
end
|
||||
if self.mode == const.LAYOUT_MODE.ZOOM_MAX then
|
||||
new_size = new_size * math.max(x_koef, y_koef)
|
||||
end
|
||||
|
||||
if self._min_size then
|
||||
new_size.x = math.max(new_size.x, self._min_size.x)
|
||||
new_size.y = math.max(new_size.y, self._min_size.y)
|
||||
end
|
||||
if self._max_size then
|
||||
new_size.x = math.min(new_size.x, self._max_size.x)
|
||||
new_size.y = math.min(new_size.y, self._max_size.y)
|
||||
end
|
||||
self._current_size = new_size
|
||||
gui.set_size(self.node, new_size)
|
||||
|
||||
self.position.x = self.origin_position.x + self.origin_position.x * (x_koef - 1)
|
||||
self.position.y = self.origin_position.y + self.origin_position.y * (y_koef - 1)
|
||||
gui.set_position(self.node, self.position)
|
||||
|
||||
self.on_size_changed:trigger(self:get_context(), new_size)
|
||||
self:refresh_layout()
|
||||
end
|
||||
|
||||
|
||||
--- Set minimal size of layout node
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @tparam vector3 min_size
|
||||
-- @treturn Layout @{Layout}
|
||||
function Layout.set_min_size(self, min_size)
|
||||
self._min_size = min_size
|
||||
-- @tparam number|nil margin_x
|
||||
-- @tparam number|nil margin_y
|
||||
-- @treturn druid.layout @{Layout}
|
||||
function M.set_margin(self, margin_x, margin_y)
|
||||
self.margin.x = margin_x or self.margin.x
|
||||
self.margin.y = margin_y or self.margin.y
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set maximum size of layout node
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @tparam vector3 max_size
|
||||
-- @treturn Layout @{Layout}
|
||||
function Layout.set_max_size(self, max_size)
|
||||
self._max_size = max_size
|
||||
-- @tparam vector4 padding The vector4 with padding values, where x - left, y - top, z - right, w - bottom
|
||||
-- @treturn druid.layout @{Layout}
|
||||
function M.set_padding(self, padding)
|
||||
self.padding = padding
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set new origin position of layout node. You should apply this on node movement
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @tparam vector3 new_origin_position
|
||||
-- @treturn Layout @{Layout}
|
||||
function Layout.set_origin_position(self, new_origin_position)
|
||||
self.origin_position = new_origin_position or self.origin_position
|
||||
self:on_window_resized()
|
||||
-- @treturn druid.layout @{Layout}
|
||||
function M.set_dirty(self)
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set new origin size of layout node. You should apply this on node manual size change
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @tparam vector3 new_origin_size
|
||||
-- @treturn Layout @{Layout}
|
||||
function Layout.set_origin_size(self, new_origin_size)
|
||||
self.origin_size = new_origin_size or self.origin_size
|
||||
self:on_window_resized()
|
||||
-- @tparam boolean is_justify
|
||||
-- @treturn druid.layout @{Layout}
|
||||
function M.set_justify(self, is_justify)
|
||||
self.is_justify = is_justify
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set max gui upscale for FIT adjust mode (or side). It happens on bigger render gui screen
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @tparam number max_gui_upscale
|
||||
-- @treturn Layout @{Layout}
|
||||
function Layout.set_max_gui_upscale(self, max_gui_upscale)
|
||||
self._max_gui_upscale = max_gui_upscale
|
||||
self:on_window_resized()
|
||||
end
|
||||
-- @tparam string type The layout type: "horizontal", "vertical", "horizontal_wrap"
|
||||
-- @treturn druid.layout @{Layout}
|
||||
function M.set_type(self, type)
|
||||
self.type = type
|
||||
self.is_dirty = true
|
||||
|
||||
|
||||
--- Set size for layout node to fit inside it
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @tparam vector3 target_size
|
||||
-- @treturn Layout @{Layout}
|
||||
function Layout.fit_into_size(self, target_size)
|
||||
self.fit_size = target_size
|
||||
self:on_window_resized()
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set node for layout node to fit inside it. Pass nil to reset
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @tparam node|nil node
|
||||
-- @treturn Layout @{Layout}
|
||||
function Layout.fit_into_node(self, node)
|
||||
self._fit_node = node
|
||||
self:on_window_resized()
|
||||
-- @tparam boolean is_hug_width
|
||||
-- @tparam boolean is_hug_height
|
||||
-- @treturn druid.layout @{Layout}
|
||||
function M.set_hug_content(self, is_hug_width, is_hug_height)
|
||||
self.is_resize_width = is_hug_width or false
|
||||
self.is_resize_height = is_hug_height or false
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set current size for layout node to fit inside it
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @treturn Layout @{Layout}
|
||||
function Layout.fit_into_window(self)
|
||||
return self:fit_into_size(vmath.vector3(
|
||||
gui.get_width(),
|
||||
gui.get_height(),
|
||||
0))
|
||||
-- @tparam string|node node_or_node_id
|
||||
-- @treturn druid.layout @{Layout}
|
||||
function M.add(self, node_or_node_id)
|
||||
-- Acquire node from entity or by id
|
||||
local node = node_or_node_id
|
||||
if type(node_or_node_id) == "table" then
|
||||
assert(node_or_node_id.node, "The entity should have a node")
|
||||
node = node_or_node_id.node
|
||||
else
|
||||
-- @cast node_or_node_id string|node
|
||||
node = self:get_node(node_or_node_id)
|
||||
end
|
||||
|
||||
-- @cast node node
|
||||
table.insert(self.entities, node)
|
||||
gui.set_parent(node, self.node)
|
||||
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
return Layout
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @treturn druid.layout @{Layout}
|
||||
function M.refresh_layout(self)
|
||||
local layout_node = self.node
|
||||
|
||||
local entities = self.entities
|
||||
local type = self.type -- vertical, horizontal, horizontal_wrap
|
||||
local margin = self.margin -- {x: horizontal, y: vertical} in pixels, between elements
|
||||
local padding = self.padding -- {x: left, y: top, z: right, w: bottom} in pixels
|
||||
local is_justify = self.is_justify
|
||||
local size = gui.get_size(layout_node)
|
||||
local max_width = size.x - padding.x - padding.z
|
||||
local max_height = size.y - padding.y - padding.w
|
||||
local layout_pivot_offset = helper.get_pivot_offset(gui.get_pivot(layout_node)) -- {x: -0.5, y: -0.5} - is left bot, {x: 0.5, y: 0.5} - is right top
|
||||
|
||||
local rows_data = self:calculate_rows_data()
|
||||
local rows = rows_data.rows
|
||||
local row_index = 1
|
||||
local row = rows[row_index]
|
||||
|
||||
-- Current x and Current y is a top left corner of the node
|
||||
local current_x = -row.width * (0.5 + layout_pivot_offset.x)
|
||||
local current_y = rows_data.total_height * (0.5 - layout_pivot_offset.y)
|
||||
|
||||
if is_justify then
|
||||
if (type == "horizontal" or type == "horizontal_wrap") and row.count > 1 then
|
||||
current_x = -max_width * (0.5 + layout_pivot_offset.x)
|
||||
end
|
||||
if type == "vertical" then
|
||||
current_y = max_height * (0.5 - layout_pivot_offset.y)
|
||||
end
|
||||
end
|
||||
|
||||
for index = 1, #entities do
|
||||
local node = entities[index]
|
||||
local node_width = rows_data.nodes_width[node]
|
||||
local node_height = rows_data.nodes_height[node]
|
||||
local pivot_offset = helper.get_pivot_offset(gui.get_pivot(node))
|
||||
|
||||
if node_width > 0 and node_height > 0 then
|
||||
-- Calculate position for current node
|
||||
local position_x, position_y
|
||||
|
||||
if type == "horizontal" then
|
||||
position_x = current_x + node_width * (0.5 + pivot_offset.x)
|
||||
position_y = current_y - row.height * (0.5 - pivot_offset.y)
|
||||
|
||||
local node_margin = margin.x
|
||||
if is_justify and row.count > 1 then
|
||||
node_margin = (max_width - row.width) / (row.count - 1) + margin.x
|
||||
end
|
||||
current_x = current_x + node_width + node_margin
|
||||
end
|
||||
|
||||
if type == "vertical" then
|
||||
position_x = current_x + row.width * (0.5 - pivot_offset.x)
|
||||
position_y = current_y - node_height * (0.5 + pivot_offset.y)
|
||||
|
||||
local node_margin = margin.y
|
||||
if is_justify then
|
||||
node_margin = (max_height - rows_data.total_height) / (#rows - 1) + margin.y
|
||||
end
|
||||
|
||||
current_y = current_y - node_height - node_margin
|
||||
end
|
||||
|
||||
if type == "horizontal_wrap" then
|
||||
local width = row.width
|
||||
if is_justify and row.count > 0 then
|
||||
width = math.max(row.width, max_width)
|
||||
end
|
||||
local new_row_width = width * (0.5 - layout_pivot_offset.x)
|
||||
|
||||
-- Compare with eps due the float loss and element flickering
|
||||
if current_x + node_width - new_row_width > 0.0001 then
|
||||
if row_index < #rows then
|
||||
row_index = row_index + 1
|
||||
row = rows[row_index]
|
||||
end
|
||||
|
||||
current_x = -row.width * (0.5 + layout_pivot_offset.x)
|
||||
current_y = current_y - row.height - margin.y
|
||||
if is_justify and row.count > 1 then
|
||||
current_x = -max_width * (0.5 + layout_pivot_offset.x)
|
||||
end
|
||||
end
|
||||
|
||||
position_x = current_x + node_width * (0.5 + pivot_offset.x)
|
||||
position_y = current_y - row.height * (0.5 - pivot_offset.y)
|
||||
|
||||
local node_margin = margin.x
|
||||
if is_justify and row.count > 1 then
|
||||
node_margin = (max_width - row.width) / (row.count - 1) + margin.x
|
||||
end
|
||||
current_x = current_x + node_width + node_margin
|
||||
end
|
||||
|
||||
do -- Padding offset
|
||||
if layout_pivot_offset.x == -0.5 then
|
||||
position_x = position_x + padding.x
|
||||
end
|
||||
if layout_pivot_offset.y == 0.5 then
|
||||
position_y = position_y - padding.y
|
||||
end
|
||||
if layout_pivot_offset.x == 0.5 then
|
||||
position_x = position_x - padding.z
|
||||
end
|
||||
if layout_pivot_offset.y == -0.5 then
|
||||
position_y = position_y + padding.w
|
||||
end
|
||||
end
|
||||
|
||||
self:set_node_position(node, position_x, position_y)
|
||||
end
|
||||
end
|
||||
|
||||
if self.is_resize_width or self.is_resize_height then
|
||||
if self.is_resize_width then
|
||||
size.x = rows_data.total_width + padding.x + padding.z
|
||||
end
|
||||
if self.is_resize_height then
|
||||
size.y = rows_data.total_height + padding.y + padding.w
|
||||
end
|
||||
gui.set_size(layout_node, size)
|
||||
end
|
||||
|
||||
self.is_dirty = false
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @treturn druid.layout @{Layout}
|
||||
function M.clear_layout(self)
|
||||
for index = #self.entities, 1, -1 do
|
||||
self.entities[index] = nil
|
||||
end
|
||||
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
-- @private
|
||||
-- @tparam node node
|
||||
-- @treturn number, number
|
||||
function M.get_node_size(node)
|
||||
if not gui.is_enabled(node, false) then
|
||||
return 0, 0
|
||||
end
|
||||
|
||||
local scale = gui.get_scale(node)
|
||||
|
||||
-- If node has text - get text size instead of node size
|
||||
if gui.get_text(node) then
|
||||
local text_metrics = helper.get_text_metrics_from_node(node)
|
||||
return text_metrics.width * scale.x, text_metrics.height * scale.y
|
||||
end
|
||||
|
||||
local size = gui.get_size(node)
|
||||
return size.x * scale.x, size.y * scale.y
|
||||
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
|
||||
function M.calculate_rows_data(self)
|
||||
local entities = self.entities
|
||||
local margin = self.margin
|
||||
local type = self.type
|
||||
local padding = self.padding
|
||||
|
||||
local size = gui.get_size(self.node)
|
||||
local max_width = size.x - padding.x - padding.z
|
||||
|
||||
-- Collect rows info about width, height and count of elements in row
|
||||
local current_row = { width = 0, height = 0, count = 0 }
|
||||
local rows_data = {
|
||||
total_width = 0,
|
||||
total_height = 0,
|
||||
nodes_width = {},
|
||||
nodes_height = {},
|
||||
rows = { current_row }
|
||||
}
|
||||
|
||||
for index = 1, #entities do
|
||||
local node = entities[index]
|
||||
local node_width = rows_data.nodes_width[node]
|
||||
local node_height = rows_data.nodes_height[node]
|
||||
|
||||
-- Get node size if it's not calculated yet
|
||||
if not node_width or not node_height then
|
||||
node_width, node_height = M.get_node_size(node)
|
||||
rows_data.nodes_width[node] = node_width
|
||||
rows_data.nodes_height[node] = node_height
|
||||
end
|
||||
|
||||
if node_width > 0 and node_height > 0 then
|
||||
if type == "horizontal" then
|
||||
current_row.width = current_row.width + node_width + margin.x
|
||||
current_row.height = math.max(current_row.height, node_height)
|
||||
current_row.count = current_row.count + 1
|
||||
end
|
||||
|
||||
if type == "vertical" then
|
||||
if current_row.count > 0 then
|
||||
current_row = { width = 0, height = 0, count = 0 }
|
||||
table.insert(rows_data.rows, current_row)
|
||||
end
|
||||
|
||||
current_row.width = math.max(current_row.width, node_width + margin.x)
|
||||
current_row.height = node_height
|
||||
current_row.count = current_row.count + 1
|
||||
end
|
||||
|
||||
if type == "horizontal_wrap" then
|
||||
if current_row.width + node_width > max_width and current_row.count > 0 then
|
||||
current_row = { width = 0, height = 0, count = 0 }
|
||||
table.insert(rows_data.rows, current_row)
|
||||
end
|
||||
|
||||
current_row.width = current_row.width + node_width + margin.x
|
||||
current_row.height = math.max(current_row.height, node_height)
|
||||
current_row.count = current_row.count + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Remove last margin of each row
|
||||
-- Calculate total width and height
|
||||
local rows_count = #rows_data.rows
|
||||
for index = 1, rows_count do
|
||||
local row = rows_data.rows[index]
|
||||
if row.width > 0 then
|
||||
row.width = row.width - margin.x
|
||||
end
|
||||
|
||||
rows_data.total_width = math.max(rows_data.total_width, row.width)
|
||||
rows_data.total_height = rows_data.total_height + row.height
|
||||
end
|
||||
|
||||
rows_data.total_height = rows_data.total_height + margin.y * (rows_count - 1)
|
||||
return rows_data
|
||||
end
|
||||
|
||||
-- @private
|
||||
-- @tparam node node
|
||||
-- @tparam number x
|
||||
-- @tparam number y
|
||||
-- @treturn node
|
||||
function M:set_node_position(node, x, y)
|
||||
local position = gui.get_position(node)
|
||||
position.x = x
|
||||
position.y = y
|
||||
gui.set_position(node, position)
|
||||
|
||||
return node
|
||||
end
|
||||
|
||||
return M
|
||||
|
@ -151,6 +151,8 @@ function Slider.on_input(self, action_id, action)
|
||||
self.value = (self.target_pos.y - self.start_pos.y) / self.dist.y
|
||||
end
|
||||
|
||||
self.value = math.abs(self.value)
|
||||
|
||||
if self.steps then
|
||||
local closest_dist = 1000
|
||||
local closest = nil
|
||||
|
@ -42,15 +42,15 @@ M["button"] = {
|
||||
end,
|
||||
|
||||
on_click_disabled = function(self, node)
|
||||
settings.play_sound(M.button.BTN_SOUND_DISABLED)
|
||||
local start_pos = self.start_pos
|
||||
gui.animate(node, "position.x", start_pos.x - 3, gui.EASING_OUTSINE, 0.05, 0, function()
|
||||
gui.animate(node, "position.x", start_pos.x + 3, gui.EASING_OUTSINE, 0.1, 0, function()
|
||||
gui.animate(node, "position.x", start_pos.x, gui.EASING_OUTSINE, 0.05)
|
||||
end)
|
||||
end)
|
||||
end,
|
||||
|
||||
on_set_enabled = function(self, node, state)
|
||||
if state then
|
||||
gui.set_color(node, M.button.ENABLED_COLOR)
|
||||
else
|
||||
gui.set_color(node, M.button.DISABLED_COLOR)
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,7 @@ function DruidInstance.initialize(self, context, style)
|
||||
end
|
||||
|
||||
|
||||
--- Create new component.
|
||||
-- Create new component.
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam BaseComponent component Component module
|
||||
-- @tparam any ... Other component params to pass it to component:init function
|
||||
@ -776,9 +776,8 @@ end
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam string|node node The_node id or gui.get_node(node_id).
|
||||
-- @tparam string mode The layout mode
|
||||
-- @tparam function|nil on_size_changed_callback The callback on window resize
|
||||
-- @treturn Layout @{Layout} component
|
||||
function DruidInstance.new_layout(self, node, mode, on_size_changed_callback)
|
||||
function DruidInstance.new_layout(self, node, mode)
|
||||
return helper.require_component_message("layout")
|
||||
end
|
||||
|
||||
|
@ -688,7 +688,8 @@ local function matcherGenerator(regex, plain)
|
||||
local sum = 0
|
||||
local bc, ec = utf8sub(str, 1, 1), utf8sub(str, 2, 2)
|
||||
local skip = len(bc) + len(ec)
|
||||
bc, ec = utf8unicode(bc), utf8unicode(ec)
|
||||
bc = utf8unicode(bc) --[[@as string]]
|
||||
ec = utf8unicode(ec) --[[@as string]]
|
||||
return function(cC)
|
||||
if cC == ec and sum > 0 then
|
||||
sum = sum - 1
|
||||
|
@ -3,18 +3,13 @@ local component = require("druid.component")
|
||||
---@class component_name : druid.base_component
|
||||
local Component = component.create("component_name")
|
||||
|
||||
local SCHEME = {
|
||||
ROOT = "root",
|
||||
BUTTON = "button",
|
||||
}
|
||||
|
||||
|
||||
-- Component constructor. Template name and nodes are optional. Pass it if you use it in your component
|
||||
function Component:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
self.root = self:get_node(SCHEME.ROOT)
|
||||
self.root = self:get_node("root")
|
||||
|
||||
self.button = self.druid:new_button(SCHEME.BUTTON, function() end)
|
||||
self.button = self.druid:new_button("button", function() end)
|
||||
end
|
||||
|
||||
|
||||
|
@ -3,13 +3,6 @@ local component = require("druid.component")
|
||||
---@class component_name : druid.base_component
|
||||
local Component = component.create("component_name")
|
||||
|
||||
-- Scheme of component gui nodes
|
||||
local SCHEME = {
|
||||
ROOT = "root",
|
||||
BUTTON = "button",
|
||||
}
|
||||
|
||||
|
||||
-- Component constructor. Template name and nodes are optional. Pass it if you use it in your component
|
||||
function Component:init(template, nodes)
|
||||
-- If your component is gui template, pass the template name and set it
|
||||
@ -18,7 +11,7 @@ function Component:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
-- self:get_node will auto process component template and nodes
|
||||
self.root = self:get_node(SCHEME.ROOT)
|
||||
self.root = self:get_node("root")
|
||||
|
||||
end
|
||||
|
||||
|
@ -14,24 +14,15 @@ local component = require("druid.component")
|
||||
---@field druid druid_instance
|
||||
local ButtonComponent = component.create("button_component")
|
||||
|
||||
local SCHEME = {
|
||||
ROOT = "root",
|
||||
TEXT = "text",
|
||||
ICON = "icon",
|
||||
CHECKBOX = "checkbox"
|
||||
}
|
||||
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function ButtonComponent:init(template, nodes)
|
||||
self:set_template(template)
|
||||
self:set_nodes(nodes)
|
||||
self.druid = self:get_druid()
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
self.root = self:get_node(SCHEME.ROOT)
|
||||
self.text = self.druid:new_text(SCHEME.TEXT)
|
||||
self.checkbox = self:get_node(SCHEME.CHECKBOX)
|
||||
self.root = self:get_node("root")
|
||||
self.text = self.druid:new_text("text")
|
||||
self.checkbox = self:get_node("checkbox")
|
||||
|
||||
self.button = self.druid:new_button(self.root, self._on_click)
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
---@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
|
||||
@ -47,6 +49,7 @@
|
||||
---@field parent node
|
||||
---@field size number
|
||||
---@field fonts table<string, string>
|
||||
---@field scale vector3
|
||||
---@field color vector4
|
||||
---@field shadow vector4
|
||||
---@field outline vector4
|
||||
@ -54,12 +57,9 @@
|
||||
---@field image_pixel_grid_snap boolean
|
||||
---@field combine_words boolean
|
||||
---@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
|
||||
@ -71,3 +71,22 @@
|
||||
---@field height number
|
||||
---@field max_ascent number
|
||||
---@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
|
||||
|
||||
|
||||
---Add generics to some functions.
|
||||
|
||||
---Create new component.
|
||||
---@generic T: druid.base_component
|
||||
---@param self druid_instance
|
||||
---@param component T Component module
|
||||
---@param ... any Other component params to pass it to component:init function
|
||||
---@return T Component instance
|
||||
function druid_instance.new(self, component, ...) end
|
Loading…
x
Reference in New Issue
Block a user