Extension-Druid/docs/modules/druid.static_grid.html
2020-09-29 23:46:32 +03:00

523 lines
13 KiB
HTML

<!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 Library</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>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><strong>druid.static_grid</strong></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid.static_grid</code></h1>
<p>Component to handle placing components by row and columns.</p>
<p> Grid can anchor your elements, get content size and other</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(parent, element[, in_row=1])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_pos">get_pos(index)</a></td>
<td class="summary">Return pos for grid node index</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_index">get_index(pos)</a></td>
<td class="summary">Return index for grid pos</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_index_by_node">get_index_by_node(node)</a></td>
<td class="summary">Return grid index by node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_anchor">set_anchor(anchor)</a></td>
<td class="summary">Set grid anchor.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#add">add(item[, index])</a></td>
<td class="summary">Add new item to the grid</td>
</tr>
<tr>
<td class="name" nowrap><a href="#remove">remove(index, is_shift_nodes)</a></td>
<td class="summary">Remove the item from the grid.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_size">get_size()</a></td>
<td class="summary">Return grid content size</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_all_pos">get_all_pos()</a></td>
<td class="summary">Return array of all node positions</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_position_function">set_position_function(callback)</a></td>
<td class="summary">Change set position function for grid nodes.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#clear">clear()</a></td>
<td class="summary">Clear grid nodes array.</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Events">Events</a></td>
<td class="summary">Component events</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Fields">Fields</a></td>
<td class="summary">Component fields</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(parent, element[, in_row=1])</strong>
</dt>
<dd>
Component init function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">parent</span>
<span class="types"><span class="type">node</span></span>
The gui node parent, where items will be placed
</li>
<li><span class="parameter">element</span>
<span class="types"><span class="type">node</span></span>
Element prefab. Need to get it size
</li>
<li><span class="parameter">in_row</span>
<span class="types"><span class="type">number</span></span>
How many nodes in row can be placed
(<em>default</em> 1)
</li>
</ul>
</dd>
<dt>
<a name = "get_pos"></a>
<strong>get_pos(index)</strong>
</dt>
<dd>
Return pos for grid node index
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span></span>
The grid element index
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3</span></span>
Node position
</ol>
</dd>
<dt>
<a name = "get_index"></a>
<strong>get_index(pos)</strong>
</dt>
<dd>
Return index for grid pos
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">pos</span>
<span class="types"><span class="type">vector3</span></span>
The node position in the grid
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
The node index
</ol>
</dd>
<dt>
<a name = "get_index_by_node"></a>
<strong>get_index_by_node(node)</strong>
</dt>
<dd>
Return grid index by node
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
The gui node in the grid
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
The node index
</ol>
</dd>
<dt>
<a name = "set_anchor"></a>
<strong>set_anchor(anchor)</strong>
</dt>
<dd>
Set grid anchor. Default anchor is equal to anchor of grid parent node
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">anchor</span>
<span class="types"><span class="type">vector3</span></span>
Anchor
</li>
</ul>
</dd>
<dt>
<a name = "add"></a>
<strong>add(item[, index])</strong>
</dt>
<dd>
Add new item to the grid
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">item</span>
<span class="types"><span class="type">node</span></span>
Gui node
</li>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span></span>
The item position. By default add as last item
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "remove"></a>
<strong>remove(index, is_shift_nodes)</strong>
</dt>
<dd>
Remove the item from the grid. Note that gui node will be not deleted
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span></span>
The grid node index to remove
</li>
<li><span class="parameter">is_shift_nodes</span>
<span class="types"><span class="type">bool</span></span>
If true, will shift nodes left after index
</li>
</ul>
</dd>
<dt>
<a name = "get_size"></a>
<strong>get_size()</strong>
</dt>
<dd>
Return grid content size
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3</span></span>
The grid content size
</ol>
</dd>
<dt>
<a name = "get_all_pos"></a>
<strong>get_all_pos()</strong>
</dt>
<dd>
Return array of all node positions
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3[]</span></span>
All grid node positions
</ol>
</dd>
<dt>
<a name = "set_position_function"></a>
<strong>set_position_function(callback)</strong>
</dt>
<dd>
Change set position function for grid nodes. It will call on
update poses on grid elements. Default: gui.set_position
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
Function on node set position
</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 = "clear"></a>
<strong>clear()</strong>
</dt>
<dd>
Clear grid nodes array. GUI nodes will be not deleted!
If you want to delete GUI nodes, use static_grid.nodes array before grid:clear
<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>
<dl class="function">
<dt>
<a name = "Events"></a>
<strong>Events</strong>
</dt>
<dd>
Component events
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_add_item</span>
<span class="types"><span class="type">druid_event</span></span>
On item add callback
</li>
<li><span class="parameter">on_remove_item</span>
<span class="types"><span class="type">druid_event</span></span>
On item remove callback
</li>
<li><span class="parameter">on_change_items</span>
<span class="types"><span class="type">druid_event</span></span>
On item add or remove callback
</li>
<li><span class="parameter">on_clear</span>
<span class="types"><span class="type">druid_event</span></span>
On grid clear callback
</li>
<li><span class="parameter">on_update_positions</span>
<span class="types"><span class="type">druid_event</span></span>
On update item positions callback
</li>
</ul>
</dd>
<dt>
<a name = "Fields"></a>
<strong>Fields</strong>
</dt>
<dd>
Component fields
<h3>Fields:</h3>
<ul>
<li><span class="parameter">parent</span>
<span class="types"><span class="type">node</span></span>
Parent gui node
</li>
<li><span class="parameter">nodes</span>
<span class="types"><span class="type">node[]</span></span>
List of all grid nodes
</li>
<li><span class="parameter">first_index</span>
<span class="types"><span class="type">number</span></span>
The first index of node in grid
</li>
<li><span class="parameter">last_index</span>
<span class="types"><span class="type">number</span></span>
The last index of node in grid
</li>
<li><span class="parameter">anchor</span>
<span class="types"><span class="type">vector3</span></span>
Item anchor
</li>
<li><span class="parameter">node_size</span>
<span class="types"><span class="type">vector3</span></span>
Item size
</li>
<li><span class="parameter">border</span>
<span class="types"><span class="type">vector4</span></span>
The size of item content
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>