From 10556ba31a404dd679ee7068da113b6e410b5b68 Mon Sep 17 00:00:00 2001 From: Insality Date: Thu, 20 Mar 2025 00:26:29 +0200 Subject: [PATCH] Remove html api, update docs --- README.md | 55 +- .../properties_panel/property_input_api.md | 4 +- docs/{druid => }/archive/archive_files.json | 0 docs/{druid => }/archive/game0.arcd | Bin docs/{druid => }/archive/game0.arci | Bin docs/{druid => }/archive/game0.dmanifest | Bin docs/{druid => }/archive/game0.projectc | 0 docs/{druid => }/archive/game0.public.der | Bin docs/{druid => }/archive/game1.arcd | Bin docs/{druid => }/dmloader.js | 0 docs/{druid => }/druid.wasm | Bin docs/{druid => }/druid_logo.png | Bin docs/{druid => }/druid_wasm.js | 0 .../{druid/index.html => index 11.20.31.html} | 0 docs/index.html | 186 --- docs/ldoc_fixed.css | 311 ----- docs/modules/BackHandler.html | 172 --- docs/modules/BaseComponent.html | 549 -------- docs/modules/Blocker.html | 233 ---- docs/modules/Button.html | 880 ------------ docs/modules/Checkbox.html | 350 ----- docs/modules/CheckboxGroup.html | 259 ---- docs/modules/DataList.html | 712 ---------- docs/modules/Drag.html | 633 --------- docs/modules/Druid.html | 374 ----- docs/modules/DruidEvent.html | 399 ------ docs/modules/DruidInstance.html | 1223 ----------------- docs/modules/DynamicGrid.html | 788 ----------- docs/modules/Helper.html | 927 ------------- docs/modules/Hotkey.html | 373 ----- docs/modules/Hover.html | 469 ------- docs/modules/Input.html | 1086 --------------- docs/modules/LangText.html | 380 ----- docs/modules/Layout.html | 147 -- docs/modules/PinKnob.html | 299 ---- docs/modules/Progress.html | 569 -------- docs/modules/RadioGroup.html | 259 ---- docs/modules/RichInput.html | 567 -------- docs/modules/RichText.html | 560 -------- docs/modules/Scroll.html | 1183 ---------------- docs/modules/Slider.html | 531 ------- docs/modules/StaticGrid.html | 1094 --------------- docs/modules/Swipe.html | 288 ---- docs/modules/Text.html | 942 ------------- docs/modules/Timer.html | 409 ------ docs/modules/druid.extended.layout.html | 95 -- docs/modules/druid.system.utf8.html | 93 -- druid/base/back_handler.lua | 10 +- druid/base/blocker.lua | 14 +- druid/base/button.lua | 29 +- druid/base/scroll.lua | 28 +- druid/base/text.lua | 29 +- druid/custom/rich_text/rich_text.lua | 8 + druid/extended/container.lua | 17 +- druid/extended/data_list.lua | 14 +- druid/extended/hotkey.lua | 13 +- druid/extended/input.lua | 13 +- druid/extended/lang_text.lua | 23 +- druid/extended/layout.lua | 27 +- druid/extended/progress.lua | 24 +- druid/extended/slider.lua | 12 +- druid/extended/timer.lua | 12 +- druid/system/druid_instance.lua | 2 +- example/other/go_bindings/go_widget.gui | 2 +- game.project | 2 +- wiki/01-components.md | 372 ----- wiki/02-creating_custom_components.md | 2 + wiki/FAQ.md | 36 - wiki/widgets.md | 76 +- 69 files changed, 294 insertions(+), 17870 deletions(-) rename docs/{druid => }/archive/archive_files.json (100%) rename docs/{druid => }/archive/game0.arcd (100%) rename docs/{druid => }/archive/game0.arci (100%) rename docs/{druid => }/archive/game0.dmanifest (100%) rename docs/{druid => }/archive/game0.projectc (100%) rename docs/{druid => }/archive/game0.public.der (100%) rename docs/{druid => }/archive/game1.arcd (100%) rename docs/{druid => }/dmloader.js (100%) rename docs/{druid => }/druid.wasm (100%) rename docs/{druid => }/druid_logo.png (100%) rename docs/{druid => }/druid_wasm.js (100%) rename docs/{druid/index.html => index 11.20.31.html} (100%) delete mode 100644 docs/index.html delete mode 100644 docs/ldoc_fixed.css delete mode 100644 docs/modules/BackHandler.html delete mode 100644 docs/modules/BaseComponent.html delete mode 100644 docs/modules/Blocker.html delete mode 100644 docs/modules/Button.html delete mode 100644 docs/modules/Checkbox.html delete mode 100644 docs/modules/CheckboxGroup.html delete mode 100644 docs/modules/DataList.html delete mode 100644 docs/modules/Drag.html delete mode 100644 docs/modules/Druid.html delete mode 100644 docs/modules/DruidEvent.html delete mode 100644 docs/modules/DruidInstance.html delete mode 100644 docs/modules/DynamicGrid.html delete mode 100644 docs/modules/Helper.html delete mode 100644 docs/modules/Hotkey.html delete mode 100644 docs/modules/Hover.html delete mode 100644 docs/modules/Input.html delete mode 100644 docs/modules/LangText.html delete mode 100644 docs/modules/Layout.html delete mode 100644 docs/modules/PinKnob.html delete mode 100644 docs/modules/Progress.html delete mode 100644 docs/modules/RadioGroup.html delete mode 100644 docs/modules/RichInput.html delete mode 100644 docs/modules/RichText.html delete mode 100644 docs/modules/Scroll.html delete mode 100644 docs/modules/Slider.html delete mode 100644 docs/modules/StaticGrid.html delete mode 100644 docs/modules/Swipe.html delete mode 100644 docs/modules/Text.html delete mode 100644 docs/modules/Timer.html delete mode 100644 docs/modules/druid.extended.layout.html delete mode 100644 docs/modules/druid.system.utf8.html delete mode 100644 wiki/01-components.md delete mode 100644 wiki/FAQ.md diff --git a/README.md b/README.md index e186b98..66ddf00 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ ## Druid Example -Check the [**HTML5 version**](https://insality.github.io/druid/druid/) of the **Druid** example app. +Check the [**HTML5 version**](https://insality.github.io/druid/) of the **Druid** example app. In this example you can inspect a variety of **Druid** components and see how they work. Each example page provides a direct link to the corresponding example code, making it easier for you to understand how to use **Druid**. @@ -44,7 +44,7 @@ Here is a list of [all releases](https://github.com/Insality/druid/releases). > **Note:** The library size is calculated based on the build report per platform. -| Platform | Library Size | +| Platform | Full Size | | ---------------- | ------------- | | HTML5 | **84.52 KB** | | Desktop / Mobile | **141.03 KB** | @@ -84,7 +84,7 @@ function final(self) self.druid:final() end --- "update" is used in progress bar, scroll, and timer basic components +-- "update" is used in progress bar, scroll, and timer components function update(self, dt) self.druid:update(dt) end @@ -163,39 +163,39 @@ Best start is from the [Quick API Reference](api/quick_api_reference.md) With next quick links: - [Druid Instance](api/druid_instance_api.md) - **Druid** instance returned from `druid.new(self)` -- [Helper](api/helper_api.md) - A lot of useful functions -- [Widgets](wiki/widgets.md) - All widgets with examples +- [Helper](api/druid_helper_api.md) - A lot of useful functions +- [Widgets](wiki/widgets.md) - About widgets and how to use them ## Druid Components Here is full **Druid** components list. -### Basic Components +### Components | Name | Description | Example |
Preview
| |------|-------------|---------|---------| -| **[Button](https://insality.github.io/druid/modules/Button.html)** | Logic over GUI Node. Handle the user click interactions: click, long click, double click, etc. | [Button Example](https://insality.github.io/druid/druid/?example=ui_example_basic_button) | | -| **[Text](https://insality.github.io/druid/modules/Text.html)** | Logic over GUI Text. By default Text component fit the text inside text node size area with different adjust modes. | [Text Example](https://insality.github.io/druid/druid/?example=ui_example_basic_text) | | -| **[Scroll](https://insality.github.io/druid/modules/Scroll.html)** | Logic over two GUI Nodes: input and content. Provides basic behaviour for scrollable content. | [Scroll Example](https://insality.github.io/druid/druid/?example=ui_example_basic_scroll) | | -| **[Blocker](https://insality.github.io/druid/modules/Blocker.html)** | Logic over GUI Node. Don't pass any user input below node area size. | [Blocker Example](https://insality.github.io/druid/druid/?example=ui_example_basic_blocker) | | -| **[Back Handler](https://insality.github.io/druid/modules/BackHandler.html)** | Call callback on user "Back" action. It's a Android back button or keyboard backspace key | [Back Handler Example](https://insality.github.io/druid/druid/?example=ui_example_basic_back_handler) | | -| **[Static Grid](https://insality.github.io/druid/modules/StaticGrid.html)** | Logic over GUI Node. Component to manage node positions with all equal node sizes. | [Static Gid Example](https://insality.github.io/druid/druid/?example=ui_example_basic_grid) | | -| **[Hover](https://insality.github.io/druid/modules/Hover.html)** | Logic over GUI Node. Handle hover action over node. For both: mobile touch and mouse cursor. | [Hover Example](https://insality.github.io/druid/druid/?example=ui_example_basic_hover) | | -| **[Swipe](https://insality.github.io/druid/modules/Swipe.html)** | Logic over GUI Node. Handle swipe gestures over node. | [Swipe Example](https://insality.github.io/druid/druid/?example=ui_example_basic_swipe) | | -| **[Drag](https://insality.github.io/druid/modules/Drag.html)** | Logic over GUI Node. Handle drag input actions. Can be useful to make on screen controlls. | [Drag Example](https://insality.github.io/druid/druid/?example=ui_example_basic_drag) | | -| **[Data List](https://insality.github.io/druid/modules/DataList.html)** | Logic over Scroll and Grid components. Create only visible GUI nodes or components to make "infinity" scroll befaviour | [Data List Example](https://insality.github.io/druid/druid/?example=ui_example_data_list_basic) | | -| **[Input](https://insality.github.io/druid/modules/Input.html)** | Logic over GUI Node and GUI Text (or Text component). Provides basic user text input. | [Input Example](https://insality.github.io/druid/druid/?example=ui_example_basic_input) | | -| **[Lang text](https://insality.github.io/druid/modules/LangText.html)** | Logic over Text component to handle localization. Can be translated in real-time with `druid.on_language_change` | [Lang Text Example](https://insality.github.io/druid/druid/?example=ui_example_window_language) | | -| **[Progress](https://insality.github.io/druid/modules/Progress.html)** | Logic over GUI Node. Handle node size and scale to handle progress node size. | [Progress Example](https://insality.github.io/druid/druid/?example=ui_example_basic_progress_bar) | | -| **[Slider](https://insality.github.io/druid/modules/Slider.html)** | Logic over GUI Node. Handle draggable node with position restrictions. | [Slider Example](https://insality.github.io/druid/druid/?example=ui_example_basic_slider) | | -| **[Timer](https://insality.github.io/druid/modules/Timer.html)** | Logic over GUI Text. Handle basic timer functions. | [Timer Example](https://insality.github.io/druid/druid/?example=ui_example_basic_timer) | | -| **[Hotkey](https://insality.github.io/druid/modules/Hotkey.html)** | Allow to set callbacks for keyboard hotkeys with key modificators. | [Hotkey Example](https://insality.github.io/druid/druid/?example=ui_example_basic_hotkey) | | -| **[Layout](https://insality.github.io/druid/modules/Layout.html)** | Logic over GUI Node. Arrange nodes inside layout node with margin/paddings settings. | [Layout Example](https://insality.github.io/druid/druid/?example=ui_example_layout_basic) | | -| **[Rich Input](https://insality.github.io/druid/modules/RichInput.html)** | Logic over GUI Node and GUI Text (or Text component). Provides rich text input with different styles and text formatting. | [Rich Input Example](https://insality.github.io/druid/druid/?example=ui_example_basic_rich_input) | | -| **[Rich Text](https://insality.github.io/druid/modules/RichText.html)** | Logic over GUI Text. Provides rich text formatting with different styles and text formatting. | [Rich Text Example](https://insality.github.io/druid/druid/?example=ui_example_basic_rich_text) | | +| **[Button](https://insality.github.io/druid/modules/Button.html)** | Logic over GUI Node. Handle the user click interactions: click, long click, double click, etc. | [Button Example](https://insality.github.io/druid/?example=ui_example_basic_button) | | +| **[Text](https://insality.github.io/druid/modules/Text.html)** | Logic over GUI Text. By default Text component fit the text inside text node size area with different adjust modes. | [Text Example](https://insality.github.io/druid/?example=ui_example_basic_text) | | +| **[Scroll](https://insality.github.io/druid/modules/Scroll.html)** | Logic over two GUI Nodes: input and content. Provides basic behaviour for scrollable content. | [Scroll Example](https://insality.github.io/druid/?example=ui_example_basic_scroll) | | +| **[Blocker](https://insality.github.io/druid/modules/Blocker.html)** | Logic over GUI Node. Don't pass any user input below node area size. | [Blocker Example](https://insality.github.io/druid/?example=ui_example_basic_blocker) | | +| **[Back Handler](https://insality.github.io/druid/modules/BackHandler.html)** | Call callback on user "Back" action. It's a Android back button or keyboard backspace key | [Back Handler Example](https://insality.github.io/druid/?example=ui_example_basic_back_handler) | | +| **[Static Grid](https://insality.github.io/druid/modules/StaticGrid.html)** | Logic over GUI Node. Component to manage node positions with all equal node sizes. | [Static Gid Example](https://insality.github.io/druid/?example=ui_example_basic_grid) | | +| **[Hover](https://insality.github.io/druid/modules/Hover.html)** | Logic over GUI Node. Handle hover action over node. For both: mobile touch and mouse cursor. | [Hover Example](https://insality.github.io/druid/?example=ui_example_basic_hover) | | +| **[Swipe](https://insality.github.io/druid/modules/Swipe.html)** | Logic over GUI Node. Handle swipe gestures over node. | [Swipe Example](https://insality.github.io/druid/?example=ui_example_basic_swipe) | | +| **[Drag](https://insality.github.io/druid/modules/Drag.html)** | Logic over GUI Node. Handle drag input actions. Can be useful to make on screen controlls. | [Drag Example](https://insality.github.io/druid/?example=ui_example_basic_drag) | | +| **[Data List](https://insality.github.io/druid/modules/DataList.html)** | Logic over Scroll and Grid components. Create only visible GUI nodes or components to make "infinity" scroll befaviour | [Data List Example](https://insality.github.io/druid/?example=ui_example_data_list_basic) | | +| **[Input](https://insality.github.io/druid/modules/Input.html)** | Logic over GUI Node and GUI Text (or Text component). Provides basic user text input. | [Input Example](https://insality.github.io/druid/?example=ui_example_basic_input) | | +| **[Lang text](https://insality.github.io/druid/modules/LangText.html)** | Logic over Text component to handle localization. Can be translated in real-time with `druid.on_language_change` | [Lang Text Example](https://insality.github.io/druid/?example=ui_example_window_language) | | +| **[Progress](https://insality.github.io/druid/modules/Progress.html)** | Logic over GUI Node. Handle node size and scale to handle progress node size. | [Progress Example](https://insality.github.io/druid/?example=ui_example_basic_progress_bar) | | +| **[Slider](https://insality.github.io/druid/modules/Slider.html)** | Logic over GUI Node. Handle draggable node with position restrictions. | [Slider Example](https://insality.github.io/druid/?example=ui_example_basic_slider) | | +| **[Timer](https://insality.github.io/druid/modules/Timer.html)** | Logic over GUI Text. Handle basic timer functions. | [Timer Example](https://insality.github.io/druid/?example=ui_example_basic_timer) | | +| **[Hotkey](https://insality.github.io/druid/modules/Hotkey.html)** | Allow to set callbacks for keyboard hotkeys with key modificators. | [Hotkey Example](https://insality.github.io/druid/?example=ui_example_basic_hotkey) | | +| **[Layout](https://insality.github.io/druid/modules/Layout.html)** | Logic over GUI Node. Arrange nodes inside layout node with margin/paddings settings. | [Layout Example](https://insality.github.io/druid/?example=ui_example_layout_basic) | | +| **[Rich Input](https://insality.github.io/druid/modules/RichInput.html)** | Logic over GUI Node and GUI Text (or Text component). Provides rich text input with different styles and text formatting. | [Rich Input Example](https://insality.github.io/druid/?example=ui_example_basic_rich_input) | | +| **[Rich Text](https://insality.github.io/druid/modules/RichText.html)** | Logic over GUI Text. Provides rich text formatting with different styles and text formatting. | [Rich Text Example](https://insality.github.io/druid/?example=ui_example_basic_rich_text) | | -For a complete overview, see: **_[components.md](docs_md/01-components.md)_**. +For a complete overview, see: ***[components.md](docs_md/01-components.md)***. ## Druid Events @@ -234,7 +234,7 @@ end) ## Examples -Try the [**HTML5 version**](https://insality.github.io/druid/druid/) of the **Druid** example app. +Try the [**HTML5 version**](https://insality.github.io/druid/) of the **Druid** example app. Each example page provides a direct link to the corresponding example code, making it easier for you to understand how to use **Druid**. @@ -247,7 +247,6 @@ You can find the full **Druid** functions at [Quick API Reference](api/quick_api To better understand **Druid**, read the following documentation: - [How To GUI in Defold](https://forum.defold.com/t/how-to-gui-in-defold/73256) - [Widgets](wiki/widgets.md) -- [Druid components](docs_md/01-components.md) - [Create custom components](docs_md/02-creating_custom_components.md) - [Druid styles](docs_md/03-styles.md) diff --git a/api/components/widgets/properties_panel/property_input_api.md b/api/components/widgets/properties_panel/property_input_api.md index 8e5fdfe..f889ddb 100644 --- a/api/components/widgets/properties_panel/property_input_api.md +++ b/api/components/widgets/properties_panel/property_input_api.md @@ -2,15 +2,15 @@ > at /druid/widget/properties_panel/properties/property_input.lua - ## Functions + - [init](#init) - [set_text_property](#set_text_property) - [set_text_value](#set_text_value) - [on_change](#on_change) - ## Fields + - [root](#root) - [container](#container) - [text_name](#text_name) diff --git a/docs/druid/archive/archive_files.json b/docs/archive/archive_files.json similarity index 100% rename from docs/druid/archive/archive_files.json rename to docs/archive/archive_files.json diff --git a/docs/druid/archive/game0.arcd b/docs/archive/game0.arcd similarity index 100% rename from docs/druid/archive/game0.arcd rename to docs/archive/game0.arcd diff --git a/docs/druid/archive/game0.arci b/docs/archive/game0.arci similarity index 100% rename from docs/druid/archive/game0.arci rename to docs/archive/game0.arci diff --git a/docs/druid/archive/game0.dmanifest b/docs/archive/game0.dmanifest similarity index 100% rename from docs/druid/archive/game0.dmanifest rename to docs/archive/game0.dmanifest diff --git a/docs/druid/archive/game0.projectc b/docs/archive/game0.projectc similarity index 100% rename from docs/druid/archive/game0.projectc rename to docs/archive/game0.projectc diff --git a/docs/druid/archive/game0.public.der b/docs/archive/game0.public.der similarity index 100% rename from docs/druid/archive/game0.public.der rename to docs/archive/game0.public.der diff --git a/docs/druid/archive/game1.arcd b/docs/archive/game1.arcd similarity index 100% rename from docs/druid/archive/game1.arcd rename to docs/archive/game1.arcd diff --git a/docs/druid/dmloader.js b/docs/dmloader.js similarity index 100% rename from docs/druid/dmloader.js rename to docs/dmloader.js diff --git a/docs/druid/druid.wasm b/docs/druid.wasm similarity index 100% rename from docs/druid/druid.wasm rename to docs/druid.wasm diff --git a/docs/druid/druid_logo.png b/docs/druid_logo.png similarity index 100% rename from docs/druid/druid_logo.png rename to docs/druid_logo.png diff --git a/docs/druid/druid_wasm.js b/docs/druid_wasm.js similarity index 100% rename from docs/druid/druid_wasm.js rename to docs/druid_wasm.js diff --git a/docs/druid/index.html b/docs/index 11.20.31.html similarity index 100% rename from docs/druid/index.html rename to docs/index 11.20.31.html diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index 192ca28..0000000 --- a/docs/index.html +++ /dev/null @@ -1,186 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- - -

Documentation for Druid Framework

- -

Modules

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BackHandlerComponent with event on back and backspace button.
BlockerComponent to consume input in special zone defined by GUI node.
ButtonDruid Component for Handling User Click Interactions: Click, Long Click, Double Click, and More.
DragComponent to handle drag action on node.
HoverComponent to handle hover node interaction
ScrollComponent to handle scroll content.
StaticGridComponent to handle component's position by row and columns.
TextComponent for Wrapping GUI Text Nodes: Druid Text -

## Overview ## -

Druid Text is a component that provides various adjustment modes for text nodes.

BaseComponentBasic class for all Druid components.
RichInputDruid Rich Input custom component.
RichTextDruid Rich Text Custom Component.
DruidDruid UI Component Framework.
DruidEventDruid Event Module -

The Event module provides a simple class for handling callbacks.

DataListComponent to manage data for huge dataset in scroll.
DynamicGridComponent to handle placing components in row
HotkeyDruid hotkey component
InputDruid input text component.
LangTextComponent to wrap over GUI Text nodes with localization helpers -

# Overview # -

• The initialization of druid.set_text_function is required to enable localization - using the localization ID.

LayoutLayout management on node
ProgressDruid component to handle the progress bars.
SliderDruid slider component
SwipeComponent to handle swipe gestures on node.
TimerComponent to handle GUI timers.
HelperHelper module with various usefull GUI functions.
DruidInstanceDruid Instance which you use for component creation.
- -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/ldoc_fixed.css b/docs/ldoc_fixed.css deleted file mode 100644 index e63d191..0000000 --- a/docs/ldoc_fixed.css +++ /dev/null @@ -1,311 +0,0 @@ -/* 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: 900px; - 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; } - diff --git a/docs/modules/BackHandler.html b/docs/modules/BackHandler.html deleted file mode 100644 index e8f7dc7..0000000 --- a/docs/modules/BackHandler.html +++ /dev/null @@ -1,172 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module BackHandler

-

Component with event on back and backspace button.

-

- # Overview # -

Back Handler is recommended to put in every game window to close it - or in main screen to call settings window. -

# Notes # -

• Back Handler inheritance BaseComponent, you can use all of its methods in addition to those described here. -

• Back Handler react on release action ACTION_BACK or ACTION_BACKSPACE

-

Usage:

-
    -
    local callback = function(self, params) ... end
    -
    -local params = {}
    -local back_handler = self.druid:new_back_handler(callback, [params])
    -
    -
- - -

Fields

- - - - - - - - - -
on_backThe DruidEvent Event on back handler action.
paramsCustom args to pass in the callback
- -
-
- - -

Fields

- -
-
- - on_back -
-
- The DruidEvent Event on back handler action. -

Trigger on input action ACTION_BACK or ACTION_BACKSPACE - - -

- - - - -

Usage:

-
    -
    -- Subscribe additional callbacks:
    -back_handler.on_back:subscribe(callback)
    -
- -
-
- - params -
-
- Custom args to pass in the callback - - -
    -
  • params - any or nil - -
  • -
- - - - -

Usage:

-
    -
    -- Replace params on runtime:
    -back_handler.params = { ... }
    -
- -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/BaseComponent.html b/docs/modules/BaseComponent.html deleted file mode 100644 index 39eb118..0000000 --- a/docs/modules/BaseComponent.html +++ /dev/null @@ -1,549 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module BaseComponent

-

Basic class for all Druid components.

-

- To create you custom component, use static function `component.create`

-

Usage:

-
    -
    -- Create your component:
    -local component = require("druid.component")
    -
    -local AwesomeComponent = component.create("awesome_component")
    -
    -function AwesomeComponent:init(template, nodes)
    -    self:set_template(template)
    -    self:set_nodes(nodes)
    -    self.druid = self:get_druid()
    -end
    -
    -return AwesomeComponent
    -
    -
- - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
get_childrens(self)Return all children components, recursive
get_context(self)Context used as first arg in all Druid events
get_druid(self, template, nodes)Get Druid instance for inner component creation.
get_input_priority(self)Return component input priority
get_name(self)Return component name
get_node(self, node_or_name)Get component node by name.
get_parent_component(self)Return the parent component if exist
get_parent_name(self)Return parent component name
get_template(self)Get current component template name.
get_uid(self)Return component UID.
reset_input_priority(self)Reset component input priority to default value
set_input_enabled(self, state)Set component input state.
set_input_priority(self, value, is_temporary)Set component input priority
- -
-
- - -

Functions

- -
-
- - get_childrens(self) -
-
- Return all children components, recursive - - -

Parameters:

- - -

Returns:

-
    - - table - Array of childrens if the Druid component instance -
- - - - -
-
- - get_context(self) -
-
- Context used as first arg in all Druid events Context is usually self of gui_script. - - -

Parameters:

- - -

Returns:

-
    - - table - BaseComponent context -
- - - - -
-
- - get_druid(self, template, nodes) -
-
- Get Druid instance for inner component creation. - - -

Parameters:

-
    -
  • self - BaseComponent - BaseComponent -
  • -
  • template - string or nil - The template name -
  • -
  • nodes - table or nil - The nodes table -
  • -
- -

Returns:

-
    - - DruidInstance - Druid instance with component context -
- - - - -
-
- - get_input_priority(self) -
-
- Return component input priority - - -

Parameters:

- - -

Returns:

-
    - - number - The component input priority -
- - - - -
-
- - get_name(self) -
-
- Return component name - - -

Parameters:

- - -

Returns:

-
    - - string - The component name -
- - - - -
-
- - get_node(self, node_or_name) -
-
- Get component node by name. -

If component has nodes, node_or_name should be string - It autopick node by template name or from nodes by gui.clone_tree - if they was setup via component:set_nodes, component:set_template. - If node is not found, the exception will fired - - -

Parameters:

-
    -
  • self - BaseComponent - BaseComponent -
  • -
  • node_or_name - string or node - Node name or node itself -
  • -
- -

Returns:

-
    - - node - Gui node -
- - - - -
-
- - get_parent_component(self) -
-
- Return the parent component if exist - - -

Parameters:

- - -

Returns:

-
    - - BaseComponent or nil - The druid component instance or nil -
- - - - -
-
- - get_parent_name(self) -
-
- Return parent component name - - -

Parameters:

- - -

Returns:

-
    - - string or nil - The parent component name if exist or bil -
- - - - -
-
- - get_template(self) -
-
- Get current component template name. - - -

Parameters:

- - -

Returns:

-
    - - string - Component full template name -
- - - - -
-
- - get_uid(self) -
-
- Return component UID. -

UID generated in component creation order. - - -

Parameters:

- - -

Returns:

-
    - - number - The component uid -
- - - - -
-
- - reset_input_priority(self) -
-
- Reset component input priority to default value - - -

Parameters:

- - -

Returns:

-
    - - number - The component input priority -
- - - - -
-
- - set_input_enabled(self, state) -
-
- Set component input state. By default it enabled -

If input is disabled, the component will not receive input events - - -

Parameters:

-
    -
  • self - BaseComponent - BaseComponent -
  • -
  • state - boolean or nil - The component input state -
  • -
- -

Returns:

-
    - - BaseComponent - BaseComponent itself -
- - - - -
-
- - set_input_priority(self, value, is_temporary) -
-
- Set component input priority Default value: 10 - - -

Parameters:

-
    -
  • self - BaseComponent - BaseComponent -
  • -
  • value - number - The new input priority value -
  • -
  • is_temporary - boolean or nil - If true, the reset input priority will return to previous value -
  • -
- -

Returns:

-
    - - number - The component input priority -
- - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/Blocker.html b/docs/modules/Blocker.html deleted file mode 100644 index c3ec691..0000000 --- a/docs/modules/Blocker.html +++ /dev/null @@ -1,233 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module Blocker

-

Component to consume input in special zone defined by GUI node.

-

- # Overview # -

# Notes # -

Blocker consume input if `gui.pick_node` works on it. -

• Blocker inheritance BaseComponent, you can use all of its methods in addition to those described here. -

• Blocker initial enabled state is `gui.is_enabled(node, true)` -

• The Blocker node should be enabled to capture the input

-

Usage:

-
    -
    local node = gui.get_node("blocker_node")
    -local blocker = self.druid:new_blocker(node)
    -
    -
- - -

Functions

- - - - - - - - - - - - - -
init(self, node)The Blocker constructor
is_enabled(self)Return blocker enabled state
set_enabled(self, state)Set enabled blocker component state.
-

Fields

- - - - - -
nodeBlocker node
- -
-
- - -

Functions

- -
-
- - init(self, node) -
-
- The Blocker constructor - - -

Parameters:

-
    -
  • self - Blocker - Blocker -
  • -
  • node - node - Gui node -
  • -
- - - - - -
-
- - is_enabled(self) -
-
- Return blocker enabled state - - -

Parameters:

- - -

Returns:

-
    - - boolean - @True, if blocker is enabled -
- - - - -
-
- - set_enabled(self, state) -
-
- Set enabled blocker component state. -

Don't change node enabled state itself. - - -

Parameters:

-
    -
  • self - Blocker - Blocker -
  • -
  • state - boolean or nil - Enabled state -
  • -
- - - - - -
-
-

Fields

- -
-
- - node -
-
- Blocker node - - -
    -
  • node - node - -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/Button.html b/docs/modules/Button.html deleted file mode 100644 index 6bcc4cd..0000000 --- a/docs/modules/Button.html +++ /dev/null @@ -1,880 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module Button

-

Druid Component for Handling User Click Interactions: Click, Long Click, Double Click, and More.

-

-

# Overview # -

This component provides a versatile solution for handling user click interactions. - It allows you to make any GUI node clickable and define various callbacks for different types of clicks. -

# Notes # -

• The click callback will not trigger if the cursor moves outside the node's - area between the pressed and released states. -

• If a button has a double click event subscriber and the double click event is triggered, - the regular click callback will not be triggered. -

• Buttons can be triggered using a keyboard key by calling the button:set_key_trigger method. -

• To animate a small icon on a big button panel, you can use an animation node. - The trigger node name should be set as "big panel," and the animation node should be set as "small icon." -

Example Link

-

Usage:

-
    -
    local function on_button_click(self, args, button)
    -    print("Button has clicked with params: " .. args)
    -    print("Also the button component is passed in callback params")
    -end
    -
    -local custom_args = "Any variable to pass inside callback"
    -local button = self.druid:new_button("button_name", on_button_click, custom_args)
    -
    -
- - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
get_key_trigger(self)Get current key name to trigger this button.
init(self, node, callback, custom_args, anim_node)The Button constructor
is_enabled(self)Get button enabled state.
set_check_function(self, check_function, failure_callback)Set function for additional check for button click availability
set_click_zone(self, zone)Set additional button click area.
set_enabled(self, state)Set button enabled state.
set_key_trigger(self, key)Set key name to trigger this button by keyboard.
set_web_user_interaction(self, is_web_mode)Set Button mode to work inside user HTML5 interaction event.
-

Tables

- - - - - -
styleComponent style params.
-

Fields

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
anim_nodeButton animation node.
click_zoneAdditional button click area, defined by another GUI node
hoverThe Hover: Button Hover component
nodeButton trigger node
node_idThe GUI node id from button node
on_clickThe DruidEvent: Event on successful release action over button.
on_click_outsideThe DruidEvent: Event calls if click event was outside of button.
on_double_clickThe DruidEvent: Event on double tap action over button.
on_hold_callbackThe DruidEvent: Event calls every frame before on_long_click event.
on_long_clickThe DruidEvent: Event on long tap action over button.
on_pressedThe DruidEvent: Event triggered if button was pressed by user.
on_repeated_clickThe DruidEvent: Event on repeated action over button.
paramsCustom args for any Button event.
- -
-
- - -

Functions

- -
-
- - get_key_trigger(self) -
-
- Get current key name to trigger this button. - - -

Parameters:

-
    -
  • self - Button - -
  • -
- -

Returns:

-
    - - hash - The action_id of the input key -
- - - -

Usage:

-
    -
    local key_hash = button:get_key_trigger()
    -
- -
-
- - init(self, node, callback, custom_args, anim_node) -
-
- The Button constructor - - -

Parameters:

-
    -
  • self - Button - Button -
  • -
  • node - string or node - The node_id or gui.get_node(node_id) -
  • -
  • callback - function - On click button callback -
  • -
  • custom_args - any or nil - Button events custom arguments -
  • -
  • anim_node - string, node or nil - Node to animate instead of trigger node. -
  • -
- - - - - -
-
- - is_enabled(self) -
-
- Get button enabled state. -

By default all Buttons is enabled on creating. - - -

Parameters:

-
    -
  • self - Button - Button -
  • -
- -

Returns:

-
    - - boolean - @True, if button is enabled now, False overwise -
- - - -

Usage:

-
    -
    local is_enabled = button:is_enabled()
    -
- -
-
- - set_check_function(self, check_function, failure_callback) -
-
- Set function for additional check for button click availability - - -

Parameters:

-
    -
  • self - Button - -
  • -
  • check_function - function or nil - Should return true or false. If true - button can be pressed. -
  • -
  • failure_callback - function or nil - Function will be called on button click, if check function return false -
  • -
- -

Returns:

-
    - - Button - Current button instance -
- - - - -
-
- - set_click_zone(self, zone) -
-
- Set additional button click area. - Useful to restrict click outside out stencil node or scrollable content. -

This functions calls automatically if you don't disable it in game.project: druid.no_stencil_check - - -

Parameters:

- - -

Returns:

-
    - - Button - Current button instance -
- - - -

Usage:

-
    -
    button:set_click_zone("stencil_node")
    -
- -
-
- - set_enabled(self, state) -
-
- Set button enabled state. - The style.on_set_enabled will be triggered. - Disabled button is not clickable. - - -

Parameters:

-
    -
  • self - Button - Button -
  • -
  • state - boolean or nil - Enabled state -
  • -
- -

Returns:

-
    - - Button - Current button instance -
- - - -

Usage:

-
    -
    button:set_enabled(false)
    -button:set_enabled(true)
    -
- -
-
- - set_key_trigger(self, key) -
-
- Set key name to trigger this button by keyboard. - - -

Parameters:

-
    -
  • self - Button - Button -
  • -
  • key - hash or string - The action_id of the input key -
  • -
- -

Returns:

-
    - - Button - Current button instance -
- - - -

Usage:

-
    -
    button:set_key_trigger("key_space")
    -
- -
-
- - set_web_user_interaction(self, is_web_mode) -
-
- Set Button mode to work inside user HTML5 interaction event. -

It's required to make protected things like copy & paste text, show mobile keyboard, etc - The HTML5 button's doesn't call any events except on_click event. -

If the game is not HTML, html mode will be not enabled - - -

Parameters:

-
    -
  • self - Button - -
  • -
  • is_web_mode - boolean or nil - If true - button will be called inside html5 callback -
  • -
- -

Returns:

-
    - - Button - Current button instance -
- - - -

Usage:

-
    -
    button:set_web_user_interaction(true)
    -
- -
-
-

Tables

- -
-
- - style -
-
- Component style params. - You can override this component styles params in Druid styles table - or create your own style - - -

Fields:

-
    -
  • LONGTAP_TIME - number or nil - Minimum time to trigger on_hold_callback. Default: 0.4 -
  • -
  • AUTOHOLD_TRIGGER - number or nil - Maximum hold time to trigger button release while holding. Default: 0.8 -
  • -
  • DOUBLETAP_TIME - number or nil - Time between double taps. Default: 0.4 -
  • -
  • on_click - function - function(self, node) -
  • -
  • on_click_disabled - function - function(self, node) -
  • -
  • on_hover - function - function(self, node, hover_state) -
  • -
  • on_mouse_hover - function - function(self, node, hover_state) -
  • -
  • on_set_enabled - function - function(self, node, enabled_state) -
  • -
- - - - - -
-
-

Fields

- -
-
- - anim_node -
-
- Button animation node. - In default case equals to clickable node. -

Usecase: You have the big clickable panel, but want to animate only one small icon on it. - - -

    -
  • anim_node - node or nil - Default node -
  • -
- - - - - -
-
- - click_zone -
-
- Additional button click area, defined by another GUI node - - -
    -
  • click_zone - node or nil - -
  • -
- - - - - -
-
- - hover -
-
- The Hover: Button Hover component - - -
    -
  • hover - Hover - Hover -
  • -
- - - - - -
-
- - node -
-
- Button trigger node - - -
    -
  • node - node - -
  • -
- - - - - -
-
- - node_id -
-
- The GUI node id from button node - - -
    -
  • node_id - hash - -
  • -
- - - - - -
-
- - on_click -
-
- The DruidEvent: Event on successful release action over button. - - - - - - - -

Usage:

-
    -
    -- Custom args passed in Button constructor
    -button.on_click:subscribe(function(self, custom_args, button_instance)
    -    print("On button click!")
    -end)
    -
- -
-
- - on_click_outside -
-
- The DruidEvent: Event calls if click event was outside of button. -

This event will be triggered for each button what was not clicked on user click action -

Usecase: Hide the popup when click outside - - -

    -
  • on_click_outside - DruidEvent - DruidEvent -
  • -
- - - - -

Usage:

-
    -
    -- Custom args passed in Button constructor
    -button.on_click_outside:subscribe(function(self, custom_args, button_instance)
    -    print("On click Button outside!")
    -end)
    -
- -
-
- - on_double_click -
-
- The DruidEvent: Event on double tap action over button. -

If secondary click was too fast after previous one, the double - click will be called instead usual click (if on_double_click subscriber exists) - - -

- - - - -

Usage:

-
    -
    -- Custom args passed in Button constructor
    -button.on_double_click:subscribe(function(self, custom_args, button_instance, click_amount)
    -    print("On double Button click!")
    -end)
    -
- -
-
- - on_hold_callback -
-
- The DruidEvent: Event calls every frame before on_long_click event. -

If long_click subscriber exists, the on_hold_callback will be called before long_click trigger. -

Usecase: Animate button progress of long tap - - -

    -
  • on_hold_callback - DruidEvent - DruidEvent -
  • -
- - - - -

Usage:

-
    -
    -- Custom args passed in Button constructor
    -button.on_double_click:subscribe(function(self, custom_args, button_instance, time)
    -    print("On hold Button callback!")
    -end)
    -
- -
-
- - on_long_click -
-
- The DruidEvent: Event on long tap action over button. -

This callback will be triggered if user pressed the button and hold the some amount of time. - The amount of time picked from button style param: LONGTAP_TIME - - -

- - - - -

Usage:

-
    -
    -- Custom args passed in Button constructor
    -button.on_long_click:subscribe(function(self, custom_args, button_instance, hold_time)
    -    print("On long Button click!")
    -end)
    -
- -
-
- - on_pressed -
-
- The DruidEvent: Event triggered if button was pressed by user. - - - - - - - -

Usage:

-
    -
    -- Custom args passed in Button constructor
    -button.on_pressed:subscribe(function(self, custom_args, button_instance)
    -    print("On Button pressed!")
    -end)
    -
- -
-
- - on_repeated_click -
-
- The DruidEvent: Event on repeated action over button. -

This callback will be triggered if user hold the button. The repeat rate pick from `input.repeat_interval` in game.project - - -

    -
  • on_repeated_click - DruidEvent - DruidEvent -
  • -
- - - - -

Usage:

-
    -
    -- Custom args passed in Button constructor
    -button.on_repeated_click:subscribe(function(self, custom_args, button_instance, click_count)
    -    print("On repeated Button click!")
    -end)
    -
- -
-
- - params -
-
- Custom args for any Button event. Setup in Button constructor - - -
    -
  • params - any - -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/Checkbox.html b/docs/modules/Checkbox.html deleted file mode 100644 index fd0aef1..0000000 --- a/docs/modules/Checkbox.html +++ /dev/null @@ -1,350 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module Checkbox

-

Druid checkbox component

-

Example Link

- - -

Functions

- - - - - - - - - - - - - -
get_state(self)Return checkbox state
init(self, node, callback, click_node, initial_state)The Checkbox constructor
set_state(self, state, is_silent, is_instant)Set checkbox state
-

Tables

- - - - - -
styleComponent style params.
-

Fields

- - - - - - - - - - - - - - - - - -
buttonButton component from click_node
click_nodeButton trigger node
nodeVisual node
on_change_stateOn change state callback(self, state)
- -
-
- - -

Functions

- -
-
- - get_state(self) -
-
- Return checkbox state - - -

Parameters:

- - -

Returns:

-
    - - boolean - Checkbox state -
- - - - -
-
- - init(self, node, callback, click_node, initial_state) -
-
- The Checkbox constructor - - -

Parameters:

-
    -
  • self - Checkbox - Checkbox -
  • -
  • node - node - Gui node -
  • -
  • callback - function - Checkbox callback -
  • -
  • click_node - node or nil - Trigger node, by default equals to node. Default: node -
  • -
  • initial_state - boolean or nil - The initial state of checkbox, default - false -
  • -
- - - - - -
-
- - set_state(self, state, is_silent, is_instant) -
-
- Set checkbox state - - -

Parameters:

-
    -
  • self - Checkbox - Checkbox -
  • -
  • state - boolean or nil - Checkbox state -
  • -
  • is_silent - boolean or nil - Don't trigger on_change_state if true -
  • -
  • is_instant - boolean or nil - If instant checkbox change -
  • -
- - - - - -
-
-

Tables

- -
-
- - style -
-
- Component style params. - You can override this component styles params in druid styles table - or create your own style - - -

Fields:

-
    -
  • on_change_state - function - (self, node, state) -
  • -
- - - - - -
-
-

Fields

- -
-
- - button -
-
- Button component from click_node - - -
    -
  • button - Button - Button -
  • -
- - - - - -
-
- - click_node -
-
- Button trigger node - - -
    -
  • click_node - node or nil - -
  • -
- - - - - -
-
- - node -
-
- Visual node - - -
    -
  • node - node - -
  • -
- - - - - -
-
- - on_change_state -
-
- On change state callback(self, state) - - - - - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/CheckboxGroup.html b/docs/modules/CheckboxGroup.html deleted file mode 100644 index 5ff8ec1..0000000 --- a/docs/modules/CheckboxGroup.html +++ /dev/null @@ -1,259 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module CheckboxGroup

-

Checkbox group module

-

Example Link

- - -

Functions

- - - - - - - - - - - - - -
get_state(self)Return checkbox group state
init(self, nodes, callback, click_nodes)The CheckboxGroup constructor
set_state(self, indexes, is_instant)Set checkbox group state
-

Fields

- - - - - - - - - -
checkboxesArray of checkbox components
on_checkbox_clickOn any checkbox click callback(self, index)
- -
-
- - -

Functions

- -
-
- - get_state(self) -
-
- Return checkbox group state - - -

Parameters:

- - -

Returns:

-
    - - boolean[] - Array if checkboxes state -
- - - - -
-
- - init(self, nodes, callback, click_nodes) -
-
- The CheckboxGroup constructor - - -

Parameters:

-
    -
  • self - CheckboxGroup - CheckboxGroup -
  • -
  • nodes - node[] - Array of gui node -
  • -
  • callback - function - Checkbox callback -
  • -
  • click_nodes - node[] or nil - Array of trigger nodes, by default equals to nodes -
  • -
- - - - - -
-
- - set_state(self, indexes, is_instant) -
-
- Set checkbox group state - - -

Parameters:

-
    -
  • self - CheckboxGroup - CheckboxGroup -
  • -
  • indexes - boolean[] - Array of checkbox state -
  • -
  • is_instant - boolean or nil - If instant state change -
  • -
- - - - - -
-
-

Fields

- -
-
- - checkboxes -
-
- Array of checkbox components - - - - - - - - -
-
- - on_checkbox_click -
-
- On any checkbox click callback(self, index) - - -
    -
  • on_checkbox_click - DruidEvent - DruidEvent -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/DataList.html b/docs/modules/DataList.html deleted file mode 100644 index 680d3ce..0000000 --- a/docs/modules/DataList.html +++ /dev/null @@ -1,712 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module DataList

-

Component to manage data for huge dataset in scroll.

-

- It requires Druid Scroll and Druid Grid (Static or Dynamic) components -

Example Link

- - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
add(self, data, index, shift_policy)Add element to DataList.
clear(self)Clear the DataList and refresh visuals
get_created_components(self)Return all currenly created components in DataList
get_created_nodes(self)Return all currenly created nodes in DataList
get_data(self)Return current data from DataList component
get_index(self, data)Return index for data value
init(self, scroll, grid, create_function)The DataList constructor
on_remove(self)Druid System on_remove function
remove(self, index, shift_policy)Remove element from DataList.
remove_by_data(self, data, shift_policy)Remove element from DataList by data value.
scroll_to_index(self, index)Instant scroll to element with passed index
set_data(self, data)Set new data set for DataList component
set_use_cache(self, is_use_cache)Set refresh function for DataList component
-

Fields

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
gridThe Druid Grid component
last_indexThe current last index of visual elements
on_element_addOn DataList visual element created Event callback(self, index, node, instance)
on_element_removeOn DataList visual element created Event callback(self, index)
on_scroll_progress_changeEvent triggered when scroll progress is changed; event(self, progress_value)
scrollThe Druid scroll component
scroll_progressThe current progress of scroll posititon
top_indexThe current top index of visual elements
- -
-
- - -

Functions

- -
-
- - add(self, data, index, shift_policy) -
-
- Add element to DataList. Currenly untested - - -

Parameters:

-
    -
  • self - DataList - DataList -
  • -
  • data - table - -
  • -
  • index - number or nil - -
  • -
  • shift_policy - number or nil - The constant from const.SHIFT.* -
  • -
- - - - - -
-
- - clear(self) -
-
- Clear the DataList and refresh visuals - - -

Parameters:

- - - - - - -
-
- - get_created_components(self) -
-
- Return all currenly created components in DataList - - -

Parameters:

- - -

Returns:

-
    - - druid.base_component[] - List of created nodes -
- - - - -
-
- - get_created_nodes(self) -
-
- Return all currenly created nodes in DataList - - -

Parameters:

- - -

Returns:

-
    - - node[] - List of created nodes -
- - - - -
-
- - get_data(self) -
-
- Return current data from DataList component - - -

Parameters:

- - -

Returns:

-
    - - table - The current data array -
- - - - -
-
- - get_index(self, data) -
-
- Return index for data value - - -

Parameters:

- - - - - - -
-
- - init(self, scroll, grid, create_function) -
-
- The DataList constructor - - -

Parameters:

-
    -
  • self - DataList - DataList -
  • -
  • scroll - Scroll - The Scroll instance for Data List component -
  • -
  • grid - StaticGrid - The StaticGrid or DynamicGrid instance for Data List component -
  • -
  • create_function - function - The create function callback(self, data, index, data_list). Function should return (node, [component]) -
  • -
- - - - - -
-
- - on_remove(self) -
-
- Druid System on_remove function - - -

Parameters:

- - - - - - -
-
- - remove(self, index, shift_policy) -
-
- Remove element from DataList. Currenly untested - - -

Parameters:

-
    -
  • self - DataList - DataList -
  • -
  • index - number or nil - -
  • -
  • shift_policy - number or nil - The constant from const.SHIFT.* -
  • -
- - - - - -
-
- - remove_by_data(self, data, shift_policy) -
-
- Remove element from DataList by data value. Currenly untested - - -

Parameters:

-
    -
  • self - DataList - DataList -
  • -
  • data - table - -
  • -
  • shift_policy - number or nil - The constant from const.SHIFT.* -
  • -
- - - - - -
-
- - scroll_to_index(self, index) -
-
- Instant scroll to element with passed index - - -

Parameters:

-
    -
  • self - DataList - DataList -
  • -
  • index - number - -
  • -
- - - - - -
-
- - set_data(self, data) -
-
- Set new data set for DataList component - - -

Parameters:

-
    -
  • self - DataList - DataList -
  • -
  • data - table - The new data array -
  • -
- -

Returns:

-
    - - druid.data_list - Current DataList instance -
- - - - -
-
- - set_use_cache(self, is_use_cache) -
-
- Set refresh function for DataList component - - -

Parameters:

-
    -
  • self - DataList - DataList -
  • -
  • is_use_cache - boolean - Use cache version of DataList. Requires make setup of components in on_element_add callback and clean in on_element_remove -
  • -
- -

Returns:

-
    - - druid.data_list - Current DataList instance -
- - - - -
-
-

Fields

- -
-
- - grid -
-
- The Druid Grid component - - - - - - - - -
-
- - last_index -
-
- The current last index of visual elements - - -
    -
  • last_index - number - -
  • -
- - - - - -
-
- - on_element_add -
-
- On DataList visual element created Event callback(self, index, node, instance) - - - - - - - - -
-
- - on_element_remove -
-
- On DataList visual element created Event callback(self, index) - - -
    -
  • on_element_remove - DruidEvent - DruidEvent -
  • -
- - - - - -
-
- - on_scroll_progress_change -
-
- Event triggered when scroll progress is changed; event(self, progress_value) - - -
    -
  • on_scroll_progress_change - DruidEvent - DruidEvent -
  • -
- - - - - -
-
- - scroll -
-
- The Druid scroll component - - -
    -
  • scroll - Scroll - Scroll -
  • -
- - - - - -
-
- - scroll_progress -
-
- The current progress of scroll posititon - - -
    -
  • scroll_progress - number - -
  • -
- - - - - -
-
- - top_index -
-
- The current top index of visual elements - - -
    -
  • top_index - number - -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/Drag.html b/docs/modules/Drag.html deleted file mode 100644 index 51a7c36..0000000 --- a/docs/modules/Drag.html +++ /dev/null @@ -1,633 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module Drag

-

Component to handle drag action on node.

-

- Drag have correct handling for multitouch and swap - touched while dragging. Drag will be processed even - the cursor is outside of node, if drag is already started -

Example Link

- - -

Functions

- - - - - - - - - - - - - - - - - -
init(self, node, on_drag_callback)The Drag constructor
is_enabled(self)Check if Drag component is enabled
set_click_zone(self, node)Strict drag click area.
set_enabled(self, is_enabled)Set Drag input enabled or disabled
-

Tables

- - - - - -
styleComponent style params.
-

Fields

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
can_xIs drag component process vertical dragging.
can_yIs drag component process horizontal.
is_dragIs component now dragging
is_touchIs component now touching
nodeDrag node
on_dragon drag progress callback(self, dx, dy, total_x, total_y, touch)
on_drag_endEvent on drag end callback(self, total_x, total_y, touch)
on_drag_startEvent on drag start callback(self, touch)
on_touch_endEvent on touch end callback(self)
on_touch_startEvent on touch start callback(self)
screen_xCurrent touch x screen position
screen_yCurrent touch y screen position
touch_start_posTouch start position
xCurrent touch x position
yCurrent touch y position
- -
-
- - -

Functions

- -
-
- - init(self, node, on_drag_callback) -
-
- The Drag constructor - - -

Parameters:

-
    -
  • self - Drag - Drag -
  • -
  • node - node - GUI node to detect dragging -
  • -
  • on_drag_callback - function - Callback for on_drag_event(self, dx, dy) -
  • -
- - - - - -
-
- - is_enabled(self) -
-
- Check if Drag component is enabled - - -

Parameters:

-
    -
  • self - Drag - Drag -
  • -
- -

Returns:

-
    - - boolean - -
- - - - -
-
- - set_click_zone(self, node) -
-
- Strict drag click area. Useful for - restrict events outside stencil node - - -

Parameters:

- - - - - - -
-
- - set_enabled(self, is_enabled) -
-
- Set Drag input enabled or disabled - - -

Parameters:

-
    -
  • self - Drag - Drag -
  • -
  • is_enabled - boolean or nil - -
  • -
- - - - - -
-
-

Tables

- -
-
- - style -
-
- Component style params. - You can override this component styles params in druid styles table - or create your own style - - -

Fields:

-
    -
  • DRAG_DEADZONE - number or nil - Distance in pixels to start dragging. Default: 10 -
  • -
  • NO_USE_SCREEN_KOEF - boolean or nil - If screen aspect ratio affects on drag values. Default: false -
  • -
- - - - - -
-
-

Fields

- -
-
- - can_x -
-
- Is drag component process vertical dragging. Default - true - - -
    -
  • can_x - boolean - -
  • -
- - - - - -
-
- - can_y -
-
- Is drag component process horizontal. Default - true - - -
    -
  • can_y - boolean - -
  • -
- - - - - -
-
- - is_drag -
-
- Is component now dragging - - -
    -
  • is_drag - boolean - -
  • -
- - - - - -
-
- - is_touch -
-
- Is component now touching - - -
    -
  • is_touch - boolean - -
  • -
- - - - - -
-
- - node -
-
- Drag node - - -
    -
  • node - node - -
  • -
- - - - - -
-
- - on_drag -
-
- on drag progress callback(self, dx, dy, total_x, total_y, touch) - - - - - - - - -
-
- - on_drag_end -
-
- Event on drag end callback(self, total_x, total_y, touch) - - - - - - - - -
-
- - on_drag_start -
-
- Event on drag start callback(self, touch) - - - - - - - - -
-
- - on_touch_end -
-
- Event on touch end callback(self) - - - - - - - - -
-
- - on_touch_start -
-
- Event on touch start callback(self) - - - - - - - - -
-
- - screen_x -
-
- Current touch x screen position - - -
    -
  • screen_x - number - -
  • -
- - - - - -
-
- - screen_y -
-
- Current touch y screen position - - -
    -
  • screen_y - number - -
  • -
- - - - - -
-
- - touch_start_pos -
-
- Touch start position - - -
    -
  • touch_start_pos - vector3 - -
  • -
- - - - - -
-
- - x -
-
- Current touch x position - - -
    -
  • x - number - -
  • -
- - - - - -
-
- - y -
-
- Current touch y position - - -
    -
  • y - number - -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/Druid.html b/docs/modules/Druid.html deleted file mode 100644 index 0af243a..0000000 --- a/docs/modules/Druid.html +++ /dev/null @@ -1,374 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module Druid

-

Druid UI Component Framework.

-

- # Overview # -

Druid - powerful Defold component UI library. Use basic and extended - Druid components or make your own game-specific components to make - amazing GUI in your games. -

To start using Druid, please refer to the Usage section below. -

# Notes # -

• Each Druid instance maintains the self context from the constructor and passes it to each Druid callback. -

See next: DruidInstance -

-

Usage:

-
    -
    local druid = require("druid.druid")
    -
    -local function on_play(self)
    -    print("Gonna play!")
    -end
    -
    -function init(self)
    -    self.druid = druid.new(self)
    -    self.druid:new_button("button_play", on_play)
    -end
    -
    -function final(self)
    -    self.druid:final()
    -end
    -
    -function update(self, dt)
    -    self.druid:update(dt)
    -end
    -
    -function on_message(self, message_id, message, sender)
    -    self.druid:on_message(message_id, message, sender)
    -end
    -
    -function on_input(self, action_id, action)
    -    return self.druid:on_input(action_id, action)
    -end
    -
    -
- - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
druid.new(context, style)Create a new Druid instance for creating GUI components.
druid.on_language_change()Call this function when the game language changes.
druid.on_window_callback(event)Set the window callback to enable on_focus_gain and on_focus_lost functions.
druid.register(name, module)Register a new external Druid component.
druid.set_default_style(style)Set your own default style for all Druid instances.
druid.set_sound_function(callback)Set the Druid sound function to play UI sounds if used.
druid.set_text_function(callback)Set the text function for the LangText component.
- -
-
- - -

Functions

- -
-
- - druid.new(context, style) -
-
- Create a new Druid instance for creating GUI components. - - -

Parameters:

-
    -
  • context - table - The Druid context. Usually, this is the self of the gui_script. It is passed into all Druid callbacks. -
  • -
  • style - table or nil - The Druid style table to override style parameters for this Druid instance. -
  • -
- -

Returns:

-
    - - druid_instance - The Druid instance DruidInstance. -
- - - -

Usage:

-
    -
    local druid = require("druid.druid")
    -
    -function init(self)
    -   self.druid = druid.new(self)
    -end
    -
- -
-
- - druid.on_language_change() -
-
- Call this function when the game language changes. -

This function will translate all current LangText components. - - - - - - -

Usage:

-
    -
    druid.on_language_change()
    -
- -
-
- - druid.on_window_callback(event) -
-
- Set the window callback to enable on_focus_gain and on_focus_lost functions. -

This is used to trigger the on_focus_lost and on_focus_gain functions in Druid components. - - -

Parameters:

-
    -
  • event - string - Event param from window listener -
  • -
- - - - -

Usage:

-
    -
    window.set_listener(function(_, event)
    -   druid.on_window_callback(event)
    -end)
    -
- -
-
- - druid.register(name, module) -
-
- Register a new external Druid component. -

You can register your own components to make new alias: the druid:new_{name} function. - For example, if you want to register a component called "my_component", you can create it using druid:new_my_component(...). - This can be useful if you have your own "basic" components that you don't want to re-create each time. - - -

Parameters:

-
    -
  • name - string - module name -
  • -
  • module - table - lua table with component -
  • -
- - - - -

Usage:

-
    -
    local my_component = require("path.to.my.component")
    -druid.register("my_component", my_component)
    -...
    -local druid = druid.new(self)
    -local component_instance = self.druid:new_my_component(...)
    -
- -
-
- - druid.set_default_style(style) -
-
- Set your own default style for all Druid instances. -

To create your own style file, copy the default style file and make changes to it. - Register the new style before creating your Druid instances. - - -

Parameters:

-
    -
  • style - table - Druid style module -
  • -
- - - - -

Usage:

-
    -
    local my_style = require("path.to.my.style")
    -druid.set_default_style(my_style)
    -
- -
-
- - druid.set_sound_function(callback) -
-
- Set the Druid sound function to play UI sounds if used. -

Set a function to play a sound given a sound_id. This function is used for button clicks to play the "click" sound. - It can also be used to play sounds in your custom components (see the default Druid style file for an example). - - -

Parameters:

-
    -
  • callback - function - Sound play callback -
  • -
- - - - -

Usage:

-
    -
    druid.set_sound_function(function(sound_id)
    -    sound.play(sound_id) -- Replace with your real function
    -end)
    -
- -
-
- - druid.set_text_function(callback) -
-
- Set the text function for the LangText component. -

The Druid locale component will call this function to get translated text. - After setting the text function, all existing locale components will be updated. - - -

Parameters:

-
    -
  • callback - function - Get localized text function -
  • -
- - - - -

Usage:

-
    -
    druid.set_text_function(function(text_id)
    -   return lang_data[text_id] -- Replace with your real function
    -end)
    -
- -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/DruidEvent.html b/docs/modules/DruidEvent.html deleted file mode 100644 index a761399..0000000 --- a/docs/modules/DruidEvent.html +++ /dev/null @@ -1,399 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module DruidEvent

-

Druid Event Module -

The Event module provides a simple class for handling callbacks.

-

It is used in many Druid components. -

You can subscribe to an event using the `:subscribe` method and unsubscribe using the `:unsubscribe` method.

- - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
clear(self)Clear the all event handlers
create(callback, callback_context)DruidEvent constructor
is_empty(self)Return true, if event not have handler
is_exist(self)Return true, if event have at lease one handler
is_subscribed(self, callback, callback_context)Check is event subscribed.
subscribe(self, callback, callback_context)Subscribe callback on event
trigger(self, ...)Trigger the event and call all subscribed callbacks
unsubscribe(self, callback, callback_context)Unsubscribe callback on event
- -
-
- - -

Functions

- -
-
- - clear(self) -
-
- Clear the all event handlers - - -

Parameters:

- - - - - -

Usage:

-
    -
    button.on_long_click:clear()
    -
- -
-
- - create(callback, callback_context) -
-
- DruidEvent constructor - - -

Parameters:

-
    -
  • callback - function or nil - Subscribe the callback on new event, if callback exist -
  • -
  • callback_context - any or nil - Additional context as first param to callback call -
  • -
- - - - -

Usage:

-
    -
    local Event = require("druid.event")
    -...
    -local event = Event(callback)
    -
- -
-
- - is_empty(self) -
-
- Return true, if event not have handler - - -

Parameters:

- - -

Returns:

-
    - - boolean - True if event not have handlers -
- - - -

Usage:

-
    -
    local is_long_click_handler_not_exists = button.on_long_click:is_empty()
    -
- -
-
- - is_exist(self) -
-
- Return true, if event have at lease one handler - - -

Parameters:

- - -

Returns:

-
    - - boolean - True if event have handlers -
- - - -

Usage:

-
    -
    local is_long_click_handler_exists = button.on_long_click:is_exist()
    -
- -
-
- - is_subscribed(self, callback, callback_context) -
-
- Check is event subscribed. - - -

Parameters:

-
    -
  • self - DruidEvent - DruidEvent -
  • -
  • callback - function - Callback itself -
  • -
  • callback_context - any or nil - Additional context as first param to callback call -
  • -
- -

Returns:

-
    - - boolean, - number|nil @Is event subscribed, return index of callback in event as second param -
- - - - -
-
- - subscribe(self, callback, callback_context) -
-
- Subscribe callback on event - - -

Parameters:

-
    -
  • self - DruidEvent - DruidEvent -
  • -
  • callback - function - Callback itself -
  • -
  • callback_context - any or nil - Additional context as first param to callback call, usually it's self -
  • -
- -

Returns:

-
    - - boolean - True if callback was subscribed -
- - - -

Usage:

-
    -
    local function on_long_callback(self)
    -    print("Long click!")
    -end
    -...
    -local button = self.druid:new_button("button", callback)
    -button.on_long_click:subscribe(on_long_callback, self)
    -
- -
-
- - trigger(self, ...) -
-
- Trigger the event and call all subscribed callbacks - - -

Parameters:

-
    -
  • self - DruidEvent - DruidEvent -
  • -
  • ... - any - All event params -
  • -
- - - - -

Usage:

-
    -
    local Event = require("druid.event")
    -...
    -local event = Event()
    -event:trigger("Param1", "Param2")
    -
- -
-
- - unsubscribe(self, callback, callback_context) -
-
- Unsubscribe callback on event - - -

Parameters:

-
    -
  • self - DruidEvent - DruidEvent -
  • -
  • callback - function - Callback itself -
  • -
  • callback_context - any or nil - Additional context as first param to callback call -
  • -
- - - - -

Usage:

-
    -
    local function on_long_callback(self)
    -    print("Long click!")
    -end
    -...
    -button.on_long_click:unsubscribe(on_long_callback, self)
    -
- -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/DruidInstance.html b/docs/modules/DruidInstance.html deleted file mode 100644 index afa2ecb..0000000 --- a/docs/modules/DruidInstance.html +++ /dev/null @@ -1,1223 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module DruidInstance

-

Druid Instance which you use for component creation.

-

-

# Component List # -

For a list of all available components, please refer to the "See Also" section. -

# Notes # -

Please review the following API pages: -

Helper - A useful set of functions for working with GUI nodes, such as centering nodes, get GUI scale ratio, etc -

DruidEvent - The core event system in Druid. Learn how to subscribe to any event in every Druid component. -

BaseComponent - The parent class of all Druid components. You can find all default component methods there. -

# Tech Info # -

• To use Druid, you need to create a Druid instance first. This instance is used to spawn components. -

• When using Druid components, provide the node name as a string argument directly. Avoid calling gui.get_node() before passing it to the component. Because Druid can get nodes from template and cloned gui nodes. -

• All Druid and component methods are called using the colon operator (e.g., self.druid:new_button()).

-

See also:

- -

Usage:

-
    -
    local druid = require("druid.druid")
    -
    -local function close_window(self)
    -    print("Yeah! You closed the game!")
    -end
    -
    -function init(self)
    -    self.druid = druid.new(self)
    -
    -    -- Call all druid instance function with ":" syntax:
    -    local text = self.druid:new_text("text_header", "Hello Druid!")
    -    local button = self.druid:new_button("button_close", close_window)
    -
    -    -- You not need to save component reference if not need it
    -    self.druid:new_back_handler(close_window)
    -end
    -
    -
- - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
final(self)Call this in gui_script final function.
new_back_handler(self, callback, params)Create BackHandler component
new_blocker(self, node)Create Blocker component
new_button(self, node, callback, params, anim_node)Create Button component
new_data_list(self, druid_scroll, druid_grid, create_function)Create DataList component
new_drag(self, node, on_drag_callback)Create Drag component
new_dynamic_grid(self, parent_node)Create DynamicGrid component - Deprecated
new_hotkey(self, keys_array, callback, callback_argument)Create Hotkey component
new_hover(self, node, on_hover_callback, on_mouse_hover_callback)Create Hover component
new_input(self, click_node, text_node, keyboard_type)Create Input component
new_lang_text(self, node, locale_id, adjust_type)Create LangText component
new_layout(self, node, mode)Create Layout component
new_progress(self, node, key, init_value)Create Progress component
new_rich_input(self, template, nodes)Create RichInput component.
new_rich_text(self, text_node, value)Create RichText component.
new_scroll(self, view_node, content_node)Create Scroll component
new_slider(self, pin_node, end_pos, callback)Create Slider component
new_static_grid(self, parent_node, item, in_row)Create StaticGrid component
new_swipe(self, node, on_swipe_callback)Create Swipe component
new_text(self, node, value, no_adjust)Create Text component
new_timer(self, node, seconds_from, seconds_to, callback)Create Timer component
on_input(self, action_id, action)Call this in gui_script on_input function.
on_message(self, message_id, message, sender)Call this in gui_script on_message function.
remove(self, component)Remove created component from Druid instance.
set_blacklist(self, blacklist_components)Set blacklist components for input processing.
set_whitelist(self, whitelist_components)Set whitelist components for input processing.
update(self, dt)Call this in gui_script update function.
- -
-
- - -

Functions

- -
-
- - final(self) -
-
- Call this in gui_script final function. - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
- - - - - -
-
- - new_back_handler(self, callback, params) -
-
- Create BackHandler component - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • callback - function or nil - @The callback(self, custom_args) to call on back event -
  • -
  • params - any or nil - Callback argument -
  • -
- -

Returns:

-
    - - BackHandler - BackHandler component -
- - - - -
-
- - new_blocker(self, node) -
-
- Create Blocker component - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • node - string or node - The node_id or gui.get_node(node_id) -
  • -
- -

Returns:

-
    - - Blocker - Blocker component -
- - - - -
-
- - new_button(self, node, callback, params, anim_node) -
-
- Create Button component - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • node - string or node - The node_id or gui.get_node(node_id) -
  • -
  • callback - function or nil - Button callback -
  • -
  • params - any or nil - Button callback params -
  • -
  • anim_node - node, string or nil - Button anim node (node, if not provided) -
  • -
- -

Returns:

-
    - - Button - Button component -
- - - - -
-
- - new_data_list(self, druid_scroll, druid_grid, create_function) -
-
- Create DataList component - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • druid_scroll - Scroll - The Scroll instance for Data List component -
  • -
  • druid_grid - StaticGrid - The StaticGrid or DynamicGrid instance for Data List component -
  • -
  • create_function - function - The create function callback(self, data, index, data_list). Function should return (node, [component]) -
  • -
- -

Returns:

-
    - - DataList - DataList component -
- - - - -
-
- - new_drag(self, node, on_drag_callback) -
-
- Create Drag component - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • node - string or node - The node_id or gui.get_node(node_id). Will used as user input node. -
  • -
  • on_drag_callback - function or nil - Callback for on_drag_event(self, dx, dy) -
  • -
- -

Returns:

-
    - - Drag - Drag component -
- - - - -
-
- - new_dynamic_grid(self, parent_node) -
-
- Create DynamicGrid component - Deprecated - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • parent_node - string or node - The node_id or gui.get_node(node_id). Parent of all Grid items. -
  • -
- -

Returns:

-
    - - DynamicGrid - DynamicGrid component -
- - - - -
-
- - new_hotkey(self, keys_array, callback, callback_argument) -
-
- Create Hotkey component - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • keys_array - string or string[] - Keys for trigger action. Should contains one action key and any amount of modificator keys -
  • -
  • callback - function - The callback function -
  • -
  • callback_argument - any or nil - The argument to pass into the callback function -
  • -
- -

Returns:

-
    - - Hotkey - Hotkey component -
- - - - -
-
- - new_hover(self, node, on_hover_callback, on_mouse_hover_callback) -
-
- Create Hover component - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • node - string or node - The node_id or gui.get_node(node_id) -
  • -
  • on_hover_callback - function or nil - Hover callback -
  • -
  • on_mouse_hover_callback - function or nil - Mouse hover callback -
  • -
- -

Returns:

-
    - - Hover - Hover component -
- - - - -
-
- - new_input(self, click_node, text_node, keyboard_type) -
-
- Create Input component - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • click_node - string or node - Button node to enabled input component -
  • -
  • text_node - string, node or druid.text - Text node what will be changed on user input -
  • -
  • keyboard_type - number or nil - Gui keyboard type for input field -
  • -
- -

Returns:

-
    - - Input - Input component -
- - - - -
-
- - new_lang_text(self, node, locale_id, adjust_type) -
-
- Create LangText component - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • node - string or node - The_node id or gui.get_node(node_id) -
  • -
  • locale_id - string or nil - Default locale id or text from node as default -
  • -
  • adjust_type - string or nil - Adjust type for text node. Default: const.TEXT_ADJUST.DOWNSCALE -
  • -
- -

Returns:

-
    - - LangText - LangText component -
- - - - -
-
- - new_layout(self, node, mode) -
-
- Create Layout component - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • node - string or node - The_node id or gui.get_node(node_id). -
  • -
  • mode - string - The layout mode -
  • -
- -

Returns:

-
    - - Layout - Layout component -
- - - - -
-
- - new_progress(self, node, key, init_value) -
-
- Create Progress component - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • node - string or node - Progress bar fill node or node name -
  • -
  • key - string - Progress bar direction: const.SIDE.X or const.SIDE.Y -
  • -
  • init_value - number or nil - Initial value of progress bar. Default: 1 -
  • -
- -

Returns:

-
    - - Progress - Progress component -
- - - - -
-
- - new_rich_input(self, template, nodes) -
-
- Create RichInput component. - As a template please check rich_input.gui layout. - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • template - string - The template string name -
  • -
  • nodes - table - Nodes table from gui.clone_tree -
  • -
- -

Returns:

-
    - - RichInput - RichInput component -
- - - - -
-
- - new_rich_text(self, text_node, value) -
-
- Create RichText component. - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • text_node - string or node - The text node to make Rich Text -
  • -
  • value - string or nil - The initial text value. Default will be gui.get_text(text_node) -
  • -
- -

Returns:

-
    - - RichText - RichText component -
- - - - -
-
- - new_scroll(self, view_node, content_node) -
-
- Create Scroll component - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • view_node - string or node - The node_id or gui.get_node(node_id). Will used as user input node. -
  • -
  • content_node - string or node - The node_id or gui.get_node(node_id). Will used as scrollable node inside view_node. -
  • -
- -

Returns:

-
    - - Scroll - Scroll component -
- - - - -
-
- - new_slider(self, pin_node, end_pos, callback) -
-
- Create Slider component - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • pin_node - string or node - The_node id or gui.get_node(node_id). -
  • -
  • end_pos - vector3 - The end position of slider -
  • -
  • callback - function or nil - On slider change callback -
  • -
- -

Returns:

-
    - - Slider - Slider component -
- - - - -
-
- - new_static_grid(self, parent_node, item, in_row) -
-
- Create StaticGrid component - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • parent_node - string or node - The node_id or gui.get_node(node_id). Parent of all Grid items. -
  • -
  • item - string or node - Item prefab. Required to get grid's item size. Can be adjusted separately. -
  • -
  • in_row - number or nil - How many nodes in row can be placed -
  • -
- -

Returns:

-
    - - StaticGrid - StaticGrid component -
- - - - -
-
- - new_swipe(self, node, on_swipe_callback) -
-
- Create Swipe component - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • node - string or node - The node_id or gui.get_node(node_id). Will used as user input node. -
  • -
  • on_swipe_callback - function or nil - Swipe callback for on_swipe_end event -
  • -
- -

Returns:

-
    - - Swipe - Swipe component -
- - - - -
-
- - new_text(self, node, value, no_adjust) -
-
- Create Text component - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • node - string or node - The node_id or gui.get_node(node_id) -
  • -
  • value - string or nil - Initial text. Default value is node text from GUI scene. -
  • -
  • no_adjust - boolean or nil - If true, text will be not auto-adjust size -
  • -
- -

Returns:

-
    - - Text - Text component -
- - - - -
-
- - new_timer(self, node, seconds_from, seconds_to, callback) -
-
- Create Timer component - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • node - string or node - Gui text node -
  • -
  • seconds_from - number - Start timer value in seconds -
  • -
  • seconds_to - number or nil - End timer value in seconds -
  • -
  • callback - function or nil - Function on timer end -
  • -
- -

Returns:

-
    - - Timer - Timer component -
- - - - -
-
- - on_input(self, action_id, action) -
-
- Call this in gui_script on_input function. -

Used for almost all components - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • action_id - hash - Action_id from on_input -
  • -
  • action - table - Action from on_input -
  • -
- -

Returns:

-
    - - boolean - The boolean value is input was consumed -
- - - - -
-
- - on_message(self, message_id, message, sender) -
-
- Call this in gui_script on_message function. -

Used for special actions. See SPECIFIC_UI_MESSAGES table - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • message_id - hash - Message_id from on_message -
  • -
  • message - table - Message from on_message -
  • -
  • sender - url - Sender from on_message -
  • -
- - - - - -
-
- - remove(self, component) -
-
- Remove created component from Druid instance. -

Component `on_remove` function will be invoked, if exist. - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • component - BaseComponent - Component instance -
  • -
- -

Returns:

-
    - - boolean - True if component was removed -
- - - - -
-
- - set_blacklist(self, blacklist_components) -
-
- Set blacklist components for input processing. -

If blacklist is not empty and component contains in this list, - component will be not processed on input step - - -

Parameters:

-
    -
  • self - DruidInstance - DruidInstance -
  • -
  • blacklist_components - table, BaseComponent or nil - The array of component to blacklist -
  • -
- -

Returns:

-
    - - self - DruidInstance -
- - - - -
-
- - set_whitelist(self, whitelist_components) -
-
- Set whitelist components for input processing. -

If whitelist is not empty and component not contains in this list, - component will be not processed on input step - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • whitelist_components - table, BaseComponent or nil - The array of component to whitelist -
  • -
- -

Returns:

-
    - - self - DruidInstance -
- - - - -
-
- - update(self, dt) -
-
- Call this in gui_script update function. -

Used for: scroll, progress, timer components - - -

Parameters:

-
    -
  • self - DruidInstance - -
  • -
  • dt - number - Delta time -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/DynamicGrid.html b/docs/modules/DynamicGrid.html deleted file mode 100644 index d6e7af6..0000000 --- a/docs/modules/DynamicGrid.html +++ /dev/null @@ -1,788 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module DynamicGrid

-

Component to handle placing components in row

-

Example Link

- - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_get_side_vector(self, side, is_forward)Return side vector to correct node shifting
add(self, node, index, shift_policy, is_instant)Add new node to the grid
clear(self)Clear grid nodes array.
get_all_pos(self)Return array of all node positions
get_borders(self)Return grid content borders
get_index_by_node(self, node)Return grid index by node
get_offset(self)Return DynamicGrid offset, where DynamicGrid content starts.
get_pos(self, index, node, origin_index)Return pos for grid node index
get_size(self, border)Return grid content size
init(self, parent)The DynamicGrid constructor
remove(self, index, shift_policy, is_instant)Remove the item from the grid.
set_position_function(self, callback)Change set position function for grid nodes.
-

Fields

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
borderThe size of item content
first_indexThe first index of node in grid
last_indexThe last index of node in grid
node_sizeItem size
nodesList of all grid elements.
on_add_itemOn item add callback(self, node, index)
on_change_itemsOn item add or remove callback(self, index)
on_clearOn grid clear callback(self)
on_remove_itemOn item remove callback(self, index)
on_update_positionsOn update item positions callback(self)
parentParent gui node
- -
-
- - -

Functions

- -
-
- - _get_side_vector(self, side, is_forward) -
-
- Return side vector to correct node shifting - - -

Parameters:

-
    -
  • self - -
  • -
  • side - -
  • -
  • is_forward - -
  • -
- - - - - -
-
- - add(self, node, index, shift_policy, is_instant) -
-
- Add new node to the grid - - -

Parameters:

-
    -
  • self - DynamicGrid - DynamicGrid -
  • -
  • node - node - Gui node -
  • -
  • index - number or nil - The node position. By default add as last node -
  • -
  • shift_policy - number or nil - How shift nodes, if required. Default: const.SHIFT.RIGHT -
  • -
  • is_instant - boolean or nil - If true, update node positions instantly -
  • -
- - - - - -
-
- - clear(self) -
-
- Clear grid nodes array. GUI nodes will be not deleted! - If you want to delete GUI nodes, use dynamic_grid.nodes array before grid:clear - - -

Parameters:

- - -

Returns:

-
    - - druid.dynamic_grid - Current grid instance -
- - - - -
-
- - get_all_pos(self) -
-
- Return array of all node positions - - -

Parameters:

- - -

Returns:

-
    - - vector3[] - All grid node positions -
- - - - -
-
- - get_borders(self) -
-
- Return grid content borders - - -

Parameters:

- - -

Returns:

-
    - - vector3 - The grid content borders -
- - - - -
-
- - get_index_by_node(self, node) -
-
- Return grid index by node - - -

Parameters:

-
    -
  • self - DynamicGrid - DynamicGrid -
  • -
  • node - node - The gui node in the grid -
  • -
- -

Returns:

-
    - - number - The node index -
- - - - -
-
- - get_offset(self) -
-
- Return DynamicGrid offset, where DynamicGrid content starts. - - -

Parameters:

-
    -
  • self - DynamicGrid - DynamicGrid The DynamicGrid instance -
  • -
- -

Returns:

-
    - - vector3 - The DynamicGrid offset -
- - - - -
-
- - get_pos(self, index, node, origin_index) -
-
- Return pos for grid node index - - -

Parameters:

-
    -
  • self - DynamicGrid - DynamicGrid -
  • -
  • index - number - The grid element index -
  • -
  • node - node - The node to be placed -
  • -
  • origin_index - number or nil - Index of nearby node -
  • -
- -

Returns:

-
    - - vector3 - node position -
- - - - -
-
- - get_size(self, border) -
-
- Return grid content size - - -

Parameters:

-
    -
  • self - DynamicGrid - DynamicGrid -
  • -
  • border - vector3 - -
  • -
- -

Returns:

-
    - - vector3 - The grid content size -
- - - - -
-
- - init(self, parent) -
-
- The DynamicGrid constructor - - -

Parameters:

-
    -
  • self - DynamicGrid - DynamicGrid -
  • -
  • parent - node - The gui node parent, where items will be placed -
  • -
- - - - - -
-
- - remove(self, index, shift_policy, is_instant) -
-
- Remove the item from the grid. Note that gui node will be not deleted - - -

Parameters:

-
    -
  • self - DynamicGrid - DynamicGrid -
  • -
  • index - number - The grid node index to remove -
  • -
  • shift_policy - number or nil - How shift nodes, if required. Default: const.SHIFT.RIGHT -
  • -
  • is_instant - boolean or nil - If true, update node positions instantly -
  • -
- -

Returns:

-
    - - node - The deleted gui node from grid -
- - - - -
-
- - set_position_function(self, callback) -
-
- Change set position function for grid nodes. It will call on - update poses on grid elements. Default: gui.set_position - - -

Parameters:

-
    -
  • self - DynamicGrid - DynamicGrid -
  • -
  • callback - function - Function on node set position -
  • -
- -

Returns:

-
    - - druid.dynamic_grid - Current grid instance -
- - - - -
-
-

Fields

- -
-
- - border -
-
- The size of item content - - -
    -
  • border - vector4 - -
  • -
- - - - - -
-
- - first_index -
-
- The first index of node in grid - - -
    -
  • first_index - number - -
  • -
- - - - - -
-
- - last_index -
-
- The last index of node in grid - - -
    -
  • last_index - number - -
  • -
- - - - - -
-
- - node_size -
-
- Item size - - -
    -
  • node_size - vector3 - -
  • -
- - - - - -
-
- - nodes -
-
- List of all grid elements. Contains from node, pos, size, pivot - - -
    -
  • nodes - node[] - -
  • -
- - - - - -
-
- - on_add_item -
-
- On item add callback(self, node, index) - - - - - - - - -
-
- - on_change_items -
-
- On item add or remove callback(self, index) - - - - - - - - -
-
- - on_clear -
-
- On grid clear callback(self) - - - - - - - - -
-
- - on_remove_item -
-
- On item remove callback(self, index) - - - - - - - - -
-
- - on_update_positions -
-
- On update item positions callback(self) - - -
    -
  • on_update_positions - DruidEvent - DruidEvent -
  • -
- - - - - -
-
- - parent -
-
- Parent gui node - - -
    -
  • parent - node - -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/Helper.html b/docs/modules/Helper.html deleted file mode 100644 index 1bc2ed6..0000000 --- a/docs/modules/Helper.html +++ /dev/null @@ -1,927 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module Helper

-

Helper module with various usefull GUI functions.

-

-

Usage:

-
    -
    local helper = require("druid.helper")
    -helper.centrate_nodes(0, node_1, node_2)
    -
    -
- - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
helper.add_array(target, source)Add all elements from source array to the target array
helper.centrate_nodes(margin, ...)Centerate nodes by x position with margin.
helper.clamp(a, min, max)Clamp value between min and max
helper.contains(t, value)Check if value is in array and return index of it
helper.deepcopy(orig_table)Make a copy table with all nested tables
helper.distance(x1, y1, x2, y2)Calculate distance between two points
helper.get_border(node, offset)Distance from node position to his borders
helper.get_closest_stencil_node(node)Return closest non inverted clipping parent node for given node
helper.get_gui_scale()Get current GUI scale for each side
helper.get_pivot_offset(pivot)Get node offset for given GUI pivot.
helper.get_scaled_size(node)Get node size adjusted by scale
helper.get_scene_scale(node, include_passed_node_scale)Get cumulative parent's node scale
helper.get_screen_aspect_koef()Get current screen stretch multiplier for each side
helper.get_text_metrics_from_node(text_node)Get text metric from GUI node.
helper.insert_with_shift(array, any, index, shift_policy)Add value to array with shift policy
helper.is_mobile()Check if device is native mobile (Android or iOS)
helper.is_multitouch_supported()Check if device is mobile and can support multitouch
helper.is_web()Check if device is HTML5
helper.is_web_mobile()Check if device is HTML5 mobile
helper.lerp(a, b, t)Lerp between two values
helper.remove_with_shift(array, index, shift_policy)Remove value from array with shift policy
helper.round(num, num_decimal_places)Round number to specified decimal places
helper.sign(val)Return sign of value (-1, 0, 1)
helper.step(current, target, step)Move value from current to target value with step amount
helper.table_to_string(t)Simple table to one-line string converter
- -
-
- - -

Functions

- -
-
- - helper.add_array(target, source) -
-
- Add all elements from source array to the target array - - -

Parameters:

-
    -
  • target - any[] - Array to put elements from source -
  • -
  • source - any[] or nil - The source array to get elements from -
  • -
- -

Returns:

-
    - - any[] - The target array -
- - - - -
-
- - helper.centrate_nodes(margin, ...) -
-
- Centerate nodes by x position with margin. -

This functions calculate total width of nodes and set position for each node. - The centrate will be around 0 x position. - - -

Parameters:

-
    -
  • margin - number or nil - Offset between nodes -
  • -
  • ... - Gui nodes -
  • -
- - - - - -
-
- - helper.clamp(a, min, max) -
-
- Clamp value between min and max - - -

Parameters:

-
    -
  • a - number - Value -
  • -
  • min - number - Min value -
  • -
  • max - number - Max value -
  • -
- -

Returns:

-
    - - number - Clamped value -
- - - - -
-
- - helper.contains(t, value) -
-
- Check if value is in array and return index of it - - -

Parameters:

-
    -
  • t - table - Array -
  • -
  • value - Value -
  • -
- -

Returns:

-
    - - number or nil - Index of value or nil -
- - - - -
-
- - helper.deepcopy(orig_table) -
-
- Make a copy table with all nested tables - - -

Parameters:

-
    -
  • orig_table - table - Original table -
  • -
- -

Returns:

-
    - - table - Copy of original table -
- - - - -
-
- - helper.distance(x1, y1, x2, y2) -
-
- Calculate distance between two points - - -

Parameters:

-
    -
  • x1 - number - First point x -
  • -
  • y1 - number - First point y -
  • -
  • x2 - number - Second point x -
  • -
  • y2 - number - Second point y -
  • -
- -

Returns:

-
    - - number - Distance -
- - - - -
-
- - helper.get_border(node, offset) -
-
- Distance from node position to his borders - - -

Parameters:

-
    -
  • node - node - GUI node -
  • -
  • offset - vector3 or nil - Offset from node position. Pass current node position to get non relative border values -
  • -
- -

Returns:

-
    - - vector4 - Vector4 with border values (left, top, right, down) -
- - - - -
-
- - helper.get_closest_stencil_node(node) -
-
- Return closest non inverted clipping parent node for given node - - -

Parameters:

-
    -
  • node - node - GUI node -
  • -
- -

Returns:

-
    - - node or nil - The closest stencil node or nil -
- - - - -
-
- - helper.get_gui_scale() -
-
- Get current GUI scale for each side - - - -

Returns:

-
    -
  1. - number - scale_x
  2. -
  3. - number - scale_y
  4. -
- - - - -
-
- - helper.get_pivot_offset(pivot) -
-
- Get node offset for given GUI pivot. -

Offset shown in [-0.5 .. 0.5] range, where -0.5 is left or bottom, 0.5 is right or top. - - -

Parameters:

-
    -
  • pivot - number - The gui.PIVOT_* constant -
  • -
- -

Returns:

-
    - - vector3 - Vector offset with [-0.5..0.5] values -
- - - - -
-
- - helper.get_scaled_size(node) -
-
- Get node size adjusted by scale - - -

Parameters:

-
    -
  • node - node - GUI node -
  • -
- -

Returns:

-
    - - vector3 - Scaled size -
- - - - -
-
- - helper.get_scene_scale(node, include_passed_node_scale) -
-
- Get cumulative parent's node scale - - -

Parameters:

-
    -
  • node - node - Gui node -
  • -
  • include_passed_node_scale - boolean or nil - True if add current node scale to result -
  • -
- -

Returns:

-
    - - vector3 - The scene node scale -
- - - - -
-
- - helper.get_screen_aspect_koef() -
-
- Get current screen stretch multiplier for each side - - - -

Returns:

-
    -
  1. - number - stretch_x
  2. -
  3. - number - stretch_y
  4. -
- - - - -
-
- - helper.get_text_metrics_from_node(text_node) -
-
- Get text metric from GUI node. - - -

Parameters:

-
    -
  • text_node - node - -
  • -
- -

Returns:

-
    - - GUITextMetrics - -
- - - -

Usage:

-
    -
    type GUITextMetrics = {
    -  width: number,
    -  height: number,
    -  max_ascent: number,
    -  max_descent: number
    -}
    -
- -
-
- - helper.insert_with_shift(array, any, index, shift_policy) -
-
- Add value to array with shift policy Shift policy can be: left, right, no_shift - - -

Parameters:

-
    -
  • array - table - Array -
  • -
  • any - Item to insert -
  • -
  • index - number or nil - Index to insert. If nil, item will be inserted at the end of array -
  • -
  • shift_policy - number or nil - The druid_const.SHIFT.* constant -
  • -
- -

Returns:

-
    - - any - Inserted item -
- - - - -
-
- - helper.is_mobile() -
-
- Check if device is native mobile (Android or iOS) - - - -

Returns:

-
    - - boolean - Is mobile -
- - - - -
-
- - helper.is_multitouch_supported() -
-
- Check if device is mobile and can support multitouch - - - -

Returns:

-
    - - boolean - Is multitouch supported -
- - - - -
-
- - helper.is_web() -
-
- Check if device is HTML5 - - - -

Returns:

-
    - - boolean - Is web -
- - - - -
-
- - helper.is_web_mobile() -
-
- Check if device is HTML5 mobile - - - -

Returns:

-
    - - boolean - Is web mobile -
- - - - -
-
- - helper.lerp(a, b, t) -
-
- Lerp between two values - - -

Parameters:

-
    -
  • a - number - First value -
  • -
  • b - number - Second value -
  • -
  • t - number - Lerp amount -
  • -
- -

Returns:

-
    - - number - Lerped value -
- - - - -
-
- - helper.remove_with_shift(array, index, shift_policy) -
-
- Remove value from array with shift policy Shift policy can be: left, right, no_shift - - -

Parameters:

-
    -
  • array - table - Array -
  • -
  • index - number or nil - Index to remove. If nil, item will be removed from the end of array -
  • -
  • shift_policy - number or nil - The druid_const.SHIFT.* constant -
  • -
- -

Returns:

-
    - - any - Removed item -
- - - - -
-
- - helper.round(num, num_decimal_places) -
-
- Round number to specified decimal places - - -

Parameters:

-
    -
  • num - number - Number -
  • -
  • num_decimal_places - number or nil - Decimal places -
  • -
- -

Returns:

-
    - - number - Rounded number -
- - - - -
-
- - helper.sign(val) -
-
- Return sign of value (-1, 0, 1) - - -

Parameters:

-
    -
  • val - number - Value -
  • -
- -

Returns:

-
    - - number - Sign -
- - - - -
-
- - helper.step(current, target, step) -
-
- Move value from current to target value with step amount - - -

Parameters:

-
    -
  • current - number - Current value -
  • -
  • target - number - Target value -
  • -
  • step - number - Step amount -
  • -
- -

Returns:

-
    - - number - New value -
- - - - -
-
- - helper.table_to_string(t) -
-
- Simple table to one-line string converter - - -

Parameters:

- - -

Returns:

-
    - - string - -
- - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/Hotkey.html b/docs/modules/Hotkey.html deleted file mode 100644 index 6237aa5..0000000 --- a/docs/modules/Hotkey.html +++ /dev/null @@ -1,373 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module Hotkey

-

Druid hotkey component

-

Example Link

- - -

Functions

- - - - - - - - - - - - - -
add_hotkey(self, keys, callback_argument)Add hotkey for component callback
init(self, keys, callback, callback_argument)The Hotkey constructor
set_repeat(self, is_enabled_repeated)If true, the callback will be triggered on action.repeated
-

Tables

- - - - - -
styleComponent style params.
-

Fields

- - - - - - - - - - - - - - - - - - - - - -
buttonButton component from click_node
click_nodeButton trigger node
nodeVisual node
on_hotkey_pressedOn hotkey released callback(self, argument)
on_hotkey_releasedOn hotkey released callback(self, argument)
- -
-
- - -

Functions

- -
-
- - add_hotkey(self, keys, callback_argument) -
-
- Add hotkey for component callback - - -

Parameters:

-
    -
  • self - Hotkey - Hotkey -
  • -
  • keys - string[], hash[], string or hash - that have to be pressed before key pressed to activate -
  • -
  • callback_argument - any or nil - The argument to pass into the callback function -
  • -
- -

Returns:

-
    - - Hotkey - Current instance -
- - - - -
-
- - init(self, keys, callback, callback_argument) -
-
- The Hotkey constructor - - -

Parameters:

-
    -
  • self - Hotkey - Hotkey -
  • -
  • keys - string[] or string - The keys to be pressed for trigger callback. Should contains one key and any modificator keys -
  • -
  • callback - function - The callback function -
  • -
  • callback_argument - any or nil - The argument to pass into the callback function -
  • -
- - - - - -
-
- - set_repeat(self, is_enabled_repeated) -
-
- If true, the callback will be triggered on action.repeated - - -

Parameters:

-
    -
  • self - Hotkey - Hotkey -
  • -
  • is_enabled_repeated - bool - The flag value -
  • -
- -

Returns:

-
    - - Hotkey - -
- - - - -
-
-

Tables

- -
-
- - style -
-
- Component style params. - You can override this component styles params in druid styles table - or create your own style - - -

Fields:

-
    -
  • MODIFICATORS - string[] - The list of action_id as hotkey modificators -
  • -
- - - - - -
-
-

Fields

- -
-
- - button -
-
- Button component from click_node - - -
    -
  • button - Button - Button -
  • -
- - - - - -
-
- - click_node -
-
- Button trigger node - - -
    -
  • click_node - node or nil - -
  • -
- - - - - -
-
- - node -
-
- Visual node - - -
    -
  • node - node - -
  • -
- - - - - -
-
- - on_hotkey_pressed -
-
- On hotkey released callback(self, argument) - - -
    -
  • on_hotkey_pressed - DruidEvent - DruidEvent -
  • -
- - - - - -
-
- - on_hotkey_released -
-
- On hotkey released callback(self, argument) - - -
    -
  • on_hotkey_released - DruidEvent - DruidEvent -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/Hover.html b/docs/modules/Hover.html deleted file mode 100644 index 65c7eed..0000000 --- a/docs/modules/Hover.html +++ /dev/null @@ -1,469 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module Hover

-

Component to handle hover node interaction

-

- - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
init(self, node, on_hover_callback, on_mouse_hover)The Hover constructor
is_enabled(self)Return current hover enabled state
is_hovered(self)Return current hover state.
is_mouse_hovered(self)Return current hover state.
set_click_zone(self, zone)Strict hover click area.
set_enabled(self, state)Set enable state of hover component.
set_hover(self, state)Set hover state
set_mouse_hover(self, state)Set mouse hover state
-

Tables

- - - - - -
styleComponent style params.
-

Fields

- - - - - - - - - - - - - -
nodeHover node
on_hoverOn hover callback(self, state, hover_instance)
on_mouse_hoverOn mouse hover callback(self, state, hover_instance)
- -
-
- - -

Functions

- -
-
- - init(self, node, on_hover_callback, on_mouse_hover) -
-
- The Hover constructor - - -

Parameters:

-
    -
  • self - Hover - Hover -
  • -
  • node - node - Gui node -
  • -
  • on_hover_callback - function - Hover callback -
  • -
  • on_mouse_hover - function - On mouse hover callback -
  • -
- - - - - -
-
- - is_enabled(self) -
-
- Return current hover enabled state - - -

Parameters:

-
    -
  • self - Hover - Hover -
  • -
- -

Returns:

-
    - - boolean - The hover enabled state -
- - - - -
-
- - is_hovered(self) -
-
- Return current hover state. True if touch action was on the node at current time - - -

Parameters:

-
    -
  • self - Hover - Hover -
  • -
- -

Returns:

-
    - - boolean - The current hovered state -
- - - - -
-
- - is_mouse_hovered(self) -
-
- Return current hover state. True if nil action_id (usually desktop mouse) was on the node at current time - - -

Parameters:

-
    -
  • self - Hover - Hover -
  • -
- -

Returns:

-
    - - boolean - The current hovered state -
- - - - -
-
- - set_click_zone(self, zone) -
-
- Strict hover click area. Useful for - no click events outside stencil node - - -

Parameters:

- - - - - - -
-
- - set_enabled(self, state) -
-
- Set enable state of hover component. - If hover is not enabled, it will not generate - any hover events - - -

Parameters:

-
    -
  • self - Hover - Hover -
  • -
  • state - boolean or nil - The hover enabled state -
  • -
- - - - - -
-
- - set_hover(self, state) -
-
- Set hover state - - -

Parameters:

-
    -
  • self - Hover - Hover -
  • -
  • state - boolean or nil - The hover state -
  • -
- - - - - -
-
- - set_mouse_hover(self, state) -
-
- Set mouse hover state - - -

Parameters:

-
    -
  • self - Hover - Hover -
  • -
  • state - boolean or nil - The mouse hover state -
  • -
- - - - - -
-
-

Tables

- -
-
- - style -
-
- Component style params. - You can override this component styles params in druid styles table - or create your own style - - -

Fields:

-
    -
  • ON_HOVER_CURSOR - string - Mouse hover style on node hover - (optional) -
  • -
  • ON_MOUSE_HOVER_CURSOR - string - Mouse hover style on node mouse hover - (optional) -
  • -
- - - - - -
-
-

Fields

- -
-
- - node -
-
- Hover node - - -
    -
  • node - node - -
  • -
- - - - - -
-
- - on_hover -
-
- On hover callback(self, state, hover_instance) - - - - - - - - -
-
- - on_mouse_hover -
-
- On mouse hover callback(self, state, hover_instance) - - - - - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/Input.html b/docs/modules/Input.html deleted file mode 100644 index ee1a9e4..0000000 --- a/docs/modules/Input.html +++ /dev/null @@ -1,1086 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module Input

-

Druid input text component.

-

- Carry on user text input -

Example Link

-

Info:

-
    -
  • Author: Part of code from Britzl gooey input component
  • -
- - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
get_text(self)Return current input field text
get_text_selected_replaced(self, text)Replace selected text with new text
init(self, click_node, text_node, keyboard_type)The Input constructor
move_selection(self, delta, is_add_to_selection, is_move_to_end)Change cursor position by delta
reset_changes(self)Reset current input selection and return previous value
select(self)Select input field.
select_cursor(self, cursor_index, start_index, end_index)Set cursor position in input field
set_allowed_characters(self, characters)Set allowed charaters for input field.
set_max_length(self, max_length)Set maximum length for input field.
set_text(self, input_text)Set text for input field
unselect(self)Remove selection from input.
-

Tables

- - - - - -
styleComponent style params.
-

Fields

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
allowerd_charactersPattern matching for user input
buttonButton component
current_valueCurrent input value with marked text
cursor_indexThe cursor index.
end_indexTheselection end index.
is_emptyIs current input is empty now
is_selectedIs current input selected now
keyboard_typeGui keyboard type for input field
marked_text_widthMarked text width
marked_valueMarked text for input field.
max_lengthMax length for input text
on_input_emptyOn input field text change to empty string callback(self, input_text)
on_input_fullOn input field text change to max length string callback(self, input_text)
on_input_selectOn input field select callback(self, input_instance)
on_input_textOn input field text change callback(self, input_text)
on_input_unselectOn input field unselect callback(self, input_text, input_instance)
on_input_wrongOn trying user input with not allowed character callback(self, params, input_text)
on_select_cursor_changeOn cursor position change callback(self, cursor_index, start_index, end_index)
previous_valuePrevious input value
start_indexThe selection start index.
textText component
text_widthText width
valueCurrent input value
- -
-
- - -

Functions

- -
-
- - get_text(self) -
-
- Return current input field text - - -

Parameters:

-
    -
  • self - Input - Input -
  • -
- -

Returns:

-
    - - string - The current input field text -
- - - - -
-
- - get_text_selected_replaced(self, text) -
-
- Replace selected text with new text - - -

Parameters:

-
    -
  • self - Input - Input -
  • -
  • text - string - The text to replace selected text -
  • -
- -

Returns:

-
    - - string - New input text -
- - - - -
-
- - init(self, click_node, text_node, keyboard_type) -
-
- The Input constructor - - -

Parameters:

-
    -
  • self - Input - Input -
  • -
  • click_node - node - Node to enabled input component -
  • -
  • text_node - node or Text - Text node what will be changed on user input. You can pass text component instead of text node name Text -
  • -
  • keyboard_type - number or nil - Gui keyboard type for input field -
  • -
- - - - - -
-
- - move_selection(self, delta, is_add_to_selection, is_move_to_end) -
-
- Change cursor position by delta - - -

Parameters:

-
    -
  • self - Input - Input -
  • -
  • delta - number - side for cursor position, -1 for left, 1 for right -
  • -
  • is_add_to_selection - boolean - (Shift key) -
  • -
  • is_move_to_end - boolean - (Ctrl key) -
  • -
- - - - - -
-
- - reset_changes(self) -
-
- Reset current input selection and return previous value - - -

Parameters:

-
    -
  • self - Input - Input -
  • -
- -

Returns:

-
    - - druid.input - Current input instance -
- - - - -
-
- - select(self) -
-
- Select input field. It will show the keyboard and trigger on_select events - - -

Parameters:

-
    -
  • self - Input - Input -
  • -
- - - - - -
-
- - select_cursor(self, cursor_index, start_index, end_index) -
-
- Set cursor position in input field - - -

Parameters:

-
    -
  • self - Input - Input -
  • -
  • cursor_index - number or nil - Cursor index for cursor position, if nil - will be set to the end of the text -
  • -
  • start_index - number or nil - Start index for cursor position, if nil - will be set to the end of the text -
  • -
  • end_index - number or nil - End index for cursor position, if nil - will be set to the start_index -
  • -
- -

Returns:

-
    - - druid.input - Current input instance -
- - - - -
-
- - set_allowed_characters(self, characters) -
-
- Set allowed charaters for input field. - See: https://defold.com/ref/stable/string/ - ex: [%a%d] for alpha and numeric - - -

Parameters:

-
    -
  • self - Input - Input -
  • -
  • characters - string - Regulax exp. for validate user input -
  • -
- -

Returns:

-
    - - druid.input - Current input instance -
- - - - -
-
- - set_max_length(self, max_length) -
-
- Set maximum length for input field. - Pass nil to make input field unliminted (by default) - - -

Parameters:

-
    -
  • self - Input - Input -
  • -
  • max_length - number - Maximum length for input text field -
  • -
- -

Returns:

-
    - - druid.input - Current input instance -
- - - - -
-
- - set_text(self, input_text) -
-
- Set text for input field - - -

Parameters:

-
    -
  • self - Input - Input -
  • -
  • input_text - string - The string to apply for input field -
  • -
- - - - - -
-
- - unselect(self) -
-
- Remove selection from input. It will hide the keyboard and trigger on_unselect events - - -

Parameters:

-
    -
  • self - Input - Input -
  • -
- - - - - -
-
-

Tables

- -
-
- - style -
-
- Component style params. - You can override this component styles params in druid styles table - or create your own style - - -

Fields:

-
    -
  • IS_LONGTAP_ERASE - boolean - Is long tap will erase current input data. Default: false -
  • -
  • MASK_DEFAULT_CHAR - string - Default character mask for password input. Default: *] -
  • -
  • IS_UNSELECT_ON_RESELECT - boolean - If true, call unselect on select selected input. Default: false -
  • -
  • on_select - function - (self, button_node) Callback on input field selecting -
  • -
  • on_unselect - function - (self, button_node) Callback on input field unselecting -
  • -
  • on_input_wrong - function - (self, button_node) Callback on wrong user input -
  • -
- - - - - -
-
-

Fields

- -
-
- - allowerd_characters -
-
- Pattern matching for user input - - -
    -
  • allowerd_characters - string or nil - -
  • -
- - - - - -
-
- - button -
-
- Button component - - -
    -
  • button - Button - Button -
  • -
- - - - - -
-
- - current_value -
-
- Current input value with marked text - - -
    -
  • current_value - string - -
  • -
- - - - - -
-
- - cursor_index -
-
- The cursor index. The index of letter cursor after. Leftmost cursor - 0 - - -
    -
  • cursor_index - number - -
  • -
- - - - - -
-
- - end_index -
-
- Theselection end index. The index of letter cursor before. Rightmost selection - #text - - -
    -
  • end_index - number - -
  • -
- - - - - -
-
- - is_empty -
-
- Is current input is empty now - - -
    -
  • is_empty - boolean - -
  • -
- - - - - -
-
- - is_selected -
-
- Is current input selected now - - -
    -
  • is_selected - boolean - -
  • -
- - - - - -
-
- - keyboard_type -
-
- Gui keyboard type for input field - - -
    -
  • keyboard_type - number - -
  • -
- - - - - -
-
- - marked_text_width -
-
- Marked text width - - -
    -
  • marked_text_width - number - -
  • -
- - - - - -
-
- - marked_value -
-
- Marked text for input field. Info: https://defold.com/manuals/input-key-and-text/#marked-text - - -
    -
  • marked_value - string - -
  • -
- - - - - -
-
- - max_length -
-
- Max length for input text - - -
    -
  • max_length - number or nil - -
  • -
- - - - - -
-
- - on_input_empty -
-
- On input field text change to empty string callback(self, input_text) - - - - - - - - -
-
- - on_input_full -
-
- On input field text change to max length string callback(self, input_text) - - - - - - - - -
-
- - on_input_select -
-
- On input field select callback(self, input_instance) - - - - - - - - -
-
- - on_input_text -
-
- On input field text change callback(self, input_text) - - - - - - - - -
-
- - on_input_unselect -
-
- On input field unselect callback(self, input_text, input_instance) - - -
    -
  • on_input_unselect - DruidEvent - DruidEvent -
  • -
- - - - - -
-
- - on_input_wrong -
-
- On trying user input with not allowed character callback(self, params, input_text) - - - - - - - - -
-
- - on_select_cursor_change -
-
- On cursor position change callback(self, cursor_index, start_index, end_index) - - -
    -
  • on_select_cursor_change - DruidEvent - DruidEvent -
  • -
- - - - - -
-
- - previous_value -
-
- Previous input value - - -
    -
  • previous_value - string - -
  • -
- - - - - -
-
- - start_index -
-
- The selection start index. The index of letter cursor after. Leftmost selection - 0 - - -
    -
  • start_index - number - -
  • -
- - - - - -
-
- - text -
-
- Text component - - -
    -
  • text - Text - Text -
  • -
- - - - - -
-
- - text_width -
-
- Text width - - -
    -
  • text_width - number - -
  • -
- - - - - -
-
- - value -
-
- Current input value - - - - - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/LangText.html b/docs/modules/LangText.html deleted file mode 100644 index be1a8b1..0000000 --- a/docs/modules/LangText.html +++ /dev/null @@ -1,380 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module LangText

-

Component to wrap over GUI Text nodes with localization helpers -

# Overview # -

• The initialization of druid.set_text_function is required to enable localization - using the localization ID.

-

-

• The LangText component supports up to 7 string format parameters. - This limitation exists due to certain issues with using ... arguments. -

# Notes # -

Example Link

- - -

Functions

- - - - - - - - - - - - - - - - - -
format(self, a, b, c, d, e, f, g)Format string with new text params on localized text
init(self, node, locale_id, adjust_type)The LangText constructor
set_to(self, text)Setup raw text to lang_text component
translate(self, locale_id, a, b, c, d, e, f, g)Translate the text by locale_id
-

Fields

- - - - - - - - - - - - - -
nodeText node
on_changeOn change text callback
textThe text component
- -
-
- - -

Functions

- -
-
- - format(self, a, b, c, d, e, f, g) -
-
- Format string with new text params on localized text - - -

Parameters:

-
    -
  • self - LangText - LangText -
  • -
  • a - string or nil - Optional param to string.format -
  • -
  • b - string or nil - Optional param to string.format -
  • -
  • c - string or nil - Optional param to string.format -
  • -
  • d - string or nil - Optional param to string.format -
  • -
  • e - string or nil - Optional param to string.format -
  • -
  • f - string or nil - Optional param to string.format -
  • -
  • g - string or nil - Optional param to string.format -
  • -
- -

Returns:

-
    - - LangText - Current instance -
- - - - -
-
- - init(self, node, locale_id, adjust_type) -
-
- The LangText constructor - - -

Parameters:

-
    -
  • self - LangText - LangText -
  • -
  • node - string or node - The node_id or gui.get_node(node_id) -
  • -
  • locale_id - string or nil - Default locale id or text from node as default -
  • -
  • adjust_type - string or nil - Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference -
  • -
- - - - - -
-
- - set_to(self, text) -
-
- Setup raw text to lang_text component - - -

Parameters:

-
    -
  • self - LangText - LangText -
  • -
  • text - string - Text for text node -
  • -
- -

Returns:

-
    - - LangText - Current instance -
- - - - -
-
- - translate(self, locale_id, a, b, c, d, e, f, g) -
-
- Translate the text by locale_id - - -

Parameters:

-
    -
  • self - LangText - LangText -
  • -
  • locale_id - string - Locale id -
  • -
  • a - string or nil - Optional param to string.format -
  • -
  • b - string or nil - Optional param to string.format -
  • -
  • c - string or nil - Optional param to string.format -
  • -
  • d - string or nil - Optional param to string.format -
  • -
  • e - string or nil - Optional param to string.format -
  • -
  • f - string or nil - Optional param to string.format -
  • -
  • g - string or nil - Optional param to string.format -
  • -
- -

Returns:

-
    - - LangText - Current instance -
- - - - -
-
-

Fields

- -
-
- - node -
-
- Text node - - -
    -
  • node - node - -
  • -
- - - - - -
-
- - on_change -
-
- On change text callback - - - - - - - - -
-
- - text -
-
- The text component - - -
    -
  • text - Text - Text -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/Layout.html b/docs/modules/Layout.html deleted file mode 100644 index 0058f48..0000000 --- a/docs/modules/Layout.html +++ /dev/null @@ -1,147 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module Layout

-

Layout management on node

-

Example Link

- - -

Fields

- - - - - - - - - -
modeCurrent layout mode
nodeLayout node
- -
-
- - -

Fields

- -
-
- - mode -
-
- Current layout mode - - - - - - - - -
-
- - node -
-
- Layout node - - -
    -
  • node - node - -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/PinKnob.html b/docs/modules/PinKnob.html deleted file mode 100644 index d97d64e..0000000 --- a/docs/modules/PinKnob.html +++ /dev/null @@ -1,299 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module PinKnob

-

Druid pin knob custom component.

-

- It's simple rotating input element

- - -

Functions

- - - - - - - - - - - - - -
init(self, callback, template, nodes)The PinKnob constructor
set_angle(self, cur_value, min, max)Set current and min/max angles for component
set_friction(self, value)Set current and min/max angles for component
-

Fields

- - - - - - - - - - - - - -
druidThe component druid instance
is_dragIs currently under user control
nodeThe pin node
- -
-
- - -

Functions

- -
-
- - init(self, callback, template, nodes) -
-
- The PinKnob constructor - - -

Parameters:

-
    -
  • self - PinKnob - PinKnob -
  • -
  • callback - function - Callback(self, value) on value changed -
  • -
  • template - string - The template string name -
  • -
  • nodes - table - Nodes table from gui.clone_tree -
  • -
- - - - - -
-
- - set_angle(self, cur_value, min, max) -
-
- Set current and min/max angles for component - - -

Parameters:

-
    -
  • self - PinKnob - PinKnob -
  • -
  • cur_value - number - The new value for pin knob -
  • -
  • min - number - The minimum value for pin knob -
  • -
  • max - number - The maximum value for pin knob -
  • -
- -

Returns:

-
    - - PinKnob - PinKnob -
- - - - -
-
- - set_friction(self, value) -
-
- Set current and min/max angles for component - - -

Parameters:

-
    -
  • self - PinKnob - PinKnob -
  • -
  • value - number or nil - The spin speed multiplier. Default: 1 -
  • -
- -

Returns:

-
    - - PinKnob - PinKnob -
- - - - -
-
-

Fields

- -
-
- - druid -
-
- The component druid instance - - - - - - - - -
-
- - is_drag -
-
- Is currently under user control - - -
    -
  • is_drag - boolean - -
  • -
- - - - - -
-
- - node -
-
- The pin node - - -
    -
  • node - node - -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/Progress.html b/docs/modules/Progress.html deleted file mode 100644 index d9fa818..0000000 --- a/docs/modules/Progress.html +++ /dev/null @@ -1,569 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module Progress

-

Druid component to handle the progress bars.

-

- # Overview # -

# Notes # -

• Progress Node should be fully filled in your GUI scene node. It will be the progress maximum size -

• Progress correct working with Slice9 nodes, it trying to set size by _set_size_ first, if it is not possible, it set up sizing via _set_scale_ -

• Progress bar can fill only by vertical or horizontal size. If you want make diagonal progress bar, just rotate node in GUI scene -

• If you have glitchy or dark texture bug with progress bar, try to disable mipmaps in your texture profiles -

- Example Link

- - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
empty(self)Empty a progress bar
fill(self)Fill a progress bar and stop progress animation
get(self)Return current progress bar value
init(self, node, key, init_value)The Progress constructor
set_max_size(self, max_size)Set progress bar max node size
set_steps(self, steps, callback)Set points on progress bar to fire the callback
set_to(self, to)Instant fill progress bar to value
to(self, to, callback)Start animation of a progress bar
-

Tables

- - - - - -
styleComponent style params.
-

Fields

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
keyThe progress bar direction.
max_sizeMaximum size of progress bar
nodeProgress bar fill node
on_changeOn progress bar change callback(self, new_value)
scaleCurrent progress bar scale
sizeCurrent progress bar size
sliceProgress bar slice9 settings
- -
-
- - -

Functions

- -
-
- - empty(self) -
-
- Empty a progress bar - - -

Parameters:

- - - - - - -
-
- - fill(self) -
-
- Fill a progress bar and stop progress animation - - -

Parameters:

- - - - - - -
-
- - get(self) -
-
- Return current progress bar value - - -

Parameters:

- - - - - - -
-
- - init(self, node, key, init_value) -
-
- The Progress constructor - - -

Parameters:

-
    -
  • self - Progress - Progress -
  • -
  • node - string or node - Node name or GUI Node itself. -
  • -
  • key - string - Progress bar direction: const.SIDE.X or const.SIDE.Y -
  • -
  • init_value - number or nil - Initial value of progress bar. Default: 1 -
  • -
- - - - - -
-
- - set_max_size(self, max_size) -
-
- Set progress bar max node size - - -

Parameters:

-
    -
  • self - Progress - Progress -
  • -
  • max_size - vector3 - The new node maximum (full) size -
  • -
- -

Returns:

-
    - - Progress - Progress -
- - - - -
-
- - set_steps(self, steps, callback) -
-
- Set points on progress bar to fire the callback - - -

Parameters:

-
    -
  • self - Progress - Progress -
  • -
  • steps - number[] - Array of progress bar values -
  • -
  • callback - function - Callback on intersect step value -
  • -
- - - - -

Usage:

-
    -
    progress:set_steps({0, 0.3, 0.6, 1}, function(self, step) end)
    -
- -
-
- - set_to(self, to) -
-
- Instant fill progress bar to value - - -

Parameters:

-
    -
  • self - Progress - Progress -
  • -
  • to - number - Progress bar value, from 0 to 1 -
  • -
- - - - - -
-
- - to(self, to, callback) -
-
- Start animation of a progress bar - - -

Parameters:

-
    -
  • self - Progress - Progress -
  • -
  • to - number - value between 0..1 -
  • -
  • callback - function or nil - Callback on animation ends -
  • -
- - - - - -
-
-

Tables

- -
-
- - style -
-
- Component style params. - You can override this component styles params in druid styles table - or create your own style - - -

Fields:

-
    -
  • SPEED - number or nil - Progress bas fill rate. More -> faster. Default: 5 -
  • -
  • MIN_DELTA - number or nil - Minimum step to fill progress bar. Default: 0.005 -
  • -
- - - - - -
-
-

Fields

- -
-
- - key -
-
- The progress bar direction. -

The values are: "x" or "y". (const.SIDE.X or const.SIDE.Y) - - -

- - - - - -
-
- - max_size -
-
- Maximum size of progress bar - - -
    -
  • max_size - number - -
  • -
- - - - - -
-
- - node -
-
- Progress bar fill node - - -
    -
  • node - node - -
  • -
- - - - - -
-
- - on_change -
-
- On progress bar change callback(self, new_value) - - - - - - - - -
-
- - scale -
-
- Current progress bar scale - - -
    -
  • scale - vector3 - -
  • -
- - - - - -
-
- - size -
-
- Current progress bar size - - -
    -
  • size - vector3 - -
  • -
- - - - - -
-
- - slice -
-
- Progress bar slice9 settings - - -
    -
  • slice - vector4 - -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/RadioGroup.html b/docs/modules/RadioGroup.html deleted file mode 100644 index 41f2b10..0000000 --- a/docs/modules/RadioGroup.html +++ /dev/null @@ -1,259 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module RadioGroup

-

Radio group module

-

Example Link

- - -

Functions

- - - - - - - - - - - - - -
get_state(self)Return radio group state
init(self, nodes, callback, click_nodes)The RadioGroup constructor
set_state(self, index, is_instant)Set radio group state
-

Fields

- - - - - - - - - -
checkboxesArray of checkbox components
on_radio_clickOn any checkbox click
- -
-
- - -

Functions

- -
-
- - get_state(self) -
-
- Return radio group state - - -

Parameters:

- - -

Returns:

-
    - - number - Index in radio group -
- - - - -
-
- - init(self, nodes, callback, click_nodes) -
-
- The RadioGroup constructor - - -

Parameters:

-
    -
  • self - RadioGroup - RadioGroup -
  • -
  • nodes - node[] - Array of gui node -
  • -
  • callback - function - Radio callback -
  • -
  • click_nodes - node[] or nil - Array of trigger nodes, by default equals to nodes. Default - nodes -
  • -
- - - - - -
-
- - set_state(self, index, is_instant) -
-
- Set radio group state - - -

Parameters:

-
    -
  • self - RadioGroup - RadioGroup -
  • -
  • index - number - Index in radio group -
  • -
  • is_instant - boolean or nil - If is instant state change -
  • -
- - - - - -
-
-

Fields

- -
-
- - checkboxes -
-
- Array of checkbox components - - -
    -
  • checkboxes - Checkbox[] - -
  • -
- - - - - -
-
- - on_radio_click -
-
- On any checkbox click - - - - - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/RichInput.html b/docs/modules/RichInput.html deleted file mode 100644 index 6c5cdf8..0000000 --- a/docs/modules/RichInput.html +++ /dev/null @@ -1,567 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module RichInput

-

Druid Rich Input custom component.

-

- It's wrapper on Input component with cursor and placeholder text

- - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
get_text(self)Set input field text
init(self, template, nodes)The RichInput constructor
select(self)Select input field
set_allowed_characters(self, characters)Set allowed charaters for input field.
set_font(self, font)Set input field font
set_placeholder(self, placeholder_text)Set placeholder text
set_text(self, text)Set input field text
-

Fields

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cursorOn input field text change to empty string callback(self, input_text)
cursor_positionOn input field text change to empty string callback(self, input_text)
cursor_textOn input field text change to empty string callback(self, input_text)
dragOn input field text change to empty string callback(self, input_text)
druidThe component druid instance
inputOn input field text change callback(self, input_text)
input_textOn input field text change to empty string callback(self, input_text)
placeholderOn input field text change to empty string callback(self, input_text)
rootRoot node
text_positionOn input field text change to empty string callback(self, input_text)
- -
-
- - -

Functions

- -
-
- - get_text(self) -
-
- Set input field text - - -

Parameters:

- - - - - - -
-
- - init(self, template, nodes) -
-
- The RichInput constructor - - -

Parameters:

-
    -
  • self - RichInput - RichInput -
  • -
  • template - string - The template string name -
  • -
  • nodes - table - Nodes table from gui.clone_tree -
  • -
- - - - - -
-
- - select(self) -
-
- Select input field - - -

Parameters:

- - - - - - -
-
- - set_allowed_characters(self, characters) -
-
- Set allowed charaters for input field. - See: https://defold.com/ref/stable/string/ - ex: [%a%d] for alpha and numeric - - -

Parameters:

-
    -
  • self - RichInput - RichInput -
  • -
  • characters - string - Regulax exp. for validate user input -
  • -
- -

Returns:

-
    - - RichInput - Current instance -
- - - - -
-
- - set_font(self, font) -
-
- Set input field font - - -

Parameters:

-
    -
  • self - RichInput - RichInput -
  • -
  • font - hash - The font hash -
  • -
- -

Returns:

-
    - - druid.input - Current input instance -
- - - - -
-
- - set_placeholder(self, placeholder_text) -
-
- Set placeholder text - - -

Parameters:

-
    -
  • self - RichInput - RichInput -
  • -
  • placeholder_text - string - The placeholder text -
  • -
- - - - - -
-
- - set_text(self, text) -
-
- Set input field text - - -

Parameters:

- - -

Returns:

-
    - - druid.input - Current input instance -
- - - - -
-
-

Fields

- -
-
- - cursor -
-
- On input field text change to empty string callback(self, input_text) - - -
    -
  • cursor - node - -
  • -
- - - - - -
-
- - cursor_position -
-
- On input field text change to empty string callback(self, input_text) - - -
    -
  • cursor_position - vector3 - -
  • -
- - - - - -
-
- - cursor_text -
-
- On input field text change to empty string callback(self, input_text) - - -
    -
  • cursor_text - node - -
  • -
- - - - - -
-
- - drag -
-
- On input field text change to empty string callback(self, input_text) - - -
    -
  • drag - druid.drag - -
  • -
- - - - - -
-
- - druid -
-
- The component druid instance - - - - - - - - -
-
- - input -
-
- On input field text change callback(self, input_text) - - -
    -
  • input - Input - Input -
  • -
- - - - - -
-
- - input_text -
-
- On input field text change to empty string callback(self, input_text) - - -
    -
  • input_text - druid.text - -
  • -
- - - - - -
-
- - placeholder -
-
- On input field text change to empty string callback(self, input_text) - - -
    -
  • placeholder - druid.text - -
  • -
- - - - - -
-
- - root -
-
- Root node - - -
    -
  • root - node - -
  • -
- - - - - -
-
- - text_position -
-
- On input field text change to empty string callback(self, input_text) - - -
    -
  • text_position - vector3 - -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/RichText.html b/docs/modules/RichText.html deleted file mode 100644 index 075846c..0000000 --- a/docs/modules/RichText.html +++ /dev/null @@ -1,560 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module RichText

-

Druid Rich Text Custom Component.

-

- # Overview # -

This custom component is inspired by defold-richtext by britzl. - It uses a similar syntax for tags but currently supports fewer tags. -

Create Rich Text on your GUI Text Node. All properties of the text node will be used as default for the text. -

# Notes # -

• Nested tags are supported -

Example Link

-

Usage:

-
    -
  • local RichText = require("druid.custom.rich_text.rich_text")
    -...
    -self.rich_text = self.druid:new(RichText, "rich_text")
    -self.rich_text:set_text("Hello, Druid Rich Text!")
    -
  • -
  • type druid.rich_text.word = {
    -  node: Node,
    -  relative_scale: number,
    -  color: vector4,
    -  position: vector3,
    -  offset: vector3,
    -  scale: vector3,
    -  size: vector3,
    -  metrics: druid.rich_text.metrics,
    -  pivot: Pivot,
    -  text: string,
    -  shadow: vector4,
    -  outline: vector4,
    -  font: string,
    -  image: druid.rich_text.image,
    -  br: boolean,
    -  nobr: boolean,
    -}
    -
    -type druid.rich_text.word.image = {
    -  texture: string,
    -  anim: string,
    -  width: number,
    -  height: number,
    -}
    -
    -type druid.rich_text.lines_metrics = {
    -  text_width: number,
    -  text_height: number,
    -  lines: table<number, druid.rich_text.metrics>,
    -}
    -
    -type druid.rich_text.metrics = {
    -  width: number,
    -  height: number,
    -  offset_x: number|nil,
    -  offset_y: number|nil,
    -  node_size: vector3|nil @For images only,
    -}
    -
  • -
- - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
characters(self, word)Split a word into it's characters
clear()Clear all created words.
get_line_metric()Get current line metrics
get_text(self)Get current text
get_words()Get all current words.
init(self, text_node, value)The RichText constructor
set_text(self, text)Set text for Rich Text
tagged(self, tag)Get all words, which has a passed tag.
-

Tables

- - - - - -
styleComponent style params.
-

Fields

- - - - - - - - - - - - - -
druidThe component druid instance
rootThe root node of the Rich Text
text_prefabThe text prefab node
- -
-
- - -

Functions

- -
-
- - characters(self, word) -
-
- Split a word into it's characters - - -

Parameters:

-
    -
  • self - RichText - RichText -
  • -
  • word - druid.rich_text.word - -
  • -
- -

Returns:

-
    - - druid.rich_text.word[] - characters -
- - - - -
-
- - clear() -
-
- Clear all created words. - - - - - - - -
-
- - get_line_metric() -
-
- Get current line metrics - - - -

Returns:

-
    - - druid.rich_text.lines_metrics - -
- - - - -
-
- - get_text(self) -
-
- Get current text - - -

Parameters:

- - -

Returns:

-
    - - string - text -
- - - - -
-
- - get_words() -
-
- Get all current words. - - - -

Returns:

-
    - - table - druid.rich_text.word[] -
- - - - -
-
- - init(self, text_node, value) -
-
- The RichText constructor - - -

Parameters:

-
    -
  • self - RichText - RichText -
  • -
  • text_node - node or string - The text node to make Rich Text -
  • -
  • value - string or nil - The initial text value. Default will be gui.get_text(text_node) -
  • -
- - - - - -
-
- - set_text(self, text) -
-
- Set text for Rich Text - - -

Parameters:

-
    -
  • self - RichText - RichText -
  • -
  • text - string or nil - The text to set -
  • -
- -

Returns:

-
    -
  1. - druid.rich_text.word[] - words
  2. -
  3. - druid.rich_text.lines_metrics - line_metrics
  4. -
- - - -

Usage:

-
    -
    • color: Change text color
    -
    -<color=red>Foobar</color>
    -<color=1.0,0,0,1.0>Foobar</color>
    -<color=#ff0000>Foobar</color>
    -<color=#ff0000ff>Foobar</color>
    -
    -• shadow: Change text shadow
    -
    -<shadow=red>Foobar</shadow>
    -<shadow=1.0,0,0,1.0>Foobar</shadow>
    -<shadow=#ff0000>Foobar</shadow>
    -<shadow=#ff0000ff>Foobar</shadow>
    -
    -• outline: Change text shadow
    -
    -<outline=red>Foobar</outline>
    -<outline=1.0,0,0,1.0>Foobar</outline>
    -<outline=#ff0000>Foobar</outline>
    -<outline=#ff0000ff>Foobar</outline>
    -
    -• font: Change font
    -
    -<font=MyCoolFont>Foobar</font>
    -
    -• size: Change text size, relative to default size
    -
    -<size=2>Twice as large</size>
    -
    -• br: Insert a line break
    -
    -<br/>
    -
    -• nobr: Prevent the text from breaking
    -
    -Words <nobr>inside tag</nobr> won't break
    -
    -• img: Display image
    -
    -<img=texture:image/>
    -<img=texture:image,size/>
    -<img=texture:image,width,height/>
    -
- -
-
- - tagged(self, tag) -
-
- Get all words, which has a passed tag. - - -

Parameters:

- - -

Returns:

-
    - - druid.rich_text.word[] - words -
- - - - -
-
-

Tables

- -
-
- - style -
-
- Component style params. - You can override this component styles params in Druid styles table - or create your own style - - -

Fields:

-
    -
  • COLORS - table or nil - Rich Text color aliases. Default: {} -
  • -
  • ADJUST_STEPS - number or nil - Amount steps of attemps text adjust by height. Default: 20 -
  • -
  • ADJUST_SCALE_DELTA - number or nil - Scale step on each height adjust step. Default: 0.02 -
  • -
- - - - - -
-
-

Fields

- -
-
- - druid -
-
- The component druid instance - - - - - - - - -
-
- - root -
-
- The root node of the Rich Text - - -
    -
  • root - node - -
  • -
- - - - - -
-
- - text_prefab -
-
- The text prefab node - - -
    -
  • text_prefab - node - -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/Scroll.html b/docs/modules/Scroll.html deleted file mode 100644 index 457f77c..0000000 --- a/docs/modules/Scroll.html +++ /dev/null @@ -1,1183 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module Scroll

-

Component to handle scroll content.

-

- # Overview # -

The Scroll component is designed to handle scrollable content and consists of two nodes: the scroll parent and the scroll input. -

The scroll input represents the user input zone and remains static. -

The scroll parent is the movable part of the scroll and changes its position. -

The initial scroll size can be set by adjusting the size of the scroll parent. - If the size of the scroll parent is smaller than the scroll input size, scrolling is not available. -

# Notes # -

• By default, the scroll style includes inertia and extra size for a stretching effect. - These settings can be adjusted using the scroll style settings. - For more details, refer to the scroll style settings. -

• "Points of interest" can be set up for the scroll. - The scroll will always be centered on the closest point of interest. - This feature allows creating a slider without inertia and with points of interest on each scroll element. -

• The scroll content size can be adjusted using the scroll:set_size(node_size) method. - This method sets a new size for the _content node. -

• Inertial scrolling mode can be enabled or disabled using the scroll:set_inert(state) method. -

• The extra stretch size can be adjusted using the scroll:set_extra_stretch_size method. -

• Multitouch is required for scrolling. The scroll component correctly handles - touch ID swaps while dragging the scroll. -

Example Link

- - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bind_grid(self, grid)Bind the grid component (Static or Dynamic) to recalculate - scroll size on grid changes
get_percent(self)Return current scroll progress status.
get_scroll_size(self)Return vector of scroll size with width and height.
init(self, view_node, content_node)The Scroll constructor
is_inert(self)Return if scroll have inertion.
is_node_in_view(self, node)Check node if it visible now on scroll.
scroll_to(self, point, is_instant)Start scroll to target point.
scroll_to_index(self, index, skip_cb)Scroll to item in scroll by point index.
scroll_to_percent(self, percent, is_instant)Start scroll to target scroll percent
set_click_zone(self, node)Strict drag scroll area.
set_extra_stretch_size(self, stretch_size)Set extra size for scroll stretching.
set_horizontal_scroll(self, state)Lock or unlock horizontal scroll
set_inert(self, state)Enable or disable scroll inert.
set_points(self, points)Set points of interest.
set_size(self, size, offset)Set scroll content size.
set_vertical_scroll(self, state)Lock or unlock vertical scroll
set_view_size(self, size)Set new scroll view size in case the node size was changed.
update_view_size(self)Refresh scroll view size
-

Tables

- - - - - -
styleComponent style params.
-

Fields

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_is_inertFlag, if scroll now moving by inertion
available_posAvailable position for content node: (min_x, max_y, max_x, min_y)
available_sizeSize of available positions: (width, height, 0)
content_nodeScroll content node
dragDrag Druid component
inertionCurrent inert speed
is_animateFlag, if scroll now animating by gui.animate
on_point_scrollOn scroll_to_index function callback(self, index, point)
on_scrollOn scroll move callback(self, position)
on_scroll_toOn scroll_to function callback(self, target, is_instant)
positionCurrent scroll posisition
selectedCurrent index of points of interests
target_positionCurrent scroll target position
view_nodeScroll view node
view_sizeScroll view size
- -
-
- - -

Functions

- -
-
- - bind_grid(self, grid) -
-
- Bind the grid component (Static or Dynamic) to recalculate - scroll size on grid changes - - -

Parameters:

-
    -
  • self - Scroll - Scroll -
  • -
  • grid - StaticGrid - Druid grid component -
  • -
- -

Returns:

-
    - - druid.scroll - Current scroll instance -
- - - - -
-
- - get_percent(self) -
-
- Return current scroll progress status. - Values will be in [0..1] interval - - -

Parameters:

-
    -
  • self - Scroll - Scroll -
  • -
- -

Returns:

-
    - - vector3 - New vector with scroll progress values -
- - - - -
-
- - get_scroll_size(self) -
-
- Return vector of scroll size with width and height. - - -

Parameters:

-
    -
  • self - Scroll - Scroll -
  • -
- -

Returns:

-
    - - vector3 - Available scroll size -
- - - - -
-
- - init(self, view_node, content_node) -
-
- The Scroll constructor - - -

Parameters:

-
    -
  • self - Scroll - Scroll -
  • -
  • view_node - string or node - GUI view scroll node -
  • -
  • content_node - string or node - GUI content scroll node -
  • -
- - - - - -
-
- - is_inert(self) -
-
- Return if scroll have inertion. - - -

Parameters:

-
    -
  • self - Scroll - Scroll -
  • -
- -

Returns:

-
    - - boolean - @If scroll have inertion -
- - - - -
-
- - is_node_in_view(self, node) -
-
- Check node if it visible now on scroll. - Extra border is not affected. Return true for elements in extra scroll zone - - -

Parameters:

-
    -
  • self - Scroll - Scroll -
  • -
  • node - node - The node to check -
  • -
- -

Returns:

-
    - - boolean - True if node in visible scroll area -
- - - - -
-
- - scroll_to(self, point, is_instant) -
-
- Start scroll to target point. - - -

Parameters:

-
    -
  • self - Scroll - Scroll -
  • -
  • point - vector3 - Target point -
  • -
  • is_instant - boolean or nil - Instant scroll flag -
  • -
- - - - -

Usage:

-
    -
  • scroll:scroll_to(vmath.vector3(0, 50, 0))
  • -
  • scroll:scroll_to(vmath.vector3(0), true)
  • -
- -
-
- - scroll_to_index(self, index, skip_cb) -
-
- Scroll to item in scroll by point index. - - -

Parameters:

-
    -
  • self - Scroll - Scroll -
  • -
  • index - number - Point index -
  • -
  • skip_cb - boolean or nil - If true, skip the point callback -
  • -
- - - - - -
-
- - scroll_to_percent(self, percent, is_instant) -
-
- Start scroll to target scroll percent - - -

Parameters:

-
    -
  • self - Scroll - Scroll -
  • -
  • percent - vector3 - target percent -
  • -
  • is_instant - boolean or nil - instant scroll flag -
  • -
- - - - -

Usage:

-
    -
    scroll:scroll_to_percent(vmath.vector3(0.5, 0, 0))
    -
- -
-
- - set_click_zone(self, node) -
-
- Strict drag scroll area. Useful for - restrict events outside stencil node - - -

Parameters:

-
    -
  • self - Drag - -
  • -
  • node - node or string - Gui node -
  • -
- - - - - -
-
- - set_extra_stretch_size(self, stretch_size) -
-
- Set extra size for scroll stretching. - Set 0 to disable stretching effect - - -

Parameters:

-
    -
  • self - Scroll - Scroll -
  • -
  • stretch_size - number or nil - Size in pixels of additional scroll area -
  • -
- -

Returns:

-
    - - druid.scroll - Current scroll instance -
- - - - -
-
- - set_horizontal_scroll(self, state) -
-
- Lock or unlock horizontal scroll - - -

Parameters:

-
    -
  • self - Scroll - Scroll -
  • -
  • state - boolean or nil - True, if horizontal scroll is enabled -
  • -
- -

Returns:

-
    - - druid.scroll - Current scroll instance -
- - - - -
-
- - set_inert(self, state) -
-
- Enable or disable scroll inert. - If disabled, scroll through points (if exist) - If no points, just simple drag without inertion - - -

Parameters:

-
    -
  • self - Scroll - Scroll -
  • -
  • state - boolean or nil - Inert scroll state -
  • -
- -

Returns:

-
    - - druid.scroll - Current scroll instance -
- - - - -
-
- - set_points(self, points) -
-
- Set points of interest. - Scroll will always centered on closer points - - -

Parameters:

-
    -
  • self - Scroll - Scroll -
  • -
  • points - table - Array of vector3 points -
  • -
- -

Returns:

-
    - - druid.scroll - Current scroll instance -
- - - - -
-
- - set_size(self, size, offset) -
-
- Set scroll content size. - It will change content gui node size - - -

Parameters:

-
    -
  • self - Scroll - Scroll -
  • -
  • size - vector3 - The new size for content node -
  • -
  • offset - vector3 or nil - Offset value to set, where content is starts -
  • -
- -

Returns:

-
    - - druid.scroll - Current scroll instance -
- - - - -
-
- - set_vertical_scroll(self, state) -
-
- Lock or unlock vertical scroll - - -

Parameters:

-
    -
  • self - Scroll - Scroll -
  • -
  • state - boolean or nil - True, if vertical scroll is enabled -
  • -
- -

Returns:

-
    - - druid.scroll - Current scroll instance -
- - - - -
-
- - set_view_size(self, size) -
-
- Set new scroll view size in case the node size was changed. - - -

Parameters:

-
    -
  • self - Scroll - Scroll -
  • -
  • size - vector3 - The new size for view node -
  • -
- -

Returns:

-
    - - druid.scroll - Current scroll instance -
- - - - -
-
- - update_view_size(self) -
-
- Refresh scroll view size - - -

Parameters:

-
    -
  • self - Scroll - Scroll -
  • -
- - - - - -
-
-

Tables

- -
-
- - style -
-
- Component style params. - You can override this component styles params in druid styles table - or create your own style - - -

Fields:

-
    -
  • FRICT - number or nil - Multiplier for free inertion. Default: 0 -
  • -
  • FRICT_HOLD - number or nil - Multiplier for inertion, while touching. Default: 0 -
  • -
  • INERT_THRESHOLD - number or nil - Scroll speed to stop inertion. Default: 3 -
  • -
  • INERT_SPEED - number or nil - Multiplier for inertion speed. Default: 30 -
  • -
  • POINTS_DEADZONE - number or nil - Speed to check points of interests in no_inertion mode. Default: 20 -
  • -
  • BACK_SPEED - number or nil - Scroll back returning lerp speed. Default: 35 -
  • -
  • ANIM_SPEED - number or nil - Scroll gui.animation speed for scroll_to function. Default: 2 -
  • -
  • EXTRA_STRETCH_SIZE - number or nil - extra size in pixels outside of scroll (stretch effect). Default: 0 -
  • -
  • SMALL_CONTENT_SCROLL - boolean or nil - If true, content node with size less than view node size can be scrolled. Default: false -
  • -
  • WHEEL_SCROLL_SPEED - boolean or nil - The scroll speed via mouse wheel scroll or touchpad. Set to 0 to disable wheel scrolling. Default: 0 -
  • -
  • WHEEL_SCROLL_INVERTED - boolean or nil - If true, invert direction for touchpad and mouse wheel scroll. Default: false -
  • -
  • WHEEL_SCROLL_BY_INERTION - boolean or nil - If true, wheel will add inertion to scroll. Direct set position otherwise.. Default: false -
  • -
- - - - - -
-
-

Fields

- -
-
- - _is_inert -
-
- Flag, if scroll now moving by inertion - - -
    -
  • _is_inert - boolean - -
  • -
- - - - - -
-
- - available_pos -
-
- Available position for content node: (min_x, max_y, max_x, min_y) - - -
    -
  • available_pos - vector4 - -
  • -
- - - - - -
-
- - available_size -
-
- Size of available positions: (width, height, 0) - - -
    -
  • available_size - vector3 - -
  • -
- - - - - -
-
- - content_node -
-
- Scroll content node - - -
    -
  • content_node - node - -
  • -
- - - - - -
-
- - drag -
-
- Drag Druid component - - -
    -
  • drag - Drag - Drag -
  • -
- - - - - -
-
- - inertion -
-
- Current inert speed - - -
    -
  • inertion - vector3 - -
  • -
- - - - - -
-
- - is_animate -
-
- Flag, if scroll now animating by gui.animate - - -
    -
  • is_animate - boolean - -
  • -
- - - - - -
-
- - on_point_scroll -
-
- On scroll_to_index function callback(self, index, point) - - - - - - - - -
-
- - on_scroll -
-
- On scroll move callback(self, position) - - - - - - - - -
-
- - on_scroll_to -
-
- On scroll_to function callback(self, target, is_instant) - - - - - - - - -
-
- - position -
-
- Current scroll posisition - - -
    -
  • position - vector3 - -
  • -
- - - - - -
-
- - selected -
-
- Current index of points of interests - - -
    -
  • selected - number or nil - -
  • -
- - - - - -
-
- - target_position -
-
- Current scroll target position - - -
    -
  • target_position - vector3 - -
  • -
- - - - - -
-
- - view_node -
-
- Scroll view node - - -
    -
  • view_node - node - -
  • -
- - - - - -
-
- - view_size -
-
- Scroll view size - - -
    -
  • view_size - vector3 - -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/Slider.html b/docs/modules/Slider.html deleted file mode 100644 index 45ce723..0000000 --- a/docs/modules/Slider.html +++ /dev/null @@ -1,531 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module Slider

-

Druid slider component

-

Example Link

- - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - -
init(self, node, end_pos, callback)The Slider constructor
is_enabled(self)Check if Slider component is enabled
set(self, value, is_silent)Set value for slider
set_enabled(self, is_enabled)Set Slider input enabled or disabled
set_input_node(self, input_node)Set input zone for slider.
set_steps(self, steps)Set slider steps.
-

Fields

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
distLength between start and end position
end_posEnd pin node position
is_dragCurrent drag state
nodeSlider pin node
on_change_valueOn change value callback(self, value)
posCurrent pin node position
start_posStart pin node position
target_posTarger pin node position
valueCurrent slider value
- -
-
- - -

Functions

- -
-
- - init(self, node, end_pos, callback) -
-
- The Slider constructor - - -

Parameters:

-
    -
  • self - Slider - Slider -
  • -
  • node - node - Gui pin node -
  • -
  • end_pos - vector3 - The end position of slider -
  • -
  • callback - function or nil - On slider change callback -
  • -
- - - - - -
-
- - is_enabled(self) -
-
- Check if Slider component is enabled - - -

Parameters:

-
    -
  • self - Slider - Slider -
  • -
- -

Returns:

-
    - - boolean - -
- - - - -
-
- - set(self, value, is_silent) -
-
- Set value for slider - - -

Parameters:

-
    -
  • self - Slider - Slider -
  • -
  • value - number - Value from 0 to 1 -
  • -
  • is_silent - boolean or nil - Don't trigger event if true -
  • -
- - - - - -
-
- - set_enabled(self, is_enabled) -
-
- Set Slider input enabled or disabled - - -

Parameters:

-
    -
  • self - Slider - Slider -
  • -
  • is_enabled - boolean - -
  • -
- - - - - -
-
- - set_input_node(self, input_node) -
-
- Set input zone for slider. - User can touch any place of node, pin instantly will - move at this position and node drag will start. - This function require the Defold version 1.3.0+ - - -

Parameters:

- - -

Returns:

-
    - - Slider - Slider -
- - - - -
-
- - set_steps(self, steps) -
-
- Set slider steps. Pin node will - apply closest step position - - -

Parameters:

-
    -
  • self - Slider - Slider -
  • -
  • steps - number[] - Array of steps -
  • -
- -

Returns:

-
    - - Slider - Slider -
- - - -

Usage:

-
    -
    slider:set_steps({0, 0.2, 0.6, 1})
    -
- -
-
-

Fields

- -
-
- - dist -
-
- Length between start and end position - - -
    -
  • dist - vector3 - -
  • -
- - - - - -
-
- - end_pos -
-
- End pin node position - - -
    -
  • end_pos - vector3 - -
  • -
- - - - - -
-
- - is_drag -
-
- Current drag state - - -
    -
  • is_drag - boolean - -
  • -
- - - - - -
-
- - node -
-
- Slider pin node - - -
    -
  • node - node - -
  • -
- - - - - -
-
- - on_change_value -
-
- On change value callback(self, value) - - - - - - - - -
-
- - pos -
-
- Current pin node position - - -
    -
  • pos - vector3 - -
  • -
- - - - - -
-
- - start_pos -
-
- Start pin node position - - -
    -
  • start_pos - vector3 - -
  • -
- - - - - -
-
- - target_pos -
-
- Targer pin node position - - -
    -
  • target_pos - vector3 - -
  • -
- - - - - -
-
- - value -
-
- Current slider value - - -
    -
  • value - number - -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/StaticGrid.html b/docs/modules/StaticGrid.html deleted file mode 100644 index 5281ef5..0000000 --- a/docs/modules/StaticGrid.html +++ /dev/null @@ -1,1094 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module StaticGrid

-

Component to handle component's position by row and columns.

-

- # Overview # -

The Static Grid component allows for positioning components in rows and columns. - It provides a static grid layout with constant node sizes, allowing for pre-calculated - node positions and the option to include gaps between nodes. -

# Notes # -

• In a static grid, the node size remains constant, enabling the calculation of node - positions before placement. If you want add gaps between nodes, increase the root prefab size, - including the padding and margin. -

• The static grid can automatically shift elements when nodes are added or removed. -

• When a node is added, the grid will set the node's parent to the specified parent_node. -

• You can obtain an array of positions for each element, which can be used to set - points of interest in a scroll component. -

• The size of all elements can be retrieved for setting up the size in a scroll component. -

• The grid can be bound to a scroll component for automatic resizing of the scroll content size. -

• The pivot of the parent_node affects the node placement within the grid. -

• A prefab node is used to determine the node size and anchor. -

• You can specify a position_function for animations using the - _static_grid:set_position_function(node, pos) callback. The default position function is gui.set_position(). -

Example Link

- - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
add(self, item, index, shift_policy, is_instant)Add new item to the grid
clear(self)Clear grid nodes array.
get_all_pos(self)Return array of all node positions
get_borders(self)Return grid content borders
get_index(self, pos)Return index for grid pos
get_index_by_node(self, node)Return grid index by node
get_offset(self)Return StaticGrid offset, where StaticGrid content starts.
get_pos(self, index)Return pos for grid node index
get_size(self)Return grid content size
init(self, parent, element, in_row)The StaticGrid constructor
refresh(self)Update grid content
remove(self, index, shift_policy, is_instant)Remove the item from the grid.
set_anchor(self, anchor)Set grid anchor.
set_in_row(self, in_row)Set new in_row elements for grid
set_item_size(self[, width[, height]])Set new node size for grid
set_items(self, nodes[, is_instant=false])Set new items to the grid.
set_position_function(self, callback)Change set position function for grid nodes.
sort_nodes(self, comparator)Sort grid nodes by custom comparator function
-

Tables

- - - - - -
styleComponent style params.
-

Fields

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
anchorItem anchor [0..1]
borderThe size of item content
first_indexThe first index of node in grid
last_indexThe last index of node in grid
node_sizeItem size
nodesList of all grid nodes
on_add_itemOn item add callback(self, node, index)
on_change_itemsOn item add, remove or change in_row callback(self, index|nil)
on_clearOn grid clear callback(self)
on_remove_itemOn item remove callback(self, index)
on_update_positionsOn update item positions callback(self)
parentParent gui node
pivotItem pivot [-0.5..0.5]
- -
-
- - -

Functions

- -
-
- - add(self, item, index, shift_policy, is_instant) -
-
- Add new item to the grid - - -

Parameters:

-
    -
  • self - StaticGrid - StaticGrid -
  • -
  • item - node - GUI node -
  • -
  • index - number or nil - The item position. By default add as last item -
  • -
  • shift_policy - number or nil - How shift nodes, if required. Default: const.SHIFT.RIGHT -
  • -
  • is_instant - boolean or nil - If true, update node positions instantly -
  • -
- - - - - -
-
- - clear(self) -
-
- Clear grid nodes array. GUI nodes will be not deleted! - If you want to delete GUI nodes, use static_grid.nodes array before grid:clear - - -

Parameters:

- - -

Returns:

-
    - - druid.static_grid - Current grid instance -
- - - - -
-
- - get_all_pos(self) -
-
- Return array of all node positions - - -

Parameters:

- - -

Returns:

-
    - - vector3[] - All grid node positions -
- - - - -
-
- - get_borders(self) -
-
- Return grid content borders - - -

Parameters:

- - -

Returns:

-
    - - vector3 - The grid content borders -
- - - - -
-
- - get_index(self, pos) -
-
- Return index for grid pos - - -

Parameters:

-
    -
  • self - StaticGrid - StaticGrid -
  • -
  • pos - vector3 - The node position in the grid -
  • -
- -

Returns:

-
    - - number - The node index -
- - - - -
-
- - get_index_by_node(self, node) -
-
- Return grid index by node - - -

Parameters:

-
    -
  • self - StaticGrid - StaticGrid -
  • -
  • node - node - The gui node in the grid -
  • -
- -

Returns:

-
    - - number - The node index -
- - - - -
-
- - get_offset(self) -
-
- Return StaticGrid offset, where StaticGrid content starts. - - -

Parameters:

-
    -
  • self - StaticGrid - StaticGrid The StaticGrid instance -
  • -
- -

Returns:

-
    - - vector3 - The StaticGrid offset -
- - - - -
-
- - get_pos(self, index) -
-
- Return pos for grid node index - - -

Parameters:

-
    -
  • self - StaticGrid - StaticGrid -
  • -
  • index - number - The grid element index -
  • -
- -

Returns:

-
    - - vector3 - @Node position -
- - - - -
-
- - get_size(self) -
-
- Return grid content size - - -

Parameters:

- - -

Returns:

-
    - - vector3 - The grid content size -
- - - - -
-
- - init(self, parent, element, in_row) -
-
- The StaticGrid constructor - - -

Parameters:

-
    -
  • self - StaticGrid - StaticGrid -
  • -
  • parent - string or node - The GUI Node container, where grid's items will be placed -
  • -
  • element - node - Element prefab. Need to get it size -
  • -
  • in_row - number or nil - How many nodes in row can be placed. By default 1 -
  • -
- - - - - -
-
- - refresh(self) -
-
- Update grid content - - -

Parameters:

- - - - - - -
-
- - remove(self, index, shift_policy, is_instant) -
-
- Remove the item from the grid. Note that gui node will be not deleted - - -

Parameters:

-
    -
  • self - StaticGrid - StaticGrid -
  • -
  • index - number - The grid node index to remove -
  • -
  • shift_policy - number or nil - How shift nodes, if required. Default: const.SHIFT.RIGHT -
  • -
  • is_instant - boolean or nil - If true, update node positions instantly -
  • -
- -

Returns:

-
    - - node - The deleted gui node from grid -
- - - - -
-
- - set_anchor(self, anchor) -
-
- Set grid anchor. Default anchor is equal to anchor of grid parent node - - -

Parameters:

-
    -
  • self - StaticGrid - StaticGrid -
  • -
  • anchor - vector3 - Anchor -
  • -
- - - - - -
-
- - set_in_row(self, in_row) -
-
- Set new in_row elements for grid - - -

Parameters:

-
    -
  • self - StaticGrid - StaticGrid -
  • -
  • in_row - number - The new in_row value -
  • -
- -

Returns:

-
    - - druid.static_grid - Current grid instance -
- - - - -
-
- - set_item_size(self[, width[, height]]) -
-
- Set new node size for grid - - -

Parameters:

-
    -
  • self - StaticGrid - StaticGrid -
  • -
  • width - number - The new node width - (optional) -
  • -
  • height - number - The new node height - (optional) -
  • -
- -

Returns:

-
    - - druid.static_grid - Current grid instance -
- - - - -
-
- - set_items(self, nodes[, is_instant=false]) -
-
- Set new items to the grid. All previous items will be removed - - -

Parameters:

-
    -
  • self - StaticGrid - StaticGrid -
  • -
  • nodes - node[] - The new grid nodes -
  • -
  • is_instant - boolean - If true, update node positions instantly - (default false) -
  • -
- - - - - -
-
- - set_position_function(self, callback) -
-
- Change set position function for grid nodes. It will call on - update poses on grid elements. Default: gui.set_position - - -

Parameters:

-
    -
  • self - StaticGrid - StaticGrid -
  • -
  • callback - function - Function on node set position -
  • -
- -

Returns:

-
    - - druid.static_grid - Current grid instance -
- - - - -
-
- - sort_nodes(self, comparator) -
-
- Sort grid nodes by custom comparator function - - -

Parameters:

-
    -
  • self - StaticGrid - StaticGrid -
  • -
  • comparator - function - The comparator function. (a, b) -> boolean -
  • -
- -

Returns:

-
    - - druid.static_grid - Current grid instance -
- - - - -
-
-

Tables

- -
-
- - style -
-
- Component style params. - You can override this component styles params in druid styles table - or create your own style - - -

Fields:

-
    -
  • IS_DYNAMIC_NODE_POSES - boolean or nil - If true, always center grid content as grid pivot sets. Default: false -
  • -
  • IS_ALIGN_LAST_ROW - boolean or nil - If true, always align last row of the grid as grid pivot sets. Default: false -
  • -
- - - - - -
-
-

Fields

- -
-
- - anchor -
-
- Item anchor [0..1] - - -
    -
  • anchor - vector3 - -
  • -
- - - - - -
-
- - border -
-
- The size of item content - - -
    -
  • border - vector4 - -
  • -
- - - - - -
-
- - first_index -
-
- The first index of node in grid - - -
    -
  • first_index - number - -
  • -
- - - - - -
-
- - last_index -
-
- The last index of node in grid - - -
    -
  • last_index - number - -
  • -
- - - - - -
-
- - node_size -
-
- Item size - - -
    -
  • node_size - vector3 - -
  • -
- - - - - -
-
- - nodes -
-
- List of all grid nodes - - -
    -
  • nodes - node[] - -
  • -
- - - - - -
-
- - on_add_item -
-
- On item add callback(self, node, index) - - - - - - - - -
-
- - on_change_items -
-
- On item add, remove or change in_row callback(self, index|nil) - - - - - - - - -
-
- - on_clear -
-
- On grid clear callback(self) - - - - - - - - -
-
- - on_remove_item -
-
- On item remove callback(self, index) - - - - - - - - -
-
- - on_update_positions -
-
- On update item positions callback(self) - - -
    -
  • on_update_positions - DruidEvent - DruidEvent -
  • -
- - - - - -
-
- - parent -
-
- Parent gui node - - -
    -
  • parent - node - -
  • -
- - - - - -
-
- - pivot -
-
- Item pivot [-0.5..0.5] - - -
    -
  • pivot - vector3 - -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/Swipe.html b/docs/modules/Swipe.html deleted file mode 100644 index 9b7a2a9..0000000 --- a/docs/modules/Swipe.html +++ /dev/null @@ -1,288 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module Swipe

-

Component to handle swipe gestures on node.

-

- Swipe will be triggered, if swipe was started and - ended on one node -

Example Link

- - -

Functions

- - - - - - - - - -
init(self, node, on_swipe_callback)The Swipe constructor
set_click_zone(self, zone)Strict swipe click area.
-

Tables

- - - - - -
styleComponent style params.
-

Fields

- - - - - - - - - - - - - -
click_zoneRestriction zone
nodeSwipe node
on_swipeTrigger on swipe event(self, swipe_side, dist, delta_time)
- -
-
- - -

Functions

- -
-
- - init(self, node, on_swipe_callback) -
-
- The Swipe constructor - - -

Parameters:

-
    -
  • self - Swipe - Swipe -
  • -
  • node - node - Gui node -
  • -
  • on_swipe_callback - function - Swipe callback for on_swipe_end event -
  • -
- - - - - -
-
- - set_click_zone(self, zone) -
-
- Strict swipe click area. Useful for - restrict events outside stencil node - - -

Parameters:

- - - - - - -
-
-

Tables

- -
-
- - style -
-
- Component style params. - You can override this component styles params in druid styles table - or create your own style - - -

Fields:

-
    -
  • SWIPE_TIME - number or nil - Maximum time for swipe trigger. Default: 0.4 -
  • -
  • SWIPE_THRESHOLD - number or nil - Minimum distance for swipe trigger. Default: 50 -
  • -
  • SWIPE_TRIGGER_ON_MOVE - boolean or nil - If true, trigger on swipe moving, not only release action. Default: false -
  • -
- - - - - -
-
-

Fields

- -
-
- - click_zone -
-
- Restriction zone - - -
    -
  • click_zone - node or nil - -
  • -
- - - - - -
-
- - node -
-
- Swipe node - - -
    -
  • node - node - -
  • -
- - - - - -
-
- - on_swipe -
-
- Trigger on swipe event(self, swipe_side, dist, delta_time) - - - - - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/Text.html b/docs/modules/Text.html deleted file mode 100644 index bcf6e6c..0000000 --- a/docs/modules/Text.html +++ /dev/null @@ -1,942 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module Text

-

Component for Wrapping GUI Text Nodes: Druid Text -

## Overview ## -

Druid Text is a component that provides various adjustment modes for text nodes.

-

It allows text to be scaled down to fit within the size of the text node. -

## Notes ## -

• The text pivot can be changed using the text:set_pivot method. - The anchoring will be inside the text node's area size. -

• There are several text adjustment types available. The default is DOWNSCALE. - You can change the default adjustment type in the Text style. Refer to the example below to see all available adjustment types: -

- const.TEXT_ADJUST.DOWNSCALE: Changes the text's scale to fit within the text node's size. -

- const.TEXT_ADJUST.TRIM: Trims the text with a postfix (default: "...", can be overridden in styles) - to fit within the text node's size. -

- const.TEXT_ADJUST.NO_ADJUST: No adjustment is applied, similar - to the default Defold Text Node behavior. -

- const.TEXT_ADJUST.DOWNSCALE_LIMITED: Changes the text's scale - with a limited downscale. You can set the minimum scale using the text:set_minimal_scale() function. -

- const.TEXT_ADJUST.SCROLL: Changes the text's pivot to imitate scrolling within the text box. - For better effect, use with a stencil node. -

- const.TEXT_ADJUST.SCALE_THEN_SCROLL: Combines two modes: limited downscale first, then scroll. -

Example Link

- - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
get_text_adjust(self, adjust_type)Return current text adjust type
get_text_index_by_width(self, width)Get chars count by width
get_text_size(self, text)Calculate text width with font with respect to trailing space
init(self, node, value, adjust_type)The Text constructor
is_multiline(self)Return true, if text with line break
set_alpha(self, alpha)Set alpha
set_color(self, color)Set color
set_minimal_scale(self, minimal_scale)Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types
set_pivot(self, pivot)Set text pivot.
set_scale(self, scale)Set scale
set_size(self, size)Set text area size
set_text_adjust(self, adjust_type, minimal_scale)Set text adjust, refresh the current text visuals, if needed
set_to(self, set_to)Set text to text field
-

Tables

- - - - - -
styleComponent style params.
-

Fields

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
adjust_typeCurrent text size adjust settings
colorCurrent text color
last_valueThe last text value
nodeText node
node_idThe node id of text node
on_set_pivotOn change pivot callback(self, pivot)
on_set_textOn set text callback(self, text)
on_update_text_scaleOn adjust text size callback(self, new_scale, text_metrics)
posCurrent text position
scaleCurrent text node scale
start_scaleInitial text node scale
start_sizeInitial text node size
text_areaCurrent text node available are
- -
-
- - -

Functions

- -
-
- - get_text_adjust(self, adjust_type) -
-
- Return current text adjust type - - -

Parameters:

-
    -
  • self - -
  • -
  • adjust_type - -
  • -
- -

Returns:

-
    - - number - The current text adjust type -
- - - - -
-
- - get_text_index_by_width(self, width) -
-
- Get chars count by width - - -

Parameters:

-
    -
  • self - Text - Text -
  • -
  • width - number - -
  • -
- -

Returns:

-
    - - number - Chars count -
- - - - -
-
- - get_text_size(self, text) -
-
- Calculate text width with font with respect to trailing space - - -

Parameters:

-
    -
  • self - Text - Text -
  • -
  • text - string - |nil -
  • -
- -

Returns:

-
    -
  1. - number - Width
  2. -
  3. - number - Height
  4. -
- - - - -
-
- - init(self, node, value, adjust_type) -
-
- The Text constructor - - -

Parameters:

-
    -
  • self - Text - Text -
  • -
  • node - string or node - Node name or GUI Text Node itself -
  • -
  • value - string or nil - Initial text. Default value is node text from GUI scene. Default: nil -
  • -
  • adjust_type - string or nil - Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference. Default: DOWNSCALE -
  • -
- - - - - -
-
- - is_multiline(self) -
-
- Return true, if text with line break - - -

Parameters:

-
    -
  • self - Text - Text -
  • -
- -

Returns:

-
    - - boolean - Is text node with line break -
- - - - -
-
- - set_alpha(self, alpha) -
-
- Set alpha - - -

Parameters:

-
    -
  • self - Text - Text -
  • -
  • alpha - number - Alpha for node -
  • -
- -

Returns:

-
    - - Text - Current text instance -
- - - - -
-
- - set_color(self, color) -
-
- Set color - - -

Parameters:

-
    -
  • self - Text - Text -
  • -
  • color - vector4 - Color for node -
  • -
- -

Returns:

-
    - - Text - Current text instance -
- - - - -
-
- - set_minimal_scale(self, minimal_scale) -
-
- Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types - - -

Parameters:

-
    -
  • self - Text - Text -
  • -
  • minimal_scale - number - If pass nil - not use minimal scale -
  • -
- -

Returns:

-
    - - Text - Current text instance -
- - - - -
-
- - set_pivot(self, pivot) -
-
- Set text pivot. Text will re-anchor inside text area - - -

Parameters:

-
    -
  • self - Text - Text -
  • -
  • pivot - number - The gui.PIVOT_* constant -
  • -
- -

Returns:

-
    - - Text - Current text instance -
- - - - -
-
- - set_scale(self, scale) -
-
- Set scale - - -

Parameters:

-
    -
  • self - Text - Text -
  • -
  • scale - vector3 - Scale for node -
  • -
- -

Returns:

-
    - - Text - Current text instance -
- - - - -
-
- - set_size(self, size) -
-
- Set text area size - - -

Parameters:

-
    -
  • self - Text - Text -
  • -
  • size - vector3 - The new text area size -
  • -
- -

Returns:

-
    - - Text - Current text instance -
- - - - -
-
- - set_text_adjust(self, adjust_type, minimal_scale) -
-
- Set text adjust, refresh the current text visuals, if needed - - -

Parameters:

-
    -
  • self - Text - Text -
  • -
  • adjust_type - string or nil - See const.TEXT_ADJUST. If pass nil - use current adjust type -
  • -
  • minimal_scale - number or nil - If pass nil - not use minimal scale -
  • -
- -

Returns:

-
    - - Text - Current text instance -
- - - - -
-
- - set_to(self, set_to) -
-
- Set text to text field - - -

Parameters:

-
    -
  • self - Text - Text -
  • -
  • set_to - string - Text for node -
  • -
- -

Returns:

-
    - - Text - Current text instance -
- - - - -
-
-

Tables

- -
-
- - style -
-
- Component style params. - You can override this component styles params in druid styles table - or create your own style - - -

Fields:

-
    -
  • TRIM_POSTFIX - string or nil - The postfix for TRIM adjust type. Default: ... -
  • -
  • DEFAULT_ADJUST - string or nil - The default adjust type for any text component. Default: DOWNSCALE -
  • -
  • ADJUST_STEPS - string or nil - Amount of iterations for text adjust by height. Default: 20 -
  • -
  • ADJUST_SCALE_DELTA - string or nil - Scale step on each height adjust step. Default: 0.02 -
  • -
- - - - - -
-
-

Fields

- -
-
- - adjust_type -
-
- Current text size adjust settings - - -
    -
  • adjust_type - number - -
  • -
- - - - - -
-
- - color -
-
- Current text color - - -
    -
  • color - vector3 - -
  • -
- - - - - -
-
- - last_value -
-
- The last text value - - - - - - - - -
-
- - node -
-
- Text node - - -
    -
  • node - node - -
  • -
- - - - - -
-
- - node_id -
-
- The node id of text node - - -
    -
  • node_id - hash - -
  • -
- - - - - -
-
- - on_set_pivot -
-
- On change pivot callback(self, pivot) - - - - - - - - -
-
- - on_set_text -
-
- On set text callback(self, text) - - - - - - - - -
-
- - on_update_text_scale -
-
- On adjust text size callback(self, new_scale, text_metrics) - - -
    -
  • on_update_text_scale - DruidEvent - DruidEvent -
  • -
- - - - - -
-
- - pos -
-
- Current text position - - -
    -
  • pos - vector3 - -
  • -
- - - - - -
-
- - scale -
-
- Current text node scale - - -
    -
  • scale - vector3 - -
  • -
- - - - - -
-
- - start_scale -
-
- Initial text node scale - - -
    -
  • start_scale - vector3 - -
  • -
- - - - - -
-
- - start_size -
-
- Initial text node size - - -
    -
  • start_size - vector3 - -
  • -
- - - - - -
-
- - text_area -
-
- Current text node available are - - -
    -
  • text_area - vector3 - -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/Timer.html b/docs/modules/Timer.html deleted file mode 100644 index 7fabb1b..0000000 --- a/docs/modules/Timer.html +++ /dev/null @@ -1,409 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module Timer

-

Component to handle GUI timers.

-

- Timer updating by game delta time. If game is not focused - - timer will be not updated.

- - -

Functions

- - - - - - - - - - - - - - - - - -
init(self, node, seconds_from, seconds_to, callback)The Timer constructor
set_interval(self, from, to)Set time interval
set_state(self, is_on)Called when update
set_to(self, set_to)Set text to text field
-

Fields

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fromInitial timer value
nodeTrigger node
on_set_enabledOn timer change enabled state callback(self, is_enabled)
on_tickOn timer tick.
on_timer_endOn timer end callback
targetTarget timer value
valueCurrent timer value
- -
-
- - -

Functions

- -
-
- - init(self, node, seconds_from, seconds_to, callback) -
-
- The Timer constructor - - -

Parameters:

-
    -
  • self - Timer - Timer -
  • -
  • node - node - Gui text node -
  • -
  • seconds_from - number or nil - Start timer value in seconds -
  • -
  • seconds_to - number or nil - End timer value in seconds -
  • -
  • callback - function or nil - Function on timer end -
  • -
- - - - - -
-
- - set_interval(self, from, to) -
-
- Set time interval - - -

Parameters:

-
    -
  • self - Timer - Timer -
  • -
  • from - number - Start time in seconds -
  • -
  • to - number - Target time in seconds -
  • -
- - - - - -
-
- - set_state(self, is_on) -
-
- Called when update - - -

Parameters:

-
    -
  • self - Timer - Timer -
  • -
  • is_on - boolean or nil - Timer enable state -
  • -
- - - - - -
-
- - set_to(self, set_to) -
-
- Set text to text field - - -

Parameters:

-
    -
  • self - Timer - Timer -
  • -
  • set_to - number - Value in seconds -
  • -
- - - - - -
-
-

Fields

- -
-
- - from -
-
- Initial timer value - - -
    -
  • from - number - -
  • -
- - - - - -
-
- - node -
-
- Trigger node - - -
    -
  • node - node - -
  • -
- - - - - -
-
- - on_set_enabled -
-
- On timer change enabled state callback(self, is_enabled) - - - - - - - - -
-
- - on_tick -
-
- On timer tick. Fire every second callback(self, value) - - - - - - - - -
-
- - on_timer_end -
-
- On timer end callback - - -
    -
  • on_timer_end - DruidEvent - (self, Timer) DruidEvent -
  • -
- - - - - -
-
- - target -
-
- Target timer value - - -
    -
  • target - number - -
  • -
- - - - - -
-
- - value -
-
- Current timer value - - -
    -
  • value - number - -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/druid.extended.layout.html b/docs/modules/druid.extended.layout.html deleted file mode 100644 index 4f01fd5..0000000 --- a/docs/modules/druid.extended.layout.html +++ /dev/null @@ -1,95 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module druid.extended.layout

-

Druid layout module -

# Overview # -

Layout component works like Dynamic Grid before - for aligning elements in a row or column.

-

Works like a Figma layout. -

# Notes

- - - -
-
- - - - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/modules/druid.system.utf8.html b/docs/modules/druid.system.utf8.html deleted file mode 100644 index 0582106..0000000 --- a/docs/modules/druid.system.utf8.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module druid.system.utf8

-

-

- - - -
-
- - - - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/druid/base/back_handler.lua b/druid/base/back_handler.lua index 68ce45b..22b459d 100644 --- a/druid/base/back_handler.lua +++ b/druid/base/back_handler.lua @@ -2,13 +2,21 @@ local event = require("event.event") local const = require("druid.const") local component = require("druid.component") ----The component that handles the back handler action, like backspace or android back button +---Component to handle back button. It handles Android back button and Backspace key. +--- +---### Setup +---Create back handler component with druid: `druid:new_back_handler(callback)` +--- +---### Notes +---- Key triggers in `input.binding` should be setup for correct working +---- It uses a key_back and key_backspace action ids ---@class druid.back_handler: druid.component ---@field on_back event Trigger on back handler action, fun(self, params) ---@field params any|nil Custom args to pass in the callback local M = component.create("back_handler") +---The Back Handler constructor ---@param callback function|nil The callback to call when the back handler is triggered ---@param params any? Custom args to pass in the callback function M:init(callback, params) diff --git a/druid/base/blocker.lua b/druid/base/blocker.lua index e1cc854..f2190cb 100644 --- a/druid/base/blocker.lua +++ b/druid/base/blocker.lua @@ -1,12 +1,22 @@ local const = require("druid.const") local component = require("druid.component") +---Druid component for block input. Use it to block input in special zone. +--- +---### Setup +---Create blocker component with druid: `druid:new_blocker(node_name)` +--- +---### Notes +---- Blocker can be used to create safe zones, where you have big buttons +---- Blocker will capture all input events that hit the node, preventing them from reaching other components +---- Blocker works placed as usual component in stack, so any other component can be placed on top of it and will work as usual ---@class druid.blocker: druid.component ----@field node node ----@field private _is_enabled boolean +---@field node node The node that will block input +---@field private _is_enabled boolean Whether blocker is enabled local M = component.create("blocker") +---The Blocker constructor ---@param node node|string The node to use as a blocker function M:init(node) self.node = self:get_node(node) diff --git a/druid/base/button.lua b/druid/base/button.lua index 3dd9375..bced6a0 100755 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -15,14 +15,29 @@ local component = require("druid.component") ---@field on_mouse_hover fun(self, node, hover_state)|nil ---@field on_set_enabled fun(self, node, enabled_state)|nil ----Druid component to make clickable node with various interaction callbacks +---Basic Druid input component. Handle input on node and provide different callbacks on touch events. +--- +---### Setup +---Create button with druid: `button = druid:new_button(node_name, callback, [params], [animation_node])` +---Where node_name is name of node from GUI scene. You can use `node_name` as input trigger zone and point another node for animation via `animation_node` +--- +---### Notes +---- Button callback have next params: (self, params, button_instance) +---- - **self** - Druid self context +---- - **params** - Additional params, specified on button creating +---- - **button_instance** - button itself +---- You can set _params_ on button callback on button creating: `druid:new_button("node_name", callback, params)`. +---- Button have several events like on_click, on_repeated_click, on_long_click, on_hold_click, on_double_click +---- Click event will not trigger if between pressed and released state cursor was outside of node zone +---- Button can have key trigger to use them by key: `button:set_key_trigger` +---- ---@class druid.button: druid.component ---@field on_click event function(self, custom_args, button_instance) ---@field on_pressed event function(self, custom_args, button_instance) ----@field on_repeated_click event function(self, custom_args, button_instance, click_count) ----@field on_long_click event function(self, custom_args, button_instance, hold_time) ----@field on_double_click event function(self, custom_args, button_instance, click_amount) ----@field on_hold_callback event function(self, custom_args, button_instance, press_time) +---@field on_repeated_click event function(self, custom_args, button_instance, click_count) Repeated click callback, while holding the button +---@field on_long_click event function(self, custom_args, button_instance, hold_time) Callback on long button tap +---@field on_double_click event function(self, custom_args, button_instance, click_amount) Different callback, if tap button 2+ in row +---@field on_hold_callback event function(self, custom_args, button_instance, press_time) Hold callback, before long_click trigger ---@field on_click_outside event function(self, custom_args, button_instance) ---@field node node Clickable node ---@field node_id hash Node id @@ -41,8 +56,8 @@ local M = component.create("button") ---The constructor for the button component ---@param node_or_node_id node|string Node name or GUI Node itself ---@param callback fun()|nil Callback on button click ----@param custom_args any|nil Custom args for any Button event ----@param anim_node node|string|nil Node to animate instead of trigger node +---@param custom_args any|nil Custom args for any Button event, will be passed to callbacks +---@param anim_node node|string|nil Node to animate instead of trigger node, useful for animating small icons on big panels function M:init(node_or_node_id, callback, custom_args, anim_node) self.druid = self:get_druid() self.node = self:get_node(node_or_node_id) diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index 82c18f2..4ab6478 100755 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -18,12 +18,29 @@ local component = require("druid.component") ---@field WHEEL_SCROLL_INVERTED boolean|nil If true, invert direction for touchpad and mouse wheel scroll. Default: false ---@field WHEEL_SCROLL_BY_INERTION boolean|nil If true, wheel will add inertion to scroll. Direct set position otherwise.. Default: false +---Basic Druid scroll component. Handles all scrolling behavior in Druid GUI. +--- +---### Setup +---Create scroll component with druid: `druid:new_scroll(view_node, content_node)` +--- +---### Notes +---- View_node is the static part that captures user input and recognizes scrolling touches +---- Content_node is the dynamic part that will change position according to the scroll system +---- Initial scroll size will be equal to content_node size +---- The initial view box will be equal to view_node size +---- Scroll by default style has inertia and extra size for stretching effect +---- You can setup "points of interest" to make scroll always center on closest point +---- Scroll events: +---- - on_scroll(self, position): On scroll move callback +---- - on_scroll_to(self, position, is_instant): On scroll_to function callback +---- - on_point_scroll(self, item_index, position): On scroll_to_index function callback +---- Multitouch is required for scroll. Scroll correctly handles touch_id swap while dragging ---@class druid.scroll: druid.component ---@field node node The root node ---@field click_zone node|nil Optional click zone to restrict scroll area ----@field on_scroll event Triggered on scroll move with (self, position) ----@field on_scroll_to event Triggered on scroll_to with (self, target, is_instant) ----@field on_point_scroll event Triggered on scroll_to_index with (self, index, point) +---@field on_scroll event Triggered on scroll move with fun(self, position) +---@field on_scroll_to event Triggered on scroll_to with fun(self, target, is_instant) +---@field on_point_scroll event Triggered on scroll_to_index with fun(self, index, point) ---@field view_node node The scroll view node (static part) ---@field view_border vector4 The scroll view borders ---@field content_node node The scroll content node (moving part) @@ -47,8 +64,9 @@ local M = component.create("scroll") ---The Scroll constructor ----@param view_node string|node GUI view scroll node ----@param content_node string|node GUI content scroll node +---@param view_node string|node GUI view scroll node - the static part that captures user input +---@param content_node string|node GUI content scroll node - the dynamic part that will change position +---@return druid.scroll function M:init(view_node, content_node) self.druid = self:get_druid() diff --git a/druid/base/text.lua b/druid/base/text.lua index 2b4d78e..a079ede 100755 --- a/druid/base/text.lua +++ b/druid/base/text.lua @@ -11,12 +11,31 @@ local utf8 = utf8 or utf8_lua --[[@as utf8]] ---@field ADJUST_STEPS number|nil Amount of iterations for text adjust by height. Default: 20 ---@field ADJUST_SCALE_DELTA number|nil Scale step on each height adjust step. Default: 0.02 ----The component to handle text behaviour over a GUI Text node, mainly used to automatically adjust text size to fit the text area +---@alias druid.text.adjust_type "downscale"|"trim"|"no_adjust"|"downscale_limited"|"scroll"|"scale_then_scroll"|"trim_left"|"scale_then_trim"|"scale_then_trim_left" + +---Basic Druid text component. Text components by default have the text size adjusting. +--- +---### Setup +---Create text node with druid: `text = druid:new_text(node_name, [initial_value], [text_adjust_type])` +--- +---### Notes +---- Text component by default have auto adjust text sizing. Text never will be bigger, than text node size, which you can setup in GUI scene. +---- Text pivot can be changed with `text:set_pivot`, and text will save their position inside their text size box +---- There are several text adjust types: +---- - **"downscale"** - Change text's scale to fit in the text node size (default) +---- - **"trim"** - Trim the text with postfix (default - "...") to fit in the text node size +---- - **"no_adjust"** - No any adjust, like default Defold text node +---- - **"downscale_limited"** - Change text's scale like downscale, but there is limit for text's scale +---- - **"scroll"** - Change text's pivot to imitate scrolling in the text box. Use with stencil node for better effect. +---- - **"scale_then_scroll"** - Combine two modes: first limited downscale, then scroll +---- - **"trim_left"** - Trim the text with postfix (default - "...") to fit in the text node size +---- - **"scale_then_trim"** - Combine two modes: first limited downscale, then trim +---- - **"scale_then_trim_left"** - Combine two modes: first limited downscale, then trim left ---@class druid.text: druid.component ---@field node node The text node ----@field on_set_text event The event triggered when the text is set, fun(self, text) ----@field on_update_text_scale event The event triggered when the text scale is updated, fun(self, scale, metrics) ----@field on_set_pivot event The event triggered when the text pivot is set, fun(self, pivot) +---@field on_set_text event fun(self, text) The event triggered when the text is set +---@field on_update_text_scale event fun(self, scale, metrics) The event triggered when the text scale is updated +---@field on_set_pivot event fun(self, pivot) The event triggered when the text pivot is set ---@field style druid.text.style The style of the text ---@field private start_pivot userdata The start pivot of the text ---@field private start_scale vector3 The start scale of the text @@ -27,7 +46,7 @@ local M = component.create("text") ---The Text constructor ---@param node string|node Node name or GUI Text Node itself ---@param value string|nil Initial text. Default value is node text from GUI scene. Default: nil ----@param adjust_type string|nil Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference. Default: DOWNSCALE +---@param adjust_type druid.text.adjust_type|nil Adjust type for text. By default is "downscale". Options: "downscale", "trim", "no_adjust", "downscale_limited", "scroll", "scale_then_scroll", "trim_left", "scale_then_trim", "scale_then_trim_left" function M:init(node, value, adjust_type) self.node = self:get_node(node) self.pos = gui.get_position(self.node) diff --git a/druid/custom/rich_text/rich_text.lua b/druid/custom/rich_text/rich_text.lua index 1863e5e..7b38045 100644 --- a/druid/custom/rich_text/rich_text.lua +++ b/druid/custom/rich_text/rich_text.lua @@ -112,22 +112,30 @@ end ---Set text for Rich Text +--- -- Color --- rich_text:set_text("<color=red>Foobar</color>") --- rich_text:set_text("<color=1.0,0,0,1.0>Foobar</color>") --- rich_text:set_text("<color=#ff0000>Foobar</color>") --- rich_text:set_text("<color=#ff0000ff>Foobar</color>") +--- -- Shadow --- rich_text:set_text("<shadow=red>Foobar</shadow>") --- rich_text:set_text("<shadow=1.0,0,0,1.0>Foobar</shadow>") --- rich_text:set_text("<shadow=#ff0000>Foobar</shadow>") --- rich_text:set_text("<shadow=#ff0000ff>Foobar</shadow>") +--- -- Outline --- rich_text:set_text("<outline=red>Foobar</outline>") --- rich_text:set_text("<outline=1.0,0,0,1.0>Foobar</outline>") --- rich_text:set_text("<outline=#ff0000>Foobar</outline>") --- rich_text:set_text("<outline=#ff0000ff>Foobar</outline>") +--- -- Font --- rich_text:set_text("<font=MyCoolFont>Foobar</font>") +--- -- Size --- rich_text:set_text("<size=2>Twice as large</size>") +--- -- Line break --- rich_text:set_text("<br/>Insert a line break") +--- -- No break --- rich_text:set_text("<nobr>Prevent the text from breaking") +--- -- Image --- rich_text:set_text("<img=texture:image>Display image") --- rich_text:set_text("<img=texture:image,size>Display image with size") --- rich_text:set_text("<img=texture:image,width,height>Display image with width and height") diff --git a/druid/extended/container.lua b/druid/extended/container.lua index 803311e..a1dbd14 100644 --- a/druid/extended/container.lua +++ b/druid/extended/container.lua @@ -30,7 +30,19 @@ local CORNER_PIVOTS = { ---@field DRAGGABLE_CORNER_SIZE vector3 Size of box node for debug draggable corners ---@field DRAGGABLE_CORNER_COLOR vector4 Color of debug draggable corners ----The component used for managing the size and positions with other containers relations to create a adaptable layouts +---Druid component to manage the size and positions with other containers relations to create a adaptable layouts. +--- +---### Setup +---Create container component with druid: `container = druid:new_container(node, mode, callback)` +--- +---### Notes +---- Container can be used to create adaptable layouts that respond to window size changes +---- Container supports different layout modes: FIT, STRETCH, STRETCH_X, STRETCH_Y +---- Container can be nested inside other containers +---- Container supports fixed margins and percentage-based sizing +---- Container can be positioned using pivot points +---- Container supports minimum size constraints +---- Container can be fitted into window or custom size ---@class druid.container: druid.component ---@field node node The gui node ---@field druid druid.instance The druid instance @@ -52,6 +64,7 @@ local CORNER_PIVOTS = { local M = component.create("container") +---The Container constructor ---@param node node Gui node ---@param mode string Layout mode ---@param callback fun(self: druid.container, size: vector3)|nil Callback on size changed @@ -245,7 +258,7 @@ function M:on_window_resized() end ----@param node_or_container node|string|druid.container|table +---@param node_or_container node|string|druid.container|table The node or container to add ---@param mode string|nil stretch, fit, stretch_x, stretch_y. Default: Pick from node, "fit" or "stretch" ---@param on_resize_callback fun(self: userdata, size: vector3)|nil ---@return druid.container Container New created layout instance diff --git a/druid/extended/data_list.lua b/druid/extended/data_list.lua index d2940aa..0bebccf 100644 --- a/druid/extended/data_list.lua +++ b/druid/extended/data_list.lua @@ -3,7 +3,18 @@ local helper = require("druid.helper") local component = require("druid.component") local event = require("event.event") ----The component used for managing a list of data with a scrollable view, used to manage huge list data and render only visible elements +---Druid component to manage a list of data with a scrollable view, used to manage huge list data and render only visible elements. +--- +---### Setup +---Create data list component with druid: `data_list = druid:new_data_list(scroll, grid, create_function)` +--- +---### Notes +---- Data List uses a scroll component for scrolling and a grid component for layout +---- Data List only renders visible elements for better performance +---- Data List supports caching of elements for better performance +---- Data List supports adding, removing and updating elements +---- Data List supports scrolling to specific elements +---- Data List supports custom element creation and cleanup ---@class druid.data_list: druid.component ---@field scroll druid.scroll The scroll instance for Data List component ---@field grid druid.grid The StaticGrid or DynamicGrid instance for Data List component @@ -21,6 +32,7 @@ local event = require("event.event") local M = component.create("data_list") +---The DataList constructor ---@param scroll druid.scroll The Scroll instance for Data List component ---@param grid druid.grid The StaticGrid instance for Data List component ---@param create_function function The create function callback(self, data, index, data_list). Function should return (node, [component]) diff --git a/druid/extended/hotkey.lua b/druid/extended/hotkey.lua index acdd51f..0671e1c 100644 --- a/druid/extended/hotkey.lua +++ b/druid/extended/hotkey.lua @@ -5,7 +5,18 @@ local component = require("druid.component") ---@class druid.hotkey.style ---@field MODIFICATORS string[]|hash[] The list of action_id as hotkey modificators ----The component used for managing hotkeys and trigger callbacks when hotkeys are pressed +---Druid component to manage hotkeys and trigger callbacks when hotkeys are pressed. +--- +---### Setup +---Create hotkey component with druid: `hotkey = druid:new_hotkey(keys, callback, callback_argument)` +--- +---### Notes +---- Hotkey can be triggered by pressing a single key or a combination of keys +---- Hotkey supports modificator keys (e.g. Ctrl, Shift, Alt) +---- Hotkey can be triggered on key press, release or repeat +---- Hotkey can be added or removed at runtime +---- Hotkey can be enabled or disabled +---- Hotkey can be set to repeat on key hold ---@class druid.hotkey: druid.component ---@field on_hotkey_pressed event fun(self, context, callback_argument) The event triggered when a hotkey is pressed ---@field on_hotkey_released event fun(self, context, callback_argument) The event triggered when a hotkey is released diff --git a/druid/extended/input.lua b/druid/extended/input.lua index 57c9c86..3f18ea8 100755 --- a/druid/extended/input.lua +++ b/druid/extended/input.lua @@ -13,7 +13,18 @@ local utf8 = utf8 or utf8_lua ---@field on_unselect fun(self: druid.input, button_node: node) Callback on input field unselecting ---@field on_input_wrong fun(self: druid.input, button_node: node) Callback on wrong user input ----The component used for managing input fields in basic way +---Basic Druid text input component. Handles user text input via component with button and text. +--- +---### Setup +---Create input component with druid: `input = druid:new_input(button_node_name, text_node_name, keyboard_type)` +--- +---### Notes +---- Input component handles user text input. Input contains button and text components +---- Button needed for selecting/unselecting input field +---- Click outside of button to unselect input field +---- On focus lost (game minimized) input field will be unselected +---- You can setup max length of the text +---- You can setup allowed characters. On add not allowed characters `on_input_wrong` will be called ---@class druid.input: druid.component ---@field on_input_select event fun(self: druid.input, input: druid.input) The event triggered when the input field is selected ---@field on_input_unselect event fun(self: druid.input, text: string, input: druid.input) The event triggered when the input field is unselected diff --git a/druid/extended/lang_text.lua b/druid/extended/lang_text.lua index 654dafc..b065104 100755 --- a/druid/extended/lang_text.lua +++ b/druid/extended/lang_text.lua @@ -2,7 +2,16 @@ local event = require("event.event") local component = require("druid.component") local settings = require("druid.system.settings") ----The component used for displaying localized text, can automatically update text when locale is changed +---The component used for displaying localized text, can automatically update text when locale is changed. +---It wraps the Text component to handle localization using druid's get_text_function to set text by its id. +--- +---### Setup +---Create lang text component with druid: `text = druid:new_lang_text(node_name, locale_id)` +--- +---### Notes +---- Component automatically updates text when locale is changed +---- Uses druid's get_text_function to get localized text by id +---- Supports string formatting with additional parameters ---@class druid.lang_text: druid.component ---@field text druid.text The text component ---@field node node The node of the text component @@ -13,7 +22,7 @@ local M = component.create("lang_text") ---@param node string|node The node_id or gui.get_node(node_id) ----@param locale_id string|nil Default locale id or text from node as default +---@param locale_id string|nil Default locale id or text from node as default. If not provided, will use text from the node ---@param adjust_type string|nil Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference function M:init(node, locale_id, adjust_type) self.druid = self:get_druid() @@ -38,7 +47,7 @@ function M:on_language_change() end ----Setup raw text to lang_text component +---Setup raw text to lang_text component. This will clear any locale settings. ---@param text string Text for text node ---@return druid.lang_text self Current instance function M:set_to(text) @@ -50,7 +59,7 @@ function M:set_to(text) end ----Setup raw text to lang_text component +---Setup raw text to lang_text component. This will clear any locale settings. ---@param text string Text for text node ---@return druid.lang_text self Current instance function M:set_text(text) @@ -58,8 +67,8 @@ function M:set_text(text) end ----Translate the text by locale_id ----@param locale_id string Locale id +---Translate the text by locale_id. The text will be automatically updated when locale changes. +---@param locale_id string Locale id to get text from ---@param ... string Optional params for string.format ---@return druid.lang_text self Current instance function M:translate(locale_id, ...) @@ -71,7 +80,7 @@ function M:translate(locale_id, ...) end ----Format string with new text params on localized text +---Format string with new text params on localized text. Keeps the current locale but updates the format parameters. ---@param ... string Optional params for string.format ---@return druid.lang_text self Current instance function M:format(...) diff --git a/druid/extended/layout.lua b/druid/extended/layout.lua index f4faaa4..e5e5085 100644 --- a/druid/extended/layout.lua +++ b/druid/extended/layout.lua @@ -2,7 +2,7 @@ local event = require("event.event") local helper = require("druid.helper") local component = require("druid.component") ----@alias druid.layout.mode "horizontal"|"vertical"|"horizontal_wrap" +---@alias druid.layout.type "horizontal"|"vertical"|"horizontal_wrap" ---@class event.on_size_changed: event ---@field subscribe fun(_, callback: fun(new_size: vector3), context: any|nil) @@ -19,11 +19,22 @@ local component = require("druid.component") ---@field nodes_height table ---@field rows druid.layout.row_data[]> ----The component used for managing the layout of nodes, placing them inside the node size with respect to the size and pivot of each node +---Druid component to manage the layout of nodes, placing them inside the node size with respect to the size and pivot of each node. +--- +---### Setup +---Create layout component with druid: `layout = druid:new_layout(node, layout_type)` +--- +---### Notes +---- Layout can be horizontal, vertical or horizontal with wrapping +---- Layout can resize parent node to fit content +---- Layout can justify content +---- Layout supports margins and padding +---- Layout automatically updates when nodes are added or removed +---- Layout can be manually updated by calling set_dirty() ---@class druid.layout: druid.component ---@field node node The node to manage the layout of ---@field rows_data druid.layout.rows_data Last calculated rows data ----@field is_dirty boolean +---@field is_dirty boolean True if layout needs to be updated ---@field entities node[] The entities to manage the layout of ---@field margin {x: number, y: number} The margin of the layout ---@field padding vector4 The padding of the layout @@ -35,8 +46,8 @@ local component = require("druid.component") local M = component.create("layout") ----@param node_or_node_id node|string ----@param layout_type druid.layout.mode +---@param node_or_node_id node|string The node to manage the layout of +---@param layout_type druid.layout.type The type of layout (horizontal, vertical, horizontal_wrap) function M:init(node_or_node_id, layout_type) self.node = self:get_node(node_or_node_id) @@ -138,10 +149,10 @@ function M:set_justify(is_justify) end ----@param type string The layout type: "horizontal", "vertical", "horizontal_wrap" +---@param layout_type druid.layout.type ---@return druid.layout self Current layout instance -function M:set_type(type) - self.type = type +function M:set_type(layout_type) + self.type = layout_type self.is_dirty = true return self diff --git a/druid/extended/progress.lua b/druid/extended/progress.lua index eb2a3c8..e29be6d 100644 --- a/druid/extended/progress.lua +++ b/druid/extended/progress.lua @@ -6,19 +6,29 @@ local component = require("druid.component") ---@field SPEED number|nil Progress bas fill rate. More -> faster. Default: 5 ---@field MIN_DELTA number|nil Minimum step to fill progress bar. Default: 0.005 ----The component used to manage a node as a progress bar, changing the size and scale of the node +---Basic Druid progress bar component. Changes the size or scale of a node to represent progress. +--- +---### Setup +---Create progress bar component with druid: `progress = druid:new_progress(node_name, key, init_value)` +--- +---### Notes +---- Node should have maximum node size in GUI scene, it's represent the progress bar maximum size +---- Key is value from druid const: "x" or "y" +---- Progress works correctly with 9slice nodes, it tries to set size by _set_size_ first, until minimum size is reached, then it sizing via _set_scale_ +---- Progress bar can fill only by vertical or horizontal size. For diagonal progress bar, just rotate node in GUI scene +---- If you have glitchy or dark texture bugs with progress bar, try to disable mipmaps in your texture profiles ---@class druid.progress: druid.component ----@field node node ----@field on_change event ----@field style druid.progress.style ----@field key string ----@field prop hash +---@field node node The progress bar node +---@field on_change event Event triggered when progress value changes +---@field style druid.progress.style Component style parameters +---@field key string Progress bar direction: "x" or "y" +---@field prop hash Property for scaling the progress bar local M = component.create("progress") ---@param node string|node Node name or GUI Node itself. ---@param key string Progress bar direction: "x" or "y" ----@param init_value number|nil Initial value of progress bar. Default: 1 +---@param init_value number|nil Initial value of progress bar (0 to 1). Default: 1 function M:init(node, key, init_value) assert(key == "x" or key == "y", "Progress bar key should be 'x' or 'y'") diff --git a/druid/extended/slider.lua b/druid/extended/slider.lua index e10b874..c1796d2 100644 --- a/druid/extended/slider.lua +++ b/druid/extended/slider.lua @@ -3,7 +3,17 @@ local helper = require("druid.helper") local const = require("druid.const") local component = require("druid.component") ----The component to make a draggable node over a line with a progress report +---Basic Druid slider component. Creates a draggable node over a line with progress reporting. +--- +---### Setup +---Create slider component with druid: `slider = druid:new_slider(node_name, end_pos, callback)` +--- +---### Notes +---- Pin node should be placed in initial position at zero progress +---- It will be available to move Pin node between start pos and end pos +---- You can setup points of interests on slider via `slider:set_steps`. If steps exist, slider values will be only from these steps (notched slider) +---- Start pos and end pos should be on vertical or horizontal line (their x or y value should be equal) +---- To catch input across all slider, you can setup input node via `slider:set_input_node` ---@class druid.slider: druid.component ---@field node node The node to manage the slider ---@field on_change_value event The event triggered when the slider value changes diff --git a/druid/extended/timer.lua b/druid/extended/timer.lua index f39fbd7..833e465 100644 --- a/druid/extended/timer.lua +++ b/druid/extended/timer.lua @@ -2,7 +2,15 @@ local event = require("event.event") local helper = require("druid.helper") local component = require("druid.component") ----The component that handles a text to display a seconds timer +---Druid component to handle timer work on gui text node. Displays time in a formatted way. +--- +---### Setup +---Create timer component with druid: `timer = druid:new_timer(text_node, from_seconds, to_seconds, callback)` +--- +---### Notes +---- Timer fires callback when timer value equals to _to_seconds_ +---- Timer will set text node with current timer value +---- Timer uses update function to handle time ---@class druid.timer: druid.component ---@field on_tick event fun(context, value) The event triggered when the timer ticks ---@field on_set_enabled event fun(context, is_on) The event triggered when the timer is enabled @@ -18,7 +26,7 @@ local M = component.create("timer") ---@param node node Gui text node ---@param seconds_from number|nil Start timer value in seconds ---@param seconds_to number|nil End timer value in seconds ----@param callback function|nil Function on timer end +---@param callback function|nil Function that triggers when timer value equals to seconds_to function M:init(node, seconds_from, seconds_to, callback) self.node = self:get_node(node) seconds_to = math.max(seconds_to or 0, 0) diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index 18304e0..5b35acb 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -667,7 +667,7 @@ end local progress = require("druid.extended.progress") ---Create Progress component ---@param node string|node Progress bar fill node or node name ----@param key string Progress bar direction: const.SIDE.X or const.SIDE.Y +---@param key string Progress bar direction: "x" or "y" ---@param init_value number|nil Initial value of progress bar. Default: 1 ---@return druid.progress progress The new progress component function M:new_progress(node, key, init_value) diff --git a/example/other/go_bindings/go_widget.gui b/example/other/go_bindings/go_widget.gui index b5eda2f..7a88d2b 100644 --- a/example/other/go_bindings/go_widget.gui +++ b/example/other/go_bindings/go_widget.gui @@ -1,4 +1,4 @@ -script: "/druid/druid.gui_script" +script: "/druid/druid_widget.gui_script" fonts { name: "druid_text_bold" font: "/druid/fonts/druid_text_bold.font" diff --git a/game.project b/game.project index 673dd68..c97ffb9 100644 --- a/game.project +++ b/game.project @@ -58,7 +58,7 @@ cssfile = /builtins/manifests/web/dark_theme.css show_console_banner = 0 [native_extension] -app_manifest = +app_manifest = [graphics] texture_profiles = /builtins/graphics/default.texture_profiles diff --git a/wiki/01-components.md b/wiki/01-components.md deleted file mode 100644 index ce33f02..0000000 --- a/wiki/01-components.md +++ /dev/null @@ -1,372 +0,0 @@ -# Druid components - - -## Button -[Button API here](https://insality.github.io/druid/modules/Button.html) - -### Overview -Basic Druid input component. Handle input on node and provide different callbacks on touch events. - -### Setup -Create button with druid: `button = druid:new_button(node_name, callback, [params], [animation_node])` -Where node name is name of node from GUI scene. You can use `node_name` as input trigger zone and point another node for animation via `animation_node` - -### Usecase -_fill example usecases_ - -### Notes -- Button callback have next params: (self, params, button_instance) - - **self** - Druid self context - - **params** - Additional params, specified on button creating - - **button_instance** - button itself -- You can set _params_ on button callback on button creating: `druid:new_button("node_name", callback, params)`. This _params_ will pass in callback as second argument -- Button have next events: - - **on_click** - basic button callback - - **on_repeated_click** - repeated click callback, while holding the button, don't trigger if callback is empty - - **on_long_click** - callback on long button tap, don't trigger if callback is empty - - **on_hold_click** - hold callback, before long_click trigger, don't trigger if callback is empty - - **on_double_click** - different callback, if tap button 2+ in row, don't trigger if callback is empty -- Click event will not trigger, if between pressed and released state cursor was outside of node zone -- If button have double click event and it is triggered, usual callback will be not invoked -- If you have stencil on buttons and you don't want trigger them outside of stencil node, you can use `button:set_click_zone` to restrict button click zone -- Button can have key trigger to use then by key: `button:set_key_trigger` -- Animation node can be used for example to animate small icon on big panel. Node name of trigger zone will be `big panel` and animation node will be `small icon` - - -## Text -[Text API here](https://insality.github.io/druid/modules/Text.html) - -### Overview -Basic Druid text component. Text components by default have the text size adjusting. - -### Setup -Create text node with druid: `text = druid:new_text(node_name, [initial_value], [text_adjust_type])` - -### Notes -- Text component by default have auto adjust text sizing. Text never will be bigger, than text node size, which you can setup in GUI scene. It can be disabled on component creating by settings argument `is_no_adjust` to _true_ - -![](../media/text_autosize.png) - -- Text pivot can be changed with `text:set_pivot`, and text will save their position inside their text size box: - -![](../media/text_anchor.gif) - -- There is several text adjust types. Default Downscale. You can change the default adjust type in the text style table. - - **const.TEXT_ADJUST.DOWNSCALE** - Change text's scale to fit in the text node size - - **const.TEXT_ADJUST.TRIM** - Trim the text with postfix (default - "...", override in styles) to fit in the text node size - - **const.TEXT_ADJUST.NO_ADJUST** - No any adjust, like default Defold text node - - **const.TEXT_ADJUST.DOWNSCALE_LIMITED** - Change text's scale list downscale, but there is limit for text's scale - - **const.TEXT_ADJUST.SCROLL** - Change text's pivot to imitate scrolling in the text box. Use with stencil node for better effect. - - **const.TEXT_ADJUST.SCALE_THEN_SCROLL** - Combine two modes: first limited downscale, then scroll - - -## Blocker -[Blocker API here](https://insality.github.io/druid/modules/Blocker.html) - -### Overview -Druid component for block input. Use it to block input in special zone. - -### Setup -Create blocker component with druid: `druid:new_blocker(node_name)` - -### Notes -Explanation: -![](../media/blocker_scheme.png) - -Blue zone is **button** with close_window callback - -Yellow zone is blocker with window content - -So you can do the safe zones, when you have the big buttons - - -## Back Handler -[Back handler API here](https://insality.github.io/druid/modules/BackHandler.html) - -### Overview -Component to handle back button. It handle Android back button and Backspace key. Key triggers in `input.binding` should be setup for correct working. - -### Setup -Setup callback with `druid:new_back_handler(callback)` - -### Notes - - -## Lang text -[Lang text API here](https://insality.github.io/druid/modules/LangText.html) - -### Overview -Wrap on Text component to handle localization. It uses druid get_text_function to set text by it's id - -### Setup -Create lang text component with druid `text = druid:new_lang_text(node_name, locale_id)` - -### Notes - - -## Scroll -[Scroll API here](https://insality.github.io/druid/modules/Scroll.html) - -### Overview -Basic Druid scroll component. Handle all scrolling stuff in druid GUI - -### Setup -Create scroll component with druid: `scroll = druid:new_scroll(view_node, content_node)`. - -_View_node_ - is static part. It capturing user input and recognize scrolling touches - -_Content_node_ - is dynamic part. This node will change position by scroll system - -Initial scroll size will be equal to _content_node_ node size. The initial view box will be equal to _view_node_ node size - -Usually, Place _view_node_ and as children add _content_node_: -![](../media/scroll_scheme.png) -![](../media/scroll_outline.png) - -*Here content_node below view_node, in game content_node be able to scroll left until end* - -### Notes -- Scroll by default style have inertion and extra size for strecthing effect. It can be adjust via scroll [style settings](https://insality.github.io/druid/modules/Scroll.html#Style) -- You can setup "points of interest". Scroll always will be centered on closes point of interest. It is able to create slider without inertion and points of interest on each scroll element. -- Scroll have next events: - - *on_scroll* (self, position) On scroll move callback - - *on_scroll_to* (self, position, is_instant) On scroll_to function callback - - *on_point_scroll* (self, item_index, position) On scroll_to_index function callback -- You can adjust scroll content size by `scroll:set_size(node_size)`. It will setup new size to _content node_ -- You can enabled or disable inertion mode via `scroll:set_inert(state)` -- You can adjust extra stretch size via `scroll:set_extra_stretch_size` -- Multitouch is required for scroll. Scroll is correctly handling touch_id swap while dragging scroll - - -## Progress -[Progress API here](https://insality.github.io/druid/modules/Progress.html) - -### Overview -Basic Druid progress bar component - -### Setup -Create progress bar component with druid: `progress = druid:new_progress(node_name, key, init_value)` - -Node name should have maximum node size, so in GUI scene, node_name should be fully filled. -Key is value from druid const: const.SIDE.X (or just "x") or const.SIDE.Y (or just "y") - -### Notes -- Progress correct working with 9slice nodes, it trying to set size by _set_size_ first, if it is not possible, it set up sizing via _set_scale_ -- Progress bar can fill only by vertical or horizontal size. If you want make diagonal progress bar, just rotate node in GUI scene -- If you have glitchy or dark texture bug with progress bar, try to disable mipmaps in your texture profiles - - -## Slider -[Slider API here](https://insality.github.io/druid/modules/Slider.html) - -### Overview -Basic Druid slider component - -### Setup -Create slider component with druid: `slider = druid:new_slider(node_name, end_pos, callback)` - -Pin node (node_name in params) should be placed in zero position (initial). It will be available to mode Pin node between start pos and end pos. - -### Notes -- You can setup points of interests on slider via `slider:set_steps`. If steps are exist, slider values will be only from this steps (notched slider) -- For now, start pos and end pos should be on vertical or horizontal line (their x or y value should be equal) - - -## Input -[Input API here](https://insality.github.io/druid/modules/Input.html) - -### Overview -Basic Druid text input component - -### Setup -Create input component with druid: `input = druid:new_input(button_node_name, text_node_name, keyboard_type)` - -### Notes -- Input component handle user text input. Input contains from button and text components. Button needed for selecting/unselecting input field -- Long click on input field for clear and select input field (clearing can be disable via styles) -- Click outside of button to unselect input field -- On focus lost (game minimized) input field will be unselected -- You can setup max length of the text -- You can setup allowed characters. On add not allowed characters `on_input_wrong` will be called. By default it cause simple shake animation -- The keyboard for input will not show on mobile HTML5. So input field in mobile HTML5 is not working now -- To make work different keyboard type, make sure value in game.project Android:InputMethod set to HidderInputField (https://defold.com/manuals/project-settings/#input-method) - - -## Timer -[Timer API here](https://insality.github.io/druid/modules/Timer.html) - -### Overview -Handle timer work on gui text node - -### Setup -Create timer component with druid: `timer = druid:new_timer(text_node, from_seconds, to_seconds, callback)` - -### Notes -- Timer fires callback, when timer value equals to _to_seconds_ -- Timer will set text node with current timer value -- Timer uses update function to handle time - - -## Static Grid -[Static Grid API here](https://insality.github.io/druid/modules/StaticGrid.html) - -### Overview -Component for manage node positions. -Static grid have constant node size, so it possible to calculate node positions before placement. Nodes can be placed with gaps. -Static grid can shift elements on add/remove functions. - -### Setup -Create component with druid: `grid = druid:new_grid(parent_node, prefab_node, max_in_row_elements)` - -### Notes -- On _add node_ grid will set nodeup parent to _parent_node_ -- You can get array of position of every element for setup points of interest in scroll component -- You can get size of all elements for setup size in scroll component -- You can also bind the grid to the scroll component for auto resize scroll content size -- Pivot of parent_node matter for node placement -- _Prefab node_ used to get node size and anchor -- You can point *position_function* for animations with _static_grid:set_position_function(node, pos)_ callback. Default - *gui.set_position()* - -## Data List -[Data List API here](https://insality.github.io/druid/modules/DataList.html) - -### Overview -Component to manage data for huge dataset in scroll. DataList create elements only in scroll view. -It requires Druid Scroll and Druid Grid (Static or Dynamic) components - - -### Setup -Create component with druid: `grid = druid:new_data_list(scroll, grid, create_callback)` -- scroll - already created Scroll component -- grid - already created StaticGrid or DynamicGrid component -- create_function - your function to create node instances. This callback have next parameters: fun(self, data, index, data_list) - - self - Script/Druid context - - data- your element data - - index - element index - - data_list - current DataList component - -Create function should return root node and optionaly, Druid component. It’s required to manage create/remove lifecycle. - -### Notes -- Set data with `data_list:set_data({...})` after component initialize -- You can use `data_list:scroll_to_index()` function to show data element - - -## Hover -[Hover API here](https://insality.github.io/druid/modules/Hover.html) - -### Overview -System Druid component, handle hover node state. - -### Setup -Create hover component with druid: `hover = druid:new_hover(node, callback)` - -### Notes -- By default, hover handles _hover event_ with pressed touch action_id. So it's mean, what mouse or touch have to be pressed -- On desktop platforms there is _on_mouse_hover_ event. It's event on mouse hover without any action id -- By default, assume what node is on not hovered state (both _hover_ and _mouse_hover_) - - -## Swipe -[Swipe API here](https://insality.github.io/druid/modules/Swipe.html) - -### Overview -System Druid component, handle swipe actions on node - -### Setup -Create swipe component with druid: `hover = druid:new_swipe(node, swipe_callback)` - -### Notes -- Swipe callback have next params: (self, swipe_side, distance, time) - - **self** - Druid self context - - **swipe_side**: *string* - values from ["up", "down", "left", "right"] - - **distance**: *number* - in pixels, distance of swipe - - **time**: *number* - in seconds, time of swiping -- Swipe trigger only, if all input actions was on swipe node. If action will be outside of node, swipe status will be reseted -- In swipe style table you can adjust minimal distance and maximum time to trigg- Hover state trigger only with touch on mobile devices or button mouse holding. Just mouse over swipe -- In swipe style table you can toggle type of swipe triggering. if SWIPE_TRIGGER_ON_MOVE setup to true - swipe will trigger as swipe can be triggered. If setup to false - swipe will trigger only on released action -- If you have stencil on swipe node and you don't want trigger it outside of stencil node, you can use `swipe:set_click_zone` to restrict swipe zonethout buttons is now not allowed. - - -## Drag -[Drag API here](https://insality.github.io/druid/modules/Drag.html) - -### Overview -System Druid component, handle drag actions on node - -### Setup -Create drag component with druid: `hover = druid:new_drag(node, drag_callback)` - -### Notes -- Drag callback have next params: (self, dx, dy, total_x, total_y) - - **self**: Druid self context - - **dx**: *number* - delta x position - - **dy**: *number* - delta y position - - **total_x**: *number* - total delta x position - - **total_y**: *number* - total delta y position -- In styles, you can point the drag start deadzone. Default value is 10 pixels -- Drag correctly process multitouch. You can switch touch_id, while dragging on node with correct _dx_ and _dy_ values (made for correct scrolling) -- You can restrict horizontal or vertical dragging by setting `drag.can_x` or `drag.can_y` to _false_ value -- You can get info about current drag state: - - _is_touch_ - Is currently node touching - - _is_drag_ - Is currently node is dragging - - _x_ and _y_ - Current touch position - - _touch_start_pos_ - Touch stat positions -- Drag have next events: - - _on_touch_start_ (self) - Event on touch start - - _on_touch_end_ (self) - Event on touch end - - _on_drag_start_ (self) - Event on drag start - - _on_drag_ (self, dx, dy) - Event on drag process - - _on_drag_end_ (self) - Event on drag end -- Drag node zone can be restricted via `drag:set_click_zone(node)` - - -## Hotkey -[Hotkey API here](https://insality.github.io/druid/modules/Hotkey.html) - -### Overview -Druid component to handle keyboard hotkeys with key modificators - -### Setup -This is extended component. Before use it, you should register it: -``` -local druid = require("druid.druid") -local hotkey = require("druid.extended.hotkey") -druid.register("hotkey", hotkey) -``` -Create hotkey component with druid: `hotkey = druid:new_hotkey(keys_array, callback, [callback_argument])` - -### Notes -- Hotkey callback is similar with button callback: (self, callback_argument) - - **self**: Druid self context - - **callback_argument**: *value* - Any value passed at component constructor -- In styles, you can point the array of modificator keys. This keys should be pressed with main key to trigger the callback -- The keys_arrays should contains one action key and any amount of modificator keys -- You can add additional hotkeys to hotkey component with `hotkey:add_hotkey(keys_array, callback_argument)` - - -## Layout -[Layout API here](https://insality.github.io/druid/modules/Layout.html) - -### Overview -Component to arrange nodes inside layout node with margin/paddings settings. Works with different node sizes and pivots. Works in the same way as Figma AutoLayout - -### Setup -This is extended component. Before use it, you should register it: -``` -local druid = require("druid.druid") -local layout = require("druid.extended.layout") -druid.register("layout", layout) -``` -Create layout component with druid: `layout = druid:new_layout(node, layout_mode)` - - -### Notes -- Layout mode can be next: - - `horizontal` - arrange nodes in horizontal line - - `vertical` - arrange nodes in vertical line - - `horizontal_wrap` - arrange nodes in horizontal line with wrap to next line -- You can setup margin and padding for layout nodes -- You can set "justify" alignment to place nodes with the same margin between layout node borders -- You can set "hug" by content. This option will set layout node size by content size. Can be setup separately for width and height - diff --git a/wiki/02-creating_custom_components.md b/wiki/02-creating_custom_components.md index bc69516..bd5177d 100644 --- a/wiki/02-creating_custom_components.md +++ b/wiki/02-creating_custom_components.md @@ -16,6 +16,7 @@ Every component is a child of the Basic Druid component. You can call methods of ## Custom Components ### Basic Component Template + A basic custom component template looks like this (you can copy it from `/druid/templates/component.template.lua`): ```lua @@ -39,6 +40,7 @@ return M ``` Then you can create your custom component with Druid: + ```lua local druid = require("druid.druid") diff --git a/wiki/FAQ.md b/wiki/FAQ.md deleted file mode 100644 index 4812a91..0000000 --- a/wiki/FAQ.md +++ /dev/null @@ -1,36 +0,0 @@ -# Druid FAQ - -Welcome to the Druid FAQ! Here are answers to some common questions you may have: - -### Q: How do I remove a Druid component instance? -**A:** To remove a created Druid component, use the `druid:remove` function. You can find more information in the [API reference](https://insality.github.io/druid/modules/druid_instance.html#druid:remove). - -### Q: How does Druid process input? -**A:** Input processing in Druid follows a Last-In-First-Out (LIFO) queue. Buttons added later have higher priority than those added earlier. To ensure correct button behavior, place your buttons from back to front in most cases. - -### Q: What is the purpose of the Blocker component? -**A:** The Blocker component is used to block input in a specific zone. It is useful for creating unclickable zones within buttons or for creating a panel of buttons on top of another button (e.g., closing windows by clicking on the window background). You can find more information about the Blocker component [here](https://github.com/Insality/druid/blob/master/docs_md/01-components.md#notes-2). - -### Q: What can I do with custom components? -**A:** With custom components in Druid, the possibilities are endless! Custom components allow you to separate component placement and game logic from other elements, making them reusable and easier to test and develop. Custom components can be used for scroll elements with buttons, custom GUI widgets, or even components with custom game logic. Templates often accompany custom components, allowing you to create multiple visual variations for a single component module. You can find some examples of custom components [here](https://github.com/Insality/druid-assets). - -### Q: How does `self:get_node()` work? -**A:** The `self:get_node()` function in a Druid component searches for nodes in the GUI directly or in cloned nodes created using `gui.clone_tree()`. It also considers nodes placed as templates, with the full node ID composed of the template name and node name (including cloned nodes). To ensure correct usage of `self:get_node()`, set up the component nodes using `self:set_template()` and `self:set_component_nodes()` before calling `self:get_node()`. It's best to pass the string name of the node, rather than the GUI node itself. - -### Q: My button in a scroll is clickable outside the stencil node. How can I fix this? -**A:** When using Druid, the stencil node does not prevent buttons from being clickable outside its bounds. To address this, you can set up an additional click zone on your buttons using the `button:set_click_zone()` function. After adding a button to the scroll, you can use the following code: -```lua --- Assuming the scroll view node is the stencil node -button:set_click_zone(scroll.view_node) -``` - -### Q: How do I use EmmyLua annotations? (from Druid 0.6.0) -**A:** EmmyLua annotations are used for better autocompletion and type inference in editors. To use the generated EmmyLua annotations, copy the `druid/annotations.lua` file to your project. After copying, you may need to restart the EmmyLua server to ensure the changes take effect. Once the annotations are processed, you can specify the type of Druid in your code: -```lua ----@type druid -local druid = require("druid.druid") - --- Autocomplete and type information should now work -``` - -Feel free to ask any additional questions you have about Druid! diff --git a/wiki/widgets.md b/wiki/widgets.md index 2fb3acb..492b26f 100644 --- a/wiki/widgets.md +++ b/wiki/widgets.md @@ -1,111 +1,109 @@ # Widgets -What are widgets +Widgets are reusable UI components that simplify the creation and management of user interfaces in your game. ## What is widget -Before widget, there are a "custom components". Widgets goes to replace custom components. Basically, it's totally the same thing, only the difference to initialize it. -Let's see at basic custom component template: +Before widgets, there were "custom components". Widgets replace custom components. Basically, they're the same thing, with the only difference being how they're initialized. + +Let's see a basic custom component template: + ```lua local component = require("druid.component") local M = component.create("my_component") function M:init(template, nodes, output_string) - self:set_template(template) - self:set_nodes(nodes) - self.druid = self:get_druid() + self:set_template(template) + self:set_nodes(nodes) + self.druid = self:get_druid() - self.druid:new_button("button_node_name", print, output_string) + self.druid:new_button("button_node_name", print, output_string) end ``` -So the basic components we created with `druid:new()` function. +Basic components are created with the `druid:new()` function: ```lua local my_component = druid:new("my_component", template, nodes, "Hello world!") ``` Now, let's see how to do it with widgets: + ```lua ---@type my_widget: druid.widget local M = {} function M:init(output_string) - self.druid:new_button("button_node_name", print, output_string) + self.druid:new_button("button_node_name", print, output_string) end return M ``` -That's all! The same thing, but no any boilerplate code, just a lua table. The druid instance, the templates and nodes are already created. +That's all! The same functionality but without any boilerplate code, just a Lua table. The Druid instance, templates and nodes are already created and available. And you can create your own widgets like this: + ```lua local druid = require("druid.druid") local my_widget = require("widgets.my_widget.my_widget") function init(self) - self.druid = druid.new(self) - self.my_widget = self.druid:new_widget(my_widget, template, nodes, "Hello world!") + self.druid = druid.new(self) + self.my_widget = self.druid:new_widget(my_widget, template, nodes, "Hello world!") end ``` -So now the creation of "custom components" called as widgets is much easier and cleaner. - +So now creating UI components with widgets is much easier and cleaner than using custom components. ## Create a new widget -Let's start from beginning. Widgets usually consist from 2 parts: +Let's start from the beginning. Widgets usually consist of 2 parts: + 1. GUI scene -2. Widget lua module +2. Widget Lua module -Make a GUI scene of your widget (user portrait avatar panel, shop window, game panel menu, etc). Make it as you wish, but recomment to add a one `root` node with `name` `root` and make all your nodes as children of this node. This will make much easier to work with the widget. +Make a GUI scene of your widget (user portrait avatar panel, shop window, game panel menu, etc). Design it as you wish, but it's recommended to add one `root` node with the name `root` and make all your other nodes children of this node. This makes working with the widget much easier. -Let's create a new widget by creating a new file nearby the our GUI scene file. +Let's create a new widget by creating a new file next to our GUI scene file: ```lua -- my_widget.lua local M = {} function M:init() - self.root = self:get_node("root") - self.button = self.druid:new_button("button_open", self.open_widget, self) + self.root = self:get_node("root") + self.button = self.druid:new_button("button_open", self.open_widget, self) end function M:open_widget() - print("Open widget pressed") + print("Open widget pressed") end return M ``` -that's a basic about creation. Now we have a widget, where we ask for the root node and use node "button_open" as a button. +That's the basic creation process. Now we have a widget where we access the root node and use the "button_open" node as a button. -Now, let's create a widget inside you game scene. +Now, let's create a widget inside your game scene. -Place a widget (GUI template) on your main scene. Then you need to import druid and create a new widget instance over this GUI template placed on the scene. +Place a widget (GUI template) on your main scene. Then import Druid and create a new widget instance using this GUI template placed on the scene: ```lua local druid = require("druid.druid") local my_widget = require("widgets.my_widget.my_widget") function init(self) - self.druid = druid.new(self) - self.my_widget = self.druid:new_widget(my_widget, "my_widget") + self.druid = druid.new(self) + self.my_widget = self.druid:new_widget(my_widget, "my_widget") - -- In case we want to clone it and use several times we can pass the nodes table - local array_of_widgets = {} - for index = 1, 10 do - local nodes = gui.clone_tree(self.my_widget.root) - local widget = self.druid:new_widget(my_widget, "my_widget", nodes) - table.insert(array_of_widgets, widget) - end + -- In case we want to clone it and use several times we can pass the nodes table + local array_of_widgets = {} + for index = 1, 10 do + local nodes = gui.clone_tree(self.my_widget.root) + local widget = self.druid:new_widget(my_widget, "my_widget", nodes) + table.insert(array_of_widgets, widget) + end end ``` - - - - - -