Merge branch 'develop'

This commit is contained in:
Insality 2020-06-14 20:15:07 +03:00
commit 5f873c2305
47 changed files with 293 additions and 98 deletions

View File

@ -5,7 +5,7 @@
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/insality/druid)](https://github.com/Insality/druid/releases) [![GitHub release (latest by date)](https://img.shields.io/github/v/release/insality/druid)](https://github.com/Insality/druid/releases)
**Druid** - powerful defold component UI library. Use basic **Druid** components or make your own game-specific components to make amazing GUI in your games. **Druid** - powerful Defold component UI library. Use basic **Druid** components or make your own game-specific components to make amazing GUI in your games.
## Setup ## Setup
@ -184,18 +184,19 @@ function on_message(self, message_id, message, sender)
end end
``` ```
- *final* required function for correct druid lifecycle
- *on_input* used for almost all basic druid components - *on_input* used for almost all basic druid components
- *update* used for progress bar, scroll and timer base components - *update* used for progress bar, scroll and timer base components
- *on_message* used for specific druid events, like language change or layout change - *on_message* used for specific druid events, like language change or layout change
- *final* used for custom components, what have to do several action before destroy
Recommended is fully integrate al druid lifecycles functions Recommended is fully integrate all druid lifecycles functions
## Features ## Features
- Druid input goes as stack. Last created button will checked first. So create your GUI from back - Druid input goes as stack. Last created button will checked first. So create your GUI from back
- Don't forget about `return` in `on_input`: `return self.druid:on_input()`. It need, if you have more than 1 acquire inputs (several druid, other input system, etc) - Don't forget about `return` in `on_input`: `return self.druid:on_input()`. It need, if you have more than 1 acquire inputs (several druid, other input system, etc)
- Druid by default do _acquire_input_focus_. So you don't need do it manually. Buy only if you have components, which requires _on_input_
## Examples ## Examples

View File

@ -200,7 +200,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -510,7 +510,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -218,7 +218,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -237,7 +237,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -99,11 +99,11 @@
<td class="summary">Return button enabled state</td> <td class="summary">Return button enabled state</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#set_click_zone">set_click_zone(zone, Self)</a></td> <td class="name" nowrap><a href="#set_click_zone">set_click_zone(zone)</a></td>
<td class="summary">Strict button click area.</td> <td class="summary">Strict button click area.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#set_key_trigger">set_key_trigger(key, Self)</a></td> <td class="name" nowrap><a href="#set_key_trigger">set_key_trigger(key)</a></td>
<td class="summary">Set key-code to trigger this button</td> <td class="summary">Set key-code to trigger this button</td>
</tr> </tr>
<tr> <tr>
@ -185,6 +185,12 @@
</li> </li>
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.button</span></span>
Current button instance
</ol>
@ -212,7 +218,7 @@
</dd> </dd>
<dt> <dt>
<a name = "set_click_zone"></a> <a name = "set_click_zone"></a>
<strong>set_click_zone(zone, Self)</strong> <strong>set_click_zone(zone)</strong>
</dt> </dt>
<dd> <dd>
Strict button click area. Useful for Strict button click area. Useful for
@ -225,12 +231,14 @@
<span class="types"><span class="type">node</span></span> <span class="types"><span class="type">node</span></span>
Gui node Gui node
</li> </li>
<li><span class="parameter">Self</span>
<span class="types"><span class="type">druid.button</span></span>
instance to make chain calls
</li>
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.button</span></span>
Current button instance
</ol>
@ -238,7 +246,7 @@
</dd> </dd>
<dt> <dt>
<a name = "set_key_trigger"></a> <a name = "set_key_trigger"></a>
<strong>set_key_trigger(key, Self)</strong> <strong>set_key_trigger(key)</strong>
</dt> </dt>
<dd> <dd>
Set key-code to trigger this button Set key-code to trigger this button
@ -250,12 +258,14 @@
<span class="types"><span class="type">hash</span></span> <span class="types"><span class="type">hash</span></span>
The action_id of the key The action_id of the key
</li> </li>
<li><span class="parameter">Self</span>
<span class="types"><span class="type">druid.button</span></span>
instance to make chain calls
</li>
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.button</span></span>
Current button instance
</ol>
@ -438,7 +448,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -282,7 +282,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -242,7 +242,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -282,7 +282,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -374,7 +374,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -298,7 +298,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -102,6 +102,14 @@
<td class="name" nowrap><a href="#set_click_zone">set_click_zone(zone)</a></td> <td class="name" nowrap><a href="#set_click_zone">set_click_zone(zone)</a></td>
<td class="summary">Strict hover click area.</td> <td class="summary">Strict hover click area.</td>
</tr> </tr>
<tr>
<td class="name" nowrap><a href="#set_enabled">set_enabled(state)</a></td>
<td class="summary">Set enable state of hover component.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#is_enabled">is_enabled()</a></td>
<td class="summary">Return current hover enabled state</td>
</tr>
</table> </table>
<h2><a href="#Tables">Tables</a></h2> <h2><a href="#Tables">Tables</a></h2>
<table class="function_list"> <table class="function_list">
@ -206,6 +214,49 @@
</dd>
<dt>
<a name = "set_enabled"></a>
<strong>set_enabled(state)</strong>
</dt>
<dd>
Set enable state of hover component.
If hover is not enabled, it will not generate
any hover events
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">state</span>
<span class="types"><span class="type">bool</span></span>
The hover enabled state
</li>
</ul>
</dd>
<dt>
<a name = "is_enabled"></a>
<strong>is_enabled()</strong>
</dt>
<dd>
Return current hover enabled state
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">bool</span></span>
The hover enabled state
</ol>
</dd> </dd>
</dl> </dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2> <h2 class="section-header "><a name="Tables"></a>Tables</h2>
@ -243,7 +294,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -329,7 +329,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -194,7 +194,7 @@
<ol> <ol>
<span class="types"><span class="type">druid.input</span></span> <span class="types"><span class="type">druid.input</span></span>
Self instance to make chain calls Current input instance
</ol> </ol>
@ -223,7 +223,7 @@
<ol> <ol>
<span class="types"><span class="type">druid.input</span></span> <span class="types"><span class="type">druid.input</span></span>
Self instance to make chain calls Current input instance
</ol> </ol>
@ -388,7 +388,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -243,7 +243,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -386,7 +386,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -242,7 +242,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -122,7 +122,7 @@
<td class="summary">Return if scroll have inertion.</td> <td class="summary">Return if scroll have inertion.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#set_extra_strech_size">set_extra_strech_size([stretch_size=0])</a></td> <td class="name" nowrap><a href="#set_extra_stretch_size">set_extra_stretch_size([stretch_size=0])</a></td>
<td class="summary">Set extra size for scroll stretching.</td> <td class="summary">Set extra size for scroll stretching.</td>
</tr> </tr>
<tr> <tr>
@ -311,7 +311,7 @@
<ol> <ol>
<span class="types"><span class="type">druid.scroll</span></span> <span class="types"><span class="type">druid.scroll</span></span>
Self instance Current scroll instance
</ol> </ol>
@ -340,7 +340,7 @@
<ol> <ol>
<span class="types"><span class="type">druid.scroll</span></span> <span class="types"><span class="type">druid.scroll</span></span>
Self instance Current scroll instance
</ol> </ol>
@ -368,8 +368,8 @@
</dd> </dd>
<dt> <dt>
<a name = "set_extra_strech_size"></a> <a name = "set_extra_stretch_size"></a>
<strong>set_extra_strech_size([stretch_size=0])</strong> <strong>set_extra_stretch_size([stretch_size=0])</strong>
</dt> </dt>
<dd> <dd>
Set extra size for scroll stretching. Set extra size for scroll stretching.
@ -389,7 +389,7 @@
<ol> <ol>
<span class="types"><span class="type">druid.scroll</span></span> <span class="types"><span class="type">druid.scroll</span></span>
Self instance Current scroll instance
</ol> </ol>
@ -437,7 +437,7 @@
<ol> <ol>
<span class="types"><span class="type">druid.scroll</span></span> <span class="types"><span class="type">druid.scroll</span></span>
Self instance Current scroll instance
</ol> </ol>
@ -586,7 +586,7 @@
Scroll gui.animation speed for scroll_to function Scroll gui.animation speed for scroll_to function
(<em>default</em> 0.2) (<em>default</em> 0.2)
</li> </li>
<li><span class="parameter">EXTRA_STRECH_SIZE</span> <li><span class="parameter">EXTRA_STRETCH_SIZE</span>
<span class="types"><span class="type">number</span></span> <span class="types"><span class="type">number</span></span>
extra size in pixels outside of scroll (stretch effect) extra size in pixels outside of scroll (stretch effect)
(<em>default</em> 0) (<em>default</em> 0)
@ -610,7 +610,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -281,7 +281,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -256,7 +256,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -407,7 +407,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -296,7 +296,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -242,7 +242,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -913,7 +913,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -129,7 +129,8 @@ Where node name is name of node from GUI scene. You can use <code>node_name</cod
- **on_double_click** - different callback, if tap button 2+ in row, don'</span>t trigger <span class="keyword">if</span> callback is empty - **on_double_click** - different callback, if tap button 2+ in row, don'</span>t trigger <span class="keyword">if</span> callback is empty
</pre> </pre>
<p>- If button have double click event and it is triggered, usual callback will be not invoked <p>- Click event will not trigger, if between pressed and released state cursor was outside of node zone
- If button have double click event and it is triggered, usual callback will be not invoked
- If you have stencil on buttons and you don't want trigger them outside of stencil node, you can use <a href="../modules/druid.button.html#set_click_zone">button:set_click_zone</a> to restrict button click zone - If you have stencil on buttons and you don't want trigger them outside of stencil node, you can use <a href="../modules/druid.button.html#set_click_zone">button:set_click_zone</a> to restrict button click zone
- Button can have key trigger to use then by key: <a href="../modules/druid.button.html#set_key_trigger">button:set_key_trigger</a> - Button can have key trigger to use then by key: <a href="../modules/druid.button.html#set_key_trigger">button:set_key_trigger</a>
- Animation node can be used for example to animate small icon on big panel. Node name of trigger zone will be <code>big panel</code> and animation node will be <code>small icon</code></p> - Animation node can be used for example to animate small icon on big panel. Node name of trigger zone will be <code>big panel</code> and animation node will be <code>small icon</code></p>
@ -239,7 +240,7 @@ Where node name is name of node from GUI scene. You can use <code>node_name</cod
<p>- You can adjust scroll content size by <code>scroll:set_size(node_size)</code>. It will setup new size to <em>content node</em> <p>- You can adjust scroll content size by <code>scroll:set_size(node_size)</code>. It will setup new size to <em>content node</em>
- You can enabled or disable inertion mode via <code>scroll:set_intert(state)</code> - You can enabled or disable inertion mode via <code>scroll:set_intert(state)</code>
- You can adjust extra stretch size via <code>scroll:set_extra_stretch_size</code> - You can adjust extra stretch size via <a href="../modules/druid.scroll.html#set_extra_stretch_size">scroll:set_extra_stretch_size</a>
- Multitouch is required for scroll. Scroll is correctly handling touch_id swap while dragging scroll</p> - Multitouch is required for scroll. Scroll is correctly handling touch_id swap while dragging scroll</p>
@ -386,7 +387,8 @@ Key is value from druid const: const.SIDE.X (or just "x") or const.SIDE.Y (or ju
<h3>Notes</h3> <h3>Notes</h3>
<p>- By default, hover handles <em>hover event</em> with pressed touch action_id. So it's mean, what mouse or touch have to be pressed <p>- By default, hover handles <em>hover event</em> with pressed touch action_id. So it's mean, what mouse or touch have to be pressed
- On desktop platforms there is <em>on</em>mouse<em>hover</em> event. It's event on mouse hover without any action id</p> - On desktop platforms there is <em>on</em>mouse<em>hover</em> event. It's event on mouse hover without any action id
- By default, assume what node is on not hovered state (both <em>hover</em> and <em>mouse</em>hover_)</p>
<p><a name="Swipe"></a></p> <p><a name="Swipe"></a></p>
@ -463,7 +465,7 @@ Key is value from druid const: const.SIDE.X (or just "x") or const.SIDE.Y (or ju
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -121,8 +121,8 @@
</span><span class="keyword">function</span> M.on_message(self, message_id, message, sender) </span><span class="keyword">function</span> M.on_message(self, message_id, message, sender)
<span class="keyword">end</span> <span class="keyword">end</span>
<span class="comment">-- Call only if component with ON_LANGUAGE_CHANGE interest <span class="comment">-- Call only if component with ON_ANGUAGECHANinterest
</span><span class="keyword">function</span> M.on_language_change(self) </span><span class="keyword">function</span> M.on_anguagechanself)
<span class="keyword">end</span> <span class="keyword">end</span>
<span class="comment">-- Call only if component with ON_LAYOUT_CHANGE interest <span class="comment">-- Call only if component with ON_LAYOUT_CHANGE interest
@ -245,7 +245,7 @@ There is next interests in druid:
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -155,7 +155,7 @@ You can pass <em>nil</em> or <em>empty</em>table_ to use default values for all
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -92,7 +92,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -90,7 +90,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -90,7 +90,7 @@
<p><a href="https://github.com/Insality/druid/releases"><img src="https://img.shields.io/github/v/release/insality/druid" alt="GitHub release (latest by date)"/></a></p> <p><a href="https://github.com/Insality/druid/releases"><img src="https://img.shields.io/github/v/release/insality/druid" alt="GitHub release (latest by date)"/></a></p>
<p><strong>Druid</strong> - powerful defold component UI library. Use basic <strong>Druid</strong> components or make your own game-specific components to make amazing GUI in your games.</p> <p><strong>Druid</strong> - powerful Defold component UI library. Use basic <strong>Druid</strong> components or make your own game-specific components to make amazing GUI in your games.</p>
<p><a name="Setup"></a></p> <p><a name="Setup"></a></p>
@ -271,13 +271,13 @@
<ul> <ul>
<li><em>final</em> required function for correct druid lifecycle</li>
<li>*on_input* used for almost all basic druid components</li> <li>*on_input* used for almost all basic druid components</li>
<li><em>update</em> used for progress bar, scroll and timer base components</li> <li><em>update</em> used for progress bar, scroll and timer base components</li>
<li>*on_message* used for specific druid events, like language change or layout change</li> <li>*on_message* used for specific druid events, like language change or layout change</li>
<li><em>final</em> used for custom components, what have to do several action before destroy</li>
</ul> </ul>
<p>Recommended is fully integrate al druid lifecycles functions</p> <p>Recommended is fully integrate all druid lifecycles functions</p>
<p><a name="Features"></a></p> <p><a name="Features"></a></p>
@ -286,6 +286,7 @@
<ul> <ul>
<li>Druid input goes as stack. Last created button will checked first. So create your GUI from back</li> <li>Druid input goes as stack. Last created button will checked first. So create your GUI from back</li>
<li>Don't forget about <code>return</code> in <code>on_input</code>: <code>return self.druid:on_input()</code>. It need, if you have more than 1 acquire inputs (several druid, other input system, etc)</li> <li>Don't forget about <code>return</code> in <code>on_input</code>: <code>return self.druid:on_input()</code>. It need, if you have more than 1 acquire inputs (several druid, other input system, etc)</li>
<li>Druid by default do <em>acquire</em>input<em>focus</em>. So you don't need do it manually. Buy only if you have components, which requires <em>on</em>input_ </li>
</ul> </ul>
@ -339,7 +340,7 @@ https://insality.github.io/druid/</p>
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -72,8 +72,7 @@
<div id="content"> <div id="content">
Druid 0.3.0:</p>
<p>Druid 0.3.0:</p>
<ul> <ul>
<li><p><code>Druid:final()</code> now is important function for correct working</p></li> <li><p><code>Druid:final()</code> now is important function for correct working</p></li>
@ -133,11 +132,11 @@
- on_drag_start (self) - on_drag_start (self)
- on_drag (self, dx, dy) - on_drag (self, dx, dy)
- on_drag_end (self) - on_drag_end (self)
- You can restriction side of draggin by changing _drag.can_x_ <span class="keyword">and</span> _drag.can_y_ fields - You can restriction side of dragging by changing _drag.can_x_ <span class="keyword">and</span> _drag.can_y_ fields
- You can setup drag deadzone to detect, when dragging is started (by default <span class="number">10</span> pixels) - You can setup drag deadzone to detect, when dragging is started (_by default <span class="number">10</span> pixels_)
</pre> </pre>
</li> </li>
<li><p>Druid <em>Scroll</em> component fully reworked. Input logic moved to <em>Drag</em> component</p> <li><p>[Breaking changes] Druid <em>Scroll</em> component fully reworked. Input logic moved to <em>Drag</em> component</p>
<pre> <pre>
- Update scroll documentation - Update scroll documentation
@ -151,7 +150,7 @@
- Different anchoring is supported (<span class="keyword">for</span> easier layouting) - Different anchoring is supported (<span class="keyword">for</span> easier layouting)
- Function _scroll_to_ now accept position relative to _content node_. It's more easier <span class="keyword">for</span> handling. _Example:_ <span class="keyword">if</span> you have children node of _content_node_, you can pass this node position to scroll to this. - Function _scroll_to_ now accept position relative to _content node_. It's more easier <span class="keyword">for</span> handling. _Example:_ <span class="keyword">if</span> you have children node of _content_node_, you can pass this node position to scroll to this.
- **Resolve #<span class="number">52</span>**: _Content node size_ now can be less than _view node size_. In this case, content will be scrolled only inside _view size_ (can be disabled via style field: _SMALL_CONTENT_SCROLL_) - **Resolve #<span class="number">52</span>**: _Content node size_ now can be less than _view node size_. In this case, content will be scrolled only inside _view size_ (can be disabled via style field: _SMALL_CONTENT_SCROLL_)
- **Fix #<span class="number">50</span>**: If style:SOFT_ZONE_SIZE equals to [<span class="number">0.</span>.<span class="number">1</span>], scroll can be disappeared - **Fix #<span class="number">50</span>**: If style.SOFT_ZONE_SIZE equals to [<span class="number">0.</span>.<span class="number">1</span>], scroll can be disappeared
</pre> </pre>
</li> </li>
<li><p>Druid <em>Grid</em> Update</p> <li><p>Druid <em>Grid</em> Update</p>
@ -172,9 +171,9 @@
<pre> <pre>
- Styles <span class="global">table</span> now can be empty, every component have their default style values - Styles <span class="global">table</span> now can be empty, every component have their default style values
- Remove <span class="backtick"><code>component:get_style</code></span> <span class="keyword">function</span>. Now style can be only set - Remove <span class="backtick"><code>component:get_style</code></span> <span class="keyword">function</span>. Now you can only set styles
- To get style values <span class="keyword">in</span> component, add <span class="backtick"><code>component:on_style_change</code></span> <span class="keyword">function</span>. It's invoked on <span class="backtick"><a href="../modules/component.html#set_style">component:set_style</a></span> <span class="keyword">function</span> - To get style values <span class="keyword">in</span> component, add <span class="backtick"><code>component:on_style_change</code></span> <span class="keyword">function</span>. It's invoked on <span class="backtick"><a href="../modules/component.html#set_style">component:set_style</a></span> <span class="keyword">function</span>
- You can look up default values inside <span class="backtick"><code>component:on_style_change</code></span> <span class="keyword">function</span> <span class="keyword">or</span> style component API on Druid API - You can look up default values inside <span class="backtick"><code>component:on_style_change</code></span> <span class="keyword">function</span> <span class="keyword">or</span> style component API on [Druid API](https://insality.github.<span class="global">io</span>/druid/index.html)
</pre> </pre>
</li> </li>
<li><p>Druid update:</p> <li><p>Druid update:</p>
@ -183,17 +182,24 @@
- Now <span class="keyword">function</span> <span class="backtick"><code>druid:remove</code></span> remove instance <span class="keyword">and</span> all instance children components. No more manual deleting child components (#<span class="number">41</span>) - Now <span class="keyword">function</span> <span class="backtick"><code>druid:remove</code></span> remove instance <span class="keyword">and</span> all instance children components. No more manual deleting child components (#<span class="number">41</span>)
</pre> </pre>
</li> </li>
<li><p><strong>Fix:</strong> Blocker component bug (blocker had very high priority, so it's block even button components, created after bloker)</p></li> <li><p><strong>Fix:</strong> Blocker component bug (blocker had very high priority, so it's block even button components, created after blocker)</p></li>
<li><p><strong>Fix #58:</strong> Bug, when druid instance should be always named <a href="../modules/druid.html#">druid</a> (ex: <code>self.druid = druid.new(self)</code>)</p></li> <li><p><strong>Fix #58:</strong> Bug, when druid instance should be always named <a href="../modules/druid.html#">druid</a> (ex: <code>self.druid = druid.new(self)</code>)</p></li>
<li><p><strong>Fix #53:</strong> Bug with final <em>Druid instance</em> without any components</p></li> <li><p><strong>Fix #53:</strong> Bug with final <em>Druid instance</em> without any components</p></li>
</ul> </ul>
<p>Druid 0.5.0:
- <strong>Fix #61:</strong> Button component: fix button animation node creation
- <strong>Fix #64:</strong> Hover component: wrong mouse_hover default state
- <strong>Fix #71:</strong> Blocker: blocker now correct block mouse hover event
- <strong>Fix #72:</strong> Fix <code>return nil</code> in some <code>on_input</code> functions
- <strong>Fix #74:</strong> Fix typo: strech -> stretch. Scroll function <code>set_extra_stretch_size</code> renamed
</div> <!-- id="content" --> </div> <!-- id="content" -->
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i> <i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -25,6 +25,7 @@ Where node name is name of node from GUI scene. You can use `node_name` as input
- **on_long_click** - callback on long button tap, don't trigger if callback is empty - **on_long_click** - callback on long button tap, don't trigger if callback is empty
- **on_hold_click** - hold callback, before long_click trigger, don't trigger if callback is empty - **on_hold_click** - hold callback, before long_click trigger, don't trigger if callback is empty
- **on_double_click** - different callback, if tap button 2+ in row, don't trigger if callback is empty - **on_double_click** - different callback, if tap button 2+ in row, don't trigger if callback is empty
- Click event will not trigger, if between pressed and released state cursor was outside of node zone
- If button have double click event and it is triggered, usual callback will be not invoked - If button have double click event and it is triggered, usual callback will be not invoked
- If you have stencil on buttons and you don't want trigger them outside of stencil node, you can use `button:set_click_zone` to restrict button click zone - If you have stencil on buttons and you don't want trigger them outside of stencil node, you can use `button:set_click_zone` to restrict button click zone
- Button can have key trigger to use then by key: `button:set_key_trigger` - Button can have key trigger to use then by key: `button:set_key_trigger`

View File

@ -36,8 +36,8 @@ end
function M.on_message(self, message_id, message, sender) function M.on_message(self, message_id, message, sender)
end end
-- Call only if component with ON_LANGUAGE_CHANGE interest -- Call only if component with ON_ANGUAGECHANinterest
function M.on_language_change(self) function M.on_anguagechanself)
end end
-- Call only if component with ON_LAYOUT_CHANGE interest -- Call only if component with ON_LAYOUT_CHANGE interest

View File

@ -96,3 +96,8 @@ Druid 0.4.0:
Druid 0.5.0: Druid 0.5.0:
- **Fix #61:** Button component: fix button animation node creation - **Fix #61:** Button component: fix button animation node creation
- **Fix #64:** Hover component: wrong mouse_hover default state - **Fix #64:** Hover component: wrong mouse_hover default state
- **Fix #71:** Blocker: blocker now correct block mouse hover event
- **Fix #72:** Fix `return nil` in some `on_input` functions
- **Fix #74:** Fix typo: strech -> stretch. Scroll function `set_extra_stretch_size` renamed
- Add `component.tempalte.lua` as template for Druid custom component

View File

@ -29,7 +29,9 @@ end
function M.on_input(self, action_id, action) function M.on_input(self, action_id, action)
if action_id ~= const.ACTION_TOUCH and action_id ~= const.ACTION_MULTITOUCH then if action_id ~= const.ACTION_TOUCH and
action_id ~= const.ACTION_MULTITOUCH and
action_id ~= nil then
return false return false
end end

View File

@ -265,9 +265,13 @@ end
--- Set enabled button component state --- Set enabled button component state
-- @function button:set_enabled -- @function button:set_enabled
-- @tparam bool state Enabled state -- @tparam bool state Enabled state
-- @treturn druid.button Current button instance
function M.set_enabled(self, state) function M.set_enabled(self, state)
self.disabled = not state self.disabled = not state
self.hover:set_enabled(state)
self.style.on_set_enabled(self, self.node, state) self.style.on_set_enabled(self, self.node, state)
return self
end end
@ -283,10 +287,11 @@ end
-- no click events outside stencil node -- no click events outside stencil node
-- @function button:set_click_zone -- @function button:set_click_zone
-- @tparam node zone Gui node -- @tparam node zone Gui node
-- @tparam druid.button Self instance to make chain calls -- @treturn druid.button Current button instance
function M.set_click_zone(self, zone) function M.set_click_zone(self, zone)
self.click_zone = self:get_node(zone) self.click_zone = self:get_node(zone)
self.hover:set_click_zone(zone) self.hover:set_click_zone(zone)
return self return self
end end
@ -294,9 +299,10 @@ end
--- Set key-code to trigger this button --- Set key-code to trigger this button
-- @function button:set_key_trigger -- @function button:set_key_trigger
-- @tparam hash key The action_id of the key -- @tparam hash key The action_id of the key
-- @tparam druid.button Self instance to make chain calls -- @treturn druid.button Current button instance
function M.set_key_trigger(self, key) function M.set_key_trigger(self, key)
self.key_trigger = hash(key) self.key_trigger = hash(key)
return self return self
end end

View File

@ -0,0 +1,64 @@
local const = require("druid.const")
local component = require("druid.component")
local M = component.create("my_component_name", { const.ON_UPDATE })
-- Component constructor
function M.init(self, ...)
end
-- Call only if exist interest: const.ON_UPDATE
function M.update(self, dt)
end
-- Call only if exist interest: const.ON_INPUT or const.ON_INPUT_HIGH
function M.on_input(self, action_id, action)
return false
end
-- Call on component creation and on component:set_style() function
function M.on_style_change(self, style)
end
-- Call only if exist interest: const.ON_MESSAGE
function M.on_message(self, message_id, message, sender)
end
-- Call only if component with ON_LANGUAGE_CHANGE interest
function M.on_language_change(self)
end
-- Call only if component with ON_LAYOUT_CHANGE interest
function M.on_layout_change(self)
end
-- Call, if input was capturing before this component
-- Example: scroll is start scrolling, so you need unhover button
function M.on_input_interrupt(self)
end
-- Call, if game lost focus. Need ON_FOCUS_LOST intereset
function M.on_focus_lost(self)
end
-- Call, if game gained focus. Need ON_FOCUS_GAINED intereset
function M.on_focus_gained(self)
end
-- Call on component remove or on druid:final
function M.on_remove(self)
end
return M

View File

@ -172,7 +172,7 @@ end
function M.on_input(self, action_id, action) function M.on_input(self, action_id, action)
if action_id ~= const.ACTION_TOUCH and action_id ~= const.ACTION_MULTITOUCH then if action_id ~= const.ACTION_TOUCH and action_id ~= const.ACTION_MULTITOUCH then
return return false
end end
if not helper.is_enabled(self.node) then if not helper.is_enabled(self.node) then

View File

@ -24,6 +24,8 @@ function M.init(self, node, on_hover_callback)
self._is_hovered = false self._is_hovered = false
self._is_mouse_hovered = false self._is_mouse_hovered = false
self._is_enabled = true
self.on_hover = Event(on_hover_callback) self.on_hover = Event(on_hover_callback)
self.on_mouse_hover = Event() self.on_mouse_hover = Event()
end end
@ -31,14 +33,14 @@ end
function M.on_input(self, action_id, action) function M.on_input(self, action_id, action)
if action_id ~= const.ACTION_TOUCH and action_id ~= nil then if action_id ~= const.ACTION_TOUCH and action_id ~= nil then
return return false
end end
if not action_id and helper.is_mobile() then if not action_id and helper.is_mobile() then
return false return false
end end
if not helper.is_enabled(self.node) then if not helper.is_enabled(self.node) or not self._is_enabled then
return false return false
end end
@ -97,4 +99,31 @@ function M.set_click_zone(self, zone)
end end
--- Set enable state of hover component.
-- If hover is not enabled, it will not generate
-- any hover events
-- @function hover:set_enabled
-- @tparam bool state The hover enabled state
function M.set_enabled(self, state)
self._is_enabled = state
if not state then
if self._is_hovered then
M.set_hover(false)
end
if self._is_mouse_hovered then
M.set_mouse_hover(false)
end
end
end
--- Return current hover enabled state
-- @function hover:is_enabled
-- @treturn bool The hover enabled state
function M.is_enabled(self)
return self._is_enabled
end
return M return M

View File

@ -282,7 +282,7 @@ end
-- Pass nil to make input field unliminted (by default) -- Pass nil to make input field unliminted (by default)
-- @function input:set_max_length -- @function input:set_max_length
-- @tparam number max_length Maximum length for input text field -- @tparam number max_length Maximum length for input text field
-- @treturn druid.input Self instance to make chain calls -- @treturn druid.input Current input instance
function M.set_max_length(self, max_length) function M.set_max_length(self, max_length)
self.max_length = max_length self.max_length = max_length
return self return self
@ -294,7 +294,7 @@ end
-- ex: [%a%d] for alpha and numeric -- ex: [%a%d] for alpha and numeric
-- @function input:set_allowerd_characters -- @function input:set_allowerd_characters
-- @tparam string characters Regulax exp. for validate user input -- @tparam string characters Regulax exp. for validate user input
-- @treturn druid.input Self instance to make chain calls -- @treturn druid.input Current input instance
function M.set_allowed_characters(self, characters) function M.set_allowed_characters(self, characters)
self.allowed_characters = characters self.allowed_characters = characters
return self return self

View File

@ -290,7 +290,7 @@ local function update_size(self)
-- We add extra size only if scroll is available -- We add extra size only if scroll is available
-- Even the content zone size less than view zone size -- Even the content zone size less than view zone size
local content_border_extra = helper.get_border(self.content_node) local content_border_extra = helper.get_border(self.content_node)
local stretch_size = self.style.EXTRA_STRECH_SIZE local stretch_size = self.style.EXTRA_STRETCH_SIZE
if self.drag.can_x then if self.drag.can_x then
local sign = content_size.x > view_size.x and 1 or -1 local sign = content_size.x > view_size.x and 1 or -1
@ -325,11 +325,11 @@ end
-- @tfield[opt=20] number POINTS_DEADZONE Speed to check points of interests in no_inertion mode -- @tfield[opt=20] number POINTS_DEADZONE Speed to check points of interests in no_inertion mode
-- @tfield[opt=0.35] number BACK_SPEED Scroll back returning lerp speed -- @tfield[opt=0.35] number BACK_SPEED Scroll back returning lerp speed
-- @tfield[opt=0.2] number ANIM_SPEED Scroll gui.animation speed for scroll_to function -- @tfield[opt=0.2] number ANIM_SPEED Scroll gui.animation speed for scroll_to function
-- @tfield[opt=0] number EXTRA_STRECH_SIZE extra size in pixels outside of scroll (stretch effect) -- @tfield[opt=0] number EXTRA_STRETCH_SIZE extra size in pixels outside of scroll (stretch effect)
-- @tfield[opt=false] bool SMALL_CONTENT_SCROLL If true, content node with size less than view node size can be scrolled -- @tfield[opt=false] bool SMALL_CONTENT_SCROLL If true, content node with size less than view node size can be scrolled
function M.on_style_change(self, style) function M.on_style_change(self, style)
self.style = {} self.style = {}
self.style.EXTRA_STRECH_SIZE = style.EXTRA_STRECH_SIZE or 0 self.style.EXTRA_STRETCH_SIZE = style.EXTRA_STRETCH_SIZE or 0
self.style.ANIM_SPEED = style.ANIM_SPEED or 0.2 self.style.ANIM_SPEED = style.ANIM_SPEED or 0.2
self.style.BACK_SPEED = style.BACK_SPEED or 0.35 self.style.BACK_SPEED = style.BACK_SPEED or 0.35
@ -473,7 +473,7 @@ end
-- It will change content gui node size -- It will change content gui node size
-- @function scroll:set_size -- @function scroll:set_size
-- @tparam vector3 size The new size for content node -- @tparam vector3 size The new size for content node
-- @treturn druid.scroll Self instance -- @treturn druid.scroll Current scroll instance
function M.set_size(self, size) function M.set_size(self, size)
gui.set_size(self.content_node, size) gui.set_size(self.content_node, size)
update_size(self) update_size(self)
@ -487,9 +487,10 @@ end
-- If no points, just simple drag without inertion -- If no points, just simple drag without inertion
-- @function scroll:set_inert -- @function scroll:set_inert
-- @tparam bool state Inert scroll state -- @tparam bool state Inert scroll state
-- @treturn druid.scroll Self instance -- @treturn druid.scroll Current scroll instance
function M.set_inert(self, state) function M.set_inert(self, state)
self._is_inert = state self._is_inert = state
return self return self
end end
@ -504,11 +505,11 @@ end
--- Set extra size for scroll stretching. --- Set extra size for scroll stretching.
-- Set 0 to disable stretching effect -- Set 0 to disable stretching effect
-- @function scroll:set_extra_strech_size -- @function scroll:set_extra_stretch_size
-- @tparam[opt=0] number stretch_size Size in pixels of additional scroll area -- @tparam[opt=0] number stretch_size Size in pixels of additional scroll area
-- @treturn druid.scroll Self instance -- @treturn druid.scroll Current scroll instance
function M.set_extra_strech_size(self, stretch_size) function M.set_extra_stretch_size(self, stretch_size)
self.style.EXTRA_STRECH_SIZE = stretch_size or 0 self.style.EXTRA_STRETCH_SIZE = stretch_size or 0
update_size(self) update_size(self)
return self return self
@ -527,7 +528,7 @@ end
-- Scroll will always centered on closer points -- Scroll will always centered on closer points
-- @function scroll:set_points -- @function scroll:set_points
-- @tparam table points Array of vector3 points -- @tparam table points Array of vector3 points
-- @treturn druid.scroll Self instance -- @treturn druid.scroll Current scroll instance
function M.set_points(self, points) function M.set_points(self, points)
self.points = points self.points = points

View File

@ -95,7 +95,7 @@ end
function M.on_input(self, action_id, action) function M.on_input(self, action_id, action)
if action_id ~= const.ACTION_TOUCH then if action_id ~= const.ACTION_TOUCH then
return return false
end end
if not helper.is_enabled(self.node) then if not helper.is_enabled(self.node) then

View File

@ -109,13 +109,15 @@ function Component.get_node(self, node_or_name)
template_name = template_name .. "/" template_name = template_name .. "/"
end end
local node_type = type(node_or_name)
if nodes then if nodes then
assert(type(node_or_name) == "strings", "You should pass node name instead of node") assert(node_type == const.STRING, "You should pass node name instead of node")
return nodes[template_name .. node_or_name] return nodes[template_name .. node_or_name]
else else
if type(node_or_name) == const.STRING then if node_type == const.STRING then
return gui.get_node(template_name .. node_or_name) return gui.get_node(template_name .. node_or_name)
else else
-- Assume it's already node from gui.get_node
return node_or_name return node_or_name
end end
end end

View File

@ -63,7 +63,7 @@ M["scroll"] = {
FRICT_HOLD = 0.79, -- mult. for inert, while touching FRICT_HOLD = 0.79, -- mult. for inert, while touching
INERT_THRESHOLD = 2.5, -- speed to stop inertion INERT_THRESHOLD = 2.5, -- speed to stop inertion
INERT_SPEED = 30, -- koef. of inert speed INERT_SPEED = 30, -- koef. of inert speed
EXTRA_STRECH_SIZE = 100, -- extra size in pixels outside of scroll (stretch effect) EXTRA_STRETCH_SIZE = 100, -- extra size in pixels outside of scroll (stretch effect)
POINTS_DEADZONE = 20, -- Speed to check points of interests in no_inertion mode POINTS_DEADZONE = 20, -- Speed to check points of interests in no_inertion mode
SCROLL_WHEEL_SPEED = 20, SCROLL_WHEEL_SPEED = 20,

View File

@ -58,6 +58,18 @@ local function input_init(self)
end end
local function input_release(self)
if sys.get_config("druid.no_auto_input") == "1" then
return
end
if self.input_inited then
self.input_inited = false
druid_input.remove()
end
end
-- Create the component itself -- Create the component itself
local function create(self, instance_class) local function create(self, instance_class)
local instance = instance_class() local instance = instance_class()
@ -160,6 +172,8 @@ function Druid.final(self)
end end
self._deleted = true self._deleted = true
input_release(self)
end end

View File

@ -54,7 +54,7 @@ function M.setup_page(self)
-- Content with less size than view -- Content with less size than view
self.druid:new_scroll("scroll_smaller_view", "scroll_smaller_content") self.druid:new_scroll("scroll_smaller_view", "scroll_smaller_content")
:set_extra_strech_size(0) :set_extra_stretch_size(0)
:set_inert(false) :set_inert(false)
-- Scroll with points of interests -- Scroll with points of interests

View File

@ -10,7 +10,7 @@ height = 900
[project] [project]
title = druid title = druid
version = 0.4.0 version = 0.4.3
[library] [library]
include_dirs = druid include_dirs = druid