mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 18:37:44 +02:00
661 lines
18 KiB
HTML
661 lines
18 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 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>Contents</h2>
|
|
<ul>
|
|
<li><a href="#Functions">Functions</a></li>
|
|
</ul>
|
|
|
|
|
|
<h2>Modules</h2>
|
|
<ul class="nowrap">
|
|
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
|
|
<li><strong>BaseComponent</strong></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>
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<div id="content">
|
|
|
|
<h1>Module <code>BaseComponent</code></h1>
|
|
<p>Basic class for all Druid components.</p>
|
|
<p>
|
|
To create you custom component, use static function `component.create`</p>
|
|
<h3>Usage:</h3>
|
|
<ul>
|
|
<pre class="example">-- Create your component:
|
|
local component = require("druid.component")
|
|
|
|
local AwesomeComponent = component.create("awesome_component")
|
|
|
|
function AwesomeComponent:init(template, nodes)
|
|
self:set_template(template)
|
|
self:set_nodes(nodes)
|
|
self.druid = self:get_druid()
|
|
end
|
|
|
|
return AwesomeComponent
|
|
</pre>
|
|
</ul>
|
|
|
|
|
|
<h2><a href="#Functions">Functions</a></h2>
|
|
<table class="function_list">
|
|
<tr>
|
|
<td class="name" nowrap><a href="#component:get_childrens">component:get_childrens(self)</a></td>
|
|
<td class="summary">Return all children components, recursive</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#component:get_context">component:get_context(self)</a></td>
|
|
<td class="summary">Context used as first arg in all Druid events</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#component:get_druid">component:get_druid(self)</a></td>
|
|
<td class="summary">Get Druid instance for inner component creation.</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#component:get_input_priority">component:get_input_priority(self)</a></td>
|
|
<td class="summary">Return component input priority</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#component:get_name">component:get_name(self)</a></td>
|
|
<td class="summary">Return component name</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#component:get_node">component:get_node(self, node_or_name)</a></td>
|
|
<td class="summary">Get component node by name.</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#component:get_parent_component">component:get_parent_component(self)</a></td>
|
|
<td class="summary">Return the parent component if exist</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#component:get_parent_name">component:get_parent_name(self)</a></td>
|
|
<td class="summary">Return parent component name</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#component:get_template">component:get_template(self)</a></td>
|
|
<td class="summary">Get current component template name.</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#component:get_uid">component:get_uid(self)</a></td>
|
|
<td class="summary">Return component UID.</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#component:reset_input_priority">component:reset_input_priority(self)</a></td>
|
|
<td class="summary">Reset component input priority to default value</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#component:set_input_enabled">component:set_input_enabled(self, state)</a></td>
|
|
<td class="summary">Set component input state.</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#component:set_input_priority">component:set_input_priority(self, value, is_temporary)</a></td>
|
|
<td class="summary">Set component input priority</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#component:set_nodes">component:set_nodes(self, nodes)</a></td>
|
|
<td class="summary">Set current component nodes</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#component:set_style">component:set_style(self, druid_style)</a></td>
|
|
<td class="summary">Set current component style table.</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name" nowrap><a href="#component:set_template">component:set_template(self, template)</a></td>
|
|
<td class="summary">Set component template name.</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<br/>
|
|
<br/>
|
|
|
|
|
|
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
|
|
|
<dl class="function">
|
|
<dt>
|
|
<a name = "component:get_childrens"></a>
|
|
<strong>component:get_childrens(self)</strong>
|
|
</dt>
|
|
<dd>
|
|
Return all children components, recursive
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">self</span>
|
|
<span class="types"><span class="type">BaseComponent</span></span>
|
|
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Returns:</h3>
|
|
<ol>
|
|
|
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
|
Array of childrens if the Druid component instance
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "component:get_context"></a>
|
|
<strong>component:get_context(self)</strong>
|
|
</dt>
|
|
<dd>
|
|
Context used as first arg in all Druid events Context is usually self of gui_script.
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">self</span>
|
|
<span class="types"><span class="type">BaseComponent</span></span>
|
|
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Returns:</h3>
|
|
<ol>
|
|
|
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
|
BaseComponent context
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "component:get_druid"></a>
|
|
<strong>component:get_druid(self)</strong>
|
|
</dt>
|
|
<dd>
|
|
Get Druid instance for inner component creation.
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">self</span>
|
|
<span class="types"><span class="type">BaseComponent</span></span>
|
|
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Returns:</h3>
|
|
<ol>
|
|
|
|
<span class="types"><span class="type">Druid</span></span>
|
|
Druid instance with component context
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "component:get_input_priority"></a>
|
|
<strong>component:get_input_priority(self)</strong>
|
|
</dt>
|
|
<dd>
|
|
Return component input priority
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">self</span>
|
|
<span class="types"><span class="type">BaseComponent</span></span>
|
|
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Returns:</h3>
|
|
<ol>
|
|
|
|
<span class="types"><span class="type">number</span></span>
|
|
The component input priority
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "component:get_name"></a>
|
|
<strong>component:get_name(self)</strong>
|
|
</dt>
|
|
<dd>
|
|
Return component name
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">self</span>
|
|
<span class="types"><span class="type">BaseComponent</span></span>
|
|
<a href="../modules/BaseComponent.html#">BaseComponent</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>
|
|
The component name
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "component:get_node"></a>
|
|
<strong>component:get_node(self, node_or_name)</strong>
|
|
</dt>
|
|
<dd>
|
|
Get component node by name.
|
|
<p> If component has nodes, node_or_name should be string
|
|
It autopick node by template name or from nodes by gui.clone_tree
|
|
if they was setup via component:set_nodes, component:set_template.
|
|
If node is not found, the exception will fired
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">self</span>
|
|
<span class="types"><span class="type">BaseComponent</span></span>
|
|
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
</li>
|
|
<li><span class="parameter">node_or_name</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">node</span></span>
|
|
Node name or node itself
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Returns:</h3>
|
|
<ol>
|
|
|
|
<span class="types"><span class="type">node</span></span>
|
|
Gui node
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "component:get_parent_component"></a>
|
|
<strong>component:get_parent_component(self)</strong>
|
|
</dt>
|
|
<dd>
|
|
Return the parent component if exist
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">self</span>
|
|
<span class="types"><span class="type">BaseComponent</span></span>
|
|
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Returns:</h3>
|
|
<ol>
|
|
|
|
<span class="types"><span class="type">BaseComponent</span> or <span class="type">nil</span></span>
|
|
The druid component instance or nil
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "component:get_parent_name"></a>
|
|
<strong>component:get_parent_name(self)</strong>
|
|
</dt>
|
|
<dd>
|
|
Return parent component name
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">self</span>
|
|
<span class="types"><span class="type">BaseComponent</span></span>
|
|
<a href="../modules/BaseComponent.html#">BaseComponent</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> or <span class="type">nil</span></span>
|
|
The parent component name if exist or bil
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "component:get_template"></a>
|
|
<strong>component:get_template(self)</strong>
|
|
</dt>
|
|
<dd>
|
|
Get current component template name.
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">self</span>
|
|
<span class="types"><span class="type">BaseComponent</span></span>
|
|
<a href="../modules/BaseComponent.html#">BaseComponent</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>
|
|
Component full template name
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "component:get_uid"></a>
|
|
<strong>component:get_uid(self)</strong>
|
|
</dt>
|
|
<dd>
|
|
Return component UID.
|
|
<p> UID generated in component creation order.
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">self</span>
|
|
<span class="types"><span class="type">BaseComponent</span></span>
|
|
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Returns:</h3>
|
|
<ol>
|
|
|
|
<span class="types"><span class="type">number</span></span>
|
|
The component uid
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "component:reset_input_priority"></a>
|
|
<strong>component:reset_input_priority(self)</strong>
|
|
</dt>
|
|
<dd>
|
|
Reset component input priority to default value
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">self</span>
|
|
<span class="types"><span class="type">BaseComponent</span></span>
|
|
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Returns:</h3>
|
|
<ol>
|
|
|
|
<span class="types"><span class="type">number</span></span>
|
|
The component input priority
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "component:set_input_enabled"></a>
|
|
<strong>component:set_input_enabled(self, state)</strong>
|
|
</dt>
|
|
<dd>
|
|
Set component input state. By default it enabled
|
|
<p> If input is disabled, the component will not receive input events
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">self</span>
|
|
<span class="types"><span class="type">BaseComponent</span></span>
|
|
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
</li>
|
|
<li><span class="parameter">state</span>
|
|
<span class="types"><span class="type">bool</span></span>
|
|
The component input state
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Returns:</h3>
|
|
<ol>
|
|
|
|
<span class="types"><span class="type">BaseComponent</span></span>
|
|
BaseComponent itself
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "component:set_input_priority"></a>
|
|
<strong>component:set_input_priority(self, value, is_temporary)</strong>
|
|
</dt>
|
|
<dd>
|
|
Set component input priority Default value: 10
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">self</span>
|
|
<span class="types"><span class="type">BaseComponent</span></span>
|
|
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
</li>
|
|
<li><span class="parameter">value</span>
|
|
<span class="types"><span class="type">number</span></span>
|
|
The new input priority value
|
|
</li>
|
|
<li><span class="parameter">is_temporary</span>
|
|
<span class="types"><span class="type">boolean</span></span>
|
|
If true, the reset input priority will return to previous value
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Returns:</h3>
|
|
<ol>
|
|
|
|
<span class="types"><span class="type">number</span></span>
|
|
The component input priority
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "component:set_nodes"></a>
|
|
<strong>component:set_nodes(self, nodes)</strong>
|
|
</dt>
|
|
<dd>
|
|
Set current component nodes Use if your component nodes was cloned with `gui.clone_tree` and you got the node tree.
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">self</span>
|
|
<span class="types"><span class="type">BaseComponent</span></span>
|
|
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
</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>
|
|
BaseComponent nodes table
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Returns:</h3>
|
|
<ol>
|
|
|
|
<span class="types"><span class="type">BaseComponent</span></span>
|
|
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
</ol>
|
|
|
|
|
|
|
|
<h3>Usage:</h3>
|
|
<ul>
|
|
<pre class="example"><span class="keyword">local</span> nodes = gui.clone_tree(self.prefab)
|
|
... In your component:
|
|
self:set_nodes(nodes)</pre>
|
|
</ul>
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "component:set_style"></a>
|
|
<strong>component:set_style(self, druid_style)</strong>
|
|
</dt>
|
|
<dd>
|
|
Set current component style table.
|
|
<p> Invoke `on_style_change` on component, if exist. Component should handle
|
|
their style changing and store all style params
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">self</span>
|
|
<span class="types"><span class="type">BaseComponent</span></span>
|
|
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
</li>
|
|
<li><span class="parameter">druid_style</span>
|
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
|
Druid style module
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Returns:</h3>
|
|
<ol>
|
|
|
|
<span class="types"><span class="type">BaseComponent</span></span>
|
|
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
<dt>
|
|
<a name = "component:set_template"></a>
|
|
<strong>component:set_template(self, template)</strong>
|
|
</dt>
|
|
<dd>
|
|
Set component template name.
|
|
<p> Use on all your custom components with GUI layouts used as templates.
|
|
It will check parent template name to build full template name in self:get_node()
|
|
|
|
|
|
<h3>Parameters:</h3>
|
|
<ul>
|
|
<li><span class="parameter">self</span>
|
|
<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></span>
|
|
BaseComponent template name
|
|
</li>
|
|
</ul>
|
|
|
|
<h3>Returns:</h3>
|
|
<ol>
|
|
|
|
<span class="types"><span class="type">BaseComponent</span></span>
|
|
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
</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>
|