mirror of
https://github.com/Insality/druid
synced 2025-09-27 18:12:21 +02:00
Update docs
This commit is contained in:
379
docs/modules/Druid.html
Normal file
379
docs/modules/Druid.html
Normal file
@@ -0,0 +1,379 @@
|
||||
<!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><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><strong>Druid</strong></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>Druid</code></h1>
|
||||
<p>Druid UI Component Framework.</p>
|
||||
<p>
|
||||
<b># Overview #</b>
|
||||
<p> Druid - powerful Defold component UI library. Use basic and extended
|
||||
Druid components or make your own game-specific components to make
|
||||
amazing GUI in your games.
|
||||
<p> To start using Druid, please refer to the Usage section below.
|
||||
<p> <b># Notes #</b>
|
||||
<p> • Each Druid instance maintains the self context from the constructor and passes it to each Druid callback.
|
||||
<p> See next: <a href="../modules/DruidInstance.html#">DruidInstance</a>
|
||||
</p>
|
||||
<h3>Usage:</h3>
|
||||
<ul>
|
||||
<pre class="example">local druid = require("druid.druid")
|
||||
|
||||
local function on_play(self)
|
||||
print("Gonna play!")
|
||||
end
|
||||
|
||||
function init(self)
|
||||
self.druid = druid.new(self)
|
||||
self.druid:new_button("button_play", on_play)
|
||||
end
|
||||
|
||||
function final(self)
|
||||
self.druid:final()
|
||||
end
|
||||
|
||||
function update(self, dt)
|
||||
self.druid:update(dt)
|
||||
end
|
||||
|
||||
function on_message(self, message_id, message, sender)
|
||||
self.druid:on_message(message_id, message, sender)
|
||||
end
|
||||
|
||||
function on_input(self, action_id, action)
|
||||
return self.druid:on_input(action_id, action)
|
||||
end
|
||||
</pre>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#druid.new">druid.new(context[, style])</a></td>
|
||||
<td class="summary">Create a new Druid instance for creating GUI components.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#druid.on_language_change">druid.on_language_change()</a></td>
|
||||
<td class="summary">Call this function when the game language changes.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#druid.on_window_callback">druid.on_window_callback(event)</a></td>
|
||||
<td class="summary">Set the window callback to enable on_focus_gain and on_focus_lost functions.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#druid.register">druid.register(name, module)</a></td>
|
||||
<td class="summary">Register a new external Druid component.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#druid.set_default_style">druid.set_default_style(style)</a></td>
|
||||
<td class="summary">Set your own default style for all Druid instances.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#druid.set_sound_function">druid.set_sound_function(callback)</a></td>
|
||||
<td class="summary">Set the Druid sound function to play UI sounds if used.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#druid.set_text_function">druid.set_text_function(callback)</a></td>
|
||||
<td class="summary">Set the text function for the LangText component.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "druid.new"></a>
|
||||
<strong>druid.new(context[, style])</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create a new Druid instance for creating GUI components.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">context</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
||||
The Druid context. Usually, this is the self of the gui_script. It is passed into all Druid callbacks.
|
||||
</li>
|
||||
<li><span class="parameter">style</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
||||
The Druid style table to override style parameters for this Druid instance.
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">druid_instance</span></span>
|
||||
The Druid instance <a href="../modules/DruidInstance.html#">DruidInstance</a>.
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
<h3>Usage:</h3>
|
||||
<ul>
|
||||
<pre class="example"><span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
|
||||
|
||||
<span class="keyword">function</span> init(self)
|
||||
self.druid = druid.new(self)
|
||||
<span class="keyword">end</span></pre>
|
||||
</ul>
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "druid.on_language_change"></a>
|
||||
<strong>druid.on_language_change()</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Call this function when the game language changes.
|
||||
<p> This function will translate all current LangText components.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3>Usage:</h3>
|
||||
<ul>
|
||||
<pre class="example">druid.on_language_change()</pre>
|
||||
</ul>
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "druid.on_window_callback"></a>
|
||||
<strong>druid.on_window_callback(event)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set the window callback to enable on_focus_gain and on_focus_lost functions.
|
||||
<p> This is used to trigger the on_focus_lost and on_focus_gain functions in Druid components.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">event</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
Event param from window listener
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
<h3>Usage:</h3>
|
||||
<ul>
|
||||
<pre class="example">window.set_listener(<span class="keyword">function</span>(_, event)
|
||||
druid.on_window_callback(event)
|
||||
<span class="keyword">end</span>)</pre>
|
||||
</ul>
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "druid.register"></a>
|
||||
<strong>druid.register(name, module)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Register a new external Druid component.
|
||||
<p> You can register your own components to make new alias: the druid:new_{name} function.
|
||||
For example, if you want to register a component called "my_component", you can create it using druid:new_my_component(...).
|
||||
This can be useful if you have your own "basic" components that you don't want to re-create each time.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">name</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
module name
|
||||
</li>
|
||||
<li><span class="parameter">module</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
||||
lua table with component
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
<h3>Usage:</h3>
|
||||
<ul>
|
||||
<pre class="example"><span class="keyword">local</span> my_component = <span class="global">require</span>(<span class="string">"path.to.my.component"</span>)
|
||||
druid.register(<span class="string">"my_component"</span>, my_component)
|
||||
...
|
||||
<span class="keyword">local</span> druid = druid.new(self)
|
||||
<span class="keyword">local</span> component_instance = self.druid:new_my_component(...)</pre>
|
||||
</ul>
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "druid.set_default_style"></a>
|
||||
<strong>druid.set_default_style(style)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set your own default style for all Druid instances.
|
||||
<p> To create your own style file, copy the default style file and make changes to it.
|
||||
Register the new style before creating your Druid instances.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">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>Usage:</h3>
|
||||
<ul>
|
||||
<pre class="example"><span class="keyword">local</span> my_style = <span class="global">require</span>(<span class="string">"path.to.my.style"</span>)
|
||||
druid.set_default_style(my_style)</pre>
|
||||
</ul>
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "druid.set_sound_function"></a>
|
||||
<strong>druid.set_sound_function(callback)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set the Druid sound function to play UI sounds if used.
|
||||
<p> Set a function to play a sound given a sound_id. This function is used for button clicks to play the "click" sound.
|
||||
It can also be used to play sounds in your custom components (see the default Druid style file for an example).
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
Sound play callback
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
<h3>Usage:</h3>
|
||||
<ul>
|
||||
<pre class="example">druid.set_sound_function(<span class="keyword">function</span>(sound_id)
|
||||
sound.play(sound_id) <span class="comment">-- Replace with your real function
|
||||
</span><span class="keyword">end</span>)</pre>
|
||||
</ul>
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "druid.set_text_function"></a>
|
||||
<strong>druid.set_text_function(callback)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set the text function for the LangText component.
|
||||
<p> The Druid locale component will call this function to get translated text.
|
||||
After setting the text function, all existing locale components will be updated.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
Get localized text function
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
<h3>Usage:</h3>
|
||||
<ul>
|
||||
<pre class="example">druid.set_text_function(<span class="keyword">function</span>(text_id)
|
||||
<span class="keyword">return</span> lang_data[text_id] <span class="comment">-- Replace with your real function
|
||||
</span><span class="keyword">end</span>)</pre>
|
||||
</ul>
|
||||
|
||||
</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>
|
Reference in New Issue
Block a user