1
.gitignore
vendored
@ -8,3 +8,4 @@ Thumbs.db
|
|||||||
.project
|
.project
|
||||||
.cproject
|
.cproject
|
||||||
builtins
|
builtins
|
||||||
|
dist
|
||||||
|
51
.luacheckrc
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
std = "max"
|
||||||
|
files['.luacheckrc'].global = false
|
||||||
|
unused_args = false
|
||||||
|
|
||||||
|
max_code_line_length = 90
|
||||||
|
max_comment_line_length = false
|
||||||
|
|
||||||
|
globals = {
|
||||||
|
"sys",
|
||||||
|
"go",
|
||||||
|
"gui",
|
||||||
|
"label",
|
||||||
|
"render",
|
||||||
|
"crash",
|
||||||
|
"sprite",
|
||||||
|
"sound",
|
||||||
|
"tilemap",
|
||||||
|
"spine",
|
||||||
|
"particlefx",
|
||||||
|
"physics",
|
||||||
|
"factory",
|
||||||
|
"collectionfactory",
|
||||||
|
"iac",
|
||||||
|
"msg",
|
||||||
|
"vmath",
|
||||||
|
"url",
|
||||||
|
"http",
|
||||||
|
"image",
|
||||||
|
"json",
|
||||||
|
"zlib",
|
||||||
|
"iap",
|
||||||
|
"push",
|
||||||
|
"facebook",
|
||||||
|
"hash",
|
||||||
|
"hash_to_hex",
|
||||||
|
"pprint",
|
||||||
|
"init",
|
||||||
|
"final",
|
||||||
|
"update",
|
||||||
|
"on_input",
|
||||||
|
"on_message",
|
||||||
|
"on_reload",
|
||||||
|
"socket",
|
||||||
|
"table",
|
||||||
|
"debug",
|
||||||
|
"timer",
|
||||||
|
"window",
|
||||||
|
"buffer",
|
||||||
|
"resource",
|
||||||
|
"defos",
|
||||||
|
}
|
148
README.md
@ -1,14 +1,146 @@
|
|||||||
# druid
|
[](https://insality.github.io/druid/)
|
||||||
Defold UI library
|
|
||||||
|
|
||||||
This project was created from the "empty" project template.
|
**Druid** - powerful defold component UI library. Use basic druid components or make your own game-specific components to make amazing GUI in your games.
|
||||||
|
|
||||||
The settings in ["game.project"](defold://open?path=/game.project) are all the default. A bootstrap empty ["main.collection"](defold://open?path=/main/main.collection) is included.
|
|
||||||
|
|
||||||
Check out [the documentation pages](https://defold.com/learn) for examples, tutorials, manuals and API docs.
|
## Setup
|
||||||
|
|
||||||
If you run into trouble, help is available in [our forum](https://forum.defold.com).
|
### Dependency
|
||||||
|
|
||||||
Happy Defolding!
|
You can use the druid extension in your own project by adding this project as a [Defold library dependency](https://www.defold.com/manuals/libraries/). Open your game.project file and in the dependencies field under project add:
|
||||||
|
|
||||||
---
|
> [https://github.com/Insality/druid/archive/master.zip](https://github.com/Insality/druid/archive/master.zip)
|
||||||
|
|
||||||
|
Or point to the ZIP file of a [specific release](https://github.com/Insality/druid/releases).
|
||||||
|
|
||||||
|
|
||||||
|
### Code
|
||||||
|
|
||||||
|
Adjust druid settings, if needed:
|
||||||
|
```lua
|
||||||
|
local druid = require("druid.druid")
|
||||||
|
|
||||||
|
-- Used for button component and custom components
|
||||||
|
druid.set_sound_function(callback)
|
||||||
|
|
||||||
|
-- Used for lang_text component
|
||||||
|
druid.set_text_function(callback)
|
||||||
|
|
||||||
|
-- Used for change default druid style
|
||||||
|
druid.set_default_style(your_style)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Components
|
||||||
|
|
||||||
|
Druid provides next basic components:
|
||||||
|
- **Button** - Basic game button
|
||||||
|
|
||||||
|
- **Text** - Wrap on text node with text size adjusting
|
||||||
|
|
||||||
|
- **Blocker** - Block input in node zone
|
||||||
|
|
||||||
|
- **Back Handler** - Handle back button (Android, backspace)
|
||||||
|
|
||||||
|
- **Lang text** - Text component with handle localization system
|
||||||
|
|
||||||
|
- **Timer** - Run timer on text node
|
||||||
|
|
||||||
|
- **Progress** - Basic progress bar
|
||||||
|
|
||||||
|
- **Scroll** - Basic scroll component
|
||||||
|
|
||||||
|
- **Grid** - Component for manage node positions
|
||||||
|
|
||||||
|
- **Slider** - Basic slider component
|
||||||
|
|
||||||
|
- **Checkbox** - Basic checkbox component
|
||||||
|
|
||||||
|
- **Checkbox group** - Several checkboxes in one group
|
||||||
|
|
||||||
|
- **Radio group** - Several checkboxes in one group with single choice
|
||||||
|
|
||||||
|
- **Hover** - Trigger component for check node hover state
|
||||||
|
|
||||||
|
- **Input** - Component to process user text input
|
||||||
|
|
||||||
|
Full info see on _components.md_
|
||||||
|
|
||||||
|
|
||||||
|
## Creating components
|
||||||
|
|
||||||
|
Any components creating via druid:
|
||||||
|
```lua
|
||||||
|
local druid = require("druid.druid")
|
||||||
|
|
||||||
|
local function init(self)
|
||||||
|
self.druid = druid.new(self)
|
||||||
|
local button = self.druid:new_button(node_name, callback)
|
||||||
|
local text = self.druid:new_text(node_text_name)
|
||||||
|
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)
|
||||||
|
self.druid:on_input(action_id, action)
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
See the [example folder](https://github.com/insality/druid/tree/develop/example/kenney) for examples of how to use Druid
|
||||||
|
|
||||||
|
See the [druid-assets repository](https://github.com/insality/druid-assets) for examples of how to create custom components and styles
|
||||||
|
|
||||||
|
Try the HTML5 version of the example app
|
||||||
|
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
To learn druid better, read next documentation:
|
||||||
|
- Druid components
|
||||||
|
- Create custom components
|
||||||
|
- Druid asset store
|
||||||
|
- Druid Styles
|
||||||
|
|
||||||
|
Full druid documentation you can find here:
|
||||||
|
https://insality.github.io/druid/
|
||||||
|
|
||||||
|
|
||||||
|
## Games powered by Druid
|
||||||
|
|
||||||
|
_Will fill later_
|
||||||
|
|
||||||
|
|
||||||
|
## Future plans
|
||||||
|
|
||||||
|
- Basic input component
|
||||||
|
|
||||||
|
- Add on_layout_change support (to keep gui data between layout change)
|
||||||
|
|
||||||
|
- Add on_change_language support (call single function to update all druid instance)
|
||||||
|
|
||||||
|
- Better documentation and examples
|
||||||
|
|
||||||
|
- Add more comfortable gamepad support for GUI (ability to select button with DPAD and other stuff)
|
||||||
|
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Original idea by [AGulev](https://github.com/AGulev)
|
||||||
|
|
||||||
|
Developed and supporting by [Insality](https://github.com/Insality)
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
|
||||||
|
## Issues and suggestions
|
||||||
|
|
||||||
|
If you have any issues, questions or suggestions please [create an issue](https://github.com/Insality/druid/issues) or contact me: [insality@gmail.com](mailto:insality@gmail.com)
|
||||||
|
38
alpha_todo.txt
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
Simple to-do for Druid Alpha 0.2.0
|
||||||
|
|
||||||
|
|
||||||
|
-- High
|
||||||
|
+ remove button event and match_event from druid
|
||||||
|
+ add hover component
|
||||||
|
+ add druid events/triggers? better callback system
|
||||||
|
+ better name for locale component? lang? lang_text?
|
||||||
|
+ better name for slider component? Slider is ok
|
||||||
|
+ Druid store assets - separate repository with rich components (progress_rich migrate)
|
||||||
|
+ refactor on_swipe. To on_scroll? Add input priority
|
||||||
|
+ separate custom data and predefined fields in components? Every component have their fields and events
|
||||||
|
+ How to set custom sprites for button states?
|
||||||
|
+ add druid settings (add auto_focus input and other stuff) (to game.project)
|
||||||
|
|
||||||
|
+ button add key trigger
|
||||||
|
+ button and hover click restriction zone?
|
||||||
|
+ button polish, actions
|
||||||
|
+ better scroll size management, check different cases. So implicit now
|
||||||
|
+ better callbacks for every components
|
||||||
|
|
||||||
|
- unify component api (get/set/to and other general stuff)
|
||||||
|
- better grid + scroll management
|
||||||
|
- better default style, add template for custom style
|
||||||
|
- compare with gooey
|
||||||
|
- add docs for all components
|
||||||
|
- add docs folder for every component with gifs? Solutions
|
||||||
|
- remove component autoremove all children component
|
||||||
|
|
||||||
|
|
||||||
|
-- Low
|
||||||
|
- add input_text component for alpha release
|
||||||
|
- add code template and example for user components
|
||||||
|
- custom input settings (name of touch, text, etc)
|
||||||
|
- add good examples with template and/or nodes (basic component no use any of them)
|
||||||
|
- try use final druid in real project (FI uses custom druid) (use in 4321?)
|
||||||
|
- ability to relocalize all locale text nodes
|
||||||
|
- ability to control buttons via controller. Select it by cursor (d-pad)
|
17
config.ld
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
project='Druid'
|
||||||
|
title='Defold Druid UI Library'
|
||||||
|
description='Documentation for Druid Library'
|
||||||
|
file={"./druid",
|
||||||
|
exclude = {
|
||||||
|
"./druid/styles/",
|
||||||
|
"./druid/system/middleclass.lua"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
package='druid'
|
||||||
|
sort=false
|
||||||
|
dir='./docs'
|
||||||
|
style='!fixed'
|
||||||
|
format='discount'
|
||||||
|
topics={"./docs_md", "README.md"}
|
||||||
|
use_markdown_titles=true
|
||||||
|
no_space_before_args=true
|
192
docs/index.html
Normal file
@ -0,0 +1,192 @@
|
|||||||
|
<!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>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="modules/druid.timer.html">druid.timer</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.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/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Documentation for Druid Library</h2>
|
||||||
|
|
||||||
|
<h2>Modules</h2>
|
||||||
|
<table class="module_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="modules/druid.back_handler.html">druid.back_handler</a></td>
|
||||||
|
<td class="summary">Component to handle back key (android, backspace)</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="modules/druid.blocker.html">druid.blocker</a></td>
|
||||||
|
<td class="summary">Component to block input on specify zone by node</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="modules/druid.button.html">druid.button</a></td>
|
||||||
|
<td class="summary">Component to handle basic GUI button</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="modules/druid.checkbox.html">druid.checkbox</a></td>
|
||||||
|
<td class="summary">Druid checkbox component</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="modules/druid.checkbox_group.html">druid.checkbox_group</a></td>
|
||||||
|
<td class="summary">Checkbox group module</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="modules/druid.grid.html">druid.grid</a></td>
|
||||||
|
<td class="summary">Component to handle placing components by row and columns.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="modules/druid.hover.html">druid.hover</a></td>
|
||||||
|
<td class="summary">Component to handle hover node interaction</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="modules/druid.input.html">druid.input</a></td>
|
||||||
|
<td class="summary">Druid input text component.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="modules/druid.lang_text.html">druid.lang_text</a></td>
|
||||||
|
<td class="summary">Component to handle all GUI texts
|
||||||
|
Good working with localization system</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="modules/druid.progress.html">druid.progress</a></td>
|
||||||
|
<td class="summary">Basic progress bar component.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="modules/druid.radio_group.html">druid.radio_group</a></td>
|
||||||
|
<td class="summary">Radio group module</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="modules/druid.scroll.html">druid.scroll</a></td>
|
||||||
|
<td class="summary">Component to handle scroll content.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="modules/druid.slider.html">druid.slider</a></td>
|
||||||
|
<td class="summary">Druid slider component</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="modules/druid.text.html">druid.text</a></td>
|
||||||
|
<td class="summary">Component to handle all GUI texts.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="modules/druid.timer.html">druid.timer</a></td>
|
||||||
|
<td class="summary">Component to handle GUI timers.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="modules/component.html">component</a></td>
|
||||||
|
<td class="summary">Basic class for all Druid components.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="modules/druid.html">druid</a></td>
|
||||||
|
<td class="summary">Druid UI Library.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="modules/druid_event.html">druid_event</a></td>
|
||||||
|
<td class="summary">Lua event small library</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="modules/druid.helper.html">druid.helper</a></td>
|
||||||
|
<td class="summary">Text node or icon node can be nil</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="modules/druid_instance.html">druid_instance</a></td>
|
||||||
|
<td class="summary">Druid main class.</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<h2>Topics</h2>
|
||||||
|
<table class="module_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="topics/components.md.html">components.md</a></td>
|
||||||
|
<td class="summary"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="topics/creating_custom_components.md.html">creating_custom_components.md</a></td>
|
||||||
|
<td class="summary"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="topics/druid_assets.md.html">druid_assets.md</a></td>
|
||||||
|
<td class="summary"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="topics/examples.md.html">examples.md</a></td>
|
||||||
|
<td class="summary"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="topics/styles.md.html">styles.md</a></td>
|
||||||
|
<td class="summary"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="topics/README.md.html">README.md</a></td>
|
||||||
|
<td class="summary"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
311
docs/ldoc_fixed.css
Normal file
@ -0,0 +1,311 @@
|
|||||||
|
/* BEGIN RESET
|
||||||
|
|
||||||
|
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||||
|
Code licensed under the BSD License:
|
||||||
|
http://developer.yahoo.com/yui/license.html
|
||||||
|
version: 2.8.2r1
|
||||||
|
*/
|
||||||
|
html {
|
||||||
|
color: #000;
|
||||||
|
background: #FFF;
|
||||||
|
}
|
||||||
|
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
border-spacing: 0;
|
||||||
|
}
|
||||||
|
fieldset,img {
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
address,caption,cite,code,dfn,em,strong,th,var,optgroup {
|
||||||
|
font-style: inherit;
|
||||||
|
font-weight: inherit;
|
||||||
|
}
|
||||||
|
del,ins {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
li {
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
caption,th {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
h1,h2,h3,h4,h5,h6 {
|
||||||
|
font-size: 100%;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
q:before,q:after {
|
||||||
|
content: '';
|
||||||
|
}
|
||||||
|
abbr,acronym {
|
||||||
|
border: 0;
|
||||||
|
font-variant: normal;
|
||||||
|
}
|
||||||
|
sup {
|
||||||
|
vertical-align: baseline;
|
||||||
|
}
|
||||||
|
sub {
|
||||||
|
vertical-align: baseline;
|
||||||
|
}
|
||||||
|
legend {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
input,button,textarea,select,optgroup,option {
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: inherit;
|
||||||
|
font-style: inherit;
|
||||||
|
font-weight: inherit;
|
||||||
|
}
|
||||||
|
input,button,textarea,select {*font-size:100%;
|
||||||
|
}
|
||||||
|
/* END RESET */
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin-left: 1em;
|
||||||
|
margin-right: 1em;
|
||||||
|
font-family: arial, helvetica, geneva, sans-serif;
|
||||||
|
background-color: #ffffff; margin: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
code, tt { font-family: monospace; font-size: 1.1em; }
|
||||||
|
span.parameter { font-family:monospace; }
|
||||||
|
span.parameter:after { content:":"; }
|
||||||
|
span.types:before { content:"("; }
|
||||||
|
span.types:after { content:")"; }
|
||||||
|
.type { font-weight: bold; font-style:italic }
|
||||||
|
|
||||||
|
body, p, td, th { font-size: .95em; line-height: 1.2em;}
|
||||||
|
|
||||||
|
p, ul { margin: 10px 0 0 0px;}
|
||||||
|
|
||||||
|
strong { font-weight: bold;}
|
||||||
|
|
||||||
|
em { font-style: italic;}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 1.5em;
|
||||||
|
margin: 0 0 20px 0;
|
||||||
|
}
|
||||||
|
h2, h3, h4 { margin: 15px 0 10px 0; }
|
||||||
|
h2 { font-size: 1.25em; }
|
||||||
|
h3 { font-size: 1.15em; }
|
||||||
|
h4 { font-size: 1.06em; }
|
||||||
|
|
||||||
|
a:link { font-weight: bold; color: #004080; text-decoration: none; }
|
||||||
|
a:visited { font-weight: bold; color: #006699; text-decoration: none; }
|
||||||
|
a:link:hover { text-decoration: underline; }
|
||||||
|
|
||||||
|
hr {
|
||||||
|
color:#cccccc;
|
||||||
|
background: #00007f;
|
||||||
|
height: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockquote { margin-left: 3em; }
|
||||||
|
|
||||||
|
ul { list-style-type: disc; }
|
||||||
|
|
||||||
|
p.name {
|
||||||
|
font-family: "Andale Mono", monospace;
|
||||||
|
padding-top: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
background-color: rgb(245, 245, 245);
|
||||||
|
border: 1px solid #C0C0C0; /* silver */
|
||||||
|
padding: 10px;
|
||||||
|
margin: 10px 0 10px 0;
|
||||||
|
overflow: auto;
|
||||||
|
font-family: "Andale Mono", monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre.example {
|
||||||
|
font-size: .85em;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.index { border: 1px #00007f; }
|
||||||
|
table.index td { text-align: left; vertical-align: top; }
|
||||||
|
|
||||||
|
#container {
|
||||||
|
margin-left: 1em;
|
||||||
|
margin-right: 1em;
|
||||||
|
background-color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
#product {
|
||||||
|
text-align: center;
|
||||||
|
border-bottom: 1px solid #cccccc;
|
||||||
|
background-color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
#product big {
|
||||||
|
font-size: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#main {
|
||||||
|
background-color:#FFFFFF; // #f0f0f0;
|
||||||
|
border-left: 1px solid #cccccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
#navigation {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
float: left;
|
||||||
|
width: 14em;
|
||||||
|
vertical-align: top;
|
||||||
|
background-color:#FFFFFF; // #f0f0f0;
|
||||||
|
border-right: 2px solid #cccccc;
|
||||||
|
overflow: visible;
|
||||||
|
overflow-y: scroll;
|
||||||
|
height: 100%;
|
||||||
|
padding-left: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#navigation h2 {
|
||||||
|
background-color:#FFFFFF;//:#e7e7e7;
|
||||||
|
font-size:1.1em;
|
||||||
|
color:#000000;
|
||||||
|
text-align: left;
|
||||||
|
padding:0.2em;
|
||||||
|
border-bottom:1px solid #dddddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
#navigation ul
|
||||||
|
{
|
||||||
|
font-size:1em;
|
||||||
|
list-style-type: none;
|
||||||
|
margin: 1px 1px 10px 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#navigation li {
|
||||||
|
text-indent: -1em;
|
||||||
|
display: block;
|
||||||
|
margin: 3px 0px 0px 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#navigation li li a {
|
||||||
|
margin: 0px 3px 0px -1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content {
|
||||||
|
margin-left: 14em;
|
||||||
|
padding: 1em;
|
||||||
|
padding-left: 2em;
|
||||||
|
width: 700px;
|
||||||
|
border-left: 2px solid #cccccc;
|
||||||
|
// border-right: 2px solid #cccccc;
|
||||||
|
background-color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
#about {
|
||||||
|
clear: both;
|
||||||
|
padding-left: 1em;
|
||||||
|
margin-left: 14em; // avoid the damn sidebar!
|
||||||
|
border-top: 2px solid #cccccc;
|
||||||
|
border-left: 2px solid #cccccc;
|
||||||
|
background-color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
body {
|
||||||
|
font: 12pt "Times New Roman", "TimeNR", Times, serif;
|
||||||
|
}
|
||||||
|
a { font-weight: bold; color: #004080; text-decoration: underline; }
|
||||||
|
|
||||||
|
#main {
|
||||||
|
background-color: #ffffff;
|
||||||
|
border-left: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#container {
|
||||||
|
margin-left: 2%;
|
||||||
|
margin-right: 2%;
|
||||||
|
background-color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content {
|
||||||
|
padding: 1em;
|
||||||
|
background-color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
#navigation {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
pre.example {
|
||||||
|
font-family: "Andale Mono", monospace;
|
||||||
|
font-size: 10pt;
|
||||||
|
page-break-inside: avoid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
table.module_list {
|
||||||
|
border-width: 1px;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: #cccccc;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
table.module_list td {
|
||||||
|
border-width: 1px;
|
||||||
|
padding: 3px;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: #cccccc;
|
||||||
|
}
|
||||||
|
table.module_list td.name { background-color: #f0f0f0; ; min-width: 200px; }
|
||||||
|
table.module_list td.summary { width: 100%; }
|
||||||
|
|
||||||
|
table.function_list {
|
||||||
|
border-width: 1px;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: #cccccc;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
table.function_list td {
|
||||||
|
border-width: 1px;
|
||||||
|
padding: 3px;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: #cccccc;
|
||||||
|
}
|
||||||
|
table.function_list td.name { background-color: #f6f6ff; ; min-width: 200px; }
|
||||||
|
table.function_list td.summary { width: 100%; }
|
||||||
|
|
||||||
|
dl.table dt, dl.function dt {border-top: 1px solid #ccc; padding-top: 1em;}
|
||||||
|
dl.table dd, dl.function dd {padding-bottom: 1em; margin: 10px 0 0 20px;}
|
||||||
|
dl.table h3, dl.function h3 {font-size: .95em;}
|
||||||
|
|
||||||
|
ul.nowrap {
|
||||||
|
overflow:auto;
|
||||||
|
whitespace:nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* stop sublists from having initial vertical space */
|
||||||
|
ul ul { margin-top: 0px; }
|
||||||
|
ol ul { margin-top: 0px; }
|
||||||
|
ol ol { margin-top: 0px; }
|
||||||
|
ul ol { margin-top: 0px; }
|
||||||
|
|
||||||
|
/* make the target distinct; helps when we're navigating to a function */
|
||||||
|
a:target + * {
|
||||||
|
background-color: #FF9;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* styles for prettification of source */
|
||||||
|
pre .comment { color: #558817; }
|
||||||
|
pre .constant { color: #a8660d; }
|
||||||
|
pre .escape { color: #844631; }
|
||||||
|
pre .keyword { color: #aa5050; font-weight: bold; }
|
||||||
|
pre .library { color: #0e7c6b; }
|
||||||
|
pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; }
|
||||||
|
pre .string { color: #8080ff; }
|
||||||
|
pre .number { color: #f8660d; }
|
||||||
|
pre .operator { color: #2239a8; font-weight: bold; }
|
||||||
|
pre .preprocessor, pre .prepro { color: #a33243; }
|
||||||
|
pre .global { color: #800080; }
|
||||||
|
pre .user-keyword { color: #800080; }
|
||||||
|
pre .prompt { color: #558817; }
|
||||||
|
pre .url { color: #272fc2; text-decoration: underline; }
|
||||||
|
|
413
docs/modules/component.html
Normal file
@ -0,0 +1,413 @@
|
|||||||
|
<!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>
|
||||||
|
</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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
|
||||||
|
<li><strong>component</strong></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.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/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<h1>Module <code>component</code></h1>
|
||||||
|
<p>Basic class for all Druid components.</p>
|
||||||
|
<p> To create you component, use <a href="../modules/component.html#Component.create">component.create</a></p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a href="#Functions">Functions</a></h2>
|
||||||
|
<table class="function_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#get_style">get_style()</a></td>
|
||||||
|
<td class="summary">Get current component style table</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_style">set_style(style)</a></td>
|
||||||
|
<td class="summary">Set current component style table</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#get_template">get_template()</a></td>
|
||||||
|
<td class="summary">Get current component template name</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_template">set_template(template)</a></td>
|
||||||
|
<td class="summary">Set current component template name</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#get_nodes">get_nodes()</a></td>
|
||||||
|
<td class="summary">Get current component nodes</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_nodes">set_nodes(nodes)</a></td>
|
||||||
|
<td class="summary">Set current component nodes</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#get_context">get_context()</a></td>
|
||||||
|
<td class="summary">Get current component context</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_context">set_context(context)</a></td>
|
||||||
|
<td class="summary">Set current component context</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#get_interests">get_interests()</a></td>
|
||||||
|
<td class="summary">Get current component interests</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#get_druid">get_druid()</a></td>
|
||||||
|
<td class="summary">Return druid with context of calling component.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#setup_component">setup_component(table, table)</a></td>
|
||||||
|
<td class="summary">Setup component context and his style table</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#Component.create">Component.create(name, interest)</a></td>
|
||||||
|
<td class="summary">Create new component.</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
|
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||||
|
|
||||||
|
<dl class="function">
|
||||||
|
<dt>
|
||||||
|
<a name = "get_style"></a>
|
||||||
|
<strong>get_style()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Get current component style table
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
|
||||||
|
Component style table
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_style"></a>
|
||||||
|
<strong>set_style(style)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set current component style table
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">style</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
|
||||||
|
Druid style module
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "get_template"></a>
|
||||||
|
<strong>get_template()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Get current component template name
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
|
||||||
|
Component template name
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_template"></a>
|
||||||
|
<strong>set_template(template)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set current component template name
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">template</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
|
||||||
|
Component template name
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "get_nodes"></a>
|
||||||
|
<strong>get_nodes()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Get current component nodes
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
|
||||||
|
Component nodes table
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_nodes"></a>
|
||||||
|
<strong>set_nodes(nodes)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set current component nodes
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">nodes</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
|
||||||
|
Component nodes table
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "get_context"></a>
|
||||||
|
<strong>get_context()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Get current component context
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
|
||||||
|
Component context
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_context"></a>
|
||||||
|
<strong>set_context(context)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set current component context
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">context</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
|
||||||
|
Druid context. Usually it is self of script
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "get_interests"></a>
|
||||||
|
<strong>get_interests()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Get current component interests
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
|
||||||
|
List of component interests
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "get_druid"></a>
|
||||||
|
<strong>get_druid()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Return druid with context of calling component.
|
||||||
|
Use it to create component inside of other components.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">Druid</span></span>
|
||||||
|
Druid instance with component context
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "setup_component"></a>
|
||||||
|
<strong>setup_component(table, table)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Setup component context and his style table
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">table</span>
|
||||||
|
<span class="types"><span class="type">style</span></span>
|
||||||
|
Druid style module
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">table</span>
|
||||||
|
<span class="types"><span class="type">style</span></span>
|
||||||
|
Druid style module
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">Component</span></span>
|
||||||
|
Component itself
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "Component.create"></a>
|
||||||
|
<strong>Component.create(name, interest)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Create new component. It will inheritance from basic
|
||||||
|
druid component.
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">name</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
|
||||||
|
Component name
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">interest</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
|
||||||
|
List of component's interest
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
222
docs/modules/druid.back_handler.html
Normal file
@ -0,0 +1,222 @@
|
|||||||
|
<!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><strong>druid.back_handler</strong></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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.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/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<h1>Module <code>druid.back_handler</code></h1>
|
||||||
|
<p>Component to handle back key (android, backspace)</p>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a href="#Functions">Functions</a></h2>
|
||||||
|
<table class="function_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#init">init(callback[, Callback])</a></td>
|
||||||
|
<td class="summary">Component init function</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#on_input">on_input(action_id, action)</a></td>
|
||||||
|
<td class="summary">Input handler for component</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(callback[, Callback])</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component init function
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">callback</span>
|
||||||
|
<span class="types"><span class="type">callback</span></span>
|
||||||
|
On back button
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">Callback</span>
|
||||||
|
<span class="types"><span class="type">params</span></span>
|
||||||
|
argument
|
||||||
|
(<em>optional</em>)
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "on_input"></a>
|
||||||
|
<strong>on_input(action_id, action)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Input handler for component
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">action_id</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
|
||||||
|
on_input action id
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">action</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
|
||||||
|
on_input action
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</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_back</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On back handler callback
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "Fields"></a>
|
||||||
|
<strong>Fields</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component fields
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Fields:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">params</span>
|
||||||
|
<span class="types"><span class="type">any</span></span>
|
||||||
|
Params to click callbacks
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
241
docs/modules/druid.blocker.html
Normal file
@ -0,0 +1,241 @@
|
|||||||
|
<!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><strong>druid.blocker</strong></li>
|
||||||
|
<li><a href="../modules/druid.button.html">druid.button</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.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.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/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<h1>Module <code>druid.blocker</code></h1>
|
||||||
|
<p>Component to block input on specify zone by node</p>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a href="#Functions">Functions</a></h2>
|
||||||
|
<table class="function_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#init">init(node)</a></td>
|
||||||
|
<td class="summary">Component init function</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_enabled">set_enabled(state)</a></td>
|
||||||
|
<td class="summary">Set enabled blocker component state</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#is_enabled">is_enabled()</a></td>
|
||||||
|
<td class="summary">Return blocked enabled state</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(node)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component init function
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Gui node
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_enabled"></a>
|
||||||
|
<strong>set_enabled(state)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set enabled blocker component state
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">state</span>
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
Enabled state
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "is_enabled"></a>
|
||||||
|
<strong>is_enabled()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Return blocked enabled state
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
True, if blocker is enabled
|
||||||
|
</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_click</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On release button callback
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">on_enable_change</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On enable/disable callback
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "Fields"></a>
|
||||||
|
<strong>Fields</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component fields
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Fields:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Trigger node
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
412
docs/modules/druid.button.html
Normal file
@ -0,0 +1,412 @@
|
|||||||
|
<!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><strong>druid.button</strong></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.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.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/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<h1>Module <code>druid.button</code></h1>
|
||||||
|
<p>Component to handle basic GUI button</p>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a href="#Functions">Functions</a></h2>
|
||||||
|
<table class="function_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#init">init(node, callback[, params[, anim_node[, event]]])</a></td>
|
||||||
|
<td class="summary">Component init function</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_enabled">set_enabled(state)</a></td>
|
||||||
|
<td class="summary">Set enabled button component state</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#is_enabled">is_enabled()</a></td>
|
||||||
|
<td class="summary">Return button enabled state</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_click_zone">set_click_zone(zone)</a></td>
|
||||||
|
<td class="summary">Strict button click area.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<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>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#get_key_trigger">get_key_trigger()</a></td>
|
||||||
|
<td class="summary">Get key-code to trigger this button</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>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#Style">Style</a></td>
|
||||||
|
<td class="summary">Component style params</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(node, callback[, params[, anim_node[, event]]])</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component init function
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Gui node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">callback</span>
|
||||||
|
<span class="types"><span class="type">function</span></span>
|
||||||
|
Button callback
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">params</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
|
||||||
|
Button callback params
|
||||||
|
(<em>optional</em>)
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">anim_node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Button anim node (node, if not provided)
|
||||||
|
(<em>optional</em>)
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">event</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
|
||||||
|
Button react event, const.ACTION_TOUCH by default
|
||||||
|
(<em>optional</em>)
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_enabled"></a>
|
||||||
|
<strong>set_enabled(state)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set enabled button component state
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">state</span>
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
Enabled state
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "is_enabled"></a>
|
||||||
|
<strong>is_enabled()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Return button enabled state
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
True, if button is enabled
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_click_zone"></a>
|
||||||
|
<strong>set_click_zone(zone)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Strict button click area. Useful for
|
||||||
|
no click events outside stencil node
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">zone</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Gui node
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_key_trigger"></a>
|
||||||
|
<strong>set_key_trigger(key)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set key-code to trigger this button
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">key</span>
|
||||||
|
<span class="types"><span class="type">hash</span></span>
|
||||||
|
The action_id of the key
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "get_key_trigger"></a>
|
||||||
|
<strong>get_key_trigger()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Get key-code to trigger this button
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">hash</span></span>
|
||||||
|
The action_id of the key
|
||||||
|
</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_click</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On release button callback
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">on_repeated_click</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On repeated action button callback
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">on_long_click</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On long tap button callback
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">on_double_click</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On double tap button callback
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "Fields"></a>
|
||||||
|
<strong>Fields</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component fields
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Fields:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Trigger node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">anim_node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Animation node
|
||||||
|
(<em>default</em> node)
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">scale_from</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Initial scale of anim_node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">pos</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Initial pos of anim_node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">params</span>
|
||||||
|
<span class="types"><span class="type">any</span></span>
|
||||||
|
Params to click callbacks
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">hover</span>
|
||||||
|
<span class="types"><span class="type">druid.hover</span></span>
|
||||||
|
Druid hover logic component
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">click_zone</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Restriction zone
|
||||||
|
(<em>optional</em>)
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "Style"></a>
|
||||||
|
<strong>Style</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component style params
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Fields:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">on_click</span>
|
||||||
|
<span class="types"><span class="type">function</span></span>
|
||||||
|
(self, node)
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">on_click_disabled</span>
|
||||||
|
<span class="types"><span class="type">function</span></span>
|
||||||
|
(self, node)
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">on_hover</span>
|
||||||
|
<span class="types"><span class="type">function</span></span>
|
||||||
|
(self, node, hover_state)
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">on_set_enabled</span>
|
||||||
|
<span class="types"><span class="type">function</span></span>
|
||||||
|
(self, node, enabled_state)
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">IS_HOVER</span>
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
284
docs/modules/druid.checkbox.html
Normal file
@ -0,0 +1,284 @@
|
|||||||
|
<!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><strong>druid.checkbox</strong></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.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/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<h1>Module <code>druid.checkbox</code></h1>
|
||||||
|
<p>Druid checkbox component</p>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a href="#Functions">Functions</a></h2>
|
||||||
|
<table class="function_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#init">init(node, callback[, click=node])</a></td>
|
||||||
|
<td class="summary">Component init function</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_state">set_state(state, is_silent)</a></td>
|
||||||
|
<td class="summary">Set checkbox state</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#get_state">get_state()</a></td>
|
||||||
|
<td class="summary">Return checkbox state</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>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#Style">Style</a></td>
|
||||||
|
<td class="summary">Component style params</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(node, callback[, click=node])</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component init function
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Gui node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">callback</span>
|
||||||
|
<span class="types"><span class="type">function</span></span>
|
||||||
|
Checkbox callback
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">click</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
node Trigger node, by default equals to node
|
||||||
|
(<em>default</em> node)
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_state"></a>
|
||||||
|
<strong>set_state(state, is_silent)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set checkbox state
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">state</span>
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
Checkbox state
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">is_silent</span>
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
Don't trigger on<em>change</em>state if true
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "get_state"></a>
|
||||||
|
<strong>get_state()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Return checkbox state
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
Checkbox state
|
||||||
|
</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_change_state</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On change state callback
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "Fields"></a>
|
||||||
|
<strong>Fields</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component fields
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Fields:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Visual node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">click_node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Button trigger node
|
||||||
|
(<em>default</em> node)
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">button</span>
|
||||||
|
<span class="types"><span class="type">druid.button</span></span>
|
||||||
|
Button component from click_node
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "Style"></a>
|
||||||
|
<strong>Style</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component style params
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Fields:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">on_change_state</span>
|
||||||
|
<span class="types"><span class="type">function</span></span>
|
||||||
|
(self, node, state)
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
246
docs/modules/druid.checkbox_group.html
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
<!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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><strong>druid.checkbox_group</strong></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.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/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<h1>Module <code>druid.checkbox_group</code></h1>
|
||||||
|
<p>Checkbox group module</p>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a href="#Functions">Functions</a></h2>
|
||||||
|
<table class="function_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#init">init(node, callback[, click=node])</a></td>
|
||||||
|
<td class="summary">Component init function</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_state">set_state(state)</a></td>
|
||||||
|
<td class="summary">Set checkbox group state</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#get_state">get_state()</a></td>
|
||||||
|
<td class="summary">Return checkbox group state</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(node, callback[, click=node])</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component init function
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">node</span>
|
||||||
|
<span class="types"><span class="type">node[]</span></span>
|
||||||
|
Array of gui node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">callback</span>
|
||||||
|
<span class="types"><span class="type">function</span></span>
|
||||||
|
Checkbox callback
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">click</span>
|
||||||
|
<span class="types"><span class="type">node[]</span></span>
|
||||||
|
node Array of trigger nodes, by default equals to nodes
|
||||||
|
(<em>default</em> node)
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_state"></a>
|
||||||
|
<strong>set_state(state)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set checkbox group state
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">state</span>
|
||||||
|
<span class="types"><span class="type">bool[]</span></span>
|
||||||
|
Array of checkbox state
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "get_state"></a>
|
||||||
|
<strong>get_state()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Return checkbox group state
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">bool[]</span></span>
|
||||||
|
Array if checkboxes state
|
||||||
|
</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_checkbox_click</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On any checkbox click
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "Fields"></a>
|
||||||
|
<strong>Fields</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component fields
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Fields:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">checkboxes</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
|
||||||
|
Array of checkbox components
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
377
docs/modules/druid.grid.html
Normal file
@ -0,0 +1,377 @@
|
|||||||
|
<!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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><strong>druid.grid</strong></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.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/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<h1>Module <code>druid.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="#set_offset">set_offset(offset)</a></td>
|
||||||
|
<td class="summary">Set grid items offset, the distance between items</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_anchor">set_anchor(acnhor)</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="#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="#clear">clear()</a></td>
|
||||||
|
<td class="summary">Clear all items from the grid</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 = "set_offset"></a>
|
||||||
|
<strong>set_offset(offset)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set grid items offset, the distance between items
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">offset</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Offset
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_anchor"></a>
|
||||||
|
<strong>set_anchor(acnhor)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set grid anchor
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">acnhor</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 = "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 = "clear"></a>
|
||||||
|
<strong>clear()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Clear all items from the grid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</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_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">offset</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Item distance between each other items
|
||||||
|
</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>
|
||||||
|
<li><span class="parameter">border_offer</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
The border offset for correct anchor calculations
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
243
docs/modules/druid.helper.html
Normal file
@ -0,0 +1,243 @@
|
|||||||
|
<!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>
|
||||||
|
</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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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><strong>druid.helper</strong></li>
|
||||||
|
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
|
||||||
|
</ul>
|
||||||
|
<h2>Topics</h2>
|
||||||
|
<ul class="">
|
||||||
|
<li><a href="../topics/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<h1>Module <code>druid.helper</code></h1>
|
||||||
|
<p>Text node or icon node can be nil</p>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a href="#Functions">Functions</a></h2>
|
||||||
|
<table class="function_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#centrate_text_with_icon">centrate_text_with_icon([text_node][, icon_node], margin)</a></td>
|
||||||
|
<td class="summary">Center two nodes.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#centrate_icon_with_text">centrate_icon_with_text([icon_node[, text_node[, margin=0]]])</a></td>
|
||||||
|
<td class="summary">Center two nodes.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#is_enabled">is_enabled(node)</a></td>
|
||||||
|
<td class="summary">Check if node is enabled in gui hierarchy.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#get_pivot_offset">get_pivot_offset(pivot)</a></td>
|
||||||
|
<td class="summary">Get node offset for given gui pivot</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
|
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||||
|
|
||||||
|
<dl class="function">
|
||||||
|
<dt>
|
||||||
|
<a name = "centrate_text_with_icon"></a>
|
||||||
|
<strong>centrate_text_with_icon([text_node][, icon_node], margin)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Center two nodes.
|
||||||
|
Nodes will be center around 0 x position
|
||||||
|
text_node will be first (at left side)
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">text_node</span>
|
||||||
|
<span class="types"><span class="type">text</span></span>
|
||||||
|
Gui text node
|
||||||
|
(<em>optional</em>)
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">icon_node</span>
|
||||||
|
<span class="types"><span class="type">box</span></span>
|
||||||
|
Gui box node
|
||||||
|
(<em>optional</em>)
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">margin</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Offset between nodes
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "centrate_icon_with_text"></a>
|
||||||
|
<strong>centrate_icon_with_text([icon_node[, text_node[, margin=0]]])</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Center two nodes.
|
||||||
|
Nodes will be center around 0 x position
|
||||||
|
icon_node will be first (at left side)
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">icon_node</span>
|
||||||
|
<span class="types"><span class="type">box</span></span>
|
||||||
|
Gui box node
|
||||||
|
(<em>optional</em>)
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">text_node</span>
|
||||||
|
<span class="types"><span class="type">text</span></span>
|
||||||
|
Gui text node
|
||||||
|
(<em>optional</em>)
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">margin</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Offset between nodes
|
||||||
|
(<em>default</em> 0)
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "is_enabled"></a>
|
||||||
|
<strong>is_enabled(node)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Check if node is enabled in gui hierarchy.
|
||||||
|
Return false, if node or any his parent is disabled
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Gui node
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
Is enabled in hierarchy
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "get_pivot_offset"></a>
|
||||||
|
<strong>get_pivot_offset(pivot)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Get node offset for given gui pivot
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">pivot</span>
|
||||||
|
<span class="types"><span class="type">gui.pivot</span></span>
|
||||||
|
The node pivot
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Vector offset with [-1..1] values
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
218
docs/modules/druid.hover.html
Normal file
@ -0,0 +1,218 @@
|
|||||||
|
<!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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><strong>druid.hover</strong></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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.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/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<h1>Module <code>druid.hover</code></h1>
|
||||||
|
<p>Component to handle hover node interaction</p>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a href="#Functions">Functions</a></h2>
|
||||||
|
<table class="function_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#init">init(node, on_hover_callback)</a></td>
|
||||||
|
<td class="summary">Component init function</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_hover">set_hover(state)</a></td>
|
||||||
|
<td class="summary">Set hover state</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_click_zone">set_click_zone(zone)</a></td>
|
||||||
|
<td class="summary">Strict button click area.</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>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
|
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||||
|
|
||||||
|
<dl class="function">
|
||||||
|
<dt>
|
||||||
|
<a name = "init"></a>
|
||||||
|
<strong>init(node, on_hover_callback)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component init function
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Gui node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">on_hover_callback</span>
|
||||||
|
<span class="types"><span class="type">function</span></span>
|
||||||
|
Hover callback
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_hover"></a>
|
||||||
|
<strong>set_hover(state)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set hover state
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">state</span>
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
The hover state
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_click_zone"></a>
|
||||||
|
<strong>set_click_zone(zone)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Strict button click area. Useful for
|
||||||
|
no click events outside stencil node
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">zone</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Gui node
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</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_hover</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On hover callback
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
188
docs/modules/druid.html
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
<!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>
|
||||||
|
</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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
|
||||||
|
<li><a href="../modules/component.html">component</a></li>
|
||||||
|
<li><strong>druid</strong></li>
|
||||||
|
<li><a href="../modules/druid_event.html">druid_event</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/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<h1>Module <code>druid</code></h1>
|
||||||
|
<p>Druid UI Library.</p>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
<p> Powerful Defold component based UI library. Use standart
|
||||||
|
components or make your own game-specific components to
|
||||||
|
make amazing GUI in your games.</p>
|
||||||
|
|
||||||
|
<p> Contains the several basic components and examples
|
||||||
|
to how to do your custom complex components to
|
||||||
|
separate UI game logic to small files</p>
|
||||||
|
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a href="#Functions">Functions</a></h2>
|
||||||
|
<table class="function_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#register">register(name, module)</a></td>
|
||||||
|
<td class="summary">Register external druid component.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#new">new(context[, style])</a></td>
|
||||||
|
<td class="summary">Create Druid instance.</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
|
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||||
|
|
||||||
|
<dl class="function">
|
||||||
|
<dt>
|
||||||
|
<a name = "register"></a>
|
||||||
|
<strong>register(name, module)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Register external druid component.
|
||||||
|
After register you can create the component with
|
||||||
|
druid<em>instance:new</em>{name}. For example <code>druid:new_button(...)</code>
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">name</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.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.3/manual.html#6.6">table</a></span>
|
||||||
|
lua table with component
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "new"></a>
|
||||||
|
<strong>new(context[, style])</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Create Druid instance.
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">context</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
|
||||||
|
Druid context. Usually it is self of script
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">style</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
|
||||||
|
Druid style module
|
||||||
|
(<em>optional</em>)
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">druid_instance</span></span>
|
||||||
|
Druid instance
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
93
docs/modules/druid.input.html
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
|
<html>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||||
|
<head>
|
||||||
|
<title>Defold Druid UI 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>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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
|
||||||
|
<li><strong>druid.input</strong></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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.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/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<h1>Module <code>druid.input</code></h1>
|
||||||
|
<p>Druid input text component.</p>
|
||||||
|
<p> Carry on user text input
|
||||||
|
UNIMPLEMENTED</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
247
docs/modules/druid.lang_text.html
Normal file
@ -0,0 +1,247 @@
|
|||||||
|
<!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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
|
||||||
|
<li><a href="../modules/druid.input.html">druid.input</a></li>
|
||||||
|
<li><strong>druid.lang_text</strong></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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.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/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<h1>Module <code>druid.lang_text</code></h1>
|
||||||
|
<p>Component to handle all GUI texts
|
||||||
|
Good working with localization system</p>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a href="#Functions">Functions</a></h2>
|
||||||
|
<table class="function_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#init">init(node, locale_id, no_adjust)</a></td>
|
||||||
|
<td class="summary">Component init function</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_to">set_to(text)</a></td>
|
||||||
|
<td class="summary">Setup raw text to lang_text component</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#translate">translate(locale_id)</a></td>
|
||||||
|
<td class="summary">Translate the text by locale_id</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(node, locale_id, no_adjust)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component init function
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
The text node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">locale_id</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
|
||||||
|
Default locale id
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">no_adjust</span>
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
If true, will not correct text size
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_to"></a>
|
||||||
|
<strong>set_to(text)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Setup raw text to lang_text component
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">text</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
|
||||||
|
Text for text node
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "translate"></a>
|
||||||
|
<strong>translate(locale_id)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Translate the text by locale_id
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">locale_id</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
|
||||||
|
Locale id
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</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_change</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On change text callback
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "Fields"></a>
|
||||||
|
<strong>Fields</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component fields
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Fields:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">text</span>
|
||||||
|
<span class="types"><span class="type">druid.text</span></span>
|
||||||
|
The text component
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
385
docs/modules/druid.progress.html
Normal file
@ -0,0 +1,385 @@
|
|||||||
|
<!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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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><strong>druid.progress</strong></li>
|
||||||
|
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
|
||||||
|
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.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/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<h1>Module <code>druid.progress</code></h1>
|
||||||
|
<p>Basic progress bar component.</p>
|
||||||
|
<p> For correct progress bar init it should be in max size from gui</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a href="#Functions">Functions</a></h2>
|
||||||
|
<table class="function_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#init">init(node, key, init_value)</a></td>
|
||||||
|
<td class="summary">Component init function</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#fill">fill()</a></td>
|
||||||
|
<td class="summary">Fill a progress bar and stop progress animation</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#empty">empty()</a></td>
|
||||||
|
<td class="summary">Empty a progress bar</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_to">set_to(to)</a></td>
|
||||||
|
<td class="summary">Instant fill progress bar to value</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#get">get()</a></td>
|
||||||
|
<td class="summary">Return current progress bar value</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_steps">set_steps(steps, callback)</a></td>
|
||||||
|
<td class="summary">Set points on progress bar to fire the callback</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#to">to(to[, callback])</a></td>
|
||||||
|
<td class="summary">Start animation of a progress bar</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>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#Style">Style</a></td>
|
||||||
|
<td class="summary">Component style params</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(node, key, init_value)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component init function
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">node</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a> or <span class="type">node</span></span>
|
||||||
|
Progress bar fill node or node name
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">key</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
|
||||||
|
Progress bar direction: const.SIDE.X or const.SIDE.Y
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">init_value</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Initial value of progress bar
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "fill"></a>
|
||||||
|
<strong>fill()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Fill a progress bar and stop progress animation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "empty"></a>
|
||||||
|
<strong>empty()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Empty a progress bar
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_to"></a>
|
||||||
|
<strong>set_to(to)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Instant fill progress bar to value
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">to</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Progress bar value, from 0 to 1
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "get"></a>
|
||||||
|
<strong>get()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Return current progress bar value
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_steps"></a>
|
||||||
|
<strong>set_steps(steps, callback)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set points on progress bar to fire the callback
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">steps</span>
|
||||||
|
<span class="types"><span class="type">number[]</span></span>
|
||||||
|
Array of progress bar values
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">callback</span>
|
||||||
|
<span class="types"><span class="type">function</span></span>
|
||||||
|
Callback on intersect step value
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Usage:</h3>
|
||||||
|
<ul>
|
||||||
|
<pre class="example">progress:set_steps({<span class="number">0</span>, <span class="number">0.3</span>, <span class="number">0.6</span>, <span class="number">1</span>}, <span class="keyword">function</span>(self, step) <span class="keyword">end</span>)</pre>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "to"></a>
|
||||||
|
<strong>to(to[, callback])</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Start animation of a progress bar
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">to</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
value between 0..1
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">callback</span>
|
||||||
|
<span class="types"><span class="type">function</span></span>
|
||||||
|
Callback on animation ends
|
||||||
|
(<em>optional</em>)
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</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_change</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On progress bar change callback
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "Fields"></a>
|
||||||
|
<strong>Fields</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component fields
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Fields:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Progress bar fill node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">key</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
|
||||||
|
The progress bar direction
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">scale</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Current progress bar scale
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">size</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Current progress bar size
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">max_size</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Maximum size of progress bar
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">slice</span>
|
||||||
|
<span class="types"><span class="type">vector4</span></span>
|
||||||
|
Progress bar slice9 settings
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "Style"></a>
|
||||||
|
<strong>Style</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component style params
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Fields:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">SPEED</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Progress bas fill rate. More -> faster
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">MIN_DELTA</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Minimum step to fill progress bar
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
246
docs/modules/druid.radio_group.html
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
<!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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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><strong>druid.radio_group</strong></li>
|
||||||
|
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.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/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<h1>Module <code>druid.radio_group</code></h1>
|
||||||
|
<p>Radio group module</p>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a href="#Functions">Functions</a></h2>
|
||||||
|
<table class="function_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#init">init(node, callback[, click=node])</a></td>
|
||||||
|
<td class="summary">Component init function</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_state">set_state(state)</a></td>
|
||||||
|
<td class="summary">Set radio group state</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#get_state">get_state()</a></td>
|
||||||
|
<td class="summary">Return radio group state</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(node, callback[, click=node])</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component init function
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">node</span>
|
||||||
|
<span class="types"><span class="type">node[]</span></span>
|
||||||
|
Array of gui node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">callback</span>
|
||||||
|
<span class="types"><span class="type">function</span></span>
|
||||||
|
Radio callback
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">click</span>
|
||||||
|
<span class="types"><span class="type">node[]</span></span>
|
||||||
|
node Array of trigger nodes, by default equals to nodes
|
||||||
|
(<em>default</em> node)
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_state"></a>
|
||||||
|
<strong>set_state(state)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set radio group state
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">state</span>
|
||||||
|
<span class="types"><span class="type">bool[]</span></span>
|
||||||
|
Array of checkbox state
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "get_state"></a>
|
||||||
|
<strong>get_state()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Return radio group state
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">bool[]</span></span>
|
||||||
|
Array if checkboxes state
|
||||||
|
</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_radio_click</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On any checkbox click
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "Fields"></a>
|
||||||
|
<strong>Fields</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component fields
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Fields:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">checkboxes</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
|
||||||
|
Array of checkbox components
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
514
docs/modules/druid.scroll.html
Normal file
@ -0,0 +1,514 @@
|
|||||||
|
<!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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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><strong>druid.scroll</strong></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.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/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<h1>Module <code>druid.scroll</code></h1>
|
||||||
|
<p>Component to handle scroll content.</p>
|
||||||
|
<p> Scroll consist from two nodes: scroll parent and scroll input
|
||||||
|
Scroll input the user input zone, it's static
|
||||||
|
Scroll parent the scroll moving part, it will change position.
|
||||||
|
Setup initial scroll size by changing scroll parent size. If scroll parent
|
||||||
|
size will be less than scroll_input size, no scroll is available. For scroll
|
||||||
|
parent size should be more than input size</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a href="#Functions">Functions</a></h2>
|
||||||
|
<table class="function_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#init">init(scroll_parent, input_zone)</a></td>
|
||||||
|
<td class="summary">Component init function</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#scroll_to">scroll_to(vector3[, is_instant])</a></td>
|
||||||
|
<td class="summary">Start scroll to target point</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#scroll_to_percent">scroll_to_percent(vector3[, is_instant])</a></td>
|
||||||
|
<td class="summary">Start scroll to target scroll percent</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#init">init(index[, skip_cb])</a></td>
|
||||||
|
<td class="summary">Scroll to item in scroll by point index</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_points">set_points(points)</a></td>
|
||||||
|
<td class="summary">Set points of interest.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_inert">set_inert(state)</a></td>
|
||||||
|
<td class="summary">Enable or disable scroll inert.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#on_point_move">on_point_move(callback)</a></td>
|
||||||
|
<td class="summary">Set the callback on scrolling to point (if exist)</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_border">set_border(border)</a></td>
|
||||||
|
<td class="summary">Set the scroll possibly area</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#get_scroll_percent">get_scroll_percent()</a></td>
|
||||||
|
<td class="summary">Return current scroll progress</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>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#Style">Style</a></td>
|
||||||
|
<td class="summary">Component style params</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(scroll_parent, input_zone)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component init function
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">scroll_parent</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Gui node where placed scroll content. This node will change position
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">input_zone</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Gui node where input is catched
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "scroll_to"></a>
|
||||||
|
<strong>scroll_to(vector3[, is_instant])</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Start scroll to target point
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">vector3</span>
|
||||||
|
<span class="types"><span class="type">point</span></span>
|
||||||
|
target point
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">is_instant</span>
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
instant scroll flag
|
||||||
|
(<em>optional</em>)
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Usage:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><pre class="example">scroll:scroll_to(vmath.vector3(<span class="number">0</span>, <span class="number">50</span>, <span class="number">0</span>))</pre></li>
|
||||||
|
<li><pre class="example">scroll:scroll_to(vmath.vector3(<span class="number">0</span>), <span class="keyword">true</span>)</pre></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "scroll_to_percent"></a>
|
||||||
|
<strong>scroll_to_percent(vector3[, is_instant])</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Start scroll to target scroll percent
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">vector3</span>
|
||||||
|
<span class="types"><span class="type">point</span></span>
|
||||||
|
target percent
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">is_instant</span>
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
instant scroll flag
|
||||||
|
(<em>optional</em>)
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Usage:</h3>
|
||||||
|
<ul>
|
||||||
|
<pre class="example">scroll:scroll_to_percent(vmath.vector3(<span class="number">0.5</span>, <span class="number">0</span>, <span class="number">0</span>))</pre>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "init"></a>
|
||||||
|
<strong>init(index[, skip_cb])</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Scroll to item in scroll by point index
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">index</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Point index
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">skip_cb</span>
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
If true, skip the point callback
|
||||||
|
(<em>optional</em>)
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_points"></a>
|
||||||
|
<strong>set_points(points)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set points of interest.
|
||||||
|
Scroll will always centered on closer points
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">points</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
|
||||||
|
Array of vector3 points
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_inert"></a>
|
||||||
|
<strong>set_inert(state)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Enable or disable scroll inert.
|
||||||
|
If disabled, scroll through points (if exist)
|
||||||
|
If no points, just simple drag without inertion
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">state</span>
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
Inert scroll state
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "on_point_move"></a>
|
||||||
|
<strong>on_point_move(callback)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set the callback on scrolling to point (if exist)
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">callback</span>
|
||||||
|
<span class="types"><span class="type">function</span></span>
|
||||||
|
Callback on scroll to point of interest
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_border"></a>
|
||||||
|
<strong>set_border(border)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set the scroll possibly area
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">border</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Size of scrolling area
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "get_scroll_percent"></a>
|
||||||
|
<strong>get_scroll_percent()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Return current scroll progress
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Scroll progress
|
||||||
|
</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_scroll</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On scroll move callback
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">on_scroll_to</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On scroll_to function callback
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">on_point_scroll</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On scroll<em>to</em>index function callbck
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "Fields"></a>
|
||||||
|
<strong>Fields</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component fields
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Fields:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Scroll parent node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">input_zone</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Scroll input node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">zone_size</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Current scroll content size
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">soft_size</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Soft zone size from style table
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">center_offset</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Distance from node to node's center
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">is_inert</span>
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
Flag, if scroll now moving by inertion
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">inert</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Current inert speed
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">pos</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Current scroll posisition
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">target</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Current scroll target position
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "Style"></a>
|
||||||
|
<strong>Style</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component style params
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Fields:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">FRICT_HOLD</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Multiplier for inertion, while touching
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">FRICT</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Multiplier for free inertion
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">INERT_THRESHOLD</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Scroll speed to stop inertion
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">INERT_SPEED</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Multiplier for inertion speed
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">DEADZONE</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Deadzone for start scrol in pixels
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">SOFT_ZONE_SIZE</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Size of outside zone in pixels (for scroll back moving)
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">BACK_SPEED</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Scroll back returning lerp speed
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">ANIM_SPEED</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Scroll gui.animation speed for scroll_to function
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
255
docs/modules/druid.slider.html
Normal file
@ -0,0 +1,255 @@
|
|||||||
|
<!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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><strong>druid.slider</strong></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.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/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<h1>Module <code>druid.slider</code></h1>
|
||||||
|
<p>Druid slider component</p>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a href="#Functions">Functions</a></h2>
|
||||||
|
<table class="function_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#init">init(node, end_pos[, callback])</a></td>
|
||||||
|
<td class="summary">Component init function</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set">set(value[, is_silent])</a></td>
|
||||||
|
<td class="summary">Set value for slider</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(node, end_pos[, callback])</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component init function
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Gui pin node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">end_pos</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
The end position of slider
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">callback</span>
|
||||||
|
<span class="types"><span class="type">function</span></span>
|
||||||
|
On slider change callback
|
||||||
|
(<em>optional</em>)
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set"></a>
|
||||||
|
<strong>set(value[, is_silent])</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set value for slider
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">value</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Value from 0 to 1
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">is_silent</span>
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
Don't trigger event if true
|
||||||
|
(<em>optional</em>)
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</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_change_value</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On change value callback
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "Fields"></a>
|
||||||
|
<strong>Fields</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component fields
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Fields:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Slider pin node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">start_pos</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Start pin node position
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">pos</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Current pin node position
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">target_pos</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Targer pin node position
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">end_pos</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
End pin node position
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">dist</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Length between start and end position
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">is_drag</span>
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
Current drag state
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">value</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Current slider value
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
359
docs/modules/druid.text.html
Normal file
@ -0,0 +1,359 @@
|
|||||||
|
<!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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><strong>druid.text</strong></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.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/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<h1>Module <code>druid.text</code></h1>
|
||||||
|
<p>Component to handle all GUI texts.</p>
|
||||||
|
<p> Druid text can adjust itself for text node size
|
||||||
|
Text will never will be outside of his text size (even multiline)</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a href="#Functions">Functions</a></h2>
|
||||||
|
<table class="function_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#init">init(node[, value[, no_adjust]])</a></td>
|
||||||
|
<td class="summary">Component init function</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_to">set_to(set_to)</a></td>
|
||||||
|
<td class="summary">Set text to text field</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_color">set_color(color)</a></td>
|
||||||
|
<td class="summary">Set color</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_alpha">set_alpha(alpha)</a></td>
|
||||||
|
<td class="summary">Set alpha</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_scale">set_scale(scale)</a></td>
|
||||||
|
<td class="summary">Set scale</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_pivot">set_pivot(pivot)</a></td>
|
||||||
|
<td class="summary">Set text pivot.</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(node[, value[, no_adjust]])</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component init function
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Gui text node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">value</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
|
||||||
|
Initial text
|
||||||
|
(<em>optional</em>)
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">no_adjust</span>
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
If true, text will be not auto-adjust size
|
||||||
|
(<em>optional</em>)
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_to"></a>
|
||||||
|
<strong>set_to(set_to)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set text to text field
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">set_to</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
|
||||||
|
Text for node
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_color"></a>
|
||||||
|
<strong>set_color(color)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set color
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">color</span>
|
||||||
|
<span class="types"><span class="type">vector4</span></span>
|
||||||
|
Color for node
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_alpha"></a>
|
||||||
|
<strong>set_alpha(alpha)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set alpha
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">alpha</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Alpha for node
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_scale"></a>
|
||||||
|
<strong>set_scale(scale)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set scale
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">scale</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Scale for node
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_pivot"></a>
|
||||||
|
<strong>set_pivot(pivot)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set text pivot. Text will re-anchor inside
|
||||||
|
his text area
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">pivot</span>
|
||||||
|
<span class="types"><span class="type">gui.pivot</span></span>
|
||||||
|
Gui pivot constant
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</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_set_text</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On set text callback
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">on_update_text_scale</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On adjust text size callback
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">on_set_pivot</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On change pivot callback
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "Fields"></a>
|
||||||
|
<strong>Fields</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component fields
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Fields:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Text node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">pos</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Current text position
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">start_scale</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Initial text node scale
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">scale</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Current text node scale
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">start_size</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Initial text node size
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">text_area</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Current text node available are
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">is_no_adjust</span>
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
Current text size adjust settings
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">color</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Current text color
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
314
docs/modules/druid.timer.html
Normal file
@ -0,0 +1,314 @@
|
|||||||
|
<!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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><strong>druid.timer</strong></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.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/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<h1>Module <code>druid.timer</code></h1>
|
||||||
|
<p>Component to handle GUI timers.</p>
|
||||||
|
<p> Timer updating by game delta time. If game is not focused -
|
||||||
|
timer will be not updated.</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a href="#Functions">Functions</a></h2>
|
||||||
|
<table class="function_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#init">init(node, seconds_from[, seconds_to=0[, callback]])</a></td>
|
||||||
|
<td class="summary">Component init function</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_to">set_to(set_to)</a></td>
|
||||||
|
<td class="summary">Set text to text field</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_state">set_state(is_on)</a></td>
|
||||||
|
<td class="summary">Called when update</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#set_interval">set_interval(from, to)</a></td>
|
||||||
|
<td class="summary">Set time interval</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(node, seconds_from[, seconds_to=0[, callback]])</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component init function
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Gui text node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">seconds_from</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Start timer value in seconds
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">seconds_to</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
End timer value in seconds
|
||||||
|
(<em>default</em> 0)
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">callback</span>
|
||||||
|
<span class="types"><span class="type">function</span></span>
|
||||||
|
Function on timer end
|
||||||
|
(<em>optional</em>)
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_to"></a>
|
||||||
|
<strong>set_to(set_to)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set text to text field
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">set_to</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Value in seconds
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_state"></a>
|
||||||
|
<strong>set_state(is_on)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Called when update
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">is_on</span>
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
Timer enable state
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "set_interval"></a>
|
||||||
|
<strong>set_interval(from, to)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set time interval
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">from</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Start time in seconds
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">to</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Target time in seconds
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</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_tick</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On timer tick callback. Fire every second
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">on_set_enabled</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On timer change enabled state callback
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">on_timer_end</span>
|
||||||
|
<span class="types"><span class="type">druid_event</span></span>
|
||||||
|
On timer end callback
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "Fields"></a>
|
||||||
|
<strong>Fields</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Component fields
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Fields:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Trigger node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">anim_node</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Animation node
|
||||||
|
(<em>default</em> node)
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">scale_from</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Initial scale of anim_node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">pos</span>
|
||||||
|
<span class="types"><span class="type">vector3</span></span>
|
||||||
|
Initial pos of anim_node
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">params</span>
|
||||||
|
<span class="types"><span class="type">any</span></span>
|
||||||
|
Params to click callbacks
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">hover</span>
|
||||||
|
<span class="types"><span class="type">druid.hover</span></span>
|
||||||
|
Druid hover logic component
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">click_zone</span>
|
||||||
|
<span class="types"><span class="type">node</span></span>
|
||||||
|
Restriction zone
|
||||||
|
(<em>optional</em>)
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
246
docs/modules/druid_event.html
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
<!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>
|
||||||
|
</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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
|
||||||
|
<li><a href="../modules/component.html">component</a></li>
|
||||||
|
<li><a href="../modules/druid.html">druid</a></li>
|
||||||
|
<li><strong>druid_event</strong></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/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<h1>Module <code>druid_event</code></h1>
|
||||||
|
<p>Lua event small library</p>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a href="#Functions">Functions</a></h2>
|
||||||
|
<table class="function_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#Event">Event(initial_callback)</a></td>
|
||||||
|
<td class="summary">Event constructur</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#event:subscribe">event:subscribe(callback)</a></td>
|
||||||
|
<td class="summary">Subscribe callback on event</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#event:unsubscribe">event:unsubscribe(callback)</a></td>
|
||||||
|
<td class="summary">Unsubscribe callback on event</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#event:is_exist">event:is_exist()</a></td>
|
||||||
|
<td class="summary">Return true, if event have at lease one handler</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#event:clear">event:clear()</a></td>
|
||||||
|
<td class="summary">Clear the all event handlers</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#event:trigger">event:trigger(...)</a></td>
|
||||||
|
<td class="summary">Trigger the event and call all subscribed callbacks</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
|
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||||
|
|
||||||
|
<dl class="function">
|
||||||
|
<dt>
|
||||||
|
<a name = "Event"></a>
|
||||||
|
<strong>Event(initial_callback)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Event constructur
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">initial_callback</span>
|
||||||
|
<span class="types"><span class="type">function</span></span>
|
||||||
|
Subscribe the callback on new event, if callback exist
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "event:subscribe"></a>
|
||||||
|
<strong>event:subscribe(callback)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Subscribe callback on event
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">callback</span>
|
||||||
|
<span class="types"><span class="type">function</span></span>
|
||||||
|
Callback itself
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "event:unsubscribe"></a>
|
||||||
|
<strong>event:unsubscribe(callback)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Unsubscribe callback on event
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">callback</span>
|
||||||
|
<span class="types"><span class="type">function</span></span>
|
||||||
|
Callback itself
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "event:is_exist"></a>
|
||||||
|
<strong>event:is_exist()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Return true, if event have at lease one handler
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
True if event have handlers
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "event:clear"></a>
|
||||||
|
<strong>event:clear()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Clear the all event handlers
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "event:trigger"></a>
|
||||||
|
<strong>event:trigger(...)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Trigger the event and call all subscribed callbacks
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">...</span>
|
||||||
|
All event params
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
757
docs/modules/druid_instance.html
Normal file
@ -0,0 +1,757 @@
|
|||||||
|
<!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>
|
||||||
|
</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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.helper.html">druid.helper</a></li>
|
||||||
|
<li><strong>druid_instance</strong></li>
|
||||||
|
</ul>
|
||||||
|
<h2>Topics</h2>
|
||||||
|
<ul class="">
|
||||||
|
<li><a href="../topics/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<h1>Module <code>druid_instance</code></h1>
|
||||||
|
<p>Druid main class.</p>
|
||||||
|
<p> Create instance of this
|
||||||
|
to start creating components</p>
|
||||||
|
<h3>See also:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><a href="../modules/druid.button.html#">druid.button</a></li>
|
||||||
|
<li><a href="../modules/druid.blocker.html#">druid.blocker</a></li>
|
||||||
|
<li><a href="../modules/druid.back_handler.html#">druid.back_handler</a></li>
|
||||||
|
<li><a href="../modules/druid.input.html#">druid.input</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html#">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.lang_text.html#">druid.lang_text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html#">druid.timer</a></li>
|
||||||
|
<li><a href="../modules/druid.progress.html#">druid.progress</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html#">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.scroll.html#">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html#">druid.slider</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.radio_group.html#">druid.radio_group</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a href="#Functions">Functions</a></h2>
|
||||||
|
<table class="function_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:initialize">druid:initialize(table, table)</a></td>
|
||||||
|
<td class="summary">Druid class constructor</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:create">druid:create(component, ...)</a></td>
|
||||||
|
<td class="summary">Create new druid component</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:remove">druid:remove(component)</a></td>
|
||||||
|
<td class="summary">Remove component from druid instance.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:update">druid:update(dt)</a></td>
|
||||||
|
<td class="summary">Druid update function</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:on_input">druid:on_input(action_id, action)</a></td>
|
||||||
|
<td class="summary">Druid on_input function</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:on_message">druid:on_message(message_id, message, sender)</a></td>
|
||||||
|
<td class="summary">Druid on_message function</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:new_button">druid:new_button(...)</a></td>
|
||||||
|
<td class="summary">Create button basic component</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:new_blocker">druid:new_blocker(...)</a></td>
|
||||||
|
<td class="summary">Create blocker basic component</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:new_back_handler">druid:new_back_handler(...)</a></td>
|
||||||
|
<td class="summary">Create back_handler basic component</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:new_hover">druid:new_hover(...)</a></td>
|
||||||
|
<td class="summary">Create hover basic component</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:new_text">druid:new_text(...)</a></td>
|
||||||
|
<td class="summary">Create text basic component</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:new_lang_text">druid:new_lang_text(...)</a></td>
|
||||||
|
<td class="summary">Create lang_text basic component</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:new_timer">druid:new_timer(...)</a></td>
|
||||||
|
<td class="summary">Create timer basic component</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:new_progress">druid:new_progress(...)</a></td>
|
||||||
|
<td class="summary">Create progress basic component</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:new_grid">druid:new_grid(...)</a></td>
|
||||||
|
<td class="summary">Create grid basic component</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:new_scroll">druid:new_scroll(...)</a></td>
|
||||||
|
<td class="summary">Create scroll basic component</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:new_slider">druid:new_slider(...)</a></td>
|
||||||
|
<td class="summary">Create slider basic component</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:new_checkbox">druid:new_checkbox(...)</a></td>
|
||||||
|
<td class="summary">Create checkbox basic component</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:new_input">druid:new_input(...)</a></td>
|
||||||
|
<td class="summary">Create input basic component</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:new_checkbox_group">druid:new_checkbox_group(...)</a></td>
|
||||||
|
<td class="summary">Create checkbox_group basic component</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#druid:new_radio_group">druid:new_radio_group(...)</a></td>
|
||||||
|
<td class="summary">Create radio_group basic component</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
|
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||||
|
|
||||||
|
<dl class="function">
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:initialize"></a>
|
||||||
|
<strong>druid:initialize(table, table)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Druid class constructor
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">table</span>
|
||||||
|
<span class="types"><span class="type">style</span></span>
|
||||||
|
Druid style module
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">table</span>
|
||||||
|
<span class="types"><span class="type">style</span></span>
|
||||||
|
Druid style module
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:create"></a>
|
||||||
|
<strong>druid:create(component, ...)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Create new druid component
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">component</span>
|
||||||
|
<span class="types"><span class="type">Component</span></span>
|
||||||
|
Component module
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">...</span>
|
||||||
|
<span class="types"><span class="type">args</span></span>
|
||||||
|
Other component params to pass it to component:init function
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:remove"></a>
|
||||||
|
<strong>druid:remove(component)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Remove component from druid instance.
|
||||||
|
Component <code>on_remove</code> function will be invoked, if exist.
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">component</span>
|
||||||
|
<span class="types"><span class="type">Component</span></span>
|
||||||
|
Component instance
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:update"></a>
|
||||||
|
<strong>druid:update(dt)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Druid update function
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">dt</span>
|
||||||
|
<span class="types"><span class="type">number</span></span>
|
||||||
|
Delta time
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:on_input"></a>
|
||||||
|
<strong>druid:on_input(action_id, action)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Druid on_input function
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">action_id</span>
|
||||||
|
<span class="types"><span class="type">hash</span></span>
|
||||||
|
Action<em>id from on</em>input
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">action</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
|
||||||
|
Action from on_input
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:on_message"></a>
|
||||||
|
<strong>druid:on_message(message_id, message, sender)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Druid on_message function
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">message_id</span>
|
||||||
|
<span class="types"><span class="type">hash</span></span>
|
||||||
|
Message<em>id from on</em>message
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">message</span>
|
||||||
|
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
|
||||||
|
Message from on_message
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">sender</span>
|
||||||
|
<span class="types"><span class="type">hash</span></span>
|
||||||
|
Sender from on_message
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:new_button"></a>
|
||||||
|
<strong>druid:new_button(...)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Create button basic component
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">...</span>
|
||||||
|
<span class="types"><span class="type">args</span></span>
|
||||||
|
button init args
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">Component</span></span>
|
||||||
|
button component
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:new_blocker"></a>
|
||||||
|
<strong>druid:new_blocker(...)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Create blocker basic component
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">...</span>
|
||||||
|
<span class="types"><span class="type">args</span></span>
|
||||||
|
blocker init args
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">Component</span></span>
|
||||||
|
blocker component
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:new_back_handler"></a>
|
||||||
|
<strong>druid:new_back_handler(...)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Create back_handler basic component
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">...</span>
|
||||||
|
<span class="types"><span class="type">args</span></span>
|
||||||
|
back_handler init args
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">Component</span></span>
|
||||||
|
back_handler component
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:new_hover"></a>
|
||||||
|
<strong>druid:new_hover(...)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Create hover basic component
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">...</span>
|
||||||
|
<span class="types"><span class="type">args</span></span>
|
||||||
|
hover init args
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">Component</span></span>
|
||||||
|
hover component
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:new_text"></a>
|
||||||
|
<strong>druid:new_text(...)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Create text basic component
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">...</span>
|
||||||
|
<span class="types"><span class="type">args</span></span>
|
||||||
|
text init args
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">Component</span></span>
|
||||||
|
text component
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:new_lang_text"></a>
|
||||||
|
<strong>druid:new_lang_text(...)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Create lang_text basic component
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">...</span>
|
||||||
|
<span class="types"><span class="type">args</span></span>
|
||||||
|
lang_text init args
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">Component</span></span>
|
||||||
|
lang_text component
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:new_timer"></a>
|
||||||
|
<strong>druid:new_timer(...)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Create timer basic component
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">...</span>
|
||||||
|
<span class="types"><span class="type">args</span></span>
|
||||||
|
timer init args
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">Component</span></span>
|
||||||
|
timer component
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:new_progress"></a>
|
||||||
|
<strong>druid:new_progress(...)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Create progress basic component
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">...</span>
|
||||||
|
<span class="types"><span class="type">args</span></span>
|
||||||
|
progress init args
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">Component</span></span>
|
||||||
|
progress component
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:new_grid"></a>
|
||||||
|
<strong>druid:new_grid(...)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Create grid basic component
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">...</span>
|
||||||
|
<span class="types"><span class="type">args</span></span>
|
||||||
|
grid init args
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">Component</span></span>
|
||||||
|
grid component
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:new_scroll"></a>
|
||||||
|
<strong>druid:new_scroll(...)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Create scroll basic component
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">...</span>
|
||||||
|
<span class="types"><span class="type">args</span></span>
|
||||||
|
scroll init args
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">Component</span></span>
|
||||||
|
scroll component
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:new_slider"></a>
|
||||||
|
<strong>druid:new_slider(...)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Create slider basic component
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">...</span>
|
||||||
|
<span class="types"><span class="type">args</span></span>
|
||||||
|
slider init args
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">Component</span></span>
|
||||||
|
slider component
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:new_checkbox"></a>
|
||||||
|
<strong>druid:new_checkbox(...)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Create checkbox basic component
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">...</span>
|
||||||
|
<span class="types"><span class="type">args</span></span>
|
||||||
|
checkbox init args
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">Component</span></span>
|
||||||
|
checkbox component
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:new_input"></a>
|
||||||
|
<strong>druid:new_input(...)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Create input basic component
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">...</span>
|
||||||
|
<span class="types"><span class="type">args</span></span>
|
||||||
|
input init args
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">Component</span></span>
|
||||||
|
input component
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:new_checkbox_group"></a>
|
||||||
|
<strong>druid:new_checkbox_group(...)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Create checkbox_group basic component
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">...</span>
|
||||||
|
<span class="types"><span class="type">args</span></span>
|
||||||
|
checkbox_group init args
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">Component</span></span>
|
||||||
|
checkbox_group component
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "druid:new_radio_group"></a>
|
||||||
|
<strong>druid:new_radio_group(...)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Create radio_group basic component
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">...</span>
|
||||||
|
<span class="types"><span class="type">args</span></span>
|
||||||
|
radio_group init args
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">Component</span></span>
|
||||||
|
radio_group component
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
241
docs/topics/README.md.html
Normal file
@ -0,0 +1,241 @@
|
|||||||
|
<!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="#Setup">Setup </a></li>
|
||||||
|
<li><a href="#Components">Components </a></li>
|
||||||
|
<li><a href="#Creating_components">Creating components </a></li>
|
||||||
|
<li><a href="#Examples">Examples </a></li>
|
||||||
|
<li><a href="#Documentation">Documentation </a></li>
|
||||||
|
<li><a href="#Games_powered_by_Druid">Games powered by Druid </a></li>
|
||||||
|
<li><a href="#Future_plans">Future plans </a></li>
|
||||||
|
<li><a href="#License">License </a></li>
|
||||||
|
<li><a href="#Issues_and_suggestions">Issues and suggestions </a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Topics</h2>
|
||||||
|
<ul class="">
|
||||||
|
<li><a href="../topics/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><strong>README</strong></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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.helper.html">druid.helper</a></li>
|
||||||
|
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<a href="https://insality.github.io/druid/"><img src="media/druid_logo.png" alt=""/></a></p>
|
||||||
|
|
||||||
|
<p><strong>Druid</strong> - powerful defold component UI library. Use basic druid components or make your own game-specific components to make amazing GUI in your games.</p>
|
||||||
|
|
||||||
|
|
||||||
|
<p><a name="Setup"></a></p>
|
||||||
|
<h2>Setup</h2>
|
||||||
|
|
||||||
|
<h3>Dependency</h3>
|
||||||
|
|
||||||
|
<p>You can use the druid extension in your own project by adding this project as a <a href="https://www.defold.com/manuals/libraries/">Defold library dependency</a>. Open your game.project file and in the dependencies field under project add:</p>
|
||||||
|
|
||||||
|
<blockquote>
|
||||||
|
<p><a href="https://github.com/Insality/druid/archive/master.zip">https://github.com/Insality/druid/archive/master.zip</a></p>
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
|
<p>Or point to the ZIP file of a <a href="https://github.com/Insality/druid/releases">specific release</a>.</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Code</h3>
|
||||||
|
|
||||||
|
<p>Adjust druid settings, if needed:</p>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
|
||||||
|
|
||||||
|
<span class="comment">-- Used for button component and custom components
|
||||||
|
</span>druid.set_sound_function(callback)
|
||||||
|
|
||||||
|
<span class="comment">-- Used for lang_text component
|
||||||
|
</span>druid.set_text_function(callback)
|
||||||
|
|
||||||
|
<span class="comment">-- Used for change default druid style
|
||||||
|
</span>druid.set_default_style(your_style)
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p><a name="Components"></a></p>
|
||||||
|
<h2>Components</h2>
|
||||||
|
|
||||||
|
<p>Druid provides next basic components:
|
||||||
|
- <strong>Button</strong> - Basic game button</p>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><p><strong>Text</strong> - Wrap on text node with text size adjusting</p></li>
|
||||||
|
<li><p><strong>Blocker</strong> - Block input in node zone</p></li>
|
||||||
|
<li><p><strong>Back Handler</strong> - Handle back button (Android, backspace)</p></li>
|
||||||
|
<li><p><strong>Lang text</strong> - Text component with handle localization system</p></li>
|
||||||
|
<li><p><strong>Timer</strong> - Run timer on text node</p></li>
|
||||||
|
<li><p><strong>Progress</strong> - Basic progress bar</p></li>
|
||||||
|
<li><p><strong>Scroll</strong> - Basic scroll component</p></li>
|
||||||
|
<li><p><strong>Grid</strong> - Component for manage node positions</p></li>
|
||||||
|
<li><p><strong>Slider</strong> - Basic slider component</p></li>
|
||||||
|
<li><p><strong>Checkbox</strong> - Basic checkbox component</p></li>
|
||||||
|
<li><p><strong>Checkbox group</strong> - Several checkboxes in one group</p></li>
|
||||||
|
<li><p><strong>Radio group</strong> - Several checkboxes in one group with single choice</p></li>
|
||||||
|
<li><p><strong>Hover</strong> - Trigger component for check node hover state</p></li>
|
||||||
|
<li><p><strong>Input</strong> - Component to process user text input</p></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p>Full info see on <em>components.md</em></p>
|
||||||
|
|
||||||
|
|
||||||
|
<p><a name="Creating_components"></a></p>
|
||||||
|
<h2>Creating components</h2>
|
||||||
|
|
||||||
|
<p>Any components creating via druid:</p>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
|
||||||
|
|
||||||
|
<span class="keyword">local</span> <span class="keyword">function</span> init(self)
|
||||||
|
self.druid = druid.new(self)
|
||||||
|
<span class="keyword">local</span> button = self.druid:new_button(node_name, callback)
|
||||||
|
<span class="keyword">local</span> text = self.druid:new_text(node_text_name)
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
|
||||||
|
<span class="keyword">function</span> update(self, dt)
|
||||||
|
self.druid:update(dt)
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
|
||||||
|
<span class="keyword">function</span> on_message(self, message_id, message, sender)
|
||||||
|
self.druid:on_message(message_id, message, sender)
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
|
||||||
|
<span class="keyword">function</span> on_input(self, action_id, action)
|
||||||
|
self.druid:on_input(action_id, action)
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p><a name="Examples"></a></p>
|
||||||
|
<h2>Examples</h2>
|
||||||
|
|
||||||
|
<p>See the <a href="https://github.com/insality/druid/tree/develop/example/kenney">example folder</a> for examples of how to use Druid</p>
|
||||||
|
|
||||||
|
<p>See the <a href="https://github.com/insality/druid-assets">druid-assets repository</a> for examples of how to create custom components and styles</p>
|
||||||
|
|
||||||
|
<p>Try the HTML5 version of the example app</p>
|
||||||
|
|
||||||
|
|
||||||
|
<p><a name="Documentation"></a></p>
|
||||||
|
<h2>Documentation</h2>
|
||||||
|
|
||||||
|
<p>To learn druid better, read next documentation:
|
||||||
|
- Druid components
|
||||||
|
- Create custom components
|
||||||
|
- Druid asset store
|
||||||
|
- Druid Styles</p>
|
||||||
|
|
||||||
|
<p>Full druid documentation you can find here:
|
||||||
|
https://insality.github.io/druid/</p>
|
||||||
|
|
||||||
|
|
||||||
|
<p><a name="Games_powered_by_Druid"></a></p>
|
||||||
|
<h2>Games powered by Druid</h2>
|
||||||
|
|
||||||
|
<p><em>Will fill later</em></p>
|
||||||
|
|
||||||
|
|
||||||
|
<p><a name="Future_plans"></a></p>
|
||||||
|
<h2>Future plans</h2>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><p>Basic input component</p></li>
|
||||||
|
<li><p>Add on<em>layout</em>change support (to keep gui data between layout change)</p></li>
|
||||||
|
<li><p>Add on<em>change</em>language support (call single function to update all druid instance)</p></li>
|
||||||
|
<li><p>Better documentation and examples</p></li>
|
||||||
|
<li><p>Add more comfortable gamepad support for GUI (ability to select button with DPAD and other stuff)</p></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
<p><a name="License"></a></p>
|
||||||
|
<h2>License</h2>
|
||||||
|
|
||||||
|
<p>Original idea by <a href="https://github.com/AGulev">AGulev</a></p>
|
||||||
|
|
||||||
|
<p>Developed and supporting by <a href="https://github.com/Insality">Insality</a></p>
|
||||||
|
|
||||||
|
<p>MIT License</p>
|
||||||
|
|
||||||
|
|
||||||
|
<p><a name="Issues_and_suggestions"></a></p>
|
||||||
|
<h2>Issues and suggestions</h2>
|
||||||
|
|
||||||
|
<p>If you have any issues, questions or suggestions please <a href="https://github.com/Insality/druid/issues">create an issue</a> or contact me: <a href="mailto:insality@gmail.com">insality@gmail.com</a>
|
||||||
|
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
162
docs/topics/components.md.html
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
<!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="#Button">Button </a></li>
|
||||||
|
<li><a href="#Text">Text </a></li>
|
||||||
|
<li><a href="#Blocker">Blocker </a></li>
|
||||||
|
<li><a href="#Back_Handler">Back Handler </a></li>
|
||||||
|
<li><a href="#Locale">Locale </a></li>
|
||||||
|
<li><a href="#Timer">Timer </a></li>
|
||||||
|
<li><a href="#Progress">Progress </a></li>
|
||||||
|
<li><a href="#Scroll">Scroll </a></li>
|
||||||
|
<li><a href="#Grid">Grid </a></li>
|
||||||
|
<li><a href="#Slider">Slider </a></li>
|
||||||
|
<li><a href="#Checkbox">Checkbox </a></li>
|
||||||
|
<li><a href="#Checkbox_group">Checkbox group </a></li>
|
||||||
|
<li><a href="#Radio_group">Radio group </a></li>
|
||||||
|
<li><a href="#Hover">Hover </a></li>
|
||||||
|
<li><a href="#Input">Input </a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Topics</h2>
|
||||||
|
<ul class="">
|
||||||
|
<li><strong>Druid components</strong></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.helper.html">druid.helper</a></li>
|
||||||
|
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
|
||||||
|
<h1>Druid components</h1>
|
||||||
|
|
||||||
|
<p><a name="Button"></a></p>
|
||||||
|
<h2>Button</h2>
|
||||||
|
<p>Basic game button</p>
|
||||||
|
|
||||||
|
<p><a name="Text"></a></p>
|
||||||
|
<h2>Text</h2>
|
||||||
|
<p>Wrap on text node with text size adjusting</p>
|
||||||
|
|
||||||
|
<p><a name="Blocker"></a></p>
|
||||||
|
<h2>Blocker</h2>
|
||||||
|
<p>Block input in node zone</p>
|
||||||
|
|
||||||
|
<p><a name="Back_Handler"></a></p>
|
||||||
|
<h2>Back Handler</h2>
|
||||||
|
<p>Handle back button (Android, backspace)</p>
|
||||||
|
|
||||||
|
<p><a name="Locale"></a></p>
|
||||||
|
<h2>Locale</h2>
|
||||||
|
<p>Text component with handle localization system</p>
|
||||||
|
|
||||||
|
<p><a name="Timer"></a></p>
|
||||||
|
<h2>Timer</h2>
|
||||||
|
<p>Run timer on text node</p>
|
||||||
|
|
||||||
|
<p><a name="Progress"></a></p>
|
||||||
|
<h2>Progress</h2>
|
||||||
|
<p>Basic progress bar</p>
|
||||||
|
|
||||||
|
<p><a name="Scroll"></a></p>
|
||||||
|
<h2>Scroll</h2>
|
||||||
|
<p>Basic scroll component</p>
|
||||||
|
|
||||||
|
<p><a name="Grid"></a></p>
|
||||||
|
<h2>Grid</h2>
|
||||||
|
<p>Component for manage node positions</p>
|
||||||
|
|
||||||
|
<p><a name="Slider"></a></p>
|
||||||
|
<h2>Slider</h2>
|
||||||
|
<p>Basic slider component</p>
|
||||||
|
|
||||||
|
<p><a name="Checkbox"></a></p>
|
||||||
|
<h2>Checkbox</h2>
|
||||||
|
<p>Basic checkbox component</p>
|
||||||
|
|
||||||
|
<p><a name="Checkbox_group"></a></p>
|
||||||
|
<h2>Checkbox group</h2>
|
||||||
|
<p>Several checkboxes in one group</p>
|
||||||
|
|
||||||
|
<p><a name="Radio_group"></a></p>
|
||||||
|
<h2>Radio group</h2>
|
||||||
|
<p>Several checkboxes in one group with single choice</p>
|
||||||
|
|
||||||
|
<p><a name="Hover"></a></p>
|
||||||
|
<h2>Hover</h2>
|
||||||
|
<p>Trigger component for check node hover state</p>
|
||||||
|
|
||||||
|
<p><a name="Input"></a></p>
|
||||||
|
<h2>Input</h2>
|
||||||
|
<p>Component to process user text input</p>
|
||||||
|
|
||||||
|
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
172
docs/topics/create_custom_components.md.html
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
<!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>Topics</h2>
|
||||||
|
<ul class="">
|
||||||
|
<li><a href="../topics/components.md.html">Druid components</a></li>
|
||||||
|
<li><strong>Custom components</strong></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/online_example.md.html">Online example</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.helper.html">druid.helper</a></li>
|
||||||
|
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Custom components</h2>
|
||||||
|
|
||||||
|
<p>Add your custom components via <a href="../modules/druid.html#register">druid.register</a></p>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
|
||||||
|
<span class="keyword">local</span> my_component = <span class="global">require</span>(<span class="string">"my.amazing.component"</span>)
|
||||||
|
|
||||||
|
<span class="keyword">local</span> <span class="keyword">function</span> init(self)
|
||||||
|
druid.register(<span class="string">"my_component"</span>, my_component)
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
<p>Basic custom component template looks like this:</p>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
<span class="keyword">local</span> const = <span class="global">require</span>(<span class="string">"druid.const"</span>)
|
||||||
|
|
||||||
|
<span class="keyword">local</span> M = {}
|
||||||
|
M.interest = { const.ON_INPUT }
|
||||||
|
|
||||||
|
<span class="keyword">function</span> M.init(self, ...)
|
||||||
|
<span class="comment">-- Component constructor
|
||||||
|
</span><span class="keyword">end</span>
|
||||||
|
|
||||||
|
<span class="comment">-- Call only if exist interest: const.ON_UPDATE
|
||||||
|
</span><span class="keyword">function</span> M.update(self, dt)
|
||||||
|
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
|
||||||
|
<span class="comment">-- Call only if exist interest: const.ON_INPUT or const.ON_SWIPE
|
||||||
|
</span><span class="keyword">function</span> M.on_input(self, action_id, action)
|
||||||
|
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
|
||||||
|
<span class="comment">-- Call only if exist interest: const.ON_MESSAGE
|
||||||
|
</span><span class="keyword">function</span> M.on_message(self, message_id, message, sender)
|
||||||
|
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
|
||||||
|
<span class="comment">-- Call only if swipe was started on another component (ex. scroll)
|
||||||
|
</span><span class="keyword">function</span> M.on_swipe(self)
|
||||||
|
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
|
||||||
|
<span class="keyword">return</span> M
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Best practice on custom components</h2>
|
||||||
|
<p>On each component recomended describe component schema in next way:</p>
|
||||||
|
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
<span class="comment">-- Component module
|
||||||
|
</span><span class="keyword">local</span> helper = <span class="global">require</span>(<span class="string">"druid.helper"</span>)
|
||||||
|
|
||||||
|
<span class="keyword">local</span> M = {}
|
||||||
|
|
||||||
|
<span class="keyword">local</span> SCHEME = {
|
||||||
|
ROOT = <span class="string">"/root"</span>,
|
||||||
|
ITEM = <span class="string">"/item"</span>,
|
||||||
|
TITLE = <span class="string">"/title"</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="comment">-- TODO: Rework self.template/self.nodes
|
||||||
|
</span><span class="comment">-- Make self._inner_data? { component_name, template, nodes }
|
||||||
|
</span><span class="keyword">function</span> M.init(self, template_name, node_table)
|
||||||
|
<span class="comment">-- If component use template, setup it:
|
||||||
|
</span> self.template = template_name
|
||||||
|
|
||||||
|
<span class="comment">-- If component was cloned with gui.clone_tree, pass his nodes
|
||||||
|
</span> self.nodes = node_table
|
||||||
|
|
||||||
|
<span class="comment">-- helper can get node from gui/template/table
|
||||||
|
</span> <span class="keyword">local</span> root = helper.node(self, SCHEME.ROOT)
|
||||||
|
|
||||||
|
<span class="comment">-- This component can spawn another druid components:
|
||||||
|
</span> <span class="keyword">local</span> druid = helper.get_druid(self)
|
||||||
|
<span class="comment">-- Button self on callback is self of _this_ component
|
||||||
|
</span> <span class="keyword">local</span> button = druid:new_button(...)
|
||||||
|
|
||||||
|
<span class="comment">-- helper can return you the component style
|
||||||
|
</span> <span class="keyword">local</span> my_style = helper.get_style(self, <span class="string">"component_name"</span>)
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</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-03-21 22:00:04 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
200
docs/topics/creating_custom_components.md.html
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
<!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="#Overview">Overview </a></li>
|
||||||
|
<li><a href="#Custom_components">Custom components </a></li>
|
||||||
|
<li><a href="#Best_practice_on_custom_components">Best practice on custom components </a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Topics</h2>
|
||||||
|
<ul class="">
|
||||||
|
<li><a href="../topics/components.md.html">Druid components</a></li>
|
||||||
|
<li><strong>Creating custom components</strong></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.helper.html">druid.helper</a></li>
|
||||||
|
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
|
||||||
|
<h1>Creating custom components</h1>
|
||||||
|
|
||||||
|
<p><a name="Overview"></a></p>
|
||||||
|
<h2>Overview</h2>
|
||||||
|
<p>Druid allows you to create your custom components from druid basic components or other custom components</p>
|
||||||
|
|
||||||
|
|
||||||
|
<p><a name="Custom_components"></a></p>
|
||||||
|
<h2>Custom components</h2>
|
||||||
|
<p>Basic custom component template looks like this:</p>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
<span class="keyword">local</span> const = <span class="global">require</span>(<span class="string">"druid.const"</span>)
|
||||||
|
<span class="keyword">local</span> component = <span class="global">require</span>(<span class="string">"druid.component"</span>)
|
||||||
|
|
||||||
|
<span class="keyword">local</span> M = component.create(<span class="string">"your_component"</span>)
|
||||||
|
|
||||||
|
<span class="comment">-- Component constructor
|
||||||
|
</span><span class="keyword">function</span> M.init(self, ...)
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
|
||||||
|
<span class="comment">-- Call only if exist interest: const.ON_UPDATE
|
||||||
|
</span><span class="keyword">function</span> M.update(self, dt)
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
|
||||||
|
<span class="comment">-- Call only if exist interest: const.ON_INPUT or const.ON_INPUT_HIGH
|
||||||
|
</span><span class="keyword">function</span> M.on_input(self, action_id, action)
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
|
||||||
|
<span class="comment">-- Call only if exist interest: const.ON_MESSAGE
|
||||||
|
</span><span class="keyword">function</span> M.on_message(self, message_id, message, sender)
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
|
||||||
|
<span class="comment">-- Call only if component with ON_CHANGE_LANGUAGE interest
|
||||||
|
</span><span class="keyword">function</span> M.on_change_language(self)
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
|
||||||
|
<span class="comment">-- Call only if component with ON_LAYOUT_CHANGE interest
|
||||||
|
</span><span class="keyword">function</span> M.on_layout_change(self)
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
|
||||||
|
<span class="keyword">return</span> M
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p>Add your custom component to druid via <a href="../modules/druid.html#register">druid.register</a></p>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
|
||||||
|
<span class="keyword">local</span> my_component = <span class="global">require</span>(<span class="string">"my.amazing.component"</span>)
|
||||||
|
|
||||||
|
<span class="keyword">local</span> <span class="keyword">function</span> init(self)
|
||||||
|
druid.register(<span class="string">"my_component"</span>, my_component)
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Interest</h3>
|
||||||
|
<p>Interest - is a way to indicate what events your component will respond to.
|
||||||
|
There is next interests in druid:
|
||||||
|
- <strong>ON_MESSAGE</strong> - component will receive messages from on_message</p>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><p><strong>ON_UPDATE</strong> - component will be updated from update</p></li>
|
||||||
|
<li><p><strong>ON<em>INPUT</em>HIGH</strong> - component will receive input from on<em>input, before other components with ON</em>INPUT</p></li>
|
||||||
|
<li><p><strong>ON_INPUT</strong> - component will receive input from on<em>input, after other components with ON</em>INPUT_HIGH</p></li>
|
||||||
|
<li><p><strong>ON<em>CHANGE</em>LANGUAGE</strong> - will call <em>on</em>change<em>language</em> function on language change trigger</p></li>
|
||||||
|
<li><p><strong>ON<em>LAYOUT</em>CHANGED</strong> will call <em>on</em>layout<em>change</em> function on layout change trigger</p></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
<p><a name="Best_practice_on_custom_components"></a></p>
|
||||||
|
<h2>Best practice on custom components</h2>
|
||||||
|
<p>On each component recomended describe component scheme in next way:</p>
|
||||||
|
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
<span class="comment">-- Component module
|
||||||
|
</span><span class="keyword">local</span> component = <span class="global">require</span>(<span class="string">"druid.component"</span>)
|
||||||
|
|
||||||
|
<span class="keyword">local</span> M = component.create(<span class="string">"your_component"</span>)
|
||||||
|
|
||||||
|
<span class="keyword">local</span> SCHEME = {
|
||||||
|
ROOT = <span class="string">"/root"</span>,
|
||||||
|
ITEM = <span class="string">"/item"</span>,
|
||||||
|
TITLE = <span class="string">"/title"</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="keyword">function</span> M.init(self, template_name, node_table)
|
||||||
|
<span class="comment">-- If component use template, setup it:
|
||||||
|
</span> self:set_template(template_name)
|
||||||
|
|
||||||
|
<span class="comment">-- If component was cloned with gui.clone_tree, pass his nodes
|
||||||
|
</span> self:set_nodes(node_table)
|
||||||
|
|
||||||
|
<span class="comment">-- helper can get node from gui/template/table
|
||||||
|
</span> <span class="keyword">local</span> root = self:get_node(SCHEME.ROOT)
|
||||||
|
|
||||||
|
<span class="comment">-- This component can spawn another druid components:
|
||||||
|
</span> <span class="keyword">local</span> druid = self:get_druid()
|
||||||
|
|
||||||
|
<span class="comment">-- Button self on callback is self of _this_ component
|
||||||
|
</span> <span class="keyword">local</span> button = druid:new_button(...)
|
||||||
|
|
||||||
|
<span class="comment">-- helper can return you the component style for current component
|
||||||
|
</span> <span class="comment">-- It return by component name from
|
||||||
|
</span> <span class="keyword">local</span> my_style = self:get_style()
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
96
docs/topics/druid_assets.md.html
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
<!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="#Overview">Overview </a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Topics</h2>
|
||||||
|
<ul class="">
|
||||||
|
<li><a href="../topics/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><strong>Druid assets</strong></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.helper.html">druid.helper</a></li>
|
||||||
|
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
|
||||||
|
<h1>Druid assets</h1>
|
||||||
|
|
||||||
|
<p><a name="Overview"></a></p>
|
||||||
|
<h2>Overview</h2>
|
||||||
|
<p>I've created <a href="https://github.com/Insality/druid-assets">druid-assets repository</a> to make a <em>marketplace</em> with custom styles and components.</p>
|
||||||
|
|
||||||
|
<p>Any of druid users can push their own components and styles to share it with the other users</p>
|
||||||
|
|
||||||
|
<p>Also, this marketplace is great example to how you can create your custom components</p>
|
||||||
|
|
||||||
|
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
94
docs/topics/examples.md.html
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
<!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="#Overview">Overview </a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Topics</h2>
|
||||||
|
<ul class="">
|
||||||
|
<li><a href="../topics/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><strong>Examples</strong></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.helper.html">druid.helper</a></li>
|
||||||
|
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
|
||||||
|
<h1>Examples</h1>
|
||||||
|
|
||||||
|
<p><a name="Overview"></a></p>
|
||||||
|
<h2>Overview</h2>
|
||||||
|
<p>See the <a href="https://github.com/Insality/druid/tree/develop/example/kenney">example folder</a> for examples of how to use Druid</p>
|
||||||
|
|
||||||
|
<p>Try the HTML5 version of the example app</p>
|
||||||
|
|
||||||
|
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
86
docs/topics/online_example.md.html
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
<!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>Topics</h2>
|
||||||
|
<ul class="">
|
||||||
|
<li><a href="../topics/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/create_custom_components.md.html">Custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><strong>Online example</strong></li>
|
||||||
|
<li><a href="../topics/styles.md.html">Styles</a></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.helper.html">druid.helper</a></li>
|
||||||
|
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
|
||||||
|
<h1>Online example</h1>
|
||||||
|
|
||||||
|
<p>Check druid --here-- (link)</p>
|
||||||
|
|
||||||
|
|
||||||
|
</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-03-21 22:00:04 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
145
docs/topics/styles.md.html
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
<!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="#Overview">Overview </a></li>
|
||||||
|
<li><a href="#Usage">Usage </a></li>
|
||||||
|
<li><a href="#Create_custom_components">Create custom components </a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Topics</h2>
|
||||||
|
<ul class="">
|
||||||
|
<li><a href="../topics/components.md.html">Druid components</a></li>
|
||||||
|
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
|
||||||
|
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
|
||||||
|
<li><a href="../topics/examples.md.html">Examples</a></li>
|
||||||
|
<li><strong>Styles</strong></li>
|
||||||
|
<li><a href="../topics/README.md.html">README</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.checkbox.html">druid.checkbox</a></li>
|
||||||
|
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
|
||||||
|
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
|
||||||
|
<li><a href="../modules/druid.hover.html">druid.hover</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.scroll.html">druid.scroll</a></li>
|
||||||
|
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
|
||||||
|
<li><a href="../modules/druid.text.html">druid.text</a></li>
|
||||||
|
<li><a href="../modules/druid.timer.html">druid.timer</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.helper.html">druid.helper</a></li>
|
||||||
|
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
|
||||||
|
<h1>Styles</h1>
|
||||||
|
|
||||||
|
<p><a name="Overview"></a></p>
|
||||||
|
<h2>Overview</h2>
|
||||||
|
<p>Styles - set of functions and parameters for components to customize their behavior.</p>
|
||||||
|
|
||||||
|
<p>Styles is a table, where key is name of component, and value is style table for this component.</p>
|
||||||
|
|
||||||
|
<p>In component API documentation, you can find the style API for this component. Or just lookup for existing styles and modify them.</p>
|
||||||
|
|
||||||
|
<p><a name="Usage"></a></p>
|
||||||
|
<h2>Usage</h2>
|
||||||
|
<p>Setup default druid style for all druid instances via <code>druid.set_default_style</code></p>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
|
||||||
|
<span class="keyword">local</span> my_style = <span class="global">require</span>(<span class="string">"my.amazing.style"</span>)
|
||||||
|
|
||||||
|
<span class="keyword">local</span> <span class="keyword">function</span> init(self)
|
||||||
|
druid.set_default_style(my_style)
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
<p>Setup custom style to specific druid instance:</p>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
|
||||||
|
<span class="keyword">local</span> my_style = <span class="global">require</span>(<span class="string">"my.amazing.style"</span>)
|
||||||
|
|
||||||
|
<span class="keyword">local</span> <span class="keyword">function</span> init(self)
|
||||||
|
<span class="comment">-- This druid instance will be use my_style as default
|
||||||
|
</span> self.druid = druid.new(self, my_style)
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
<p>Change component style with <em>set</em>style_ function</p>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
|
||||||
|
<span class="keyword">local</span> my_style = <span class="global">require</span>(<span class="string">"my.amazing.style"</span>)
|
||||||
|
|
||||||
|
<span class="keyword">local</span> <span class="keyword">function</span> init(self)
|
||||||
|
self.druid = druid.new(self)
|
||||||
|
self.button = self.druid:new_button(self, <span class="string">"node"</span>)
|
||||||
|
<span class="comment">-- Setup custom style for specific component
|
||||||
|
</span> self.button:set_style(my_style)
|
||||||
|
<span class="keyword">end</span>
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
<p><a name="Create_custom_components"></a></p>
|
||||||
|
<h2>Create custom components</h2>
|
||||||
|
<p>Styles is just lua table, so it can be described in just one single file
|
||||||
|
<strong>TODO</strong></p>
|
||||||
|
|
||||||
|
|
||||||
|
</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-03-21 22:59:46 </i>
|
||||||
|
</div> <!-- id="about" -->
|
||||||
|
</div> <!-- id="container" -->
|
||||||
|
</body>
|
||||||
|
</html>
|
46
docs_md/components.md
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# Druid components
|
||||||
|
|
||||||
|
## Button
|
||||||
|
Basic game button
|
||||||
|
|
||||||
|
## Text
|
||||||
|
Wrap on text node with text size adjusting
|
||||||
|
|
||||||
|
## Blocker
|
||||||
|
Block input in node zone
|
||||||
|
|
||||||
|
## Back Handler
|
||||||
|
Handle back button (Android, backspace)
|
||||||
|
|
||||||
|
## Locale
|
||||||
|
Text component with handle localization system
|
||||||
|
|
||||||
|
## Timer
|
||||||
|
Run timer on text node
|
||||||
|
|
||||||
|
## Progress
|
||||||
|
Basic progress bar
|
||||||
|
|
||||||
|
## Scroll
|
||||||
|
Basic scroll component
|
||||||
|
|
||||||
|
## Grid
|
||||||
|
Component for manage node positions
|
||||||
|
|
||||||
|
## Slider
|
||||||
|
Basic slider component
|
||||||
|
|
||||||
|
## Checkbox
|
||||||
|
Basic checkbox component
|
||||||
|
|
||||||
|
## Checkbox group
|
||||||
|
Several checkboxes in one group
|
||||||
|
|
||||||
|
## Radio group
|
||||||
|
Several checkboxes in one group with single choice
|
||||||
|
|
||||||
|
## Hover
|
||||||
|
Trigger component for check node hover state
|
||||||
|
|
||||||
|
## Input
|
||||||
|
Component to process user text input
|
105
docs_md/creating_custom_components.md
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
# Creating custom components
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
Druid allows you to create your custom components from druid basic components or other custom components
|
||||||
|
|
||||||
|
|
||||||
|
## Custom components
|
||||||
|
Basic custom component template looks like this:
|
||||||
|
```lua
|
||||||
|
local const = require("druid.const")
|
||||||
|
local component = require("druid.component")
|
||||||
|
|
||||||
|
local M = component.create("your_component")
|
||||||
|
|
||||||
|
-- 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)
|
||||||
|
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_CHANGE_LANGUAGE interest
|
||||||
|
function M.on_change_language(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Call only if component with ON_LAYOUT_CHANGE interest
|
||||||
|
function M.on_layout_change(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Add your custom component to druid via `druid.register`
|
||||||
|
```lua
|
||||||
|
local druid = require("druid.druid")
|
||||||
|
local my_component = require("my.amazing.component")
|
||||||
|
|
||||||
|
local function init(self)
|
||||||
|
druid.register("my_component", my_component)
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
### Interest
|
||||||
|
Interest - is a way to indicate what events your component will respond to.
|
||||||
|
There is next interests in druid:
|
||||||
|
- **ON_MESSAGE** - component will receive messages from on_message
|
||||||
|
|
||||||
|
- **ON_UPDATE** - component will be updated from update
|
||||||
|
|
||||||
|
- **ON_INPUT_HIGH** - component will receive input from on_input, before other components with ON_INPUT
|
||||||
|
|
||||||
|
- **ON_INPUT** - component will receive input from on_input, after other components with ON_INPUT_HIGH
|
||||||
|
|
||||||
|
- **ON_CHANGE_LANGUAGE** - will call _on_change_language_ function on language change trigger
|
||||||
|
|
||||||
|
- **ON_LAYOUT_CHANGED** will call _on_layout_change_ function on layout change trigger
|
||||||
|
|
||||||
|
|
||||||
|
## Best practice on custom components
|
||||||
|
On each component recomended describe component scheme in next way:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
-- Component module
|
||||||
|
local component = require("druid.component")
|
||||||
|
|
||||||
|
local M = component.create("your_component")
|
||||||
|
|
||||||
|
local SCHEME = {
|
||||||
|
ROOT = "/root",
|
||||||
|
ITEM = "/item",
|
||||||
|
TITLE = "/title"
|
||||||
|
}
|
||||||
|
|
||||||
|
function M.init(self, template_name, node_table)
|
||||||
|
-- If component use template, setup it:
|
||||||
|
self:set_template(template_name)
|
||||||
|
|
||||||
|
-- If component was cloned with gui.clone_tree, pass his nodes
|
||||||
|
self:set_nodes(node_table)
|
||||||
|
|
||||||
|
-- helper can get node from gui/template/table
|
||||||
|
local root = self:get_node(SCHEME.ROOT)
|
||||||
|
|
||||||
|
-- This component can spawn another druid components:
|
||||||
|
local druid = self:get_druid()
|
||||||
|
|
||||||
|
-- Button self on callback is self of _this_ component
|
||||||
|
local button = druid:new_button(...)
|
||||||
|
|
||||||
|
-- helper can return you the component style for current component
|
||||||
|
-- It return by component name from
|
||||||
|
local my_style = self:get_style()
|
||||||
|
end
|
||||||
|
|
||||||
|
```
|
8
docs_md/druid_assets.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Druid assets
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
I've created [druid-assets repository](https://github.com/Insality/druid-assets) to make a _marketplace_ with custom styles and components.
|
||||||
|
|
||||||
|
Any of druid users can push their own components and styles to share it with the other users
|
||||||
|
|
||||||
|
Also, this marketplace is great example to how you can create your custom components
|
6
docs_md/examples.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# Examples
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
See the [example folder](https://github.com/Insality/druid/tree/develop/example/kenney) for examples of how to use Druid
|
||||||
|
|
||||||
|
Try the HTML5 version of the example app
|
47
docs_md/styles.md
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# Styles
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
Styles - set of functions and parameters for components to customize their behavior.
|
||||||
|
|
||||||
|
Styles is a table, where key is name of component, and value is style table for this component.
|
||||||
|
|
||||||
|
In component API documentation, you can find the style API for this component. Or just lookup for existing styles and modify them.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
Setup default druid style for all druid instances via `druid.set_default_style`
|
||||||
|
```lua
|
||||||
|
local druid = require("druid.druid")
|
||||||
|
local my_style = require("my.amazing.style")
|
||||||
|
|
||||||
|
local function init(self)
|
||||||
|
druid.set_default_style(my_style)
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
Setup custom style to specific druid instance:
|
||||||
|
```lua
|
||||||
|
local druid = require("druid.druid")
|
||||||
|
local my_style = require("my.amazing.style")
|
||||||
|
|
||||||
|
local function init(self)
|
||||||
|
-- This druid instance will be use my_style as default
|
||||||
|
self.druid = druid.new(self, my_style)
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
Change component style with _set_style_ function
|
||||||
|
```lua
|
||||||
|
local druid = require("druid.druid")
|
||||||
|
local my_style = require("my.amazing.style")
|
||||||
|
|
||||||
|
local function init(self)
|
||||||
|
self.druid = druid.new(self)
|
||||||
|
self.button = self.druid:new_button(self, "node")
|
||||||
|
-- Setup custom style for specific component
|
||||||
|
self.button:set_style(my_style)
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
## Create custom components
|
||||||
|
Styles is just lua table, so it can be described in just one single file
|
||||||
|
__TODO__
|
44
druid/base/back_handler.lua
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
--- Component to handle back key (android, backspace)
|
||||||
|
-- @module druid.back_handler
|
||||||
|
|
||||||
|
--- Component events
|
||||||
|
-- @table Events
|
||||||
|
-- @tfield druid_event on_back On back handler callback
|
||||||
|
|
||||||
|
--- Component fields
|
||||||
|
-- @table Fields
|
||||||
|
-- @tfield any params Params to click callbacks
|
||||||
|
|
||||||
|
local Event = require("druid.event")
|
||||||
|
local const = require("druid.const")
|
||||||
|
local component = require("druid.component")
|
||||||
|
|
||||||
|
local M = component.create("back_handler", { const.ON_INPUT })
|
||||||
|
|
||||||
|
|
||||||
|
--- Component init function
|
||||||
|
-- @function back_handler:init
|
||||||
|
-- @tparam callback callback On back button
|
||||||
|
-- @tparam[opt] params Callback argument
|
||||||
|
function M.init(self, callback, params)
|
||||||
|
self.params = params
|
||||||
|
|
||||||
|
self.on_back = Event(callback)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Input handler for component
|
||||||
|
-- @function back_handler:on_input
|
||||||
|
-- @tparam string action_id on_input action id
|
||||||
|
-- @tparam table action on_input action
|
||||||
|
function M.on_input(self, action_id, action)
|
||||||
|
if action_id == const.ACTION_BACK and action[const.RELEASED] then
|
||||||
|
self.on_back:trigger(self:get_context(), self.params)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
64
druid/base/blocker.lua
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
--- Component to block input on specify zone by node
|
||||||
|
-- @module druid.blocker
|
||||||
|
|
||||||
|
--- Component events
|
||||||
|
-- @table Events
|
||||||
|
-- @tfield druid_event on_click On release button callback
|
||||||
|
-- @tfield druid_event on_enable_change On enable/disable callback
|
||||||
|
|
||||||
|
--- Component fields
|
||||||
|
-- @table Fields
|
||||||
|
-- @tfield node node Trigger node
|
||||||
|
|
||||||
|
local Event = require("druid.event")
|
||||||
|
local const = require("druid.const")
|
||||||
|
local component = require("druid.component")
|
||||||
|
|
||||||
|
local M = component.create("blocker", { const.ON_INPUT_HIGH })
|
||||||
|
|
||||||
|
|
||||||
|
--- Component init function
|
||||||
|
-- @function blocker:init
|
||||||
|
-- @tparam node node Gui node
|
||||||
|
function M.init(self, node)
|
||||||
|
self.node = self:get_node(node)
|
||||||
|
|
||||||
|
self.on_click = Event()
|
||||||
|
self.on_enable_change = Event()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.on_input(self, action_id, action)
|
||||||
|
if action_id ~= const.ACTION_TOUCH then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if not self:is_enabled(self.node) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if gui.pick_node(self.node, action.x, action.y) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set enabled blocker component state
|
||||||
|
-- @function blocker:set_enabled
|
||||||
|
-- @tparam bool state Enabled state
|
||||||
|
function M.set_enabled(self, state)
|
||||||
|
gui.set_enabled(self.node, state)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Return blocked enabled state
|
||||||
|
-- @function blocker:is_enabled
|
||||||
|
-- @treturn bool True, if blocker is enabled
|
||||||
|
function M.is_enabled(self, state)
|
||||||
|
return gui.is_enabled(self.node)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
290
druid/base/button.lua
Normal file
@ -0,0 +1,290 @@
|
|||||||
|
--- Component to handle basic GUI button
|
||||||
|
-- @module druid.button
|
||||||
|
|
||||||
|
--- Component events
|
||||||
|
-- @table Events
|
||||||
|
-- @tfield druid_event on_click On release button callback
|
||||||
|
-- @tfield druid_event on_repeated_click On repeated action button callback
|
||||||
|
-- @tfield druid_event on_long_click On long tap button callback
|
||||||
|
-- @tfield druid_event on_double_click On double tap button callback
|
||||||
|
|
||||||
|
--- Component fields
|
||||||
|
-- @table Fields
|
||||||
|
-- @tfield node node Trigger node
|
||||||
|
-- @tfield[opt=node] node anim_node Animation node
|
||||||
|
-- @tfield vector3 scale_from Initial scale of anim_node
|
||||||
|
-- @tfield vector3 pos Initial pos of anim_node
|
||||||
|
-- @tfield any params Params to click callbacks
|
||||||
|
-- @tfield druid.hover hover Druid hover logic component
|
||||||
|
-- @tfield[opt] node click_zone Restriction zone
|
||||||
|
|
||||||
|
--- Component style params
|
||||||
|
-- @table Style
|
||||||
|
-- @tfield function on_click (self, node)
|
||||||
|
-- @tfield function on_click_disabled (self, node)
|
||||||
|
-- @tfield function on_hover (self, node, hover_state)
|
||||||
|
-- @tfield function on_set_enabled (self, node, enabled_state)
|
||||||
|
-- @tfield bool IS_HOVER
|
||||||
|
|
||||||
|
local Event = require("druid.event")
|
||||||
|
local const = require("druid.const")
|
||||||
|
local helper = require("druid.helper")
|
||||||
|
local component = require("druid.component")
|
||||||
|
|
||||||
|
local M = component.create("button", { const.ON_INPUT })
|
||||||
|
|
||||||
|
|
||||||
|
local function is_input_match(self, action_id)
|
||||||
|
if action_id == const.ACTION_TOUCH then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.key_trigger and action_id == self.key_trigger then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function on_button_hover(self, hover_state)
|
||||||
|
if not self._style.on_hover then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
self._style.on_hover(self, self.anim_node, hover_state)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function on_button_click(self)
|
||||||
|
if self._style.on_click then
|
||||||
|
self._style.on_click(self, self.anim_node)
|
||||||
|
end
|
||||||
|
self.click_in_row = 1
|
||||||
|
self.on_click:trigger(self:get_context(), self.params, self)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function on_button_repeated_click(self)
|
||||||
|
if not self.is_repeated_started then
|
||||||
|
self.click_in_row = 0
|
||||||
|
self.is_repeated_started = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if self._style.on_click then
|
||||||
|
self._style.on_click(self, self.anim_node)
|
||||||
|
end
|
||||||
|
self.click_in_row = self.click_in_row + 1
|
||||||
|
self.on_repeated_click:trigger(self:get_context(), self.params, self, self.click_in_row)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function on_button_long_click(self)
|
||||||
|
if self._style.on_click then
|
||||||
|
self._style.on_click(self, self.anim_node)
|
||||||
|
end
|
||||||
|
self.click_in_row = 1
|
||||||
|
local time = socket.gettime() - self.last_pressed_time
|
||||||
|
self.on_long_click:trigger(self:get_context(), self.params, self, time)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function on_button_double_click(self)
|
||||||
|
if self._style.on_click then
|
||||||
|
self._style.on_click(self, self.anim_node)
|
||||||
|
end
|
||||||
|
self.click_in_row = self.click_in_row + 1
|
||||||
|
self.on_double_click:trigger(self:get_context(), self.params, self, self.click_in_row)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function on_button_hold(self, press_time)
|
||||||
|
self.on_hold_callback:trigger(self:get_context(), self.params, self, press_time)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function on_button_release(self)
|
||||||
|
if self.is_repeated_started then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if not self.disabled then
|
||||||
|
if self.can_action then
|
||||||
|
self.can_action = false
|
||||||
|
|
||||||
|
local time = socket.gettime()
|
||||||
|
local is_long_click = (time - self.last_pressed_time) > self._style.LONGTAP_TIME
|
||||||
|
is_long_click = is_long_click and self.on_long_click:is_exist()
|
||||||
|
|
||||||
|
local is_double_click = (time - self.last_released_time) < self._style.DOUBLETAP_TIME
|
||||||
|
is_double_click = is_double_click and self.on_double_click:is_exist()
|
||||||
|
|
||||||
|
if is_long_click then
|
||||||
|
on_button_long_click(self)
|
||||||
|
elseif is_double_click then
|
||||||
|
on_button_double_click(self)
|
||||||
|
else
|
||||||
|
on_button_click(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
self.last_released_time = time
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
if self._style.on_click_disabled then
|
||||||
|
self._style.on_click_disabled(self, self.anim_node)
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Component init function
|
||||||
|
-- @function button:init
|
||||||
|
-- @tparam node node Gui node
|
||||||
|
-- @tparam function callback Button callback
|
||||||
|
-- @tparam[opt] table params Button callback params
|
||||||
|
-- @tparam[opt] node anim_node Button anim node (node, if not provided)
|
||||||
|
-- @tparam[opt] string event Button react event, const.ACTION_TOUCH by default
|
||||||
|
function M.init(self, node, callback, params, anim_node, event)
|
||||||
|
self.druid = self:get_druid()
|
||||||
|
self.node = self:get_node(node)
|
||||||
|
|
||||||
|
self.anim_node = anim_node and helper:get_node(anim_node) or self.node
|
||||||
|
-- TODO: rename to start_scale
|
||||||
|
self.scale_from = gui.get_scale(self.anim_node)
|
||||||
|
self.params = params
|
||||||
|
self.hover = self.druid:new_hover(node, on_button_hover)
|
||||||
|
self.click_zone = nil
|
||||||
|
self.is_repeated_started = false
|
||||||
|
self.last_pressed_time = 0
|
||||||
|
self.last_released_time = 0
|
||||||
|
self.click_in_row = 0
|
||||||
|
self.key_trigger = nil
|
||||||
|
|
||||||
|
-- Event stubs
|
||||||
|
self.on_click = Event(callback)
|
||||||
|
self.on_repeated_click = Event()
|
||||||
|
self.on_long_click = Event()
|
||||||
|
self.on_double_click = Event()
|
||||||
|
self.on_hold_callback = Event()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.on_input(self, action_id, action)
|
||||||
|
if not is_input_match(self, action_id) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if not helper.is_enabled(self.node) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local is_pick = true
|
||||||
|
local is_key_trigger = (action_id == self.key_trigger)
|
||||||
|
if not is_key_trigger then
|
||||||
|
is_pick = gui.pick_node(self.node, action.x, action.y)
|
||||||
|
if self.click_zone then
|
||||||
|
is_pick = is_pick and gui.pick_node(self.click_zone, action.x, action.y)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not is_pick then
|
||||||
|
-- Can't interact, if touch outside of button
|
||||||
|
self.can_action = false
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if is_key_trigger then
|
||||||
|
self.hover:set_hover(not action.released)
|
||||||
|
end
|
||||||
|
|
||||||
|
if action.pressed then
|
||||||
|
-- Can interact if start touch on the button
|
||||||
|
self.can_action = true
|
||||||
|
self.is_repeated_started = false
|
||||||
|
self.last_pressed_time = socket.gettime()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- While hold button, repeat rate pick from input.repeat_interval
|
||||||
|
if action.repeated then
|
||||||
|
if not self.disabled and self.on_repeated_click:is_exist() and self.can_action then
|
||||||
|
on_button_repeated_click(self)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if action.released then
|
||||||
|
return on_button_release(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not self.disabled and self.can_action and self.on_long_click:is_exist() then
|
||||||
|
local press_time = socket.gettime() - self.last_pressed_time
|
||||||
|
|
||||||
|
if self._style.AUTOHOLD_TRIGGER and self._style.AUTOHOLD_TRIGGER <= press_time then
|
||||||
|
on_button_release(self)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
if press_time >= self._style.LONGTAP_TIME then
|
||||||
|
on_button_hold(self, press_time)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return not self.disabled
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.on_input_interrupt(self)
|
||||||
|
self.can_action = false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set enabled button component state
|
||||||
|
-- @function button:set_enabled
|
||||||
|
-- @tparam bool state Enabled state
|
||||||
|
function M.set_enabled(self, state)
|
||||||
|
self.disabled = not state
|
||||||
|
if self._style.on_set_enabled then
|
||||||
|
self._style.on_set_enabled(self, self.node, state)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Return button enabled state
|
||||||
|
-- @function button:is_enabled
|
||||||
|
-- @treturn bool True, if button is enabled
|
||||||
|
function M.is_enabled(self)
|
||||||
|
return not self.disabled
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Strict button click area. Useful for
|
||||||
|
-- no click events outside stencil node
|
||||||
|
-- @function button:set_click_zone
|
||||||
|
-- @tparam node zone Gui node
|
||||||
|
function M.set_click_zone(self, zone)
|
||||||
|
self.click_zone = self:get_node(zone)
|
||||||
|
self.hover:set_click_zone(zone)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set key-code to trigger this button
|
||||||
|
-- @function button:set_key_trigger
|
||||||
|
-- @tparam hash key The action_id of the key
|
||||||
|
function M.set_key_trigger(self, key)
|
||||||
|
self.key_trigger = hash(key)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Get key-code to trigger this button
|
||||||
|
-- @function button:get_key_trigger
|
||||||
|
-- @treturn hash The action_id of the key
|
||||||
|
function M.get_key_trigger(self)
|
||||||
|
return self.key_trigger
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
75
druid/base/checkbox.lua
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
--- Druid checkbox component
|
||||||
|
-- @module druid.checkbox
|
||||||
|
|
||||||
|
--- Component events
|
||||||
|
-- @table Events
|
||||||
|
-- @tfield druid_event on_change_state On change state callback
|
||||||
|
|
||||||
|
--- Component fields
|
||||||
|
-- @table Fields
|
||||||
|
-- @tfield node node Visual node
|
||||||
|
-- @tfield[opt=node] node click_node Button trigger node
|
||||||
|
-- @tfield druid.button button Button component from click_node
|
||||||
|
|
||||||
|
--- Component style params
|
||||||
|
-- @table Style
|
||||||
|
-- @tfield function on_change_state (self, node, state)
|
||||||
|
|
||||||
|
local Event = require("druid.event")
|
||||||
|
local component = require("druid.component")
|
||||||
|
|
||||||
|
local M = component.create("checkbox")
|
||||||
|
|
||||||
|
|
||||||
|
local function on_click(self)
|
||||||
|
M.set_state(self, not self.state)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Component init function
|
||||||
|
-- @function checkbox:init
|
||||||
|
-- @tparam node node Gui node
|
||||||
|
-- @tparam function callback Checkbox callback
|
||||||
|
-- @tparam[opt=node] node click node Trigger node, by default equals to node
|
||||||
|
function M.init(self, node, callback, click_node)
|
||||||
|
self.style = self:get_style()
|
||||||
|
self.druid = self:get_druid()
|
||||||
|
self.node = self:get_node(node)
|
||||||
|
self.click_node = self:get_node(click_node)
|
||||||
|
|
||||||
|
self.button = self.druid:new_button(self.click_node or self.node, on_click)
|
||||||
|
M.set_state(self, false, true)
|
||||||
|
|
||||||
|
self.on_change_state = Event(callback)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set checkbox state
|
||||||
|
-- @function checkbox:set_state
|
||||||
|
-- @tparam bool state Checkbox state
|
||||||
|
-- @tparam bool is_silent Don't trigger on_change_state if true
|
||||||
|
function M.set_state(self, state, is_silent)
|
||||||
|
if self.state == state then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
self.state = state
|
||||||
|
if self.style.on_change_state then
|
||||||
|
self.style.on_change_state(self, self.node, state)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not is_silent then
|
||||||
|
self.on_change_state:trigger(self:get_context(), state)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Return checkbox state
|
||||||
|
-- @function checkbox:get_state
|
||||||
|
-- @treturn bool Checkbox state
|
||||||
|
function M.get_state(self)
|
||||||
|
return self.state
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
66
druid/base/checkbox_group.lua
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
--- Checkbox group module
|
||||||
|
-- @module druid.checkbox_group
|
||||||
|
|
||||||
|
--- Component events
|
||||||
|
-- @table Events
|
||||||
|
-- @tfield druid_event on_checkbox_click On any checkbox click
|
||||||
|
|
||||||
|
--- Component fields
|
||||||
|
-- @table Fields
|
||||||
|
-- @tfield table checkboxes Array of checkbox components
|
||||||
|
|
||||||
|
local Event = require("druid.event")
|
||||||
|
local component = require("druid.component")
|
||||||
|
|
||||||
|
local M = component.create("checkbox_group")
|
||||||
|
|
||||||
|
|
||||||
|
--- Component init function
|
||||||
|
-- @function checkbox_group:init
|
||||||
|
-- @tparam node[] node Array of gui node
|
||||||
|
-- @tparam function callback Checkbox callback
|
||||||
|
-- @tparam[opt=node] node[] click node Array of trigger nodes, by default equals to nodes
|
||||||
|
function M.init(self, nodes, callback, click_nodes)
|
||||||
|
self.druid = self:get_druid()
|
||||||
|
self.checkboxes = {}
|
||||||
|
|
||||||
|
self.on_checkbox_click = Event(callback)
|
||||||
|
|
||||||
|
for i = 1, #nodes do
|
||||||
|
local click_node = click_nodes and click_nodes[i] or nil
|
||||||
|
local checkbox = self.druid:new_checkbox(nodes[i], function()
|
||||||
|
self.on_checkbox_click:trigger(self:get_context(), i)
|
||||||
|
end, click_node)
|
||||||
|
|
||||||
|
table.insert(self.checkboxes, checkbox)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set checkbox group state
|
||||||
|
-- @function checkbox_group:set_state
|
||||||
|
-- @tparam bool[] state Array of checkbox state
|
||||||
|
function M.set_state(self, indexes)
|
||||||
|
for i = 1, #indexes do
|
||||||
|
if self.checkboxes[i] then
|
||||||
|
self.checkboxes[i]:set_state(indexes[i], true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Return checkbox group state
|
||||||
|
-- @function checkbox_group:get_state
|
||||||
|
-- @treturn bool[] Array if checkboxes state
|
||||||
|
function M.get_state(self)
|
||||||
|
local result = {}
|
||||||
|
|
||||||
|
for i = 1, #self.checkboxes do
|
||||||
|
table.insert(result, self.checkboxes[i]:get_state())
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
166
druid/base/grid.lua
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
--- Component to handle placing components by row and columns.
|
||||||
|
-- Grid can anchor your elements, get content size and other
|
||||||
|
-- @module druid.grid
|
||||||
|
|
||||||
|
--- Component events
|
||||||
|
-- @table Events
|
||||||
|
-- @tfield druid_event on_add_item On item add callback
|
||||||
|
-- @tfield druid_event on_remove_item On item remove callback
|
||||||
|
-- @tfield druid_event on_clear On grid clear callback
|
||||||
|
-- @tfield druid_event on_update_positions On update item positions callback
|
||||||
|
|
||||||
|
--- Component fields
|
||||||
|
-- @table Fields
|
||||||
|
-- @tfield node parent Parent gui node
|
||||||
|
-- @tfield node[] nodes List of all grid nodes
|
||||||
|
-- @tfield vector3 offset Item distance between each other items
|
||||||
|
-- @tfield vector3 anchor Item anchor
|
||||||
|
-- @tfield vector3 node_size Item size
|
||||||
|
-- @tfield vector4 border The size of item content
|
||||||
|
-- @tfield vector3 border_offer The border offset for correct anchor calculations
|
||||||
|
|
||||||
|
local Event = require("druid.event")
|
||||||
|
local component = require("druid.component")
|
||||||
|
|
||||||
|
local M = component.create("grid")
|
||||||
|
|
||||||
|
|
||||||
|
--- Component init function
|
||||||
|
-- @function grid:init
|
||||||
|
-- @tparam node parent The gui node parent, where items will be placed
|
||||||
|
-- @tparam node element Element prefab. Need to get it size
|
||||||
|
-- @tparam[opt=1] number in_row How many nodes in row can be placed
|
||||||
|
function M.init(self, parent, element, in_row)
|
||||||
|
self.parent = self:get_node(parent)
|
||||||
|
self.nodes = {}
|
||||||
|
|
||||||
|
self.offset = vmath.vector3(0)
|
||||||
|
self.anchor = vmath.vector3(0.5, 0, 0)
|
||||||
|
self.in_row = in_row or 1
|
||||||
|
self.node_size = gui.get_size(self:get_node(element))
|
||||||
|
self.border = vmath.vector4(0)
|
||||||
|
self.border_offset = vmath.vector3(0)
|
||||||
|
|
||||||
|
self.on_add_item = Event()
|
||||||
|
self.on_remove_item = Event()
|
||||||
|
self.on_clear = Event()
|
||||||
|
self.on_update_positions = Event()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function check_border(self, pos)
|
||||||
|
local border = self.border
|
||||||
|
local size = self.node_size
|
||||||
|
|
||||||
|
local W = pos.x - size.x/2 + self.border_offset.x
|
||||||
|
local E = pos.x + size.x/2 + self.border_offset.x
|
||||||
|
local N = pos.y + size.y/2 + self.border_offset.y
|
||||||
|
local S = pos.y - size.y/2 + self.border_offset.y
|
||||||
|
|
||||||
|
border.x = math.min(border.x, W)
|
||||||
|
border.y = math.max(border.y, N)
|
||||||
|
border.z = math.max(border.z, E)
|
||||||
|
border.w = math.min(border.w, S)
|
||||||
|
|
||||||
|
self.border_offset = vmath.vector3(
|
||||||
|
(border.x + (border.z - border.x) * self.anchor.x),
|
||||||
|
(border.y + (border.w - border.y) * self.anchor.y),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local temp_pos = vmath.vector3(0)
|
||||||
|
local function get_pos(self, index)
|
||||||
|
local row = math.ceil(index / self.in_row) - 1
|
||||||
|
local col = (index - row * self.in_row) - 1
|
||||||
|
|
||||||
|
temp_pos.x = col * (self.node_size.x + self.offset.x) - self.border_offset.x
|
||||||
|
temp_pos.y = -row * (self.node_size.y + self.offset.y) - self.border_offset.y
|
||||||
|
temp_pos.z = 0
|
||||||
|
|
||||||
|
return temp_pos
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function update_pos(self)
|
||||||
|
for i = 1, #self.nodes do
|
||||||
|
local node = self.nodes[i]
|
||||||
|
gui.set_position(node, get_pos(self, i))
|
||||||
|
end
|
||||||
|
|
||||||
|
self.on_update_positions:trigger(self:get_context())
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- Set grid items offset, the distance between items
|
||||||
|
-- @function grid:set_offset
|
||||||
|
-- @tparam vector3 offset Offset
|
||||||
|
function M.set_offset(self, offset)
|
||||||
|
self.offset = offset
|
||||||
|
update_pos(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set grid anchor
|
||||||
|
-- @function grid:set_anchor
|
||||||
|
-- @tparam vector3 acnhor Anchor
|
||||||
|
function M.set_anchor(self, anchor)
|
||||||
|
self.anchor = anchor
|
||||||
|
update_pos(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Add new item to the grid
|
||||||
|
-- @function grid:add
|
||||||
|
-- @tparam node item Gui node
|
||||||
|
-- @tparam[opt] number index The item position. By default add as last item
|
||||||
|
function M.add(self, item, index)
|
||||||
|
index = index or (#self.nodes + 1)
|
||||||
|
table.insert(self.nodes, index, item)
|
||||||
|
gui.set_parent(item, self.parent)
|
||||||
|
|
||||||
|
local pos = get_pos(self, index)
|
||||||
|
check_border(self, pos)
|
||||||
|
update_pos(self)
|
||||||
|
|
||||||
|
self.on_add_item:trigger(self:get_context(), item, index)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Return grid content size
|
||||||
|
-- @function grid:get_size
|
||||||
|
-- @treturn vector3 The grid content size
|
||||||
|
function M.get_size(self)
|
||||||
|
return vmath.vector3(
|
||||||
|
self.border.z - self.border.x,
|
||||||
|
self.border.y - self.border.w,
|
||||||
|
0)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Return array of all node positions
|
||||||
|
-- @function grid:get_all_pos
|
||||||
|
-- @treturn vector3[] All grid node positions
|
||||||
|
function M.get_all_pos(self)
|
||||||
|
local result = {}
|
||||||
|
for i = 1, #self.nodes do
|
||||||
|
table.insert(result, gui.get_position(self.nodes[i]))
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Clear all items from the grid
|
||||||
|
-- @function grid:clear
|
||||||
|
function M.clear(self)
|
||||||
|
for i = 1, #self.nodes do
|
||||||
|
gui.delete_node(self.nodes[i])
|
||||||
|
end
|
||||||
|
self.nodes = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
82
druid/base/hover.lua
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
--- Component to handle hover node interaction
|
||||||
|
-- @module druid.hover
|
||||||
|
|
||||||
|
--- Component events
|
||||||
|
-- @table Events
|
||||||
|
-- @tfield druid_event on_hover On hover callback
|
||||||
|
|
||||||
|
local Event = require("druid.event")
|
||||||
|
local const = require("druid.const")
|
||||||
|
local helper = require("druid.helper")
|
||||||
|
local component = require("druid.component")
|
||||||
|
|
||||||
|
local M = component.create("hover", { const.ON_INPUT })
|
||||||
|
|
||||||
|
|
||||||
|
--- Component init function
|
||||||
|
-- @function hover:init
|
||||||
|
-- @tparam node node Gui node
|
||||||
|
-- @tparam function on_hover_callback Hover callback
|
||||||
|
function M.init(self, node, on_hover_callback)
|
||||||
|
self.style = self:get_style()
|
||||||
|
self.node = self:get_node(node)
|
||||||
|
|
||||||
|
self._is_hovered = false
|
||||||
|
|
||||||
|
self.on_hover = Event(on_hover_callback)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.on_input(self, action_id, action)
|
||||||
|
if action_id ~= const.ACTION_TOUCH then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if not helper.is_enabled(self.node) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local is_pick = gui.pick_node(self.node, action.x, action.y)
|
||||||
|
if self.click_zone then
|
||||||
|
is_pick = is_pick and gui.pick_node(self.click_zone, action.x, action.y)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not is_pick then
|
||||||
|
M.set_hover(self, false)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if action.released then
|
||||||
|
M.set_hover(self, false)
|
||||||
|
else
|
||||||
|
M.set_hover(self, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.on_input_interrupt(self)
|
||||||
|
M.set_hover(self, false)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set hover state
|
||||||
|
-- @function hover:set_hover
|
||||||
|
-- @tparam bool state The hover state
|
||||||
|
function M.set_hover(self, state)
|
||||||
|
if self._is_hovered ~= state then
|
||||||
|
self._is_hovered = state
|
||||||
|
self.on_hover:trigger(self:get_context(), state)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Strict button click area. Useful for
|
||||||
|
-- no click events outside stencil node
|
||||||
|
-- @function hover:set_click_zone
|
||||||
|
-- @tparam node zone Gui node
|
||||||
|
function M.set_click_zone(self, zone)
|
||||||
|
self.click_zone = self:get_node(zone)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
16
druid/base/input.lua
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
--- Druid input text component.
|
||||||
|
-- Carry on user text input
|
||||||
|
-- UNIMPLEMENTED
|
||||||
|
-- @module druid.input
|
||||||
|
|
||||||
|
local component = require("druid.component")
|
||||||
|
|
||||||
|
local M = component.create("input")
|
||||||
|
|
||||||
|
|
||||||
|
function M.init(self, node, callback, click_node)
|
||||||
|
self.style = self:get_style()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
64
druid/base/lang_text.lua
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
--- Component to handle all GUI texts
|
||||||
|
-- Good working with localization system
|
||||||
|
-- @module druid.lang_text
|
||||||
|
|
||||||
|
--- Component events
|
||||||
|
-- @table Events
|
||||||
|
-- @tfield druid_event on_change On change text callback
|
||||||
|
|
||||||
|
--- Component fields
|
||||||
|
-- @table Fields
|
||||||
|
-- @tfield druid.text text The text component
|
||||||
|
|
||||||
|
local Event = require("druid.event")
|
||||||
|
local const = require("druid.const")
|
||||||
|
local settings = require("druid.system.settings")
|
||||||
|
local component = require("druid.component")
|
||||||
|
|
||||||
|
local M = component.create("lang_text", { const.ON_CHANGE_LANGUAGE })
|
||||||
|
|
||||||
|
|
||||||
|
--- Component init function
|
||||||
|
-- @function lang_text:init
|
||||||
|
-- @tparam node node The text node
|
||||||
|
-- @tparam string locale_id Default locale id
|
||||||
|
-- @tparam bool no_adjust If true, will not correct text size
|
||||||
|
function M.init(self, node, locale_id, no_adjust)
|
||||||
|
self.druid = self:get_druid()
|
||||||
|
self.text = self.druid:new_text(node, locale_id, no_adjust)
|
||||||
|
|
||||||
|
self.on_change = Event()
|
||||||
|
|
||||||
|
self:translate(locale_id)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.on_change_language(self)
|
||||||
|
if self.last_locale then
|
||||||
|
M.translate(self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Setup raw text to lang_text component
|
||||||
|
-- @function lang_text:set_to
|
||||||
|
-- @tparam string text Text for text node
|
||||||
|
function M.set_to(self, text)
|
||||||
|
self.last_locale = false
|
||||||
|
self.text:set_to(text)
|
||||||
|
self.on_change:trigger()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Translate the text by locale_id
|
||||||
|
-- @function lang_text:translate
|
||||||
|
-- @tparam string locale_id Locale id
|
||||||
|
function M.translate(self, locale_id)
|
||||||
|
self.last_locale = locale_id or self.last_locale
|
||||||
|
self.text:set_to(settings.get_text(self.last_locale))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
181
druid/base/progress.lua
Normal file
@ -0,0 +1,181 @@
|
|||||||
|
--- Basic progress bar component.
|
||||||
|
-- For correct progress bar init it should be in max size from gui
|
||||||
|
-- @module druid.progress
|
||||||
|
|
||||||
|
--- Component events
|
||||||
|
-- @table Events
|
||||||
|
-- @tfield druid_event on_change On progress bar change callback
|
||||||
|
|
||||||
|
--- Component fields
|
||||||
|
-- @table Fields
|
||||||
|
-- @tfield node node Progress bar fill node
|
||||||
|
-- @tfield string key The progress bar direction
|
||||||
|
-- @tfield vector3 scale Current progress bar scale
|
||||||
|
-- @tfield vector3 size Current progress bar size
|
||||||
|
-- @tfield number max_size Maximum size of progress bar
|
||||||
|
-- @tfield vector4 slice Progress bar slice9 settings
|
||||||
|
|
||||||
|
--- Component style params
|
||||||
|
-- @table Style
|
||||||
|
-- @tfield number SPEED Progress bas fill rate. More -> faster
|
||||||
|
-- @tfield number MIN_DELTA Minimum step to fill progress bar
|
||||||
|
|
||||||
|
local Event = require("druid.event")
|
||||||
|
local const = require("druid.const")
|
||||||
|
local helper = require("druid.helper")
|
||||||
|
local component = require("druid.component")
|
||||||
|
|
||||||
|
local M = component.create("progress", { const.ON_UPDATE })
|
||||||
|
|
||||||
|
|
||||||
|
local function check_steps(self, from, to, exactly)
|
||||||
|
if not self.steps then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
for i = 1, #self.steps do
|
||||||
|
local step = self.steps[i]
|
||||||
|
local v1, v2 = from, to
|
||||||
|
if v1 > v2 then
|
||||||
|
v1, v2 = v2, v1
|
||||||
|
end
|
||||||
|
|
||||||
|
if v1 < step and step < v2 then
|
||||||
|
self.step_callback(self:get_context(), step)
|
||||||
|
end
|
||||||
|
if exactly and exactly == step then
|
||||||
|
self.step_callback(self:get_context(), step)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function set_bar_to(self, set_to, is_silent)
|
||||||
|
local prev_value = self.last_value
|
||||||
|
self.last_value = set_to
|
||||||
|
|
||||||
|
local total_width = set_to * self.max_size
|
||||||
|
|
||||||
|
local scale = math.min(total_width / self.slice_size, 1)
|
||||||
|
local size = math.max(total_width, self.slice_size)
|
||||||
|
|
||||||
|
self.scale[self.key] = scale
|
||||||
|
gui.set_scale(self.node, self.scale)
|
||||||
|
self.size[self.key] = size
|
||||||
|
gui.set_size(self.node, self.size)
|
||||||
|
|
||||||
|
if not is_silent then
|
||||||
|
check_steps(self, prev_value, set_to)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Component init function
|
||||||
|
-- @function progress:init
|
||||||
|
-- @tparam string|node node Progress bar fill node or node name
|
||||||
|
-- @tparam string key Progress bar direction: const.SIDE.X or const.SIDE.Y
|
||||||
|
-- @tparam number init_value Initial value of progress bar
|
||||||
|
function M.init(self, node, key, init_value)
|
||||||
|
assert(key == const.SIDE.X or const.SIDE.Y, "Progress bar key should be 'x' or 'y'")
|
||||||
|
|
||||||
|
self.prop = hash("scale."..key)
|
||||||
|
self.key = key
|
||||||
|
|
||||||
|
self.style = self:get_style()
|
||||||
|
self.node = self:get_node(node)
|
||||||
|
self.scale = gui.get_scale(self.node)
|
||||||
|
self.size = gui.get_size(self.node)
|
||||||
|
self.max_size = self.size[self.key]
|
||||||
|
self.slice = gui.get_slice9(self.node)
|
||||||
|
if key == const.SIDE.X then
|
||||||
|
self.slice_size = self.slice.x + self.slice.z
|
||||||
|
else
|
||||||
|
self.slice_size = self.slice.y + self.slice.w
|
||||||
|
end
|
||||||
|
|
||||||
|
self.on_change = Event()
|
||||||
|
|
||||||
|
self:set_to(init_value or 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.update(self, dt)
|
||||||
|
if self.target then
|
||||||
|
local prev_value = self.last_value
|
||||||
|
local step = math.abs(self.last_value - self.target) * (self.style.SPEED*dt)
|
||||||
|
step = math.max(step, self.style.MIN_DELTA)
|
||||||
|
self:set_to(helper.step(self.last_value, self.target, step))
|
||||||
|
|
||||||
|
if self.last_value == self.target then
|
||||||
|
check_steps(self, prev_value, self.target, self.target)
|
||||||
|
|
||||||
|
if self.target_callback then
|
||||||
|
self.target_callback(self:get_context(), self.target)
|
||||||
|
end
|
||||||
|
|
||||||
|
self.target = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Fill a progress bar and stop progress animation
|
||||||
|
-- @function progress:fill
|
||||||
|
function M.fill(self)
|
||||||
|
set_bar_to(self, 1, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Empty a progress bar
|
||||||
|
-- @function progress:empty
|
||||||
|
function M.empty(self)
|
||||||
|
set_bar_to(self, 0, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Instant fill progress bar to value
|
||||||
|
-- @function progress:set_to
|
||||||
|
-- @tparam number to Progress bar value, from 0 to 1
|
||||||
|
function M.set_to(self, to)
|
||||||
|
set_bar_to(self, to)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Return current progress bar value
|
||||||
|
-- @function progress:get
|
||||||
|
function M.get(self)
|
||||||
|
return self.last_value
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set points on progress bar to fire the callback
|
||||||
|
-- @function progress:set_steps
|
||||||
|
-- @tparam number[] steps Array of progress bar values
|
||||||
|
-- @tparam function callback Callback on intersect step value
|
||||||
|
-- @usage progress:set_steps({0, 0.3, 0.6, 1}, function(self, step) end)
|
||||||
|
function M.set_steps(self, steps, callback)
|
||||||
|
self.steps = steps
|
||||||
|
self.step_callback = callback
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Start animation of a progress bar
|
||||||
|
-- @function progress:to
|
||||||
|
-- @tparam number to value between 0..1
|
||||||
|
-- @tparam[opt] function callback Callback on animation ends
|
||||||
|
function M.to(self, to, callback)
|
||||||
|
to = helper.clamp(to, 0, 1)
|
||||||
|
-- cause of float error
|
||||||
|
local value = helper.round(to, 5)
|
||||||
|
if value ~= self.last_value then
|
||||||
|
self.target = value
|
||||||
|
self.target_callback = callback
|
||||||
|
else
|
||||||
|
if callback then
|
||||||
|
callback(self:get_context(), to)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
74
druid/base/radio_group.lua
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
--- Radio group module
|
||||||
|
-- @module druid.radio_group
|
||||||
|
|
||||||
|
--- Component events
|
||||||
|
-- @table Events
|
||||||
|
-- @tfield druid_event on_radio_click On any checkbox click
|
||||||
|
|
||||||
|
--- Component fields
|
||||||
|
-- @table Fields
|
||||||
|
-- @tfield table checkboxes Array of checkbox components
|
||||||
|
|
||||||
|
local Event = require("druid.event")
|
||||||
|
local component = require("druid.component")
|
||||||
|
|
||||||
|
local M = component.create("radio_group")
|
||||||
|
|
||||||
|
|
||||||
|
local function on_checkbox_click(self, index)
|
||||||
|
for i = 1, #self.checkboxes do
|
||||||
|
self.checkboxes[i]:set_state(i == index, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
self.on_radio_click:trigger(self:get_context(), index)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Component init function
|
||||||
|
-- @function radio_group:init
|
||||||
|
-- @tparam node[] node Array of gui node
|
||||||
|
-- @tparam function callback Radio callback
|
||||||
|
-- @tparam[opt=node] node[] click node Array of trigger nodes, by default equals to nodes
|
||||||
|
function M.init(self, nodes, callback, click_nodes)
|
||||||
|
self.druid = self:get_druid()
|
||||||
|
self.checkboxes = {}
|
||||||
|
|
||||||
|
self.on_radio_click = Event(callback)
|
||||||
|
|
||||||
|
for i = 1, #nodes do
|
||||||
|
local click_node = click_nodes and click_nodes[i] or nil
|
||||||
|
local checkbox = self.druid:new_checkbox(nodes[i], function()
|
||||||
|
on_checkbox_click(self, i)
|
||||||
|
end, click_node)
|
||||||
|
|
||||||
|
table.insert(self.checkboxes, checkbox)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set radio group state
|
||||||
|
-- @function radio_group:set_state
|
||||||
|
-- @tparam bool[] state Array of checkbox state
|
||||||
|
function M.set_state(self, index)
|
||||||
|
on_checkbox_click(self, index)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Return radio group state
|
||||||
|
-- @function radio_group:get_state
|
||||||
|
-- @treturn bool[] Array if checkboxes state
|
||||||
|
function M.get_state(self)
|
||||||
|
local result = -1
|
||||||
|
|
||||||
|
for i = 1, #self.checkboxes do
|
||||||
|
if self.checkboxes[i]:get_state() then
|
||||||
|
result = i
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
538
druid/base/scroll.lua
Normal file
@ -0,0 +1,538 @@
|
|||||||
|
--- Component to handle scroll content.
|
||||||
|
-- Scroll consist from two nodes: scroll parent and scroll input
|
||||||
|
-- Scroll input the user input zone, it's static
|
||||||
|
-- Scroll parent the scroll moving part, it will change position.
|
||||||
|
-- Setup initial scroll size by changing scroll parent size. If scroll parent
|
||||||
|
-- size will be less than scroll_input size, no scroll is available. For scroll
|
||||||
|
-- parent size should be more than input size
|
||||||
|
-- @module druid.scroll
|
||||||
|
|
||||||
|
--- Component events
|
||||||
|
-- @table Events
|
||||||
|
-- @tfield druid_event on_scroll On scroll move callback
|
||||||
|
-- @tfield druid_event on_scroll_to On scroll_to function callback
|
||||||
|
-- @tfield druid_event on_point_scroll On scroll_to_index function callbck
|
||||||
|
|
||||||
|
--- Component fields
|
||||||
|
-- @table Fields
|
||||||
|
-- @tfield node node Scroll parent node
|
||||||
|
-- @tfield node input_zone Scroll input node
|
||||||
|
-- @tfield vector3 zone_size Current scroll content size
|
||||||
|
-- @tfield number soft_size Soft zone size from style table
|
||||||
|
-- @tfield vector3 center_offset Distance from node to node's center
|
||||||
|
-- @tfield bool is_inert Flag, if scroll now moving by inertion
|
||||||
|
-- @tfield vector3 inert Current inert speed
|
||||||
|
-- @tfield vector3 pos Current scroll posisition
|
||||||
|
-- @tfield vector3 target Current scroll target position
|
||||||
|
|
||||||
|
--- Component style params
|
||||||
|
-- @table Style
|
||||||
|
-- @tfield number FRICT_HOLD Multiplier for inertion, while touching
|
||||||
|
-- @tfield number FRICT Multiplier for free inertion
|
||||||
|
-- @tfield number INERT_THRESHOLD Scroll speed to stop inertion
|
||||||
|
-- @tfield number INERT_SPEED Multiplier for inertion speed
|
||||||
|
-- @tfield number DEADZONE Deadzone for start scrol in pixels
|
||||||
|
-- @tfield number SOFT_ZONE_SIZE Size of outside zone in pixels (for scroll back moving)
|
||||||
|
-- @tfield number BACK_SPEED Scroll back returning lerp speed
|
||||||
|
-- @tfield number ANIM_SPEED Scroll gui.animation speed for scroll_to function
|
||||||
|
|
||||||
|
local Event = require("druid.event")
|
||||||
|
local helper = require("druid.helper")
|
||||||
|
local const = require("druid.const")
|
||||||
|
local component = require("druid.component")
|
||||||
|
|
||||||
|
local M = component.create("scroll", { const.ON_UPDATE, const.ON_INPUT_HIGH })
|
||||||
|
|
||||||
|
|
||||||
|
-- Global on all scrolls
|
||||||
|
-- TODO: remove it
|
||||||
|
M.current_scroll = nil
|
||||||
|
|
||||||
|
|
||||||
|
local function get_border(node)
|
||||||
|
local pivot = gui.get_pivot(node)
|
||||||
|
local pivot_offset = helper.get_pivot_offset(pivot)
|
||||||
|
local size = vmath.mul_per_elem(gui.get_size(node), gui.get_scale(node))
|
||||||
|
return vmath.vector4(
|
||||||
|
-size.x*(0.5 + pivot_offset.x),
|
||||||
|
size.y*(0.5 + pivot_offset.y),
|
||||||
|
size.x*(0.5 - pivot_offset.x),
|
||||||
|
-size.y*(0.5 - pivot_offset.y)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function update_border(self)
|
||||||
|
local input_border = get_border(self.input_zone)
|
||||||
|
local content_border = get_border(self.node)
|
||||||
|
|
||||||
|
-- border.x - min content.x node pos
|
||||||
|
-- border.y - min content.y node pos
|
||||||
|
-- border.z - max content.x node pos
|
||||||
|
-- border.w - max content.y node pos
|
||||||
|
self.border = vmath.vector4(
|
||||||
|
input_border.x - content_border.x,
|
||||||
|
-input_border.w + content_border.w,
|
||||||
|
input_border.z - content_border.z,
|
||||||
|
-input_border.y + content_border.y
|
||||||
|
)
|
||||||
|
self.can_x = (self.border.x ~= self.border.z)
|
||||||
|
self.can_y = (self.border.y ~= self.border.w)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
local function set_pos(self, pos)
|
||||||
|
if self.pos.x ~= pos.x or self.pos.y ~= pos.y then
|
||||||
|
self.pos.x = pos.x
|
||||||
|
self.pos.y = pos.y
|
||||||
|
gui.set_position(self.node, self.pos)
|
||||||
|
|
||||||
|
self.on_scroll:trigger(self:get_context(), self.pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Return scroll, if it outside of scroll area
|
||||||
|
-- Using the lerp with BACK_SPEED koef
|
||||||
|
local function check_soft_target(self)
|
||||||
|
local t = self.target
|
||||||
|
local b = self.border
|
||||||
|
|
||||||
|
if t.y < b.y then
|
||||||
|
t.y = helper.step(t.y, b.y, math.abs(t.y - b.y) * self.style.BACK_SPEED)
|
||||||
|
end
|
||||||
|
if t.x > b.x then
|
||||||
|
t.x = helper.step(t.x, b.x, math.abs(t.x - b.x) * self.style.BACK_SPEED)
|
||||||
|
end
|
||||||
|
if t.y > b.w then
|
||||||
|
t.y = helper.step(t.y, b.w, math.abs(t.y - b.w) * self.style.BACK_SPEED)
|
||||||
|
end
|
||||||
|
if t.x < b.z then
|
||||||
|
t.x = helper.step(t.x, b.z, math.abs(t.x - b.z) * self.style.BACK_SPEED)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Free inert update function
|
||||||
|
local function update_hand_scroll(self, dt)
|
||||||
|
local inert = self.inert
|
||||||
|
local delta_x = self.target.x - self.pos.x
|
||||||
|
local delta_y = self.target.y - self.pos.y
|
||||||
|
|
||||||
|
if helper.sign(delta_x) ~= helper.sign(inert.x) then
|
||||||
|
inert.x = 0
|
||||||
|
end
|
||||||
|
if helper.sign(delta_y) ~= helper.sign(inert.y) then
|
||||||
|
inert.y = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
inert.x = inert.x + delta_x
|
||||||
|
inert.y = inert.y + delta_y
|
||||||
|
|
||||||
|
inert.x = math.abs(inert.x) * helper.sign(delta_x)
|
||||||
|
inert.y = math.abs(inert.y) * helper.sign(delta_y)
|
||||||
|
|
||||||
|
inert.x = inert.x * self.style.FRICT_HOLD
|
||||||
|
inert.y = inert.y * self.style.FRICT_HOLD
|
||||||
|
|
||||||
|
set_pos(self, self.target)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function get_zone_center(self)
|
||||||
|
return self.pos + self.center_offset
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Find closer point of interest
|
||||||
|
-- if no inert, scroll to next point by scroll direction
|
||||||
|
-- if inert, find next point by scroll director
|
||||||
|
-- @local
|
||||||
|
local function check_points(self)
|
||||||
|
if not self.points then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local inert = self.inert
|
||||||
|
if not self.is_inert then
|
||||||
|
if math.abs(inert.x) > self.style.DEADZONE then
|
||||||
|
self:scroll_to_index(self.selected - helper.sign(inert.x))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if math.abs(inert.y) > self.style.DEADZONE then
|
||||||
|
self:scroll_to_index(self.selected + helper.sign(inert.y))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Find closest point and point by scroll direction
|
||||||
|
-- Scroll to one of them (by scroll direction in priority)
|
||||||
|
local temp_dist = math.huge
|
||||||
|
local temp_dist_on_inert = math.huge
|
||||||
|
local index = false
|
||||||
|
local index_on_inert = false
|
||||||
|
local pos = get_zone_center(self)
|
||||||
|
for i = 1, #self.points do
|
||||||
|
local p = self.points[i]
|
||||||
|
local dist = helper.distance(pos.x, pos.y, p.x, p.y)
|
||||||
|
local on_inert = true
|
||||||
|
-- If inert ~= 0, scroll only by move direction
|
||||||
|
if inert.x ~= 0 and helper.sign(inert.x) ~= helper.sign(p.x - pos.x) then
|
||||||
|
on_inert = false
|
||||||
|
end
|
||||||
|
if inert.y ~= 0 and helper.sign(inert.y) ~= helper.sign(p.y - pos.y) then
|
||||||
|
on_inert = false
|
||||||
|
end
|
||||||
|
|
||||||
|
if dist < temp_dist then
|
||||||
|
index = i
|
||||||
|
temp_dist = dist
|
||||||
|
end
|
||||||
|
if on_inert and dist < temp_dist_on_inert then
|
||||||
|
index_on_inert = i
|
||||||
|
temp_dist_on_inert = dist
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self:scroll_to_index(index_on_inert or index)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function check_threshold(self)
|
||||||
|
local inert = self.inert
|
||||||
|
if not self.is_inert or vmath.length(inert) < self.style.INERT_THRESHOLD then
|
||||||
|
check_points(self)
|
||||||
|
inert.x = 0
|
||||||
|
inert.y = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function update_free_inert(self, dt)
|
||||||
|
local inert = self.inert
|
||||||
|
if inert.x ~= 0 or inert.y ~= 0 then
|
||||||
|
self.target.x = self.pos.x + (inert.x * dt * self.style.INERT_SPEED)
|
||||||
|
self.target.y = self.pos.y + (inert.y * dt * self.style.INERT_SPEED)
|
||||||
|
|
||||||
|
inert.x = inert.x * self.style.FRICT
|
||||||
|
inert.y = inert.y * self.style.FRICT
|
||||||
|
|
||||||
|
-- Stop, when low inert speed and go to points
|
||||||
|
check_threshold(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
check_soft_target(self)
|
||||||
|
set_pos(self, self.target)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Cancel animation on other animation or input touch
|
||||||
|
local function cancel_animate(self)
|
||||||
|
if self.animate then
|
||||||
|
self.target = gui.get_position(self.node)
|
||||||
|
self.pos.x = self.target.x
|
||||||
|
self.pos.y = self.target.y
|
||||||
|
gui.cancel_animation(self.node, gui.PROP_POSITION)
|
||||||
|
self.animate = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function add_delta(self, dx, dy)
|
||||||
|
local t = self.target
|
||||||
|
local b = self.border
|
||||||
|
local soft = self.soft_size
|
||||||
|
|
||||||
|
-- TODO: Can we calc it more easier?
|
||||||
|
-- A lot of calculations for every side of border
|
||||||
|
|
||||||
|
-- Handle soft zones
|
||||||
|
-- Percent - multiplier for delta. Less if outside of scroll zone
|
||||||
|
local x_perc = 1
|
||||||
|
local y_perc = 1
|
||||||
|
|
||||||
|
if t.x > b.x and dx < 0 then
|
||||||
|
x_perc = (soft - (b.x - t.x)) / soft
|
||||||
|
end
|
||||||
|
if t.x < b.z and dx > 0 then
|
||||||
|
x_perc = (soft - (t.x - b.z)) / soft
|
||||||
|
end
|
||||||
|
-- If disabled scroll by x
|
||||||
|
if not self.can_x then
|
||||||
|
x_perc = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
if t.y < b.y and dy < 0 then
|
||||||
|
y_perc = (soft - (b.y - t.y)) / soft
|
||||||
|
end
|
||||||
|
if t.y > b.w and dy > 0 then
|
||||||
|
y_perc = (soft - (t.y - b.w)) / soft
|
||||||
|
end
|
||||||
|
-- If disabled scroll by y
|
||||||
|
if not self.can_y then
|
||||||
|
y_perc = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Reset inert if outside of scroll zone
|
||||||
|
if x_perc ~= 1 then
|
||||||
|
self.inert.x = 0
|
||||||
|
end
|
||||||
|
if y_perc ~= 1 then
|
||||||
|
self.inert.y = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
t.x = t.x + dx * x_perc
|
||||||
|
t.y = t.y + dy * y_perc
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Component init function
|
||||||
|
-- @function scroll:init
|
||||||
|
-- @tparam node scroll_parent Gui node where placed scroll content. This node will change position
|
||||||
|
-- @tparam node input_zone Gui node where input is catched
|
||||||
|
function M.init(self, scroll_parent, input_zone)
|
||||||
|
self.style = self:get_style()
|
||||||
|
self.node = self:get_node(scroll_parent)
|
||||||
|
self.input_zone = self:get_node(input_zone)
|
||||||
|
|
||||||
|
self.zone_size = gui.get_size(self.input_zone)
|
||||||
|
self.soft_size = self.style.SOFT_ZONE_SIZE
|
||||||
|
|
||||||
|
-- Distance from node to node's center
|
||||||
|
local offset = helper.get_pivot_offset(gui.get_pivot(self.input_zone))
|
||||||
|
self.center_offset = vmath.vector3(self.zone_size)
|
||||||
|
self.center_offset.x = self.center_offset.x * offset.x
|
||||||
|
self.center_offset.y = self.center_offset.y * offset.y
|
||||||
|
|
||||||
|
self.is_inert = true
|
||||||
|
self.inert = vmath.vector3(0)
|
||||||
|
self.pos = gui.get_position(self.node)
|
||||||
|
self.target = vmath.vector3(self.pos)
|
||||||
|
|
||||||
|
self.input = {
|
||||||
|
touch = false,
|
||||||
|
start_x = 0,
|
||||||
|
start_y = 0,
|
||||||
|
side = false,
|
||||||
|
}
|
||||||
|
|
||||||
|
update_border(self)
|
||||||
|
|
||||||
|
self.on_scroll = Event()
|
||||||
|
self.on_scroll_to = Event()
|
||||||
|
self.on_point_scroll = Event()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.update(self, dt)
|
||||||
|
if self.input.touch then
|
||||||
|
if M.current_scroll == self then
|
||||||
|
update_hand_scroll(self, dt)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
update_free_inert(self, dt)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.on_input(self, action_id, action)
|
||||||
|
if action_id ~= const.ACTION_TOUCH then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local inp = self.input
|
||||||
|
local inert = self.inert
|
||||||
|
local result = false
|
||||||
|
|
||||||
|
if gui.pick_node(self.input_zone, action.x, action.y) then
|
||||||
|
if action.pressed then
|
||||||
|
inp.touch = true
|
||||||
|
inp.start_x = action.x
|
||||||
|
inp.start_y = action.y
|
||||||
|
inert.x = 0
|
||||||
|
inert.y = 0
|
||||||
|
self.target.x = self.pos.x
|
||||||
|
self.target.y = self.pos.y
|
||||||
|
else
|
||||||
|
local dist = helper.distance(action.x, action.y, inp.start_x, inp.start_y)
|
||||||
|
if not M.current_scroll and dist >= self.style.DEADZONE then
|
||||||
|
local dx = math.abs(inp.start_x - action.x)
|
||||||
|
local dy = math.abs(inp.start_y - action.y)
|
||||||
|
inp.side = (dx > dy) and const.SIDE.X or const.SIDE.Y
|
||||||
|
|
||||||
|
-- Check scroll side if we can scroll
|
||||||
|
if (self.can_x and inp.side == const.SIDE.X or
|
||||||
|
self.can_y and inp.side == const.SIDE.Y) then
|
||||||
|
M.current_scroll = self
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if inp.touch and not action.pressed then
|
||||||
|
if M.current_scroll == self then
|
||||||
|
add_delta(self, action.dx, action.dy)
|
||||||
|
result = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if action.released then
|
||||||
|
inp.touch = false
|
||||||
|
inp.side = false
|
||||||
|
if M.current_scroll == self then
|
||||||
|
M.current_scroll = nil
|
||||||
|
result = true
|
||||||
|
end
|
||||||
|
|
||||||
|
check_threshold(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Start scroll to target point
|
||||||
|
-- @function scroll:scroll_to
|
||||||
|
-- @tparam point vector3 target point
|
||||||
|
-- @tparam[opt] bool is_instant instant scroll flag
|
||||||
|
-- @usage scroll:scroll_to(vmath.vector3(0, 50, 0))
|
||||||
|
-- @usage scroll:scroll_to(vmath.vector3(0), true)
|
||||||
|
function M.scroll_to(self, point, is_instant)
|
||||||
|
local b = self.border
|
||||||
|
local target = vmath.vector3(point)
|
||||||
|
target.x = helper.clamp(point.x - self.center_offset.x, b.x, b.z)
|
||||||
|
target.y = helper.clamp(point.y - self.center_offset.y, b.y, b.w)
|
||||||
|
|
||||||
|
cancel_animate(self)
|
||||||
|
|
||||||
|
self.animate = not is_instant
|
||||||
|
|
||||||
|
if is_instant then
|
||||||
|
self.target = target
|
||||||
|
set_pos(self, target)
|
||||||
|
else
|
||||||
|
gui.animate(self.node, gui.PROP_POSITION, target, gui.EASING_OUTSINE, self.style.ANIM_SPEED, 0, function()
|
||||||
|
self.animate = false
|
||||||
|
self.target = target
|
||||||
|
set_pos(self, target)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
self.on_scroll_to:trigger(self:get_context(), target, is_instant)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Start scroll to target scroll percent
|
||||||
|
-- @function scroll:scroll_to_percent
|
||||||
|
-- @tparam point vector3 target percent
|
||||||
|
-- @tparam[opt] bool is_instant instant scroll flag
|
||||||
|
-- @usage scroll:scroll_to_percent(vmath.vector3(0.5, 0, 0))
|
||||||
|
function M.scroll_to_percent(self, percent, is_instant)
|
||||||
|
local border = self.border
|
||||||
|
|
||||||
|
local size_x = math.abs(border.z - border.x)
|
||||||
|
if size_x == 0 then
|
||||||
|
size_x = 1
|
||||||
|
end
|
||||||
|
local size_y = math.abs(border.w - border.y)
|
||||||
|
if size_y == 0 then
|
||||||
|
size_y = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local pos = vmath.vector3(
|
||||||
|
-size_x * percent.x + border.x,
|
||||||
|
-size_y * percent.y + border.y,
|
||||||
|
0)
|
||||||
|
M.scroll_to(self, pos, is_instant)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Scroll to item in scroll by point index
|
||||||
|
-- @function scroll:init
|
||||||
|
-- @tparam number index Point index
|
||||||
|
-- @tparam[opt] bool skip_cb If true, skip the point callback
|
||||||
|
function M.scroll_to_index(self, index, skip_cb)
|
||||||
|
index = helper.clamp(index, 1, #self.points)
|
||||||
|
|
||||||
|
if self.selected ~= index then
|
||||||
|
self.selected = index
|
||||||
|
|
||||||
|
if not skip_cb then
|
||||||
|
self.on_point_scroll:trigger(self:get_context(), index, self.points[index])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self:scroll_to(self.points[index])
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set points of interest.
|
||||||
|
-- Scroll will always centered on closer points
|
||||||
|
-- @function scroll:set_points
|
||||||
|
-- @tparam table points Array of vector3 points
|
||||||
|
function M.set_points(self, points)
|
||||||
|
self.points = points
|
||||||
|
-- cause of parent move in other side by y
|
||||||
|
for i = 1, #self.points do
|
||||||
|
self.points[i].y = -self.points[i].y
|
||||||
|
end
|
||||||
|
|
||||||
|
table.sort(self.points, function(a, b)
|
||||||
|
return a.x > b.x or a.y < b.y
|
||||||
|
end)
|
||||||
|
check_threshold(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Enable or disable scroll inert.
|
||||||
|
-- If disabled, scroll through points (if exist)
|
||||||
|
-- If no points, just simple drag without inertion
|
||||||
|
-- @function scroll:set_inert
|
||||||
|
-- @tparam bool state Inert scroll state
|
||||||
|
function M.set_inert(self, state)
|
||||||
|
self.is_inert = state
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set the callback on scrolling to point (if exist)
|
||||||
|
-- @function scroll:on_point_move
|
||||||
|
-- @tparam function callback Callback on scroll to point of interest
|
||||||
|
function M.on_point_move(self, callback)
|
||||||
|
self.on_point_scroll:subscribe(callback)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set the scroll possibly area
|
||||||
|
-- @function scroll:set_border
|
||||||
|
-- @tparam vector3 border Size of scrolling area
|
||||||
|
function M.set_border(self, content_size)
|
||||||
|
gui.set_size(self.node, content_size)
|
||||||
|
update_border(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Return current scroll progress
|
||||||
|
-- @function scroll:get_scroll_percent
|
||||||
|
-- @treturn vector3 Scroll progress
|
||||||
|
function M.get_scroll_percent(self)
|
||||||
|
local border = self.border
|
||||||
|
local size_x = math.abs(border.z - border.x)
|
||||||
|
if size_x == 0 then
|
||||||
|
size_x = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local size_y = math.abs(border.w - border.y)
|
||||||
|
if size_y == 0 then
|
||||||
|
size_y = 1
|
||||||
|
end
|
||||||
|
local pos = self.pos
|
||||||
|
|
||||||
|
return vmath.vector3(
|
||||||
|
(border.x - pos.x) / size_x,
|
||||||
|
(border.y - pos.y) / size_y,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
118
druid/base/slider.lua
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
--- Druid slider component
|
||||||
|
-- @module druid.slider
|
||||||
|
|
||||||
|
--- Component events
|
||||||
|
-- @table Events
|
||||||
|
-- @tfield druid_event on_change_value On change value callback
|
||||||
|
|
||||||
|
--- Component fields
|
||||||
|
-- @table Fields
|
||||||
|
-- @tfield node node Slider pin node
|
||||||
|
-- @tfield vector3 start_pos Start pin node position
|
||||||
|
-- @tfield vector3 pos Current pin node position
|
||||||
|
-- @tfield vector3 target_pos Targer pin node position
|
||||||
|
-- @tfield vector3 end_pos End pin node position
|
||||||
|
-- @tfield number dist Length between start and end position
|
||||||
|
-- @tfield bool is_drag Current drag state
|
||||||
|
-- @tfield number value Current slider value
|
||||||
|
|
||||||
|
|
||||||
|
local Event = require("druid.event")
|
||||||
|
local helper = require("druid.helper")
|
||||||
|
local const = require("druid.const")
|
||||||
|
local component = require("druid.component")
|
||||||
|
|
||||||
|
local M = component.create("slider", { const.ON_INPUT_HIGH })
|
||||||
|
|
||||||
|
|
||||||
|
local function on_change_value(self)
|
||||||
|
self.on_change_value:trigger(self:get_context(), self.value)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Component init function
|
||||||
|
-- @function slider:init
|
||||||
|
-- @tparam node node Gui pin node
|
||||||
|
-- @tparam vector3 end_pos The end position of slider
|
||||||
|
-- @tparam[opt] function callback On slider change callback
|
||||||
|
function M.init(self, node, end_pos, callback)
|
||||||
|
self.node = self:get_node(node)
|
||||||
|
|
||||||
|
self.start_pos = gui.get_position(self.node)
|
||||||
|
self.pos = gui.get_position(self.node)
|
||||||
|
self.target_pos = self.pos
|
||||||
|
self.end_pos = end_pos
|
||||||
|
|
||||||
|
self.dist = self.end_pos - self.start_pos
|
||||||
|
self.is_drag = false
|
||||||
|
self.value = 0
|
||||||
|
|
||||||
|
self.on_change_value = Event(callback)
|
||||||
|
|
||||||
|
assert(self.dist.x == 0 or self.dist.y == 0, "Slider for now can be only vertical or horizontal")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.on_input(self, action_id, action)
|
||||||
|
if action_id ~= const.ACTION_TOUCH then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if gui.pick_node(self.node, action.x, action.y) then
|
||||||
|
if action.pressed then
|
||||||
|
self.pos = gui.get_position(self.node)
|
||||||
|
self.is_drag = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.is_drag and not action.pressed then
|
||||||
|
-- move
|
||||||
|
self.pos.x = self.pos.x + action.dx
|
||||||
|
self.pos.y = self.pos.y + action.dy
|
||||||
|
|
||||||
|
local prev_x = self.target_pos.x
|
||||||
|
local prev_y = self.target_pos.y
|
||||||
|
|
||||||
|
self.target_pos.x = helper.clamp(self.pos.x, self.start_pos.x, self.end_pos.x)
|
||||||
|
self.target_pos.y = helper.clamp(self.pos.y, self.start_pos.y, self.end_pos.y)
|
||||||
|
|
||||||
|
gui.set_position(self.node, self.target_pos)
|
||||||
|
|
||||||
|
if prev_x ~= self.target_pos.x or prev_y ~= self.target_pos.y then
|
||||||
|
|
||||||
|
if self.dist.x > 0 then
|
||||||
|
self.value = (self.target_pos.x - self.start_pos.x) / self.dist.x
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.dist.y > 0 then
|
||||||
|
self.value = (self.target_pos.y - self.start_pos.y) / self.dist.y
|
||||||
|
end
|
||||||
|
|
||||||
|
on_change_value(self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if action.released then
|
||||||
|
self.is_drag = false
|
||||||
|
end
|
||||||
|
|
||||||
|
return self.is_drag
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set value for slider
|
||||||
|
-- @function slider:set
|
||||||
|
-- @tparam number value Value from 0 to 1
|
||||||
|
-- @tparam[opt] bool is_silent Don't trigger event if true
|
||||||
|
function M.set(self, value, is_silent)
|
||||||
|
value = helper.clamp(value, 0, 1)
|
||||||
|
|
||||||
|
gui.set_position(self.node, self.start_pos + self.dist * value)
|
||||||
|
self.value = value
|
||||||
|
if not is_silent then
|
||||||
|
on_change_value(self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
162
druid/base/text.lua
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
--- Component to handle all GUI texts.
|
||||||
|
-- Druid text can adjust itself for text node size
|
||||||
|
-- Text will never will be outside of his text size (even multiline)
|
||||||
|
-- @module druid.text
|
||||||
|
|
||||||
|
--- Component events
|
||||||
|
-- @table Events
|
||||||
|
-- @tfield druid_event on_set_text On set text callback
|
||||||
|
-- @tfield druid_event on_update_text_scale On adjust text size callback
|
||||||
|
-- @tfield druid_event on_set_pivot On change pivot callback
|
||||||
|
|
||||||
|
--- Component fields
|
||||||
|
-- @table Fields
|
||||||
|
-- @tfield node node Text node
|
||||||
|
-- @tfield vector3 pos Current text position
|
||||||
|
-- @tfield vector3 start_scale Initial text node scale
|
||||||
|
-- @tfield vector3 scale Current text node scale
|
||||||
|
-- @tfield vector3 start_size Initial text node size
|
||||||
|
-- @tfield vector3 text_area Current text node available are
|
||||||
|
-- @tfield bool is_no_adjust Current text size adjust settings
|
||||||
|
-- @tfield vector3 color Current text color
|
||||||
|
|
||||||
|
local Event = require("druid.event")
|
||||||
|
local const = require("druid.const")
|
||||||
|
local component = require("druid.component")
|
||||||
|
|
||||||
|
local M = component.create("text")
|
||||||
|
|
||||||
|
|
||||||
|
local function update_text_size(self)
|
||||||
|
local size = vmath.vector3(
|
||||||
|
self.start_size.x * (self.start_scale.x / self.scale.x),
|
||||||
|
self.start_size.y * (self.start_scale.y / self.scale.y),
|
||||||
|
self.start_size.z
|
||||||
|
)
|
||||||
|
gui.set_size(self.node, size)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Setup scale x, but can only be smaller, than start text scale
|
||||||
|
local function update_text_area_size(self)
|
||||||
|
gui.set_scale(self.node, self.start_scale)
|
||||||
|
gui.set_size(self.node, self.start_size)
|
||||||
|
|
||||||
|
local max_width = self.text_area.x
|
||||||
|
local max_height = self.text_area.y
|
||||||
|
|
||||||
|
local metrics = gui.get_text_metrics_from_node(self.node)
|
||||||
|
local cur_scale = gui.get_scale(self.node)
|
||||||
|
|
||||||
|
local scale_modifier = max_width / metrics.width
|
||||||
|
scale_modifier = math.min(scale_modifier, self.start_scale.x)
|
||||||
|
|
||||||
|
local scale_modifier_height = max_height / metrics.height
|
||||||
|
scale_modifier = math.min(scale_modifier, scale_modifier_height)
|
||||||
|
|
||||||
|
local new_scale = vmath.vector3(scale_modifier, scale_modifier, cur_scale.z)
|
||||||
|
gui.set_scale(self.node, new_scale)
|
||||||
|
self.scale = new_scale
|
||||||
|
|
||||||
|
update_text_size(self)
|
||||||
|
|
||||||
|
self.on_update_text_scale:trigger(self:get_context(), new_scale)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Component init function
|
||||||
|
-- @function text:init
|
||||||
|
-- @tparam node node Gui text node
|
||||||
|
-- @tparam[opt] string value Initial text
|
||||||
|
-- @tparam[opt] bool no_adjust If true, text will be not auto-adjust size
|
||||||
|
function M.init(self, node, value, no_adjust)
|
||||||
|
self.node = self:get_node(node)
|
||||||
|
self.pos = gui.get_position(self.node)
|
||||||
|
|
||||||
|
self.start_scale = gui.get_scale(self.node)
|
||||||
|
self.scale = gui.get_scale(self.node)
|
||||||
|
|
||||||
|
self.start_size = gui.get_size(self.node)
|
||||||
|
self.text_area = gui.get_size(self.node)
|
||||||
|
self.text_area.x = self.text_area.x * self.start_scale.x
|
||||||
|
self.text_area.y = self.text_area.y * self.start_scale.y
|
||||||
|
|
||||||
|
self.is_no_adjust = no_adjust
|
||||||
|
self.color = gui.get_color(self.node)
|
||||||
|
|
||||||
|
self.on_set_text = Event()
|
||||||
|
self.on_update_text_scale = Event()
|
||||||
|
self.on_set_pivot = Event()
|
||||||
|
|
||||||
|
self:set_to(value or 0)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set text to text field
|
||||||
|
-- @function text:set_to
|
||||||
|
-- @tparam string set_to Text for node
|
||||||
|
function M.set_to(self, set_to)
|
||||||
|
self.last_value = set_to
|
||||||
|
gui.set_text(self.node, set_to)
|
||||||
|
|
||||||
|
self.on_set_text:trigger(self:get_context(), set_to)
|
||||||
|
|
||||||
|
if not self.is_no_adjust then
|
||||||
|
update_text_area_size(self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set color
|
||||||
|
-- @function text:set_color
|
||||||
|
-- @tparam vector4 color Color for node
|
||||||
|
function M.set_color(self, color)
|
||||||
|
self.color = color
|
||||||
|
gui.set_color(self.node, color)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set alpha
|
||||||
|
-- @function text:set_alpha
|
||||||
|
-- @tparam number alpha Alpha for node
|
||||||
|
function M.set_alpha(self, alpha)
|
||||||
|
self.color.w = alpha
|
||||||
|
gui.set_color(self.node, self.color)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set scale
|
||||||
|
-- @function text:set_scale
|
||||||
|
-- @tparam vector3 scale Scale for node
|
||||||
|
function M.set_scale(self, scale)
|
||||||
|
self.last_scale = scale
|
||||||
|
gui.set_scale(self.node, scale)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set text pivot. Text will re-anchor inside
|
||||||
|
-- his text area
|
||||||
|
-- @function text:set_pivot
|
||||||
|
-- @tparam gui.pivot pivot Gui pivot constant
|
||||||
|
function M.set_pivot(self, pivot)
|
||||||
|
local prev_pivot = gui.get_pivot(self.node)
|
||||||
|
local prev_offset = const.PIVOTS[prev_pivot]
|
||||||
|
|
||||||
|
gui.set_pivot(self.node, pivot)
|
||||||
|
local cur_offset = const.PIVOTS[pivot]
|
||||||
|
|
||||||
|
local pos_offset = vmath.vector3(
|
||||||
|
self.text_area.x * (cur_offset.x - prev_offset.x),
|
||||||
|
self.text_area.y * (cur_offset.y - prev_offset.y),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
|
||||||
|
self.pos = self.pos + pos_offset
|
||||||
|
gui.set_position(self.node, self.pos)
|
||||||
|
|
||||||
|
self.on_set_pivot:trigger(self:get_context(), pivot)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
113
druid/base/timer.lua
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
--- Component to handle GUI timers.
|
||||||
|
-- Timer updating by game delta time. If game is not focused -
|
||||||
|
-- timer will be not updated.
|
||||||
|
-- @module druid.timer
|
||||||
|
|
||||||
|
--- Component events
|
||||||
|
-- @table Events
|
||||||
|
-- @tfield druid_event on_tick On timer tick callback. Fire every second
|
||||||
|
-- @tfield druid_event on_set_enabled On timer change enabled state callback
|
||||||
|
-- @tfield druid_event on_timer_end On timer end callback
|
||||||
|
|
||||||
|
--- Component fields
|
||||||
|
-- @table Fields
|
||||||
|
-- @tfield node node Trigger node
|
||||||
|
-- @tfield[opt=node] node anim_node Animation node
|
||||||
|
-- @tfield vector3 scale_from Initial scale of anim_node
|
||||||
|
-- @tfield vector3 pos Initial pos of anim_node
|
||||||
|
-- @tfield any params Params to click callbacks
|
||||||
|
-- @tfield druid.hover hover Druid hover logic component
|
||||||
|
-- @tfield[opt] node click_zone Restriction zone
|
||||||
|
|
||||||
|
local Event = require("druid.event")
|
||||||
|
local const = require("druid.const")
|
||||||
|
local formats = require("druid.helper.formats")
|
||||||
|
local helper = require("druid.helper")
|
||||||
|
local component = require("druid.component")
|
||||||
|
|
||||||
|
local M = component.create("timer", { const.ON_UPDATE })
|
||||||
|
|
||||||
|
|
||||||
|
--- Component init function
|
||||||
|
-- @function timer:init
|
||||||
|
-- @tparam node node Gui text node
|
||||||
|
-- @tparam number seconds_from Start timer value in seconds
|
||||||
|
-- @tparam[opt=0] number seconds_to End timer value in seconds
|
||||||
|
-- @tparam[opt] function callback Function on timer end
|
||||||
|
function M.init(self, node, seconds_from, seconds_to, callback)
|
||||||
|
self.node = self:get_node(node)
|
||||||
|
seconds_from = math.max(seconds_from, 0)
|
||||||
|
seconds_to = math.max(seconds_to or 0, 0)
|
||||||
|
|
||||||
|
self.on_tick = Event()
|
||||||
|
self.on_set_enabled = Event()
|
||||||
|
self.on_timer_end = Event(callback)
|
||||||
|
|
||||||
|
self:set_to(seconds_from)
|
||||||
|
self:set_interval(seconds_from, seconds_to)
|
||||||
|
|
||||||
|
if seconds_to - seconds_from == 0 then
|
||||||
|
self:set_state(false)
|
||||||
|
self.on_timer_end:trigger(self:get_context(), self)
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.update(self, dt)
|
||||||
|
if not self.is_on then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
self.temp = self.temp + dt
|
||||||
|
local dist = math.min(1, math.abs(self.value - self.target))
|
||||||
|
|
||||||
|
if self.temp > dist then
|
||||||
|
self.temp = self.temp - dist
|
||||||
|
self.value = helper.step(self.value, self.target, 1)
|
||||||
|
M.set_to(self, self.value)
|
||||||
|
|
||||||
|
self.on_tick:trigger(self:get_context(), self.value)
|
||||||
|
|
||||||
|
if self.value == self.target then
|
||||||
|
self:set_state(false)
|
||||||
|
self.on_timer_end:trigger(self:get_context(), self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set text to text field
|
||||||
|
-- @function timer:set_to
|
||||||
|
-- @tparam number set_to Value in seconds
|
||||||
|
function M.set_to(self, set_to)
|
||||||
|
self.last_value = set_to
|
||||||
|
gui.set_text(self.node, formats.second_string_min(set_to))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Called when update
|
||||||
|
-- @function timer:set_state
|
||||||
|
-- @tparam bool is_on Timer enable state
|
||||||
|
function M.set_state(self, is_on)
|
||||||
|
self.is_on = is_on
|
||||||
|
|
||||||
|
self.on_set_enabled:trigger(self:get_context(), is_on)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set time interval
|
||||||
|
-- @function timer:set_interval
|
||||||
|
-- @tparam number from Start time in seconds
|
||||||
|
-- @tparam number to Target time in seconds
|
||||||
|
function M.set_interval(self, from, to)
|
||||||
|
self.from = from
|
||||||
|
self.value = from
|
||||||
|
self.temp = 0
|
||||||
|
self.target = to
|
||||||
|
M.set_state(self, true)
|
||||||
|
M.set_to(self, from)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
171
druid/component.lua
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
--- Basic class for all Druid components.
|
||||||
|
-- To create you component, use `component.create`
|
||||||
|
-- @module component
|
||||||
|
|
||||||
|
local const = require("druid.const")
|
||||||
|
local class = require("druid.system.middleclass")
|
||||||
|
|
||||||
|
-- @classmod Component
|
||||||
|
local Component = class("druid.component")
|
||||||
|
|
||||||
|
|
||||||
|
--- Get current component style table
|
||||||
|
-- @function component:get_style
|
||||||
|
-- @treturn table Component style table
|
||||||
|
function Component.get_style(self)
|
||||||
|
if not self._meta.style then
|
||||||
|
return const.EMPTY_TABLE
|
||||||
|
end
|
||||||
|
|
||||||
|
return self._meta.style[self._component.name] or const.EMPTY_TABLE
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set current component style table
|
||||||
|
-- @function component:set_style
|
||||||
|
-- @tparam table style Druid style module
|
||||||
|
function Component.set_style(self, druid_style)
|
||||||
|
self._meta.style = druid_style
|
||||||
|
self._style = self:get_style()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Get current component template name
|
||||||
|
-- @function component:get_template
|
||||||
|
-- @treturn string Component template name
|
||||||
|
function Component.get_template(self)
|
||||||
|
return self._meta.template
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set current component template name
|
||||||
|
-- @function component:set_template
|
||||||
|
-- @tparam string template Component template name
|
||||||
|
function Component.set_template(self, template)
|
||||||
|
self._meta.template = template
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Get current component nodes
|
||||||
|
-- @function component:get_nodes
|
||||||
|
-- @treturn table Component nodes table
|
||||||
|
function Component.get_nodes(self)
|
||||||
|
return self._meta.nodes
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set current component nodes
|
||||||
|
-- @function component:set_nodes
|
||||||
|
-- @tparam table nodes Component nodes table
|
||||||
|
function Component.set_nodes(self, nodes)
|
||||||
|
self._meta.nodes = nodes
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Get current component context
|
||||||
|
-- @function component:get_context
|
||||||
|
-- @treturn table Component context
|
||||||
|
function Component.get_context(self, context)
|
||||||
|
return self._meta.context
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set current component context
|
||||||
|
-- @function component:set_context
|
||||||
|
-- @tparam table context Druid context. Usually it is self of script
|
||||||
|
function Component.set_context(self, context)
|
||||||
|
self._meta.context = context
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Get current component interests
|
||||||
|
-- @function component:get_interests
|
||||||
|
-- @treturn table List of component interests
|
||||||
|
function Component.get_interests(self)
|
||||||
|
return self._component.interest
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- TODO: Определиться с get_node и node
|
||||||
|
-- get_node - берет ноду по ноде или строке
|
||||||
|
-- node - может брать ноду у компонента по схеме (если есть
|
||||||
|
-- template или таблица нод после gui.clone_tree)
|
||||||
|
function Component.get_node(self, node_or_name)
|
||||||
|
local template_name = self:get_template() or const.EMPTY_STRING
|
||||||
|
local nodes = self:get_nodes()
|
||||||
|
|
||||||
|
if nodes then
|
||||||
|
assert(type(node_or_name) == "strings", "You should pass node name instead of node")
|
||||||
|
return nodes[template_name .. node_or_name]
|
||||||
|
else
|
||||||
|
if type(node_or_name) == const.STRING then
|
||||||
|
return gui.get_node(template_name .. node_or_name)
|
||||||
|
else
|
||||||
|
return node_or_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Return druid with context of calling component.
|
||||||
|
-- Use it to create component inside of other components.
|
||||||
|
-- @function component:get_druid
|
||||||
|
-- @treturn Druid Druid instance with component context
|
||||||
|
function Component.get_druid(self)
|
||||||
|
local context = { _context = self }
|
||||||
|
return setmetatable(context, { __index = self:get_context().druid })
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Setup component context and his style table
|
||||||
|
-- @function component:setup_component
|
||||||
|
-- @tparam context table Druid context. Usually it is self of script
|
||||||
|
-- @tparam style table Druid style module
|
||||||
|
-- @treturn Component Component itself
|
||||||
|
function Component.setup_component(self, context, style)
|
||||||
|
self._meta = {
|
||||||
|
template = nil,
|
||||||
|
context = nil,
|
||||||
|
nodes = nil,
|
||||||
|
style = nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
self:set_context(context)
|
||||||
|
self:set_style(style)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Basic constructor of component. It will call automaticaly
|
||||||
|
-- by `Component.static.create`
|
||||||
|
-- @function component:initialize
|
||||||
|
-- @tparam string name Component name
|
||||||
|
-- @tparam table interest List of component's interest
|
||||||
|
-- @local
|
||||||
|
function Component.initialize(self, name, interest)
|
||||||
|
self._component = {
|
||||||
|
name = name,
|
||||||
|
interest = interest
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Create new component. It will inheritance from basic
|
||||||
|
-- druid component.
|
||||||
|
-- @function Component.create
|
||||||
|
-- @tparam string name Component name
|
||||||
|
-- @tparam table interest List of component's interest
|
||||||
|
function Component.static.create(name, interest)
|
||||||
|
-- Yea, inheritance here
|
||||||
|
local new_class = class(name, Component)
|
||||||
|
|
||||||
|
new_class.initialize = function(self)
|
||||||
|
Component.initialize(self, name, interest)
|
||||||
|
end
|
||||||
|
|
||||||
|
return new_class
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return Component
|
@ -1,11 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
--- input handler
|
|
||||||
-- @param action_id - input action id
|
|
||||||
-- @param action - input action
|
|
||||||
function M.on_input(instance, action_id, action)
|
|
||||||
instance.callback(instance.parent.parent)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
@ -1,119 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
local ui_animate = require "druid.help_modules.druid_animate"
|
|
||||||
|
|
||||||
M.DEFAULT_SCALE_CHANGE = vmath.vector3(-0.05, - 0.1, 1)
|
|
||||||
M.DEFAULT_POS_CHANGE = vmath.vector3(0, - 10, 0)
|
|
||||||
M.DEFAULT_MOVE_SPEED = 5
|
|
||||||
M.DEFAULT_ALPHA_DOWN = 0.8
|
|
||||||
M.DEFAULT_TIME_ANIM = 0.1
|
|
||||||
M.DEFAULT_DEACTIVATE_COLOR = vmath.vector4(0, 0, 0, 0)
|
|
||||||
M.DEFAULT_DEACTIVATE_SCALE = vmath.vector3(0.8, 0.9, 1)
|
|
||||||
M.DEFAULT_ACTIVATE_SCALE = vmath.vector3(1, 1, 1)
|
|
||||||
M.DEFAUL_ACTIVATION_TIME = 0.2
|
|
||||||
|
|
||||||
--- Set text to text field
|
|
||||||
-- @param action_id - input action id
|
|
||||||
-- @param action - input action
|
|
||||||
function M.on_input(instance, action_id, action)
|
|
||||||
if gui.is_enabled(instance.node) and gui.pick_node(instance.node, action.x, action.y) then
|
|
||||||
if not instance.disabled then
|
|
||||||
instance.tap_anim(instance)
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
instance.sound_disable()
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.tap_scale_animation(instance)
|
|
||||||
ui_animate.scale_to(instance, instance.anim_node, instance.scale_to,
|
|
||||||
function()
|
|
||||||
if instance.back_anim then
|
|
||||||
instance.back_anim(instance)
|
|
||||||
end
|
|
||||||
instance.sound()
|
|
||||||
instance.callback(instance.parent.parent, instance.params, instance)
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.back_scale_animation(instance)
|
|
||||||
ui_animate.scale_to(instance, instance.anim_node, instance.scale_from)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.tap_tab_animation(instance, force)
|
|
||||||
ui_animate.alpha(instance, instance.anim_node, M.DEFAULT_ALPHA_DOWN, nil, M.DEFAULT_TIME_ANIM)
|
|
||||||
ui_animate.fly_to(instance, instance.anim_node, instance.pos + M.DEFAULT_POS_CHANGE, M.DEFAULT_MOVE_SPEED)
|
|
||||||
ui_animate.scale_to(instance, instance.anim_node, instance.scale_to,
|
|
||||||
function()
|
|
||||||
if instance.back_anim then
|
|
||||||
instance.back_anim(instance)
|
|
||||||
end
|
|
||||||
instance.callback(instance.parent.parent, instance.params, force)
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.back_tab_animation(instance)
|
|
||||||
ui_animate.alpha(instance, instance.anim_node, 1, nil, M.DEFAULT_TIME_ANIM)
|
|
||||||
ui_animate.fly_to(instance, instance.anim_node, instance.pos, M.DEFAULT_MOVE_SPEED)
|
|
||||||
ui_animate.scale_to(instance, instance.anim_node, instance.scale_from)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.deactivate(instance, is_animate, callback)
|
|
||||||
instance.disabled = true
|
|
||||||
if is_animate then
|
|
||||||
local counter = 0
|
|
||||||
local clbk = function()
|
|
||||||
counter = counter + 1
|
|
||||||
if counter == 3 and callback then
|
|
||||||
callback(instance.parent.parent)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
ui_animate.color(instance, instance.node, M.DEFAULT_DEACTIVATE_COLOR, clbk, M.DEFAUL_ACTIVATION_TIME, 0,
|
|
||||||
gui.EASING_OUTBOUNCE)
|
|
||||||
ui_animate.scale_y_from_to(instance, instance.node, M.DEFAULT_ACTIVATE_SCALE.x, M.DEFAULT_DEACTIVATE_SCALE.x, clbk,
|
|
||||||
M.DEFAUL_ACTIVATION_TIME, gui.EASING_OUTBOUNCE)
|
|
||||||
ui_animate.scale_x_from_to(instance, instance.node, M.DEFAULT_ACTIVATE_SCALE.y, M.DEFAULT_DEACTIVATE_SCALE.y, clbk,
|
|
||||||
M.DEFAUL_ACTIVATION_TIME, gui.EASING_OUTBOUNCE)
|
|
||||||
else
|
|
||||||
gui.set_color(instance.node, M.DEFAULT_DEACTIVATE_COLOR)
|
|
||||||
gui.set_scale(instance.node, M.DEFAULT_DEACTIVATE_SCALE)
|
|
||||||
if callback then
|
|
||||||
callback(instance.parent.parent)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.activate(instance, is_animate, callback)
|
|
||||||
if is_animate then
|
|
||||||
local counter = 0
|
|
||||||
local clbk = function()
|
|
||||||
counter = counter + 1
|
|
||||||
if counter == 3 then
|
|
||||||
instance.disabled = false
|
|
||||||
if callback then
|
|
||||||
callback(instance.parent.parent)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
ui_animate.color(instance, instance.node, ui_animate.TINT_SHOW, clbk, M.DEFAUL_ACTIVATION_TIME, 0,
|
|
||||||
gui.EASING_OUTBOUNCE)
|
|
||||||
ui_animate.scale_y_from_to(instance, instance.node, M.DEFAULT_DEACTIVATE_SCALE.x, M.DEFAULT_ACTIVATE_SCALE.x, clbk,
|
|
||||||
M.DEFAUL_ACTIVATION_TIME, gui.EASING_OUTBOUNCE)
|
|
||||||
ui_animate.scale_x_from_to(instance, instance.node, M.DEFAULT_DEACTIVATE_SCALE.y, M.DEFAULT_ACTIVATE_SCALE.y, clbk,
|
|
||||||
M.DEFAUL_ACTIVATION_TIME, gui.EASING_OUTBOUNCE)
|
|
||||||
else
|
|
||||||
gui.set_color(instance.node, ui_animate.TINT_SHOW)
|
|
||||||
gui.set_scale(instance.node, M.DEFAULT_ACTIVATE_SCALE)
|
|
||||||
instance.disabled = false
|
|
||||||
if callback then
|
|
||||||
callback(instance.parent.parent)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
@ -1,67 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
local text_field = require "druid.components.text_field"
|
|
||||||
|
|
||||||
local FRAMES = 60
|
|
||||||
|
|
||||||
--- Bounce text field
|
|
||||||
M.bounce = text_field.bounce
|
|
||||||
|
|
||||||
--- Set text to text field
|
|
||||||
-- @param set_to - set value to text field
|
|
||||||
M.set_to = text_field.set_to
|
|
||||||
|
|
||||||
--- Set color
|
|
||||||
-- @param color
|
|
||||||
M.set_color = text_field.set_color
|
|
||||||
|
|
||||||
--- Set scale
|
|
||||||
-- @param scale
|
|
||||||
M.set_scale = text_field.set_scale
|
|
||||||
|
|
||||||
--- Called when layout updated (rotate for example)
|
|
||||||
function M.on_layout_updated(instance)
|
|
||||||
text_field.on_layout_updated(instance)
|
|
||||||
if instance.last_value then
|
|
||||||
text_field.set_to(instance, instance.last_value)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Animate counter
|
|
||||||
-- @param set_to - set value to text field
|
|
||||||
function M.animate_to(instance, set_to, frames)
|
|
||||||
if set_to == instance.last_value then
|
|
||||||
text_field.set_to(instance, set_to)
|
|
||||||
elseif not instance.is_animate then
|
|
||||||
frames = frames or FRAMES
|
|
||||||
instance.end_anim_value = set_to
|
|
||||||
local diff = set_to - instance.last_value
|
|
||||||
instance.anim_step = math.floor((set_to - instance.last_value) / frames)
|
|
||||||
if diff ~= 0 and instance.anim_step == 0 then
|
|
||||||
instance.anim_step = diff > 0 and 1 or - 1
|
|
||||||
end
|
|
||||||
instance.is_animate = true
|
|
||||||
else
|
|
||||||
instance.end_anim_value = set_to
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Called when update
|
|
||||||
-- @param dt - delta time
|
|
||||||
function M.on_updated(instance, dt)
|
|
||||||
if instance.is_animate then
|
|
||||||
instance.last_value = instance.last_value + instance.anim_step
|
|
||||||
text_field.set_to(instance, instance.last_value)
|
|
||||||
if not instance.is_in_bounce then
|
|
||||||
instance.is_in_bounce = true
|
|
||||||
text_field.bounce(instance, function() instance.is_in_bounce = false end)
|
|
||||||
end
|
|
||||||
if instance.anim_step > 0 and instance.last_value >= instance.end_anim_value or
|
|
||||||
instance.anim_step < 0 and instance.last_value <= instance.end_anim_value then
|
|
||||||
instance.is_animate = false
|
|
||||||
text_field.set_to(instance, instance.end_anim_value)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
@ -1,52 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
local ui_animate = require "druid.help_modules.druid_animate"
|
|
||||||
|
|
||||||
local function fly_to(instance, pos_from, speed, callback)
|
|
||||||
local pos_to = instance.get_pos_func()
|
|
||||||
instance.last_speed = speed
|
|
||||||
instance.last_callback = callback
|
|
||||||
|
|
||||||
instance.last_particle = instance.last_particle + 1
|
|
||||||
if instance.last_particle > #instance.fly_particles then
|
|
||||||
instance.last_particle = 1
|
|
||||||
end
|
|
||||||
local fly_particle = instance.fly_particles[instance.last_particle]
|
|
||||||
if pos_from then
|
|
||||||
gui.set_position(fly_particle, pos_from)
|
|
||||||
end
|
|
||||||
gui.play_particlefx(fly_particle)
|
|
||||||
instance.is_anim = true
|
|
||||||
ui_animate.fly_to(nil, fly_particle, pos_to, speed,
|
|
||||||
function()
|
|
||||||
instance.is_anim = false
|
|
||||||
gui.stop_particlefx(fly_particle)
|
|
||||||
if callback then
|
|
||||||
callback(instance.parent.parent)
|
|
||||||
instance.last_callback = nil
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
0, gui.EASING_INSINE)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Start animation of a flying particles
|
|
||||||
-- @param pos_from - fly from this position
|
|
||||||
-- @param speed - speed of flying
|
|
||||||
-- @param callback - callback when progress ended if need
|
|
||||||
function M.fly_to(instance, pos_from, speed, callback)
|
|
||||||
fly_to(instance, pos_from, speed, callback)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Called when layout updated (rotate for example)
|
|
||||||
function M.on_layout_updated(instance)
|
|
||||||
if instance.is_anim then
|
|
||||||
instance.last_particle = instance.last_particle - 1
|
|
||||||
if instance.last_particle < 1 then
|
|
||||||
instance.last_particle = #instance.fly_particles
|
|
||||||
end
|
|
||||||
fly_to(instance, nil, instance.last_speed, instance.last_callback)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
return M
|
|
@ -1,46 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
local ui_animate = require "druid.help_modules.druid_animate"
|
|
||||||
|
|
||||||
--- Bounce image
|
|
||||||
function M.bounce(instance)
|
|
||||||
gui.set_scale(instance.node, instance.scale_from)
|
|
||||||
ui_animate.bounce(nil, instance.node, instance.scale_to)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Set image anim
|
|
||||||
-- @param set_to - index of animation or animation name
|
|
||||||
function M.set_to(instance, set_to)
|
|
||||||
instance.last_value = set_to
|
|
||||||
gui.play_flipbook(instance.node, instance.anim_table and instance.anim_table[set_to] or set_to)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Set position to the image
|
|
||||||
-- @param pos - set position of the image
|
|
||||||
function M.set_pos(instance, pos)
|
|
||||||
instance.last_pos = pos
|
|
||||||
gui.set_position(instance.node, pos)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Set tint to the image
|
|
||||||
-- @param color - set color of the image
|
|
||||||
function M.set_color(instance, color)
|
|
||||||
instance.last_color = color
|
|
||||||
gui.set_color(instance.node, color)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Called when layout updated (rotate for example)
|
|
||||||
function M.on_layout_updated(instance)
|
|
||||||
if instance.last_value then
|
|
||||||
M.set_to(instance, instance.last_value)
|
|
||||||
end
|
|
||||||
if instance.last_pos then
|
|
||||||
M.set_pos(instance, instance.last_pos)
|
|
||||||
end
|
|
||||||
if instance.last_color then
|
|
||||||
M.set_color(instance, instance.last_color)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
return M
|
|
@ -1,51 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
local FULL_FILL = 360
|
|
||||||
|
|
||||||
local function set_bar_to(instance, set_to)
|
|
||||||
instance.last_value = set_to
|
|
||||||
gui.cancel_animation(instance.node, gui.PROP_FILL_ANGLE)
|
|
||||||
gui.set_fill_angle(instance.node, FULL_FILL * set_to)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Fill a pie progress bar and stop progress animation
|
|
||||||
function M.fill_bar(instance)
|
|
||||||
set_bar_to(instance, 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- To empty a pie progress bar
|
|
||||||
function M.empty_bar(instance)
|
|
||||||
set_bar_to(instance, 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Set fill a pie progress bar to value
|
|
||||||
-- @param to - value between 0..1
|
|
||||||
function M.set_to(instance, to)
|
|
||||||
set_bar_to(instance, to)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Start animation of a pie progress bar
|
|
||||||
-- @param to - value between 0..1
|
|
||||||
-- @param duration - time of animation
|
|
||||||
-- @param callback - callback when progress ended if need
|
|
||||||
function M.start_progress_to(instance, to, duration, callback)
|
|
||||||
instance.is_anim = true
|
|
||||||
instance.last_value = to
|
|
||||||
gui.animate(instance.node, gui.PROP_FILL_ANGLE, FULL_FILL * to, gui.EASING_LINEAR, duration, 0,
|
|
||||||
function()
|
|
||||||
instance.is_anim = false
|
|
||||||
if callback then
|
|
||||||
callback(instance.parent.parent)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Called when layout updated (rotate for example)
|
|
||||||
function M.on_layout_updated(instance)
|
|
||||||
if not instance.is_anim then
|
|
||||||
set_bar_to(instance, instance.last_value)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
@ -1,93 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
local function set_bar_to(instance, set_to)
|
|
||||||
instance.last_value = set_to
|
|
||||||
gui.cancel_animation(instance.node, instance.prop)
|
|
||||||
instance.scale[instance.key] = set_to
|
|
||||||
gui.set_scale(instance.node, instance.scale)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function circle_anim(instance, full, steps, num, full_duration, callback)
|
|
||||||
local duration = (math.abs(steps[num - 1] - steps[num]) / full) * full_duration
|
|
||||||
local to = steps[num]
|
|
||||||
gui.animate(instance.node, instance.prop, to, gui.EASING_LINEAR, duration, 0,
|
|
||||||
function()
|
|
||||||
callback(num, callback)
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Fill a progress bar and stop progress animation
|
|
||||||
function M.fill_bar(instance)
|
|
||||||
set_bar_to(instance, 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- To empty a progress bar
|
|
||||||
function M.empty_bar(instance)
|
|
||||||
set_bar_to(instance, 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Set fill a progress bar to value
|
|
||||||
-- @param to - value between 0..1
|
|
||||||
function M.set_to(instance, to)
|
|
||||||
set_bar_to(instance, to)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Start animation of a progress bar
|
|
||||||
-- @param to - value between 0..1
|
|
||||||
-- @param duration - time of animation
|
|
||||||
-- @param callback - callback when progress ended if need
|
|
||||||
-- @param callback_values - whitch values should callback
|
|
||||||
function M.start_progress_to(instance, to, duration, callback, callback_values)
|
|
||||||
instance.is_anim = true
|
|
||||||
local steps
|
|
||||||
if callback_values then
|
|
||||||
steps = {instance.last_value}
|
|
||||||
if instance.last_value > to then
|
|
||||||
table.sort(callback_values, function(a, b) return a > b end)
|
|
||||||
else
|
|
||||||
table.sort(callback_values, function(a, b) return a < b end)
|
|
||||||
end
|
|
||||||
for i, v in ipairs(callback_values) do
|
|
||||||
if (instance.last_value > v and to < v) or (instance.last_value < v and to > v) then
|
|
||||||
steps[#steps + 1] = v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
steps[#steps + 1] = to
|
|
||||||
end
|
|
||||||
if not steps then
|
|
||||||
gui.animate(instance.node, instance.prop, to, gui.EASING_LINEAR, duration, 0,
|
|
||||||
function()
|
|
||||||
set_bar_to(instance, to)
|
|
||||||
instance.is_anim = false
|
|
||||||
if callback then
|
|
||||||
callback(instance.parent.parent, to)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
)
|
|
||||||
else
|
|
||||||
local full = math.abs(steps[1] - steps[#steps])
|
|
||||||
local _callback = function (num, _callback)
|
|
||||||
if num == #steps then
|
|
||||||
set_bar_to(instance, steps[num])
|
|
||||||
instance.is_anim = false
|
|
||||||
callback(instance.parent.parent, steps[num])
|
|
||||||
else
|
|
||||||
callback(instance.parent.parent, steps[num])
|
|
||||||
num = num + 1
|
|
||||||
circle_anim(instance, full, steps, num, duration, _callback)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
circle_anim(instance, full, steps, 2, duration, _callback)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Called when layout updated (rotate for example)
|
|
||||||
function M.on_layout_updated(instance)
|
|
||||||
if not instance.is_anim then
|
|
||||||
set_bar_to(instance, instance.last_value)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
return M
|
|
@ -1,241 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
local druid_input = require "druid.help_modules.druid_input"
|
|
||||||
local ui_animate = require "druid.help_modules.druid_animate"
|
|
||||||
|
|
||||||
M.START = hash("START")
|
|
||||||
M.FINISH = hash("FINISH")
|
|
||||||
|
|
||||||
M.SCROLLING = hash("SCROLLING")
|
|
||||||
M.INTEREST_MOVE = hash("INTEREST_MOVE")
|
|
||||||
M.OUT_OF_ZONE_MOVE = hash("OUT_OF_ZONE_MOVE")
|
|
||||||
|
|
||||||
M.BACK_TIME = 0.2
|
|
||||||
M.ANIM_TIME = 0.4
|
|
||||||
|
|
||||||
local function callback(instance, event, type, param)
|
|
||||||
if instance.callback then
|
|
||||||
instance.callback(instance.parent.parent, event, type, param)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function checkSwipeDirection(swipe, action)
|
|
||||||
swipe.xDistance = math.abs(swipe.endX - swipe.beginX)
|
|
||||||
swipe.yDistance = math.abs(swipe.endY - swipe.beginY)
|
|
||||||
if swipe.is_x and swipe.xDistance > swipe.yDistance then
|
|
||||||
if swipe.beginX > swipe.endX then
|
|
||||||
swipe.totalSwipeDistanceLeft = swipe.beginX - swipe.endX
|
|
||||||
if swipe.totalSwipeDistanceLeft > swipe.minSwipeDistance then
|
|
||||||
swipe.speed.x = action.dx * swipe.speed_up_coef.x * swipe.end_move_coef_x
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
else
|
|
||||||
swipe.totalSwipeDistanceRight = swipe.endX - swipe.beginX
|
|
||||||
if swipe.totalSwipeDistanceRight > swipe.minSwipeDistance then
|
|
||||||
swipe.speed.x = action.dx * swipe.speed_up_coef.x * swipe.end_move_coef_x
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif swipe.is_y and swipe.xDistance < swipe.yDistance then
|
|
||||||
if swipe.beginY > swipe.endY then
|
|
||||||
swipe.totalSwipeDistanceUp = swipe.beginY - swipe.endY
|
|
||||||
if swipe.totalSwipeDistanceUp > swipe.minSwipeDistance then
|
|
||||||
swipe.speed.y = action.dy * swipe.speed_up_coef.y * swipe.end_move_coef_y
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
else
|
|
||||||
swipe.totalSwipeDistanceDown = swipe.endY - swipe.beginY
|
|
||||||
if swipe.totalSwipeDistanceDown > swipe.minSwipeDistance then
|
|
||||||
swipe.speed.y = action.dy * swipe.speed_up_coef.y * swipe.end_move_coef_y
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function lenght(x1, y1, x2, y2)
|
|
||||||
local a, b = x1 - x2, y1 - y2
|
|
||||||
return math.sqrt(a * a + b * b)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function back_move(instance)
|
|
||||||
if not instance.swipe.end_position_x and not instance.swipe.end_position_y then
|
|
||||||
if instance.points_of_interest then
|
|
||||||
local min_index, min_lenght = 0, math.huge
|
|
||||||
local len
|
|
||||||
for k, v in pairs(instance.points_of_interest) do
|
|
||||||
len = lenght(instance.pos.x, instance.pos.y, v.x, v.y)
|
|
||||||
if len < min_lenght then
|
|
||||||
min_lenght = len
|
|
||||||
min_index = k
|
|
||||||
end
|
|
||||||
end
|
|
||||||
instance.swipe.speed.x = 0
|
|
||||||
instance.swipe.speed.y = 0
|
|
||||||
gui.cancel_animation(instance.node, gui.PROP_POSITION)
|
|
||||||
instance.swipe.special_move = true
|
|
||||||
callback(instance, M.START, M.INTEREST_MOVE, instance.points_of_interest[min_index])
|
|
||||||
gui.animate(instance.node, gui.PROP_POSITION, instance.points_of_interest[min_index],
|
|
||||||
gui.EASING_LINEAR, M.ANIM_TIME, 0,
|
|
||||||
function()
|
|
||||||
instance.swipe.special_move = false
|
|
||||||
instance.pos.x = instance.points_of_interest[min_index].x
|
|
||||||
instance.pos.y = instance.points_of_interest[min_index].y
|
|
||||||
callback(instance, M.FINISH, M.SCROLLING, instance.pos)
|
|
||||||
callback(instance, M.FINISH, M.INTEREST_MOVE, instance.pos)
|
|
||||||
end
|
|
||||||
)
|
|
||||||
else
|
|
||||||
callback(instance, M.FINISH, M.SCROLLING, instance.pos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if instance.swipe.end_position_x then
|
|
||||||
local swipe = instance.swipe
|
|
||||||
swipe.speed.x = 0
|
|
||||||
instance.pos.x = swipe.end_position_x
|
|
||||||
swipe.special_move = true
|
|
||||||
callback(instance, M.START, M.OUT_OF_ZONE_MOVE, instance.pos)
|
|
||||||
gui.animate(instance.node, ui_animate.PROP_POS_X, swipe.end_position_x, gui.EASING_INSINE, M.BACK_TIME, 0,
|
|
||||||
function()
|
|
||||||
swipe.special_move = false
|
|
||||||
callback(instance, M.FINISH, M.SCROLLING, instance.pos)
|
|
||||||
callback(instance, M.FINISH, M.OUT_OF_ZONE_MOVE, instance.pos)
|
|
||||||
end
|
|
||||||
)
|
|
||||||
swipe.end_position_x = nil
|
|
||||||
end
|
|
||||||
if instance.swipe.end_position_y then
|
|
||||||
local swipe = instance.swipe
|
|
||||||
swipe.speed.y = 0
|
|
||||||
instance.pos.y = swipe.end_position_y
|
|
||||||
swipe.special_move = true
|
|
||||||
callback(instance, M.START, M.OUT_OF_ZONE_MOVE, instance.pos)
|
|
||||||
gui.animate(instance.node, ui_animate.PROP_POS_Y, swipe.end_position_y, gui.EASING_INSINE, M.BACK_TIME, 0,
|
|
||||||
function()
|
|
||||||
swipe.special_move = false
|
|
||||||
callback(instance, M.FINISH, M.SCROLLING, instance.pos)
|
|
||||||
callback(instance, M.FINISH, M.OUT_OF_ZONE_MOVE, instance.pos)
|
|
||||||
end
|
|
||||||
)
|
|
||||||
swipe.end_position_y = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Set text to text field
|
|
||||||
-- @param action_id - input action id
|
|
||||||
-- @param action - input action
|
|
||||||
function M.on_input(instance, action_id, action)
|
|
||||||
if action_id == druid_input.A_CLICK then
|
|
||||||
if gui.pick_node(instance.scrolling_zone, action.x, action.y) then
|
|
||||||
local swipe = instance.swipe
|
|
||||||
if action.pressed then
|
|
||||||
swipe.pressed = true
|
|
||||||
swipe.beginX = action.x
|
|
||||||
swipe.beginY = action.y
|
|
||||||
druid_input.is_swipe = false
|
|
||||||
swipe.end_move_coef_x = 1
|
|
||||||
elseif not action.released and not action.pressed and not swipe.special_move then
|
|
||||||
swipe.endX = action.x
|
|
||||||
swipe.endY = action.y
|
|
||||||
local before = swipe.is_swipe
|
|
||||||
swipe.is_swipe = checkSwipeDirection(swipe, action)
|
|
||||||
if not before and swipe.is_swipe and not swipe.special_move and not swipe.waiting_for_back_move then
|
|
||||||
callback(instance, M.START, M.SCROLLING, instance.pos)
|
|
||||||
end
|
|
||||||
return swipe.is_swipe or swipe.special_move
|
|
||||||
elseif action.released then
|
|
||||||
swipe.beginX = 0
|
|
||||||
swipe.beginY = 0
|
|
||||||
swipe.endX = 0
|
|
||||||
swipe.endY = 0
|
|
||||||
swipe.pressed = false
|
|
||||||
if swipe.waiting_for_back_move then
|
|
||||||
back_move(instance)
|
|
||||||
swipe.waiting_for_back_move = false
|
|
||||||
end
|
|
||||||
return swipe.is_swipe or swipe.special_move
|
|
||||||
end
|
|
||||||
elseif action.released then
|
|
||||||
instance.swipe.pressed = false
|
|
||||||
if instance.swipe.waiting_for_back_move then
|
|
||||||
back_move(instance)
|
|
||||||
instance.swipe.waiting_for_back_move = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Called when update
|
|
||||||
-- @param dt - delta time
|
|
||||||
function M.on_updated(instance, dt)
|
|
||||||
if instance.swipe.speed.x ~= 0 or instance.swipe.speed.y ~= 0 then
|
|
||||||
local swipe = instance.swipe
|
|
||||||
instance.pos.x = instance.pos.x + swipe.speed.x
|
|
||||||
instance.pos.y = instance.pos.y + swipe.speed.y
|
|
||||||
if instance.pos.x < instance.start_pos.x then
|
|
||||||
swipe.end_move_coef_x = swipe.back_slow_coef
|
|
||||||
swipe.end_position_x = instance.start_pos.x
|
|
||||||
elseif instance.pos.x > instance.maximum.x then
|
|
||||||
swipe.end_move_coef_x = swipe.back_slow_coef
|
|
||||||
swipe.end_position_x = instance.maximum.x
|
|
||||||
else
|
|
||||||
swipe.end_move_coef_x = 1
|
|
||||||
swipe.end_position_x = nil
|
|
||||||
end
|
|
||||||
if instance.pos.y < instance.start_pos.y then
|
|
||||||
swipe.end_move_coef_y = swipe.back_slow_coef
|
|
||||||
swipe.end_position_y = instance.start_pos.y
|
|
||||||
elseif instance.pos.y > instance.maximum.y then
|
|
||||||
swipe.end_move_coef_y = swipe.back_slow_coef
|
|
||||||
swipe.end_position_y = instance.maximum.y
|
|
||||||
else
|
|
||||||
swipe.end_move_coef_y = 1
|
|
||||||
swipe.end_position_y = nil
|
|
||||||
end
|
|
||||||
gui.set_position(instance.node, instance.pos)
|
|
||||||
swipe.speed.x = swipe.speed.x / swipe.speed_down_coef * swipe.end_move_coef_x
|
|
||||||
swipe.speed.y = swipe.speed.y / swipe.speed_down_coef * swipe.end_move_coef_y
|
|
||||||
if swipe.speed.x < swipe.min_speed and swipe.speed.x > - swipe.min_speed then
|
|
||||||
swipe.speed.x = 0
|
|
||||||
if not swipe.pressed then
|
|
||||||
back_move(instance)
|
|
||||||
else
|
|
||||||
swipe.waiting_for_back_move = true
|
|
||||||
end
|
|
||||||
if swipe.speed.y < swipe.min_speed and swipe.speed.y > - swipe.min_speed then
|
|
||||||
swipe.speed.y = 0
|
|
||||||
end
|
|
||||||
if swipe.speed.y == 0 and swipe.speed.x == 0 then
|
|
||||||
swipe.is_swipe = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Scroll position to
|
|
||||||
-- @param pos - positon for set
|
|
||||||
-- @param is_animate - is animated set
|
|
||||||
function M.scroll_to(instance, pos, is_animate, cb, time_scrolling)
|
|
||||||
local time = is_animate and M.ANIM_TIME or 0
|
|
||||||
time = time_scrolling or time
|
|
||||||
instance.pos.x = pos.x
|
|
||||||
instance.pos.y = pos.y
|
|
||||||
gui.animate(instance.node, gui.PROP_POSITION, instance.pos, gui.EASING_INSINE, time, 0,
|
|
||||||
function()
|
|
||||||
if cb then
|
|
||||||
cb(instance.parent.parent)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
@ -1,62 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
--- Set animation scene
|
|
||||||
-- @param scene - animations scene
|
|
||||||
function M.set_scene(instance, scene)
|
|
||||||
instance.last_scene = scene
|
|
||||||
gui.set_spine_scene(instance.node, scene)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--- Set idle animation
|
|
||||||
-- @param anim - idle animation name or index in idle table
|
|
||||||
-- @param properties - properties of the animation
|
|
||||||
function M.play_idle(instance, anim, properties)
|
|
||||||
if not anim then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
anim = (instance.idle_table and instance.idle_table[anim]) and instance.idle_table[anim] or anim
|
|
||||||
instance.last_value = anim
|
|
||||||
properties = properties or {}
|
|
||||||
gui.play_spine_anim(instance.node, anim, gui.PLAYBACK_LOOP_FORWARD, properties)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Set active animation
|
|
||||||
-- @param anim - active animation name or index in active table
|
|
||||||
-- @param callback - call when animation done
|
|
||||||
-- @param idle_after - set idle after active anim
|
|
||||||
function M.play_active(instance, anim, callback, idle_after)
|
|
||||||
instance.is_play_now = true
|
|
||||||
anim = instance.active_table and instance.active_table[anim] or anim
|
|
||||||
instance.last_value = anim
|
|
||||||
instance.callback = callback
|
|
||||||
M.play_idle(instance, idle_after)
|
|
||||||
gui.play_spine_anim(instance.node, anim, gui.PLAYBACK_ONCE_FORWARD, {},
|
|
||||||
function()
|
|
||||||
M.play_idle(instance, idle_after)
|
|
||||||
instance.is_play_now = false
|
|
||||||
if callback then
|
|
||||||
callback(instance.parent.parent)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Called when layout updated (rotate for example)
|
|
||||||
function M.on_layout_updated(instance)
|
|
||||||
if instance.last_scene then
|
|
||||||
M.set_scene(instance, instance.last_scene)
|
|
||||||
end
|
|
||||||
if instance.last_value then
|
|
||||||
M.play_idle(instance, instance.last_value)
|
|
||||||
end
|
|
||||||
if instance.is_play_now then
|
|
||||||
instance.is_play_now = false
|
|
||||||
if instance.callback then
|
|
||||||
instance.callback(instance.parent.parent)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
return M
|
|
@ -1,92 +0,0 @@
|
|||||||
--[[ Single tab screen module. Assumed to be used with Tab Bar module.
|
|
||||||
|
|
||||||
-- Create tab screen with parental gui node:
|
|
||||||
self.tab = tab.create "tab_bkg"
|
|
||||||
|
|
||||||
-- Show and hide tab manually:
|
|
||||||
self.tab.slide_in(self, vmath.vector3(0, -540, 0))
|
|
||||||
self.tab.slide_out(self, vmath.vector3(0, -540, 0))
|
|
||||||
|
|
||||||
-- Or receive show and hide messages:
|
|
||||||
function on_message(self, message_id, message, sender)
|
|
||||||
self.tab.on_message(self, message_id, message)
|
|
||||||
end
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
local M = {}
|
|
||||||
M.T_SLIDE_IN = hash("t_slide_in")
|
|
||||||
M.T_SLIDE_OUT = hash("t_slide_out")
|
|
||||||
|
|
||||||
M.STATE_START = hash("state_start")
|
|
||||||
M.STATE_FINISH = hash("state_finish")
|
|
||||||
|
|
||||||
local ENABLE = hash("enable")
|
|
||||||
local DISABLE = hash("disable")
|
|
||||||
local PATH_COMP = "#"
|
|
||||||
|
|
||||||
M.DEFAULT_EASING = gui.EASING_INOUTQUAD
|
|
||||||
M.DEFAULT_DURATION = 0.3
|
|
||||||
|
|
||||||
function M.slide_in(instance, out_pos, is_force)
|
|
||||||
msg.post(PATH_COMP, ENABLE)
|
|
||||||
if instance.callback then
|
|
||||||
instance.callback(instance.parent.parent, instance, M.T_SLIDE_IN, M.STATE_START)
|
|
||||||
end
|
|
||||||
if is_force then
|
|
||||||
gui.set_position(instance.node, instance.in_pos)
|
|
||||||
if instance.callback then
|
|
||||||
instance.callback(instance.parent.parent, instance, M.T_SLIDE_IN, M.STATE_FINISH)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
instance.in_action = true
|
|
||||||
out_pos = out_pos or instance.put_pos
|
|
||||||
gui.set_position(instance.node, out_pos or instance.out_pos)
|
|
||||||
gui.animate(instance.node, gui.PROP_POSITION, instance.in_pos, instance.easing, instance.duration, 0,
|
|
||||||
function()
|
|
||||||
instance.in_action = false
|
|
||||||
if instance.callback then
|
|
||||||
instance.callback(instance.parent.parent, instance, M.T_SLIDE_IN, M.STATE_FINISH)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.slide_out(instance, out_pos, is_force)
|
|
||||||
out_pos = out_pos or instance.put_pos
|
|
||||||
if instance.callback then
|
|
||||||
instance.callback(instance.parent.parent, instance, M.T_SLIDE_OUT, M.STATE_START)
|
|
||||||
end
|
|
||||||
if is_force then
|
|
||||||
gui.set_position(instance.node, out_pos)
|
|
||||||
if instance.callback then
|
|
||||||
instance.callback(instance.parent.parent, instance, M.T_SLIDE_OUT, M.STATE_FINISH)
|
|
||||||
end
|
|
||||||
msg.post(PATH_COMP, DISABLE)
|
|
||||||
else
|
|
||||||
instance.in_action = true
|
|
||||||
gui.set_position(instance.node, instance.in_pos)
|
|
||||||
gui.animate(instance.node, gui.PROP_POSITION, out_pos, instance.easing, instance.duration, 0,
|
|
||||||
function()
|
|
||||||
instance.in_action = false
|
|
||||||
if instance.callback then
|
|
||||||
instance.callback(instance.parent.parent, instance, M.T_SLIDE_OUT, M.STATE_FINISH)
|
|
||||||
end
|
|
||||||
msg.post(PATH_COMP, DISABLE)
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.on_message(instance, message_id, message, sender)
|
|
||||||
if message_id == M.T_SLIDE_IN then
|
|
||||||
M.slide_in(instance, message.out_pos, message.is_force)
|
|
||||||
return true
|
|
||||||
elseif message_id == M.T_SLIDE_OUT then
|
|
||||||
M.slide_out(instance, message.out_pos, message.is_force)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
@ -1,50 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
--local helper = require "modules.render.helper"
|
|
||||||
local tab_page = require "druid.components.tab_page"
|
|
||||||
|
|
||||||
local DISABLE = hash("disable")
|
|
||||||
|
|
||||||
function M.update_sizes(instance, width)
|
|
||||||
-- width = width or helper.config_x
|
|
||||||
instance.left = vmath.vector3(width * - 1, 0, 0)
|
|
||||||
instance.right = vmath.vector3(width * 1, 0, 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Called when layout updated (rotate for example)
|
|
||||||
function M.on_layout_updated(instance, message)
|
|
||||||
-- local width = helper.settings_x
|
|
||||||
M.update_sizes(instance, width)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.switch_tab(instance, params, force)
|
|
||||||
if instance.current == params then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if instance.current then
|
|
||||||
instance.btns[instance.current.index]:manual_back()
|
|
||||||
end
|
|
||||||
local out_pos
|
|
||||||
if instance.current and instance.current.url then
|
|
||||||
out_pos = (instance.current and instance.current.index < params.index) and instance.left or instance.right
|
|
||||||
msg.post(instance.current.url, tab_page.T_SLIDE_OUT, { out_pos = out_pos, is_force = force })
|
|
||||||
end
|
|
||||||
if params and params.url then
|
|
||||||
out_pos = (instance.current and instance.current.index > params.index) and instance.left or instance.right
|
|
||||||
msg.post(params.url, tab_page.T_SLIDE_IN, { out_pos = out_pos, is_force = force })
|
|
||||||
instance.current = params
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Select current tab manually
|
|
||||||
function M.select(instance, node_name)
|
|
||||||
for k, v in pairs(instance.btns) do
|
|
||||||
if k == instance[node_name].index then
|
|
||||||
v:tap_anim(true)
|
|
||||||
else
|
|
||||||
msg.post(instance[v.name].url, DISABLE)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
@ -1,42 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
local ui_animate = require "druid.help_modules.druid_animate"
|
|
||||||
|
|
||||||
--- Bounce text field
|
|
||||||
function M.bounce(instance, callback)
|
|
||||||
gui.set_scale(instance.node, instance.scale_from)
|
|
||||||
ui_animate.bounce(nil, instance.node, instance.scale_to, callback)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Set text to text field
|
|
||||||
-- @param set_to - set value to text field
|
|
||||||
function M.set_to(instance, set_to)
|
|
||||||
instance.last_value = set_to
|
|
||||||
gui.set_text(instance.node, set_to)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Set color
|
|
||||||
-- @param color
|
|
||||||
function M.set_color(instance, color)
|
|
||||||
instance.last_color = color
|
|
||||||
gui.set_color(instance.node, color)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Set scale
|
|
||||||
-- @param scale
|
|
||||||
function M.set_scale(instance, scale)
|
|
||||||
instance.last_scale = scale
|
|
||||||
gui.set_scale(instance.node, scale)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Called when layout updated (rotate for example)
|
|
||||||
function M.on_layout_updated(instance)
|
|
||||||
if instance.last_color then
|
|
||||||
M.set_color(instance, instance.last_color)
|
|
||||||
end
|
|
||||||
if instance.last_scale then
|
|
||||||
M.set_scale(instance, instance.last_scale)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
@ -1,53 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
local formats = require "druid.help_modules.formats"
|
|
||||||
|
|
||||||
--- Set text to text field
|
|
||||||
-- @param set_to - set value in seconds
|
|
||||||
function M.set_to(instance, set_to)
|
|
||||||
instance.last_value = set_to
|
|
||||||
gui.set_text(instance.node, formats.second_string_min(set_to))
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Called when layout updated (rotate for example)
|
|
||||||
function M.on_layout_updated(instance)
|
|
||||||
M.set_to(instance, instance.last_value)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Called when update
|
|
||||||
-- @param is_on - boolean is timer on
|
|
||||||
function M.set_work_mode(instance, is_on)
|
|
||||||
instance.is_on = is_on
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Set time interval
|
|
||||||
-- @param from - "from" time in seconds
|
|
||||||
-- @param to - "to" time in seconds
|
|
||||||
function M.set_interval(instance, from, to)
|
|
||||||
instance.second_from = from
|
|
||||||
instance.seconds_counter = from
|
|
||||||
instance.seconds_temp = 0
|
|
||||||
instance.seconds_to = to
|
|
||||||
instance.second_step = from < to and 1 or - 1
|
|
||||||
M.set_work_mode(instance, true)
|
|
||||||
M.set_to(instance, from)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Called when update
|
|
||||||
-- @param dt - delta time
|
|
||||||
function M.on_updated(instance, dt)
|
|
||||||
if instance.is_on then
|
|
||||||
instance.seconds_temp = instance.seconds_temp + dt
|
|
||||||
if instance.seconds_temp > 1 then
|
|
||||||
instance.seconds_temp = instance.seconds_temp - 1
|
|
||||||
instance.seconds_counter = instance.seconds_counter + instance.second_step
|
|
||||||
M.set_to(instance, instance.seconds_counter)
|
|
||||||
if instance.seconds_counter == instance.seconds_to then
|
|
||||||
instance.is_on = false
|
|
||||||
instance.callback(instance)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
67
druid/const.lua
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
--- Druid constants
|
||||||
|
-- @local
|
||||||
|
-- @module const
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.ACTION_TOUCH = hash("touch")
|
||||||
|
M.ACTION_TEXT = hash("text")
|
||||||
|
M.ACTION_BACKSPACE = hash("backspace")
|
||||||
|
M.ACTION_ENTER = hash("enter")
|
||||||
|
M.ACTION_BACK = hash("back")
|
||||||
|
|
||||||
|
|
||||||
|
M.RELEASED = "released"
|
||||||
|
M.PRESSED = "pressed"
|
||||||
|
M.STRING = "string"
|
||||||
|
M.TABLE = "table"
|
||||||
|
M.ZERO = "0"
|
||||||
|
M.ALL = "all"
|
||||||
|
|
||||||
|
|
||||||
|
--- Component Interests
|
||||||
|
M.ON_MESSAGE = hash("on_message")
|
||||||
|
M.ON_UPDATE = hash("on_update")
|
||||||
|
M.ON_INPUT_HIGH = hash("on_input_high")
|
||||||
|
M.ON_INPUT = hash("on_input")
|
||||||
|
M.ON_CHANGE_LANGUAGE = hash("on_change_language")
|
||||||
|
M.ON_LAYOUT_CHANGED = hash("on_layout_changed")
|
||||||
|
|
||||||
|
|
||||||
|
M.PIVOTS = {
|
||||||
|
[gui.PIVOT_CENTER] = vmath.vector3(0),
|
||||||
|
[gui.PIVOT_N] = vmath.vector3(0, 0.5, 0),
|
||||||
|
[gui.PIVOT_NE] = vmath.vector3(0.5, 0.5, 0),
|
||||||
|
[gui.PIVOT_E] = vmath.vector3(0.5, 0, 0),
|
||||||
|
[gui.PIVOT_SE] = vmath.vector3(0.5, -0.5, 0),
|
||||||
|
[gui.PIVOT_S] = vmath.vector3(0, -0.5, 0),
|
||||||
|
[gui.PIVOT_SW] = vmath.vector3(-0.5, -0.5, 0),
|
||||||
|
[gui.PIVOT_W] = vmath.vector3(-0.5, 0, 0),
|
||||||
|
[gui.PIVOT_NW] = vmath.vector3(-0.5, 0.5, 0),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
M.SPECIFIC_UI_MESSAGES = {
|
||||||
|
[M.ON_CHANGE_LANGUAGE] = "on_change_language",
|
||||||
|
[M.ON_LAYOUT_CHANGED] = "on_layout_changed"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
M.UI_INPUT = {
|
||||||
|
[M.ON_INPUT_HIGH] = true,
|
||||||
|
[M.ON_INPUT] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
M.SIDE = {
|
||||||
|
X = "x",
|
||||||
|
Y = "y"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
M.EMPTY_FUNCTION = function() end
|
||||||
|
M.EMPTY_STRING = ""
|
||||||
|
M.EMPTY_TABLE = {}
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
471
druid/druid.lua
@ -1,420 +1,83 @@
|
|||||||
|
--- Druid UI Library.
|
||||||
|
-- Powerful Defold component based UI library. Use standart
|
||||||
|
-- components or make your own game-specific components to
|
||||||
|
-- make amazing GUI in your games.
|
||||||
|
--
|
||||||
|
-- Contains the several basic components and examples
|
||||||
|
-- to how to do your custom complex components to
|
||||||
|
-- separate UI game logic to small files
|
||||||
|
--
|
||||||
|
-- require("druid.druid")
|
||||||
|
-- function init(self)
|
||||||
|
-- self.druid = druid.new(self)
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- @module druid
|
||||||
|
|
||||||
|
local const = require("druid.const")
|
||||||
|
local druid_instance = require("druid.system.druid_instance")
|
||||||
|
local settings = require("druid.system.settings")
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local druid_input = require "druid.help_modules.druid_input"
|
|
||||||
M.input = druid_input
|
|
||||||
|
|
||||||
local pie_progress_bar = require "druid.components.pie_progress_bar"
|
--- Register external druid component.
|
||||||
local progress_bar = require "druid.components.progress_bar"
|
-- After register you can create the component with
|
||||||
local flying_particles = require "druid.components.flying_particles"
|
-- druid_instance:new_{name}. For example `druid:new_button(...)`
|
||||||
local text_field = require "druid.components.text_field"
|
-- @function druid:register
|
||||||
local counter = require "druid.components.counter"
|
-- @tparam string name module name
|
||||||
local image = require "druid.components.image"
|
-- @tparam table module lua table with component
|
||||||
local button = require "druid.components.button"
|
function M.register(name, module)
|
||||||
local timer = require "druid.components.timer"
|
-- TODO: Find better solution to creating elements?
|
||||||
local tab_page = require "druid.components.tab_page"
|
-- Possibly: druid.new(druid.BUTTON, etc?)
|
||||||
local tabs_container = require "druid.components.tabs_container"
|
-- Current way is very implicit
|
||||||
local spine_anim = require "druid.components.spine_anim"
|
druid_instance["new_" .. name] = function(self, ...)
|
||||||
local scrolling_box = require "druid.components.scrolling_box"
|
return druid_instance.create(self, module, ...)
|
||||||
|
end
|
||||||
|
|
||||||
local andr_back_btn = require "druid.components.andr_back_btn"
|
-- print("Register component", name)
|
||||||
|
|
||||||
local LAYOUT_CHANGED = hash("layout_changed")
|
|
||||||
local ON_MESSAGE = hash("on_message")
|
|
||||||
local ON_INPUT = hash("on_input")
|
|
||||||
local ON_SWIPE = hash("on_swipe")
|
|
||||||
local ON_UPDATE = hash("on_update")
|
|
||||||
M.TRANSLATABLE = hash("TRANSLATABLE")
|
|
||||||
|
|
||||||
local STRING = "string"
|
|
||||||
|
|
||||||
--- Call this method when you need to update translations.
|
|
||||||
function M.translate(factory)
|
|
||||||
if factory[M.TRANSLATABLE] then
|
|
||||||
local key, result
|
|
||||||
for i, v in ipairs(factory[M.TRANSLATABLE]) do
|
|
||||||
key = v.lang_key or v.name
|
|
||||||
if key then
|
|
||||||
if v.lang_params then
|
|
||||||
result = lang.txp(key, v.lang_params)
|
|
||||||
else
|
|
||||||
result = lang.txt(key)
|
|
||||||
end
|
|
||||||
if result then
|
|
||||||
lang.set_node_properties(v.node, key)
|
|
||||||
end
|
|
||||||
result = result or v.last_value
|
|
||||||
v:set_to(result)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Called on_message
|
|
||||||
function M.on_message(factory, message_id, message, sender)
|
--- Create Druid instance.
|
||||||
if message_id == LAYOUT_CHANGED then
|
-- @function druid.new
|
||||||
if factory[LAYOUT_CHANGED] then
|
-- @tparam table context Druid context. Usually it is self of script
|
||||||
M.translate(factory)
|
-- @tparam[opt] table style Druid style module
|
||||||
for i, v in ipairs(factory[LAYOUT_CHANGED]) do
|
-- @treturn druid_instance Druid instance
|
||||||
v:on_layout_updated(message)
|
function M.new(context, style)
|
||||||
end
|
return druid_instance(context, style)
|
||||||
end
|
|
||||||
elseif message_id == M.TRANSLATABLE then
|
|
||||||
M.translate(factory)
|
|
||||||
else
|
|
||||||
if factory[ON_MESSAGE] then
|
|
||||||
for i, v in ipairs(factory[ON_MESSAGE]) do
|
|
||||||
v:on_message(message_id, message, sender)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Called ON_INPUT
|
|
||||||
function M.on_input(factory, action_id, action)
|
-- Set new default style.
|
||||||
if factory[ON_SWIPE] then
|
-- @function druid.set_default_style
|
||||||
local v, result
|
-- @tparam table style Druid style module
|
||||||
local len = #factory[ON_SWIPE]
|
function M.set_default_style(style)
|
||||||
for i = 1, len do
|
settings.default_style = style
|
||||||
v = factory[ON_SWIPE][i]
|
|
||||||
result = result or v:on_input(action_id, action)
|
|
||||||
end
|
|
||||||
if result then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if factory[ON_INPUT] then
|
|
||||||
local v
|
|
||||||
local len = #factory[ON_INPUT]
|
|
||||||
for i = 1, len do
|
|
||||||
v = factory[ON_INPUT][i]
|
|
||||||
if action_id == v.event and action[v.action] and v:on_input(action_id, action) then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Called on_update
|
|
||||||
function M.on_update(factory, dt)
|
-- Set text function.
|
||||||
if factory[ON_UPDATE] then
|
-- Druid locale component will call this function
|
||||||
for i, v in ipairs(factory[ON_UPDATE]) do
|
-- to get translated text. After set_text_funtion
|
||||||
v:on_updated(dt)
|
-- all existing locale component will be updated
|
||||||
end
|
-- @function druid.set_text_function(callback)
|
||||||
end
|
-- @tparam function callback Get localized text function
|
||||||
|
function M.set_text_function(callback)
|
||||||
|
settings.get_text = callback or const.EMPTY_FUNCTION
|
||||||
|
-- TODO: Update all localized text
|
||||||
|
-- Need to store all current druid instances to iterate over it?
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create UI instance for ui elements
|
|
||||||
-- @return instance with all ui components
|
-- Set sound function.
|
||||||
function M.new(self)
|
-- Component will call this function to
|
||||||
local factory = setmetatable({}, {__index = M})
|
-- play sound by sound_id
|
||||||
factory.parent = self
|
-- @function druid.set_sound_function
|
||||||
return factory
|
-- @tparam function callback Sound play callback
|
||||||
|
function M.set_sound_function(callback)
|
||||||
|
settings.play_sound = callback or const.EMPTY_FUNCTION
|
||||||
end
|
end
|
||||||
|
|
||||||
local function input_init(factory)
|
|
||||||
if not factory.input_inited then
|
|
||||||
factory.input_inited = true
|
|
||||||
druid_input.focus()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
local function create(meta, factory, name, ...)
|
|
||||||
local instance = setmetatable({}, {__index = meta})
|
|
||||||
instance.parent = factory
|
|
||||||
if name then
|
|
||||||
if type(name) == STRING then
|
|
||||||
instance.name = name
|
|
||||||
instance.node = gui.get_node(name)
|
|
||||||
else
|
|
||||||
--name already is node
|
|
||||||
instance.name = nil
|
|
||||||
instance.node = name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
factory[#factory + 1] = instance
|
|
||||||
local register_to = {...}
|
|
||||||
for i, v in ipairs(register_to) do
|
|
||||||
if not factory[v] then
|
|
||||||
factory[v] = {}
|
|
||||||
end
|
|
||||||
factory[v][#factory[v] + 1] = instance
|
|
||||||
end
|
|
||||||
return instance
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Create new instance of a text_field
|
|
||||||
-- @param factory - parent factory
|
|
||||||
-- @param name - name of text node
|
|
||||||
-- @param init_value - init ui object with this value
|
|
||||||
-- @return instance of a text_field
|
|
||||||
function M.new_text_field(factory, name, init_value, bounce_in)
|
|
||||||
local instance = create(text_field, factory, name, M.TRANSLATABLE, LAYOUT_CHANGED)
|
|
||||||
instance.scale_from = gui.get_scale(instance.node)
|
|
||||||
instance.scale_to = bounce_in and vmath.mul_per_elem(instance.scale_from, bounce_in) or instance.scale_from
|
|
||||||
instance:set_to(init_value or 0)
|
|
||||||
return instance
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Create new instance of a counter
|
|
||||||
-- @param factory - parent factory
|
|
||||||
-- @param name - name of text node
|
|
||||||
-- @param init_value - init ui object with this value
|
|
||||||
-- @return instance of a text_field
|
|
||||||
function M.new_counter(factory, name, init_value)
|
|
||||||
local instance = create(counter, factory, name, LAYOUT_CHANGED, ON_UPDATE)
|
|
||||||
instance.scale_from = gui.get_scale(instance.node)
|
|
||||||
instance.scale_to = instance.scale_from * 1.2
|
|
||||||
instance:set_to(init_value or 0)
|
|
||||||
return instance
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Create new instance of an image
|
|
||||||
-- @param factory - parent factory
|
|
||||||
-- @param name - name of image node
|
|
||||||
-- @param anim_table - table with animations or frames
|
|
||||||
-- @param init_frame - init with this frame
|
|
||||||
-- @return instance of an image
|
|
||||||
function M.new_image(factory, name, anim_table, init_frame, bounce_in)
|
|
||||||
local instance = create(image, factory, name, LAYOUT_CHANGED)
|
|
||||||
instance.scale_from = gui.get_scale(instance.node)
|
|
||||||
instance.scale_to = bounce_in and vmath.mul_per_elem(instance.scale_from, bounce_in) or instance.scale_from
|
|
||||||
instance.anim_table = anim_table
|
|
||||||
if init_frame then
|
|
||||||
instance:set_to(init_frame)
|
|
||||||
elseif anim_table then
|
|
||||||
instance:set_to(1)
|
|
||||||
end
|
|
||||||
return instance
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Create new instance of a timer
|
|
||||||
-- @param factory - parent factory
|
|
||||||
-- @param name - name of image node
|
|
||||||
-- @param second_from - start time
|
|
||||||
-- @param seconds_to - end time
|
|
||||||
-- @param callback - call when timer finished
|
|
||||||
-- @return instance of a timer
|
|
||||||
function M.new_timer(factory, name, second_from, seconds_to, callback)
|
|
||||||
local instance = create(timer, factory, name, LAYOUT_CHANGED, ON_UPDATE)
|
|
||||||
instance:set_to(second_from)
|
|
||||||
instance:set_interval(second_from, seconds_to)
|
|
||||||
instance.is_on = true
|
|
||||||
instance.callback = callback
|
|
||||||
return instance
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Add new pie progress component for handling
|
|
||||||
-- @param factory - parent factory
|
|
||||||
-- @param name - a node name for a pie progress instance
|
|
||||||
-- @param init_value - init ui object with this value
|
|
||||||
-- @return instance with pie_progress
|
|
||||||
function M.new_pie_progress(factory, name, init_value)
|
|
||||||
local instance = create(pie_progress_bar, factory, name, LAYOUT_CHANGED)
|
|
||||||
instance:set_to(init_value or 1)
|
|
||||||
return instance
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Add new progress bar component for handling
|
|
||||||
-- @param factory - parent factory
|
|
||||||
-- @param name - name of the fill node
|
|
||||||
-- @param key - x or y - key for scale
|
|
||||||
-- @param init_value - init ui object with this value
|
|
||||||
-- @return instance with pie_progress
|
|
||||||
function M.new_progress_bar(factory, name, key, init_value)
|
|
||||||
local instance = create(progress_bar, factory, name, LAYOUT_CHANGED)
|
|
||||||
instance.prop = hash("scale."..key)
|
|
||||||
instance.key = key
|
|
||||||
instance.node = gui.get_node(name)
|
|
||||||
instance.scale = gui.get_scale(instance.node)
|
|
||||||
instance:set_to(init_value or 1)
|
|
||||||
return instance
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Create new instance of a flying particles
|
|
||||||
-- @param factory - parent factory
|
|
||||||
-- @param name - name of prototype
|
|
||||||
-- @param count - how many particles need to cache
|
|
||||||
-- @param get_pos_func - function that returns target pos for flying
|
|
||||||
-- @return instance of a flying particles
|
|
||||||
function M.new_flying_particles(factory, name, count, get_pos_func)
|
|
||||||
local instance = create(flying_particles, factory, name, LAYOUT_CHANGED)
|
|
||||||
instance.get_pos_func = get_pos_func
|
|
||||||
local node = instance.node
|
|
||||||
instance.node = node
|
|
||||||
instance.fly_particles = {}
|
|
||||||
instance.fly_particles[1] = node
|
|
||||||
for i = 2, count do
|
|
||||||
instance.fly_particles[i] = gui.clone(node)
|
|
||||||
end
|
|
||||||
instance.scale = gui.get_scale(node)
|
|
||||||
instance.last_particle = 0
|
|
||||||
return instance
|
|
||||||
end
|
|
||||||
|
|
||||||
M.BTN_SOUND_FUNC = function() end
|
|
||||||
M.BTN_SOUND_DISABLE_FUNC = function()end
|
|
||||||
|
|
||||||
--- Add new button component for handling
|
|
||||||
-- @param factory - parent factory
|
|
||||||
-- @param name - a node name for a button instance
|
|
||||||
-- @param callback - click button callback
|
|
||||||
-- @param params - callback parameters, will be returned with self callback(self, params)
|
|
||||||
-- @param animate_node_name - node for animation, if it's not a main node
|
|
||||||
-- @return instance of button
|
|
||||||
function M.new_button(factory, name, callback, params, animate_node_name, event, action, sound, sound_disable)
|
|
||||||
input_init(factory)
|
|
||||||
local instance = create(button, factory, name, ON_INPUT)
|
|
||||||
instance.event = event or druid_input.A_CLICK
|
|
||||||
instance.action = action or druid_input.RELEASED
|
|
||||||
instance.anim_node = animate_node_name and gui.get_node(animate_node_name) or instance.node
|
|
||||||
instance.scale_from = gui.get_scale(instance.anim_node)
|
|
||||||
instance.scale_to = instance.scale_from + button.DEFAULT_SCALE_CHANGE
|
|
||||||
instance.pos = gui.get_position(instance.anim_node)
|
|
||||||
instance.callback = callback
|
|
||||||
instance.params = params
|
|
||||||
instance.tap_anim = button.tap_scale_animation
|
|
||||||
instance.back_anim = button.back_scale_animation
|
|
||||||
instance.sound = sound or M.BTN_SOUND_FUNC
|
|
||||||
instance.sound_disable = sound_disable or M.BTN_SOUND_DISABLE_FUNC
|
|
||||||
return instance
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Add reaction for back btn (on Android for example)
|
|
||||||
-- @param factory - parent factory
|
|
||||||
-- @param callback - tap button callback
|
|
||||||
function M.new_back_handler(factory, callback)
|
|
||||||
input_init(factory)
|
|
||||||
local instance = create(andr_back_btn, factory, nil, ON_INPUT)
|
|
||||||
instance.event = druid_input.A_ANDR_BACK
|
|
||||||
instance.action = druid_input.RELEASED
|
|
||||||
instance.callback = callback
|
|
||||||
return instance
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Create new tab page instance
|
|
||||||
-- @param factory - parent factory
|
|
||||||
-- @param name - name of parental node that represents tab page content
|
|
||||||
-- @param easing - easing for tab page
|
|
||||||
-- @param duration - duration of animation for tab page
|
|
||||||
-- @param callback - call when change page
|
|
||||||
-- @return instance that represents the tab page
|
|
||||||
function M.new_tab_page(factory, name, easing, duration, callback)
|
|
||||||
local instance = create(tab_page, factory, name, M.EVENTS.ON_MESSAGE)
|
|
||||||
instance.in_pos = gui.get_position(instance.node)
|
|
||||||
instance.out_pos = gui.get_position(instance.node)
|
|
||||||
instance.easing = easing or tab_page.DEFAULT_EASING
|
|
||||||
instance.duration = duration or tab_page.DEFAULT_DURATION
|
|
||||||
instance.callback = callback
|
|
||||||
return instance
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Create new tab btns container instance
|
|
||||||
-- @param factory - parent factory
|
|
||||||
-- @param name - name of parental node that represents tab btns container
|
|
||||||
-- @return instance that represents the tab btns container
|
|
||||||
function M.new_tabs_container(factory, name, callback)
|
|
||||||
local instance = create(tabs_container, factory, name, LAYOUT_CHANGED)
|
|
||||||
instance:update_sizes()
|
|
||||||
instance.url = msg.url()
|
|
||||||
--- Create new tab btn instance
|
|
||||||
-- @param name - name of parental node that represents tab btn
|
|
||||||
-- @return instance that represents the tab btn
|
|
||||||
function instance.new_tab_btn(_instance, _name, url, index)
|
|
||||||
local params = {url = url, index = index, name = _name}
|
|
||||||
local btn = M.new_button(factory, _name, nil, params)
|
|
||||||
btn.back_anim = nil
|
|
||||||
btn.manual_back = button.back_tab_animation
|
|
||||||
btn.tap_anim = button.tap_tab_animation
|
|
||||||
btn.callback = function(_, _, force)
|
|
||||||
instance.switch_tab(instance, params, force)
|
|
||||||
if callback then
|
|
||||||
callback(factory.parent, index, force)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
instance[_name] = params
|
|
||||||
if not instance.btns then
|
|
||||||
instance.btns = {}
|
|
||||||
end
|
|
||||||
instance.btns[index] = btn
|
|
||||||
return btn
|
|
||||||
end
|
|
||||||
|
|
||||||
return instance
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Add new spine animation
|
|
||||||
-- @param factory - parent factory
|
|
||||||
-- @param name - a node name for a spine anim
|
|
||||||
-- @param idle_table - table with idle animations
|
|
||||||
-- @param active_table - table with active animations
|
|
||||||
-- @param init_idle - init idle animation name or index in idle table
|
|
||||||
-- @return instance with spine anim
|
|
||||||
function M.new_spine_anim(factory, name, idle_table, active_table, init_idle)
|
|
||||||
local instance = create(spine_anim, factory, name, LAYOUT_CHANGED)
|
|
||||||
instance.idle_table = idle_table
|
|
||||||
instance.active_table = active_table
|
|
||||||
instance:play_idle(init_idle)
|
|
||||||
return instance
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Add new scrolling box
|
|
||||||
-- @param factory - parent factory
|
|
||||||
-- @param name - a node name for a spine anim
|
|
||||||
-- @param zone_name - node name of zone for tap
|
|
||||||
-- @param speed_coef - vector3 coef. of speed for scrolling
|
|
||||||
-- @param maximum - vector3 maximum position for scrolling
|
|
||||||
-- @param points_of_interest - table with vector3 point of interes
|
|
||||||
-- @param callback - scrolling events callback
|
|
||||||
-- @return instance with scrolling box
|
|
||||||
function M.new_scrolling_box(factory, name, zone_name, speed_coef, maximum, points_of_interest, callback)
|
|
||||||
local instance = create(scrolling_box, factory, name, ON_UPDATE, ON_SWIPE)
|
|
||||||
instance.pos = gui.get_position(instance.node)
|
|
||||||
instance.start_pos = vmath.vector3(instance.pos)
|
|
||||||
instance.maximum = maximum
|
|
||||||
instance.points_of_interest = points_of_interest
|
|
||||||
instance.callback = callback
|
|
||||||
if instance.start_pos.x > instance.maximum.x then
|
|
||||||
instance.start_pos.x, instance.maximum.x = instance.maximum.x, instance.start_pos.x
|
|
||||||
end
|
|
||||||
if instance.start_pos.y > instance.maximum.y then
|
|
||||||
instance.start_pos.y, instance.maximum.y = instance.maximum.y, instance.start_pos.y
|
|
||||||
end
|
|
||||||
if type(name) == STRING then
|
|
||||||
instance.scrolling_zone = gui.get_node(zone_name)
|
|
||||||
else
|
|
||||||
instance.scrolling_zone = zone_name
|
|
||||||
end
|
|
||||||
instance.swipe = {
|
|
||||||
minSwipeDistance = 40,
|
|
||||||
speed_down_coef = 1.1,
|
|
||||||
speed_up_coef = speed_coef or vmath.vector3(1.1, 1.1, 0),
|
|
||||||
speed = vmath.vector3(0, 0, 0),
|
|
||||||
maximum = vmath.vector3(0, 0, 0),
|
|
||||||
min_speed = 2,
|
|
||||||
beginX = 0,
|
|
||||||
beginY = 0,
|
|
||||||
endX = 0,
|
|
||||||
endY = 0,
|
|
||||||
xDistance = nil,
|
|
||||||
yDistance = nil,
|
|
||||||
totalSwipeDistanceLeft = nil,
|
|
||||||
totalSwipeDistanceRight = nil,
|
|
||||||
totalSwipeDistanceUp = nil,
|
|
||||||
totalSwipeDistanceDown = nil,
|
|
||||||
is_swipe = nil,
|
|
||||||
end_move_coef_x = 1,
|
|
||||||
end_move_coef_y = 1,
|
|
||||||
back_slow_coef = 0.4,
|
|
||||||
end_position_x = nil,
|
|
||||||
end_position_y = nil,
|
|
||||||
is_x = instance.start_pos.x ~= instance.maximum.x,
|
|
||||||
is_y = instance.start_pos.y ~= instance.maximum.y
|
|
||||||
}
|
|
||||||
return instance
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
71
druid/event.lua
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
--- Lua event small library
|
||||||
|
-- @module druid_event
|
||||||
|
|
||||||
|
local class = require("druid.system.middleclass")
|
||||||
|
|
||||||
|
-- @class DruidEvent
|
||||||
|
local M = class("druid.event")
|
||||||
|
|
||||||
|
|
||||||
|
--- Event constructur
|
||||||
|
-- @function Event
|
||||||
|
-- @tparam function initial_callback Subscribe the callback on new event, if callback exist
|
||||||
|
function M.initialize(self, initial_callback)
|
||||||
|
self._callbacks = {}
|
||||||
|
|
||||||
|
if initial_callback then
|
||||||
|
self:subscribe(initial_callback)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Subscribe callback on event
|
||||||
|
-- @function event:subscribe
|
||||||
|
-- @tparam function callback Callback itself
|
||||||
|
function M.subscribe(self, callback)
|
||||||
|
assert(type(self) == "table", "You should subscribe to event with : syntax")
|
||||||
|
assert(type(callback) == "function", "Callback should be function")
|
||||||
|
|
||||||
|
table.insert(self._callbacks, callback)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Unsubscribe callback on event
|
||||||
|
-- @function event:unsubscribe
|
||||||
|
-- @tparam function callback Callback itself
|
||||||
|
function M.unsubscribe(self, callback)
|
||||||
|
for i = 1, #self._callbacks do
|
||||||
|
if self._callbacks[i] == callback then
|
||||||
|
table.remove(self._callbacks, i)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Return true, if event have at lease one handler
|
||||||
|
-- @function event:is_exist
|
||||||
|
-- @treturn bool True if event have handlers
|
||||||
|
function M.is_exist(self)
|
||||||
|
return #self._callbacks > 0
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Clear the all event handlers
|
||||||
|
-- @function event:clear
|
||||||
|
function M.clear(self)
|
||||||
|
self._callbacks = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Trigger the event and call all subscribed callbacks
|
||||||
|
-- @function event:trigger
|
||||||
|
-- @param ... All event params
|
||||||
|
function M.trigger(self, ...)
|
||||||
|
for i = 1, #self._callbacks do
|
||||||
|
self._callbacks[i](...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
@ -1,169 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
local PROP_SCALE = gui.PROP_SCALE
|
|
||||||
local PROP_POSITION = gui.PROP_POSITION
|
|
||||||
M.PROP_POS_X = hash("position.x")
|
|
||||||
M.PROP_POS_Y = hash("position.y")
|
|
||||||
M.PROP_ALPHA = hash("color.w")
|
|
||||||
local PROP_COLOR = hash("color")
|
|
||||||
local PROP_SCALE_X = "scale.x"
|
|
||||||
local PROP_SCALE_Y = "scale.y"
|
|
||||||
|
|
||||||
M.TINT_HIDE = vmath.vector4(1, 1, 1, 0)
|
|
||||||
M.TINT_SHOW = vmath.vector4(1, 1, 1, 1)
|
|
||||||
|
|
||||||
M.V3_ONE = vmath.vector3(1, 1, 1)
|
|
||||||
M.V3_ZERO = vmath.vector3(0, 0, 1)
|
|
||||||
|
|
||||||
M.SCALE_ANIMATION_TIME = 0.1
|
|
||||||
M.BOUNCE_ANIMATION_TIME = 0.25
|
|
||||||
M.ALPHA_ANIMATION_TIME = 0.25
|
|
||||||
|
|
||||||
function M.alpha(self, node, alpha, callback, time, delay, easing, playback)
|
|
||||||
time = time or M.ALPHA_ANIMATION_TIME
|
|
||||||
delay = delay or 0
|
|
||||||
easing = easing or gui.EASING_LINEAR
|
|
||||||
playback = playback or gui.PLAYBACK_ONCE_FORWARD
|
|
||||||
gui.animate(node, M.PROP_ALPHA, alpha, easing, time, delay,
|
|
||||||
function()
|
|
||||||
if callback then
|
|
||||||
callback(self, node)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
playback)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.color(self, node, color, callback, time, delay, easing, playback)
|
|
||||||
time = time or M.ALPHA_ANIMATION_TIME
|
|
||||||
delay = delay or 0
|
|
||||||
easing = easing or gui.EASING_LINEAR
|
|
||||||
playback = playback or gui.PLAYBACK_ONCE_FORWARD
|
|
||||||
gui.animate(node, PROP_COLOR, color, easing, time, delay,
|
|
||||||
function()
|
|
||||||
if callback then
|
|
||||||
callback(self, node)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
playback)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.shake(self, node, callback, str, time)
|
|
||||||
str = str or - 30
|
|
||||||
time = time or 0.25
|
|
||||||
local pos = gui.get_position(node)
|
|
||||||
pos.x = pos.x + str
|
|
||||||
gui.animate(node, PROP_POSITION, pos, gui.EASING_INELASTIC, time,
|
|
||||||
0,
|
|
||||||
function()
|
|
||||||
if callback then
|
|
||||||
callback(self)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
gui.PLAYBACK_ONCE_BACKWARD
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.bounce(self, node, change_to, callback, time, easing, playback, delaly)
|
|
||||||
time = time or M.BOUNCE_ANIMATION_TIME
|
|
||||||
delaly = delaly or 0
|
|
||||||
easing = easing or gui.EASING_OUTSINE
|
|
||||||
playback = playback or gui.PLAYBACK_ONCE_PINGPONG
|
|
||||||
gui.animate(node, PROP_SCALE, change_to, easing, time, delaly,
|
|
||||||
function()
|
|
||||||
if callback then
|
|
||||||
callback(self)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
playback)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.fly_to(self, node, to_pos, speed, callback, delay, easing)
|
|
||||||
easing = easing or gui.EASING_OUTSINE
|
|
||||||
delay = delay or 0
|
|
||||||
local time = vmath.length(to_pos - gui.get_position(node)) / 100 / speed
|
|
||||||
gui.animate(node, gui.PROP_POSITION, to_pos, easing, time, delay,
|
|
||||||
function()
|
|
||||||
if callback then
|
|
||||||
callback(self, node)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.fly_by_x(self, node, to_x, time, callback, delay, easing, playback)
|
|
||||||
playback = playback or gui.PLAYBACK_ONCE_FORWARD
|
|
||||||
easing = easing or gui.EASING_OUTSINE
|
|
||||||
delay = delay or 0
|
|
||||||
gui.animate(node, M.PROP_POS_X, to_x, easing, time, delay,
|
|
||||||
function()
|
|
||||||
if callback then
|
|
||||||
callback(self, node)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
playback)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.fly_by_y(self, node, to_y, time, callback, delay, easing, playback)
|
|
||||||
playback = playback or gui.PLAYBACK_ONCE_FORWARD
|
|
||||||
easing = easing or gui.EASING_OUTSINE
|
|
||||||
delay = delay or 0
|
|
||||||
time = time or 0.25
|
|
||||||
gui.animate(node, M.PROP_POS_Y, to_y, easing, time, delay,
|
|
||||||
function()
|
|
||||||
if callback then
|
|
||||||
callback(self, node)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
playback)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.scale_to(self, node, to, callback, time, delay, easing)
|
|
||||||
easing = easing or gui.EASING_INSINE
|
|
||||||
time = time or M.SCALE_ANIMATION_TIME
|
|
||||||
delay = delay or 0
|
|
||||||
time = time or 0.25
|
|
||||||
gui.animate(node, PROP_SCALE, to, easing, time, delay,
|
|
||||||
function()
|
|
||||||
if callback then
|
|
||||||
callback(self, node)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.scale_x_from_to(self, node, from, to, callback, time, easing, delay, playback)
|
|
||||||
easing = easing or gui.EASING_INSINE
|
|
||||||
time = time or M.SCALE_ANIMATION_TIME
|
|
||||||
delay = delay or 0
|
|
||||||
playback = playback or gui.PLAYBACK_ONCE_FORWARD
|
|
||||||
local scale = gui.get_scale(node)
|
|
||||||
scale.x = from
|
|
||||||
gui.set_scale(node, scale)
|
|
||||||
gui.animate(node, PROP_SCALE_X, to, easing, time, delay,
|
|
||||||
function()
|
|
||||||
if callback then
|
|
||||||
callback(self)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
playback
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.scale_y_from_to(self, node, from, to, callback, time, easing, delay, playback)
|
|
||||||
easing = easing or gui.EASING_INSINE
|
|
||||||
time = time or M.SCALE_ANIMATION_TIME
|
|
||||||
delay = delay or 0
|
|
||||||
playback = playback or gui.PLAYBACK_ONCE_FORWARD
|
|
||||||
local scale = gui.get_scale(node)
|
|
||||||
scale.y = from
|
|
||||||
gui.set_scale(node, scale)
|
|
||||||
gui.animate(node, PROP_SCALE_Y, to, easing, time, delay,
|
|
||||||
function()
|
|
||||||
if callback then
|
|
||||||
callback(self)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
playback
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
@ -1,24 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
local ADD_FOCUS = hash("acquire_input_focus")
|
|
||||||
local REMOVE_FOCUS = hash("release_input_focus")
|
|
||||||
local PATH_OBJ = "."
|
|
||||||
|
|
||||||
M.A_CLICK = hash("click")
|
|
||||||
M.A_TEXT = hash("text")
|
|
||||||
M.A_BACKSPACE = hash("backspace")
|
|
||||||
M.A_ENTER = hash("enter")
|
|
||||||
M.A_ANDR_BACK = hash("back")
|
|
||||||
|
|
||||||
M.RELEASED = "released"
|
|
||||||
M.PRESSED = "pressed"
|
|
||||||
|
|
||||||
function M.focus()
|
|
||||||
msg.post(PATH_OBJ, ADD_FOCUS)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.remove()
|
|
||||||
msg.post(PATH_OBJ, REMOVE_FOCUS)
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
@ -1,34 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
local ZERO = "0"
|
|
||||||
|
|
||||||
-- Return number with zero number prefix
|
|
||||||
-- @param num - number for conversion
|
|
||||||
-- @param count - count of numerals
|
|
||||||
-- @return string with need count of zero (1,3) -> 001
|
|
||||||
function M.add_prefix_zeros(num, count)
|
|
||||||
local result = tostring(num)
|
|
||||||
for i = string.len(result), count - 1 do
|
|
||||||
result = ZERO..result
|
|
||||||
end
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Convert seconds to string minutes:seconds
|
|
||||||
-- @param num - number of seconds
|
|
||||||
-- @return string minutes:seconds
|
|
||||||
function M.second_string_min(sec)
|
|
||||||
local mins = math.floor(sec / 60)
|
|
||||||
local seconds = math.floor(sec - mins * 60)
|
|
||||||
return string.format("%.2d:%.2d", mins, seconds)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Interpolate string with named Parameters in Table
|
|
||||||
-- @param s - string for interpolate
|
|
||||||
-- @param tab - table with parameters
|
|
||||||
-- @return string with replaced parameters
|
|
||||||
function M.interpolate_strinng(s, tab)
|
|
||||||
return (s:gsub('($%b{})', function(w) return tab[w:sub(3, -2)] or w end))
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
@ -1,16 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
function M.centrate_text_with_icon(text_node, icon_node)
|
|
||||||
local metr = gui.get_text_metrics_from_node(text_node)
|
|
||||||
local scl = gui.get_scale(text_node).x
|
|
||||||
local scl_i = gui.get_scale(icon_node).x
|
|
||||||
local pos_i = gui.get_position(icon_node)
|
|
||||||
local pos = gui.get_position(text_node)
|
|
||||||
local w = metr.width * scl * scl_i
|
|
||||||
local icon_w = gui.get_size(icon_node).x * scl_i
|
|
||||||
local width = w + icon_w + (math.abs(pos.x) - icon_w / 2) * scl_i
|
|
||||||
pos_i.x = width / 2 - (icon_w / 2)
|
|
||||||
gui.set_position(icon_node, pos_i)
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
155
druid/helper.lua
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
-- Druid helper module for gui layouts
|
||||||
|
-- @module helper
|
||||||
|
|
||||||
|
local const = require("druid.const")
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
|
||||||
|
--- Text node or icon node can be nil
|
||||||
|
local function get_text_width(text_node)
|
||||||
|
if text_node then
|
||||||
|
local text_metrics = gui.get_text_metrics_from_node(text_node)
|
||||||
|
local text_scale = gui.get_scale(text_node).x
|
||||||
|
return text_metrics.width * text_scale
|
||||||
|
end
|
||||||
|
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function get_icon_width(icon_node)
|
||||||
|
if icon_node then
|
||||||
|
local icon_scale_x = gui.get_scale(icon_node).x
|
||||||
|
return gui.get_size(icon_node).x * icon_scale_x -- icon width
|
||||||
|
end
|
||||||
|
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Center two nodes.
|
||||||
|
-- Nodes will be center around 0 x position
|
||||||
|
-- text_node will be first (at left side)
|
||||||
|
-- @function helper.centrate_text_with_icon
|
||||||
|
-- @tparam[opt] text text_node Gui text node
|
||||||
|
-- @tparam[opt] box icon_node Gui box node
|
||||||
|
-- @tparam number margin Offset between nodes
|
||||||
|
function M.centrate_text_with_icon(text_node, icon_node, margin)
|
||||||
|
margin = margin or 0
|
||||||
|
local text_width = get_text_width(text_node)
|
||||||
|
local icon_width = get_icon_width(icon_node)
|
||||||
|
local width = text_width + icon_width
|
||||||
|
|
||||||
|
if text_node then
|
||||||
|
local pos = gui.get_position(text_node)
|
||||||
|
pos.x = -width/2 + text_width - margin/2
|
||||||
|
gui.set_position(text_node, pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
if icon_node then
|
||||||
|
local icon_pos = gui.get_position(icon_node)
|
||||||
|
icon_pos.x = width/2 - icon_width + margin/2
|
||||||
|
gui.set_position(icon_node, icon_pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Center two nodes.
|
||||||
|
-- Nodes will be center around 0 x position
|
||||||
|
-- icon_node will be first (at left side)
|
||||||
|
-- @function helper.centrate_icon_with_text
|
||||||
|
-- @tparam[opt] box icon_node Gui box node
|
||||||
|
-- @tparam[opt] text text_node Gui text node
|
||||||
|
-- @tparam[opt=0] number margin Offset between nodes
|
||||||
|
function M.centrate_icon_with_text(icon_node, text_node, margin)
|
||||||
|
margin = margin or 0
|
||||||
|
local icon_width = get_icon_width(icon_node)
|
||||||
|
local text_width = get_text_width(text_node)
|
||||||
|
local width = text_width + icon_width
|
||||||
|
|
||||||
|
if text_node then
|
||||||
|
local pos = gui.get_position(text_node)
|
||||||
|
pos.x = width/2 - text_width + margin/2
|
||||||
|
gui.set_position(text_node, pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
if icon_node then
|
||||||
|
local icon_pos = gui.get_position(icon_node)
|
||||||
|
icon_pos.x = -width/2 + icon_width - margin/2
|
||||||
|
gui.set_position(icon_node, icon_pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.step(current, target, step)
|
||||||
|
if current < target then
|
||||||
|
return math.min(current + step, target)
|
||||||
|
else
|
||||||
|
return math.max(target, current - step)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.clamp(a, min, max)
|
||||||
|
if min > max then
|
||||||
|
min, max = max, min
|
||||||
|
end
|
||||||
|
|
||||||
|
if a >= min and a <= max then
|
||||||
|
return a
|
||||||
|
elseif a < min then
|
||||||
|
return min
|
||||||
|
else
|
||||||
|
return max
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.distance(x1, y1, x2, y2)
|
||||||
|
return math.sqrt((x2 - x1) ^ 2 + (y2 - y1) ^ 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.sign(val)
|
||||||
|
if val == 0 then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
return (val < 0) and -1 or 1
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.round(num, numDecimalPlaces)
|
||||||
|
local mult = 10^(numDecimalPlaces or 0)
|
||||||
|
return math.floor(num * mult + 0.5) / mult
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Check if node is enabled in gui hierarchy.
|
||||||
|
-- Return false, if node or any his parent is disabled
|
||||||
|
-- @function helper.is_enabled
|
||||||
|
-- @tparam node node Gui node
|
||||||
|
-- @treturn bool Is enabled in hierarchy
|
||||||
|
function M.is_enabled(node)
|
||||||
|
local is_enabled = gui.is_enabled(node)
|
||||||
|
local parent = gui.get_parent(node)
|
||||||
|
while parent and is_enabled do
|
||||||
|
is_enabled = is_enabled and gui.is_enabled(parent)
|
||||||
|
parent = gui.get_parent(parent)
|
||||||
|
end
|
||||||
|
|
||||||
|
return is_enabled
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Get node offset for given gui pivot
|
||||||
|
-- @function helper.get_pivot_offset
|
||||||
|
-- @tparam gui.pivot pivot The node pivot
|
||||||
|
-- @treturn vector3 Vector offset with [-1..1] values
|
||||||
|
function M.get_pivot_offset(pivot)
|
||||||
|
return const.PIVOTS[pivot]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
22
druid/helper/druid_input.lua
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
--- Druid inner module to acquire/release input
|
||||||
|
-- @module helper.input
|
||||||
|
-- @local
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
local ADD_FOCUS = hash("acquire_input_focus")
|
||||||
|
local REMOVE_FOCUS = hash("release_input_focus")
|
||||||
|
local PATH_OBJ = "."
|
||||||
|
|
||||||
|
|
||||||
|
function M.focus()
|
||||||
|
msg.post(PATH_OBJ, ADD_FOCUS)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.remove()
|
||||||
|
msg.post(PATH_OBJ, REMOVE_FOCUS)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
45
druid/helper/formats.lua
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
--- Druid module with utils on string formats
|
||||||
|
-- @local
|
||||||
|
-- @module helper.formats
|
||||||
|
|
||||||
|
local const = require("druid.const")
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
|
||||||
|
--- Return number with zero number prefix
|
||||||
|
-- @function formats.add_prefix_zeros
|
||||||
|
-- @tparam number num Number for conversion
|
||||||
|
-- @tparam number count Count of numerals
|
||||||
|
-- @return string with need count of zero (1,3) -> 001
|
||||||
|
function M.add_prefix_zeros(num, count)
|
||||||
|
local result = tostring(num)
|
||||||
|
for i = string.len(result), count - 1 do
|
||||||
|
result = const.ZERO .. result
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Convert seconds to string minutes:seconds
|
||||||
|
-- @function formats.second_string_min
|
||||||
|
-- @tparam number sec Seconds
|
||||||
|
-- @return string minutes:seconds
|
||||||
|
function M.second_string_min(sec)
|
||||||
|
local mins = math.floor(sec / 60)
|
||||||
|
local seconds = math.floor(sec - mins * 60)
|
||||||
|
return string.format("%.2d:%.2d", mins, seconds)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Interpolate string with named Parameters in Table
|
||||||
|
-- @function formats.second_string_min
|
||||||
|
-- @tparam string s Target string
|
||||||
|
-- @tparam table tab Table with parameters
|
||||||
|
-- @return string with replaced parameters
|
||||||
|
function M.interpolate_string(s, tab)
|
||||||
|
return (s:gsub('($%b{})', function(w) return tab[w:sub(3, -2)] or w end))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
38
druid/styles/default/anims.lua
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
|
||||||
|
local function scale_to(self, node, to, callback, time, delay, easing)
|
||||||
|
easing = easing or gui.EASING_INSINE
|
||||||
|
time = time or M.SCALE_ANIMATION_TIME
|
||||||
|
delay = delay or 0
|
||||||
|
time = time or 0.25
|
||||||
|
gui.animate(node, gui.PROP_SCALE, to, easing, time, delay,
|
||||||
|
function()
|
||||||
|
if callback then
|
||||||
|
callback(self, node)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.back_scale_animation(self, node, target_scale)
|
||||||
|
scale_to(self, node, target_scale)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.tap_scale_animation(self, node, target_scale)
|
||||||
|
scale_to(self, node, target_scale,
|
||||||
|
function()
|
||||||
|
M.back_scale_animation(self, node, self.scale_from)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.hover_scale(self, target, time)
|
||||||
|
gui.animate(self.anim_node, "scale", target, gui.EASING_OUTSINE, time)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
78
druid/styles/default/style.lua
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
local settings = require("druid.system.settings")
|
||||||
|
local anims = require("druid.styles.default.anims")
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
|
||||||
|
M["button"] = {
|
||||||
|
HOVER_SCALE = vmath.vector3(-0.025, -0.025, 1),
|
||||||
|
HOVER_TIME = 0.05,
|
||||||
|
SCALE_CHANGE = vmath.vector3(-0.05, -0.05, 1),
|
||||||
|
BTN_SOUND = "click",
|
||||||
|
BTN_SOUND_DISABLED = "click",
|
||||||
|
DISABLED_COLOR = vmath.vector4(0, 0, 0, 1),
|
||||||
|
ENABLED_COLOR = vmath.vector4(1),
|
||||||
|
LONGTAP_TIME = 0.4,
|
||||||
|
AUTOHOLD_TRIGGER = 0.8,
|
||||||
|
DOUBLETAP_TIME = 0.4,
|
||||||
|
IS_HOVER = true,
|
||||||
|
|
||||||
|
on_hover = function(self, node, state)
|
||||||
|
local scale_to = self.scale_from + M.button.HOVER_SCALE
|
||||||
|
|
||||||
|
local target_scale = state and scale_to or self.scale_from
|
||||||
|
anims.hover_scale(self, target_scale, M.button.HOVER_TIME)
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_click = function(self, node)
|
||||||
|
local scale_to = self.scale_from + M.button.SCALE_CHANGE
|
||||||
|
anims.tap_scale_animation(self, node, scale_to)
|
||||||
|
settings.play_sound(M.button.BTN_SOUND)
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_click_disabled = function(self, node)
|
||||||
|
settings.play_sound(M.button.BTN_SOUND_DISABLED)
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_set_enabled = function(self, node, state)
|
||||||
|
if state then
|
||||||
|
gui.set_color(node, M.button.ENABLED_COLOR)
|
||||||
|
else
|
||||||
|
gui.set_color(node, M.button.DISABLED_COLOR)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
M["scroll"] = {
|
||||||
|
FRICT_HOLD = 0.8, -- mult. for inert, while touching
|
||||||
|
FRICT = 0.93, -- mult for free inert
|
||||||
|
INERT_THRESHOLD = 2, -- speed to stop inertion
|
||||||
|
INERT_SPEED = 25, -- koef. of inert speed
|
||||||
|
DEADZONE = 6, -- in px
|
||||||
|
SOFT_ZONE_SIZE = 160, -- size of outside zone (back move)
|
||||||
|
BACK_SPEED = 0.2, -- lerp speed
|
||||||
|
ANIM_SPEED = 0.3, -- gui.animation speed to point
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
M["progress"] = {
|
||||||
|
SPEED = 5, -- progress bar fill rate, more faster
|
||||||
|
MIN_DELTA = 0.005
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
M["progress_rich"] = {
|
||||||
|
DELAY = 1, -- delay in seconds before main fill
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
M["checkbox"] = {
|
||||||
|
on_change_state = function(self, node, state)
|
||||||
|
local target = state and 1 or 0
|
||||||
|
gui.animate(node, "color.w", target, gui.EASING_OUTSINE, 0.1)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
45
druid/styles/empty/style.lua
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
|
||||||
|
M["button"] = {
|
||||||
|
BTN_SOUND = "click",
|
||||||
|
BTN_SOUND_DISABLED = "click",
|
||||||
|
DISABLED_COLOR = vmath.vector4(0, 0, 0, 1),
|
||||||
|
ENABLED_COLOR = vmath.vector4(1),
|
||||||
|
LONGTAP_TIME = 0.4,
|
||||||
|
DOUBLETAP_TIME = 0.4,
|
||||||
|
IS_HOVER = false,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
M["scroll"] = {
|
||||||
|
FRICT_HOLD = 0, -- mult. for inert, while touching
|
||||||
|
FRICT = 0, -- mult for free inert
|
||||||
|
INERT_THRESHOLD = 2, -- speed to stop inertion
|
||||||
|
INERT_SPEED = 0, -- koef. of inert speed
|
||||||
|
DEADZONE = 6, -- in px
|
||||||
|
SOFT_ZONE_SIZE = 20, -- size of outside zone (back move)
|
||||||
|
BACK_SPEED = 0, -- lerp speed
|
||||||
|
ANIM_SPEED = 0, -- gui.animation speed to point
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
M["progress"] = {
|
||||||
|
SPEED = 5, -- progress bar fill rate, more faster
|
||||||
|
MIN_DELTA = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
M["progress_rich"] = {
|
||||||
|
DELAY = 0, -- delay in seconds before main fill
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
M["checkbox"] = {
|
||||||
|
on_change_state = function(self, node, state)
|
||||||
|
gui.set_enabled(node, state)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
52
druid/styles/sprites/style.lua
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
|
||||||
|
M["button"] = {
|
||||||
|
BTN_SOUND = "click",
|
||||||
|
BTN_SOUND_DISABLED = "click",
|
||||||
|
DISABLED_COLOR = vmath.vector4(0, 0, 0, 1),
|
||||||
|
ENABLED_COLOR = vmath.vector4(1),
|
||||||
|
LONGTAP_TIME = 0.4,
|
||||||
|
DOUBLETAP_TIME = 0.4,
|
||||||
|
HOVER_IMAGE = "button_yellow",
|
||||||
|
DEFAULT_IMAGE = "button_blue",
|
||||||
|
CLICK_IMAGE = "button_red",
|
||||||
|
|
||||||
|
on_hover = function(self, node, state)
|
||||||
|
local anim = state and M.button.HOVER_IMAGE or M.button.DEFAULT_IMAGE
|
||||||
|
gui.play_flipbook(node, anim)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
M["scroll"] = {
|
||||||
|
FRICT_HOLD = 0, -- mult. for inert, while touching
|
||||||
|
FRICT = 0, -- mult for free inert
|
||||||
|
INERT_THRESHOLD = 2, -- speed to stop inertion
|
||||||
|
INERT_SPEED = 0, -- koef. of inert speed
|
||||||
|
DEADZONE = 6, -- in px
|
||||||
|
SOFT_ZONE_SIZE = 20, -- size of outside zone (back move)
|
||||||
|
BACK_SPEED = 0, -- lerp speed
|
||||||
|
ANIM_SPEED = 0, -- gui.animation speed to point
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
M["progress"] = {
|
||||||
|
SPEED = 5, -- progress bar fill rate, more faster
|
||||||
|
MIN_DELTA = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
M["progress_rich"] = {
|
||||||
|
DELAY = 0, -- delay in seconds before main fill
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
M["checkbox"] = {
|
||||||
|
on_change_state = function(self, node, state)
|
||||||
|
gui.set_enabled(node, state)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
350
druid/system/druid_instance.lua
Normal file
@ -0,0 +1,350 @@
|
|||||||
|
--- Druid main class. Create instance of this
|
||||||
|
-- to start creating components
|
||||||
|
-- @module druid_instance
|
||||||
|
-- @see druid.button
|
||||||
|
-- @see druid.blocker
|
||||||
|
-- @see druid.back_handler
|
||||||
|
-- @see druid.input
|
||||||
|
-- @see druid.text
|
||||||
|
-- @see druid.lang_text
|
||||||
|
-- @see druid.timer
|
||||||
|
-- @see druid.progress
|
||||||
|
-- @see druid.grid
|
||||||
|
-- @see druid.scroll
|
||||||
|
-- @see druid.slider
|
||||||
|
-- @see druid.checkbox
|
||||||
|
-- @see druid.checkbox_group
|
||||||
|
-- @see druid.radio_group
|
||||||
|
|
||||||
|
local const = require("druid.const")
|
||||||
|
local druid_input = require("druid.helper.druid_input")
|
||||||
|
local settings = require("druid.system.settings")
|
||||||
|
local class = require("druid.system.middleclass")
|
||||||
|
|
||||||
|
local button = require("druid.base.button")
|
||||||
|
local blocker = require("druid.base.blocker")
|
||||||
|
local back_handler = require("druid.base.back_handler")
|
||||||
|
local hover = require("druid.base.hover")
|
||||||
|
local text = require("druid.base.text")
|
||||||
|
local lang_text = require("druid.base.lang_text")
|
||||||
|
local timer = require("druid.base.timer")
|
||||||
|
local progress = require("druid.base.progress")
|
||||||
|
local grid = require("druid.base.grid")
|
||||||
|
local scroll = require("druid.base.scroll")
|
||||||
|
local slider = require("druid.base.slider")
|
||||||
|
local checkbox = require("druid.base.checkbox")
|
||||||
|
local checkbox_group = require("druid.base.checkbox_group")
|
||||||
|
local radio_group = require("druid.base.radio_group")
|
||||||
|
local input = require("druid.base.input")
|
||||||
|
-- local infinity_scroll = require("druid.base.infinity_scroll")
|
||||||
|
|
||||||
|
-- @classmod Druid
|
||||||
|
local Druid = class("druid.druid_instance")
|
||||||
|
|
||||||
|
|
||||||
|
local function input_init(self)
|
||||||
|
if not sys.get_config("druid.auto_focus") == "1" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if not self.input_inited then
|
||||||
|
self.input_inited = true
|
||||||
|
druid_input.focus()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Create the component itself
|
||||||
|
local function create(self, instance_class)
|
||||||
|
local instance = instance_class()
|
||||||
|
instance:setup_component(self._context, self._style)
|
||||||
|
|
||||||
|
self.components[const.ALL] = self.components[const.ALL] or {}
|
||||||
|
table.insert(self.components[const.ALL], instance)
|
||||||
|
|
||||||
|
local register_to = instance:get_interests()
|
||||||
|
if register_to then
|
||||||
|
for i = 1, #register_to do
|
||||||
|
local interest = register_to[i]
|
||||||
|
if not self.components[interest] then
|
||||||
|
self.components[interest] = {}
|
||||||
|
end
|
||||||
|
table.insert(self.components[interest], instance)
|
||||||
|
|
||||||
|
if const.UI_INPUT[interest] then
|
||||||
|
input_init(self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return instance
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function process_input(action_id, action, components, is_input_consumed)
|
||||||
|
if not components then
|
||||||
|
return is_input_consumed
|
||||||
|
end
|
||||||
|
|
||||||
|
for i = #components, 1, -1 do
|
||||||
|
local component = components[i]
|
||||||
|
|
||||||
|
if not is_input_consumed then
|
||||||
|
is_input_consumed = component:on_input(action_id, action)
|
||||||
|
else
|
||||||
|
if component.on_input_interrupt then
|
||||||
|
component:on_input_interrupt()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return is_input_consumed
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Druid class constructor
|
||||||
|
-- @function druid:initialize
|
||||||
|
-- @tparam context table Druid context. Usually it is self of script
|
||||||
|
-- @tparam style table Druid style module
|
||||||
|
function Druid.initialize(self, context, style)
|
||||||
|
self._context = context
|
||||||
|
self._style = style or settings.default_style
|
||||||
|
self.components = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Create new druid component
|
||||||
|
-- @function druid:create
|
||||||
|
-- @tparam Component component Component module
|
||||||
|
-- @tparam args ... Other component params to pass it to component:init function
|
||||||
|
function Druid.create(self, component, ...)
|
||||||
|
local instance = create(self, component)
|
||||||
|
|
||||||
|
if instance.init then
|
||||||
|
instance:init(...)
|
||||||
|
end
|
||||||
|
|
||||||
|
return instance
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Remove component from druid instance.
|
||||||
|
-- Component `on_remove` function will be invoked, if exist.
|
||||||
|
-- @function druid:remove
|
||||||
|
-- @tparam Component component Component instance
|
||||||
|
function Druid.remove(self, component)
|
||||||
|
local all_components = self.components[const.ALL]
|
||||||
|
for i = #all_components, 1, -1 do
|
||||||
|
if all_components[i] == component then
|
||||||
|
if component.on_remove then
|
||||||
|
component:on_remove()
|
||||||
|
end
|
||||||
|
table.remove(self, i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local interests = component:get_interests()
|
||||||
|
if interests then
|
||||||
|
for i = 1, #interests do
|
||||||
|
local interest = interests[i]
|
||||||
|
local components = self.components[interest]
|
||||||
|
for j = #components, 1, -1 do
|
||||||
|
if components[j] == component then
|
||||||
|
table.remove(components, j)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Druid update function
|
||||||
|
-- @function druid:update
|
||||||
|
-- @tparam number dt Delta time
|
||||||
|
function Druid.update(self, dt)
|
||||||
|
local components = self.components[const.ON_UPDATE]
|
||||||
|
if components then
|
||||||
|
for i = 1, #components do
|
||||||
|
components[i]:update(dt)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Druid on_input function
|
||||||
|
-- @function druid:on_input
|
||||||
|
-- @tparam hash action_id Action_id from on_input
|
||||||
|
-- @tparam table action Action from on_input
|
||||||
|
function Druid.on_input(self, action_id, action)
|
||||||
|
local is_input_consumed = false
|
||||||
|
|
||||||
|
is_input_consumed = process_input(action_id, action,
|
||||||
|
self.components[const.ON_INPUT_HIGH], is_input_consumed)
|
||||||
|
|
||||||
|
is_input_consumed = process_input(action_id, action,
|
||||||
|
self.components[const.ON_INPUT], is_input_consumed)
|
||||||
|
|
||||||
|
return is_input_consumed
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Druid on_message function
|
||||||
|
-- @function druid:on_message
|
||||||
|
-- @tparam hash message_id Message_id from on_message
|
||||||
|
-- @tparam table message Message from on_message
|
||||||
|
-- @tparam hash sender Sender from on_message
|
||||||
|
function Druid.on_message(self, message_id, message, sender)
|
||||||
|
local specific_ui_message = const.SPECIFIC_UI_MESSAGES[message_id]
|
||||||
|
if specific_ui_message then
|
||||||
|
local components = self.components[message_id]
|
||||||
|
if components then
|
||||||
|
for i = 1, #components do
|
||||||
|
local component = components[i]
|
||||||
|
component[specific_ui_message](component, message, sender)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local components = self.components[const.ON_MESSAGE] or const.EMPTY_TABLE
|
||||||
|
for i = 1, #components do
|
||||||
|
components[i]:on_message(message_id, message, sender)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Create button basic component
|
||||||
|
-- @function druid:new_button
|
||||||
|
-- @tparam args ... button init args
|
||||||
|
-- @treturn Component button component
|
||||||
|
function Druid.new_button(self, ...)
|
||||||
|
return Druid.create(self, button, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Create blocker basic component
|
||||||
|
-- @function druid:new_blocker
|
||||||
|
-- @tparam args ... blocker init args
|
||||||
|
-- @treturn Component blocker component
|
||||||
|
function Druid.new_blocker(self, ...)
|
||||||
|
return Druid.create(self, blocker, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Create back_handler basic component
|
||||||
|
-- @function druid:new_back_handler
|
||||||
|
-- @tparam args ... back_handler init args
|
||||||
|
-- @treturn Component back_handler component
|
||||||
|
function Druid.new_back_handler(self, ...)
|
||||||
|
return Druid.create(self, back_handler, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Create hover basic component
|
||||||
|
-- @function druid:new_hover
|
||||||
|
-- @tparam args ... hover init args
|
||||||
|
-- @treturn Component hover component
|
||||||
|
function Druid.new_hover(self, ...)
|
||||||
|
return Druid.create(self, hover, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Create text basic component
|
||||||
|
-- @function druid:new_text
|
||||||
|
-- @tparam args ... text init args
|
||||||
|
-- @treturn Component text component
|
||||||
|
function Druid.new_text(self, ...)
|
||||||
|
return Druid.create(self, text, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Create lang_text basic component
|
||||||
|
-- @function druid:new_lang_text
|
||||||
|
-- @tparam args ... lang_text init args
|
||||||
|
-- @treturn Component lang_text component
|
||||||
|
function Druid.new_lang_text(self, ...)
|
||||||
|
return Druid.create(self, lang_text, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Create timer basic component
|
||||||
|
-- @function druid:new_timer
|
||||||
|
-- @tparam args ... timer init args
|
||||||
|
-- @treturn Component timer component
|
||||||
|
function Druid.new_timer(self, ...)
|
||||||
|
return Druid.create(self, timer, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Create progress basic component
|
||||||
|
-- @function druid:new_progress
|
||||||
|
-- @tparam args ... progress init args
|
||||||
|
-- @treturn Component progress component
|
||||||
|
function Druid.new_progress(self, ...)
|
||||||
|
return Druid.create(self, progress, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Create grid basic component
|
||||||
|
-- @function druid:new_grid
|
||||||
|
-- @tparam args ... grid init args
|
||||||
|
-- @treturn Component grid component
|
||||||
|
function Druid.new_grid(self, ...)
|
||||||
|
return Druid.create(self, grid, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Create scroll basic component
|
||||||
|
-- @function druid:new_scroll
|
||||||
|
-- @tparam args ... scroll init args
|
||||||
|
-- @treturn Component scroll component
|
||||||
|
function Druid.new_scroll(self, ...)
|
||||||
|
return Druid.create(self, scroll, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Create slider basic component
|
||||||
|
-- @function druid:new_slider
|
||||||
|
-- @tparam args ... slider init args
|
||||||
|
-- @treturn Component slider component
|
||||||
|
function Druid.new_slider(self, ...)
|
||||||
|
return Druid.create(self, slider, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Create checkbox basic component
|
||||||
|
-- @function druid:new_checkbox
|
||||||
|
-- @tparam args ... checkbox init args
|
||||||
|
-- @treturn Component checkbox component
|
||||||
|
function Druid.new_checkbox(self, ...)
|
||||||
|
return Druid.create(self, checkbox, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Create input basic component
|
||||||
|
-- @function druid:new_input
|
||||||
|
-- @tparam args ... input init args
|
||||||
|
-- @treturn Component input component
|
||||||
|
function Druid.new_input(self, ...)
|
||||||
|
return Druid.create(self, input, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Create checkbox_group basic component
|
||||||
|
-- @function druid:new_checkbox_group
|
||||||
|
-- @tparam args ... checkbox_group init args
|
||||||
|
-- @treturn Component checkbox_group component
|
||||||
|
function Druid.new_checkbox_group(self, ...)
|
||||||
|
return Druid.create(self, checkbox_group, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Create radio_group basic component
|
||||||
|
-- @function druid:new_radio_group
|
||||||
|
-- @tparam args ... radio_group init args
|
||||||
|
-- @treturn Component radio_group component
|
||||||
|
function Druid.new_radio_group(self, ...)
|
||||||
|
return Druid.create(self, radio_group, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return Druid
|
183
druid/system/middleclass.lua
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
local middleclass = {
|
||||||
|
_VERSION = 'middleclass v4.1.1',
|
||||||
|
_DESCRIPTION = 'Object Orientation for Lua',
|
||||||
|
_URL = 'https://github.com/kikito/middleclass',
|
||||||
|
_LICENSE = [[
|
||||||
|
MIT LICENSE
|
||||||
|
|
||||||
|
Copyright (c) 2011 Enrique García Cota
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included
|
||||||
|
in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
]]
|
||||||
|
}
|
||||||
|
|
||||||
|
local function _createIndexWrapper(aClass, f)
|
||||||
|
if f == nil then
|
||||||
|
return aClass.__instanceDict
|
||||||
|
else
|
||||||
|
return function(self, name)
|
||||||
|
local value = aClass.__instanceDict[name]
|
||||||
|
|
||||||
|
if value ~= nil then
|
||||||
|
return value
|
||||||
|
elseif type(f) == "function" then
|
||||||
|
return (f(self, name))
|
||||||
|
else
|
||||||
|
return f[name]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function _propagateInstanceMethod(aClass, name, f)
|
||||||
|
f = name == "__index" and _createIndexWrapper(aClass, f) or f
|
||||||
|
aClass.__instanceDict[name] = f
|
||||||
|
|
||||||
|
for subclass in pairs(aClass.subclasses) do
|
||||||
|
if rawget(subclass.__declaredMethods, name) == nil then
|
||||||
|
_propagateInstanceMethod(subclass, name, f)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function _declareInstanceMethod(aClass, name, f)
|
||||||
|
aClass.__declaredMethods[name] = f
|
||||||
|
|
||||||
|
if f == nil and aClass.super then
|
||||||
|
f = aClass.super.__instanceDict[name]
|
||||||
|
end
|
||||||
|
|
||||||
|
_propagateInstanceMethod(aClass, name, f)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function _tostring(self) return "class " .. self.name end
|
||||||
|
local function _call(self, ...) return self:new(...) end
|
||||||
|
|
||||||
|
local function _createClass(name, super)
|
||||||
|
local dict = {}
|
||||||
|
dict.__index = dict
|
||||||
|
|
||||||
|
local aClass = { name = name, super = super, static = {},
|
||||||
|
__instanceDict = dict, __declaredMethods = {},
|
||||||
|
subclasses = setmetatable({}, {__mode='k'}) }
|
||||||
|
|
||||||
|
if super then
|
||||||
|
setmetatable(aClass.static, {
|
||||||
|
__index = function(_,k)
|
||||||
|
local result = rawget(dict,k)
|
||||||
|
if result == nil then
|
||||||
|
return super.static[k]
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
})
|
||||||
|
else
|
||||||
|
setmetatable(aClass.static, { __index = function(_,k) return rawget(dict,k) end })
|
||||||
|
end
|
||||||
|
|
||||||
|
setmetatable(aClass, { __index = aClass.static, __tostring = _tostring,
|
||||||
|
__call = _call, __newindex = _declareInstanceMethod })
|
||||||
|
|
||||||
|
return aClass
|
||||||
|
end
|
||||||
|
|
||||||
|
local function _includeMixin(aClass, mixin)
|
||||||
|
assert(type(mixin) == 'table', "mixin must be a table")
|
||||||
|
|
||||||
|
for name,method in pairs(mixin) do
|
||||||
|
if name ~= "included" and name ~= "static" then aClass[name] = method end
|
||||||
|
end
|
||||||
|
|
||||||
|
for name,method in pairs(mixin.static or {}) do
|
||||||
|
aClass.static[name] = method
|
||||||
|
end
|
||||||
|
|
||||||
|
if type(mixin.included)=="function" then mixin:included(aClass) end
|
||||||
|
return aClass
|
||||||
|
end
|
||||||
|
|
||||||
|
local DefaultMixin = {
|
||||||
|
__tostring = function(self) return "instance of " .. tostring(self.class) end,
|
||||||
|
|
||||||
|
initialize = function(self, ...) end,
|
||||||
|
|
||||||
|
isInstanceOf = function(self, aClass)
|
||||||
|
return type(aClass) == 'table'
|
||||||
|
and type(self) == 'table'
|
||||||
|
and (self.class == aClass
|
||||||
|
or type(self.class) == 'table'
|
||||||
|
and type(self.class.isSubclassOf) == 'function'
|
||||||
|
and self.class:isSubclassOf(aClass))
|
||||||
|
end,
|
||||||
|
|
||||||
|
static = {
|
||||||
|
allocate = function(self)
|
||||||
|
assert(type(self) == 'table', "Make sure that you are using 'Class:allocate' instead of 'Class.allocate'")
|
||||||
|
return setmetatable({ class = self }, self.__instanceDict)
|
||||||
|
end,
|
||||||
|
|
||||||
|
new = function(self, ...)
|
||||||
|
assert(type(self) == 'table', "Make sure that you are using 'Class:new' instead of 'Class.new'")
|
||||||
|
local instance = self:allocate()
|
||||||
|
instance:initialize(...)
|
||||||
|
return instance
|
||||||
|
end,
|
||||||
|
|
||||||
|
subclass = function(self, name)
|
||||||
|
assert(type(self) == 'table', "Make sure that you are using 'Class:subclass' instead of 'Class.subclass'")
|
||||||
|
assert(type(name) == "string", "You must provide a name(string) for your class")
|
||||||
|
|
||||||
|
local subclass = _createClass(name, self)
|
||||||
|
|
||||||
|
for methodName, f in pairs(self.__instanceDict) do
|
||||||
|
_propagateInstanceMethod(subclass, methodName, f)
|
||||||
|
end
|
||||||
|
subclass.initialize = function(instance, ...) return self.initialize(instance, ...) end
|
||||||
|
|
||||||
|
self.subclasses[subclass] = true
|
||||||
|
self:subclassed(subclass)
|
||||||
|
|
||||||
|
return subclass
|
||||||
|
end,
|
||||||
|
|
||||||
|
subclassed = function(self, other) end,
|
||||||
|
|
||||||
|
isSubclassOf = function(self, other)
|
||||||
|
return type(other) == 'table' and
|
||||||
|
type(self.super) == 'table' and
|
||||||
|
( self.super == other or self.super:isSubclassOf(other) )
|
||||||
|
end,
|
||||||
|
|
||||||
|
include = function(self, ...)
|
||||||
|
assert(type(self) == 'table', "Make sure you that you are using 'Class:include' instead of 'Class.include'")
|
||||||
|
for _,mixin in ipairs({...}) do _includeMixin(self, mixin) end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function middleclass.class(name, super)
|
||||||
|
assert(type(name) == 'string', "A name (string) is needed for the new class")
|
||||||
|
return super and super:subclass(name) or _includeMixin(_createClass(name), DefaultMixin)
|
||||||
|
end
|
||||||
|
|
||||||
|
setmetatable(middleclass, { __call = function(_, ...) return middleclass.class(...) end })
|
||||||
|
|
||||||
|
return middleclass
|
18
druid/system/settings.lua
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
--- Druid settings file
|
||||||
|
-- @module settings
|
||||||
|
-- @local
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.default_style = nil
|
||||||
|
|
||||||
|
function M.get_text(name)
|
||||||
|
return "[Druid]: locales not inited"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.play_sound(name)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
BIN
example/assets/fonts/exo2.ttf
Executable file
17
example/assets/fonts/game.font
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
font: "/example/assets/fonts/exo2.ttf"
|
||||||
|
material: "/builtins/fonts/font-df.material"
|
||||||
|
size: 40
|
||||||
|
antialias: 1
|
||||||
|
alpha: 1.0
|
||||||
|
outline_alpha: 1.0
|
||||||
|
outline_width: 2.0
|
||||||
|
shadow_alpha: 1.0
|
||||||
|
shadow_blur: 0
|
||||||
|
shadow_x: 3.0
|
||||||
|
shadow_y: -4.0
|
||||||
|
extra_characters: ""
|
||||||
|
output_format: TYPE_DISTANCE_FIELD
|
||||||
|
all_chars: true
|
||||||
|
cache_width: 0
|
||||||
|
cache_height: 0
|
||||||
|
render_mode: MODE_MULTI_LAYER
|
BIN
example/assets/images/back/back_blue.png
Executable file
After Width: | Height: | Size: 438 B |
BIN
example/assets/images/back/back_gray.png
Executable file
After Width: | Height: | Size: 585 B |
BIN
example/assets/images/back/back_green.png
Executable file
After Width: | Height: | Size: 440 B |
BIN
example/assets/images/back/back_red.png
Executable file
After Width: | Height: | Size: 442 B |
BIN
example/assets/images/buttons/button_blue.png
Executable file
After Width: | Height: | Size: 480 B |
BIN
example/assets/images/buttons/button_green.png
Executable file
After Width: | Height: | Size: 474 B |
BIN
example/assets/images/buttons/button_red.png
Executable file
After Width: | Height: | Size: 480 B |
BIN
example/assets/images/buttons/button_yellow.png
Executable file
After Width: | Height: | Size: 452 B |
BIN
example/assets/images/empty.png
Executable file
After Width: | Height: | Size: 14 KiB |
79
example/assets/images/kenney.atlas
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
images {
|
||||||
|
image: "/example/assets/images/back/back_blue.png"
|
||||||
|
sprite_trim_mode: SPRITE_TRIM_MODE_OFF
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/assets/images/back/back_gray.png"
|
||||||
|
sprite_trim_mode: SPRITE_TRIM_MODE_OFF
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/assets/images/back/back_green.png"
|
||||||
|
sprite_trim_mode: SPRITE_TRIM_MODE_OFF
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/assets/images/back/back_red.png"
|
||||||
|
sprite_trim_mode: SPRITE_TRIM_MODE_OFF
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/assets/images/buttons/button_green.png"
|
||||||
|
sprite_trim_mode: SPRITE_TRIM_MODE_OFF
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/assets/images/buttons/button_red.png"
|
||||||
|
sprite_trim_mode: SPRITE_TRIM_MODE_OFF
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/assets/images/buttons/button_yellow.png"
|
||||||
|
sprite_trim_mode: SPRITE_TRIM_MODE_OFF
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/assets/images/empty.png"
|
||||||
|
sprite_trim_mode: SPRITE_TRIM_MODE_OFF
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/assets/images/progress/progress_back.png"
|
||||||
|
sprite_trim_mode: SPRITE_TRIM_MODE_OFF
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/assets/images/progress/progress_fill_green.png"
|
||||||
|
sprite_trim_mode: SPRITE_TRIM_MODE_OFF
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/assets/images/progress/progress_fill_red.png"
|
||||||
|
sprite_trim_mode: SPRITE_TRIM_MODE_OFF
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/assets/images/progress/progress_fill_yellow.png"
|
||||||
|
sprite_trim_mode: SPRITE_TRIM_MODE_OFF
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/assets/images/radio/check_back_circle.png"
|
||||||
|
sprite_trim_mode: SPRITE_TRIM_MODE_OFF
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/assets/images/radio/check_back_square.png"
|
||||||
|
sprite_trim_mode: SPRITE_TRIM_MODE_OFF
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/assets/images/radio/checkmark.png"
|
||||||
|
sprite_trim_mode: SPRITE_TRIM_MODE_OFF
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/assets/images/radio/tick.png"
|
||||||
|
sprite_trim_mode: SPRITE_TRIM_MODE_OFF
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/assets/images/slider/slider_back.png"
|
||||||
|
sprite_trim_mode: SPRITE_TRIM_MODE_OFF
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/assets/images/slider/slider_move.png"
|
||||||
|
sprite_trim_mode: SPRITE_TRIM_MODE_OFF
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/assets/images/buttons/button_blue.png"
|
||||||
|
sprite_trim_mode: SPRITE_TRIM_MODE_OFF
|
||||||
|
}
|
||||||
|
margin: 0
|
||||||
|
extrude_borders: 2
|
||||||
|
inner_padding: 0
|
BIN
example/assets/images/progress/progress_back.png
Executable file
After Width: | Height: | Size: 439 B |
BIN
example/assets/images/progress/progress_fill_green.png
Executable file
After Width: | Height: | Size: 471 B |