mirror of
https://github.com/Insality/druid.git
synced 2025-11-26 10:50:52 +01:00
1
.defignore
Normal file
1
.defignore
Normal file
@@ -0,0 +1 @@
|
||||
/dist
|
||||
6
.github/FUNDING.yml
vendored
6
.github/FUNDING.yml
vendored
@@ -1,5 +1,5 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: insality # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
ko_fi: insality # Replace with a single Ko-fi username
|
||||
custom: ['https://www.buymeacoffee.com/insality']
|
||||
github: insality
|
||||
ko_fi: insality
|
||||
buy_me_a_coffee: insality
|
||||
|
||||
4
.github/workflows/ci-workflow.yml
vendored
4
.github/workflows/ci-workflow.yml
vendored
@@ -12,12 +12,12 @@ jobs:
|
||||
lfs: true
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: '13'
|
||||
java-version: '17'
|
||||
|
||||
- name: Build && Run
|
||||
run: |
|
||||
deployer_url="https://raw.githubusercontent.com/Insality/defold-deployer/1/deployer.sh"
|
||||
curl -s ${deployer_url} | bash -s lbd --headless --settings ./unit_test.txt
|
||||
curl -s ${deployer_url} | bash -s lbd --headless --settings ./test/test.ini
|
||||
|
||||
- name: Upload test report
|
||||
run: bash <(curl -s https://codecov.io/bash)
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -10,4 +10,8 @@ Thumbs.db
|
||||
builtins
|
||||
dist
|
||||
deployer_version_settings.txt
|
||||
|
||||
.deployer_cache
|
||||
bob*.jar
|
||||
manifest.private.der
|
||||
manifest.public.der
|
||||
56
.luacheckrc
56
.luacheckrc
@@ -1,56 +0,0 @@
|
||||
std = "max"
|
||||
files['.luacheckrc'].global = false
|
||||
unused_args = false
|
||||
|
||||
max_code_line_length = 120
|
||||
max_comment_line_length = false
|
||||
|
||||
globals = {
|
||||
"sys",
|
||||
"go",
|
||||
"gui",
|
||||
"label",
|
||||
"render",
|
||||
"crash",
|
||||
"sprite",
|
||||
"sound",
|
||||
"tilemap",
|
||||
"spine",
|
||||
"particlefx",
|
||||
"physics",
|
||||
"factory",
|
||||
"collectionfactory",
|
||||
"iac",
|
||||
"msg",
|
||||
"vmath",
|
||||
"url",
|
||||
"http",
|
||||
"image",
|
||||
"json",
|
||||
"zlib",
|
||||
"iap",
|
||||
"push",
|
||||
"facebook",
|
||||
"hash",
|
||||
"hash_to_hex",
|
||||
"pprint",
|
||||
"init",
|
||||
"final",
|
||||
"update",
|
||||
"on_input",
|
||||
"on_message",
|
||||
"on_reload",
|
||||
"socket",
|
||||
"table",
|
||||
"debug",
|
||||
"timer",
|
||||
"window",
|
||||
"buffer",
|
||||
"resource",
|
||||
"defos",
|
||||
"html5",
|
||||
"describe",
|
||||
"before",
|
||||
"after",
|
||||
"it",
|
||||
}
|
||||
42
.vscode/settings.json
vendored
Normal file
42
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"Lua.diagnostics.globals": [
|
||||
"init",
|
||||
"final",
|
||||
"update",
|
||||
"on_message",
|
||||
"on_input",
|
||||
"describe",
|
||||
"before",
|
||||
"after",
|
||||
"it",
|
||||
"utf8",
|
||||
"defos",
|
||||
"clipboard",
|
||||
"editor"
|
||||
],
|
||||
"Lua.workspace.checkThirdParty": false,
|
||||
"Lua.diagnostics.neededFileStatus": {
|
||||
"undefined-field": "Any",
|
||||
"assign-type-mismatch": "Any",
|
||||
"missing-return": "Any",
|
||||
"missing-fields": "Any",
|
||||
"return-type-mismatch": "Any",
|
||||
"lowercase-global": "Any"
|
||||
},
|
||||
"Lua.workspace.ignoreDir": [
|
||||
".vscode",
|
||||
"test/tests/*.lua",
|
||||
"utils/annotations_manual.lua"
|
||||
],
|
||||
"Lua.runtime.pathStrict": true,
|
||||
"Lua.diagnostics.libraryFiles": "Enable",
|
||||
"Lua.runtime.version": "Lua 5.1",
|
||||
"Lua.workspace.library": [
|
||||
"~/Library/Application Support/Code/User/globalStorage/astronachos.defold",
|
||||
"~/Library/Application Support/Code/User/workspaceStorage/72e25b7e0fdc873ee6f7baa61edbd6b1/astronachos.defold",
|
||||
"~/Library/Application Support/Code/User/workspaceStorage/1446075a23c89451a63f0e82b2291def/astronachos.defold"
|
||||
],
|
||||
"files.exclude": {
|
||||
"**/*.gui": true
|
||||
}
|
||||
}
|
||||
59
README.md
59
README.md
@@ -1,15 +1,19 @@
|
||||
|
||||
[](https://insality.github.io/druid/)
|
||||
|
||||
[](https://github.com/sponsors/insality) [](https://ko-fi.com/insality) [](https://www.buymeacoffee.com/insality)
|
||||
[](https://github.com/Insality/druid/tags)
|
||||
[](https://github.com/Insality/druid/actions)
|
||||
[](https://codecov.io/gh/Insality/druid)
|
||||
|
||||
[](https://github.com/Insality/druid/releases)
|
||||
[](https://github.com/Insality/druid/actions)
|
||||
[](https://codecov.io/gh/Insality/druid)
|
||||
[](https://github.com/sponsors/insality) [](https://ko-fi.com/insality) [](https://www.buymeacoffee.com/insality)
|
||||
|
||||
**Druid** - powerful **Defold** component UI framework that empowers developers to create stunning and customizable GUIs by leveraging a wide range of embedded components or effortlessly designing their own game-specific components.
|
||||
|
||||
Try the [**HTML5 version**](https://insality.github.io/druid/druid/) of the **Druid** example app.
|
||||
## Druid Example
|
||||
|
||||
Check the [**HTML5 version**](https://insality.github.io/druid/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**.
|
||||
|
||||
## Setup
|
||||
|
||||
@@ -17,18 +21,26 @@ Try the [**HTML5 version**](https://insality.github.io/druid/druid/) of the **Dr
|
||||
|
||||
To integrate the **Druid** extension into your own project, add this project as a [dependency](https://www.defold.com/manuals/libraries/) in your **Defold** game. Open your `game.project` file and add the following line to the dependencies field under the project section:
|
||||
|
||||
**Druid v0.11.0**
|
||||
**Druid v1.0**
|
||||
|
||||
> [https://github.com/Insality/druid/archive/refs/tags/0.11.0.zip](https://github.com/Insality/druid/archive/refs/tags/0.11.0.zip)
|
||||
> [https://github.com/Insality/druid/archive/refs/tags/1.0.zip](https://github.com/Insality/druid/archive/refs/tags/1.0.zip)
|
||||
|
||||
Here is a list of [all releases](https://github.com/Insality/druid/releases).
|
||||
|
||||
Size: **67.16 KB**
|
||||
|
||||
> The size metrics exlcude the extended components, which are including only on demand.
|
||||
### Library Size
|
||||
|
||||
> **Note:** The library size is calculated based on the build report per platform. The extended components are exlcuded, which are including only on demand.
|
||||
|
||||
| Platform | Library Size |
|
||||
| ---------------- | ------------- |
|
||||
| HTML5 | **38.00 KB** |
|
||||
| Desktop / Mobile | **65.74 KB** |
|
||||
|
||||
|
||||
### Input Bindings
|
||||
**Druid** utilizes the `/builtins/input/all.input_binding` input bindings. For custom input bindings, refer to the Input Binding section in the **_[Advanced Setup](docs_md/advanced-setup.md#input-bindings)_**.
|
||||
|
||||
**Druid** utilizes the `/builtins/input/all.input_binding` input bindings. Either use this file for your project by setting the `Runtime -> Input -> Game Binding` field in the `game.project` input section to `/builtins/input/all.input_binding`, or add the specific bindings you need to your game's input binding file. For custom input bindings, refer to the Input Binding section in the [Advanced Setup](https://github.com/Insality/druid/blob/master/docs_md/advanced-setup.md#input-bindings).
|
||||
|
||||
|
||||
## Usage
|
||||
@@ -110,10 +122,10 @@ Here is full **Druid** components list.
|
||||
| **[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=general_buttons) | <img src="media/preview/button.gif" width="200" height="100"> |
|
||||
| **[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=texts_general) | <img src="media/preview/text.gif" width="200" height="100"> |
|
||||
| **[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=general_scroll) | <img src="media/preview/scroll.gif" width="200" height="100"> |
|
||||
| **[Blocker](https://insality.github.io/druid/modules/Blocker.html)** | Logic over GUI Node. Don't pass any user input below node area size. | ❌ | |
|
||||
| **[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 | ❌ | |
|
||||
| **[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=timer) | <img src="media/preview/blocker.gif" width="200" height="100"> |
|
||||
| **[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=timer) | <img src="media/preview/back_handler.gif" width="200" height="100"> |
|
||||
| **[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=general_grid) | <img src="media/preview/static_grid.gif" width="200" height="100"> |
|
||||
| **[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. | ❌ | <img src="media/preview/hover.gif" width="200" height="100"> |
|
||||
| **[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=timer) | <img src="media/preview/hover.gif" width="200" height="100"> |
|
||||
| **[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=general_swipe) | <img src="media/preview/swipe.gif" width="200" height="100"> |
|
||||
| **[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=general_drag) | <img src="media/preview/drag.gif" width="200" height="100"> |
|
||||
|
||||
@@ -129,18 +141,16 @@ druid.register("data_list", data_list)
|
||||
|
||||
| Name | Description | Example | <div style="width:200px">Preview</div> |
|
||||
|------|-------------|---------|---------|
|
||||
| **[Checkbox](https://insality.github.io/druid/modules/Checkbox.html)** | Switch node state on click event. | [Checkbox Example](https://insality.github.io/druid/druid/?example=general_checkboxes) | <img src="media/preview/checkbox.gif" width="200" height="100"> |
|
||||
| **[Checkbox group](https://insality.github.io/druid/modules/CheckboxGroup.html)** | Group of checkbox components. | [Checkbox group Example](https://insality.github.io/druid/druid/?example=general_checkboxes) | <img src="media/preview/checkbox_group.gif" width="200" height="100"> |
|
||||
| **[Radio group](https://insality.github.io/druid/modules/RadioGroup.html)** | Like checkbox group but with single choise only. | [Radio Group Example](https://insality.github.io/druid/druid/?example=general_checkboxes) | <img src="media/preview/radio_group.gif" width="200" height="100"> |
|
||||
| **[Dynamic Grid](https://insality.github.io/druid/modules/DynamicGrid.html)** | Logic over GUI Node. Component to manage node positions with all different node sizes. Only one direction: horizontal or vertical. | [Dynamic Grid Example](https://insality.github.io/druid/druid/?example=general_grid) | <img src="media/preview/dynamic_grid.gif" width="200" height="100"> |
|
||||
| **[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=general_data_list) | <img src="media/preview/data_list.gif" width="200" height="100"> |
|
||||
| **[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=general_input) | <img src="media/preview/input.gif" width="200" height="100"> |
|
||||
| **[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` | ❌ | <img src="media/preview/lang_text.gif" width="200" height="100"> |
|
||||
| **[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=timer) | <img src="media/preview/lang_text.gif" width="200" height="100"> |
|
||||
| **[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=general_progress_bar) | <img src="media/preview/progress.gif" width="200" height="100"> |
|
||||
| **[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=general_sliders) | <img src="media/preview/slider.gif" width="200" height="100"> |
|
||||
| **[Timer](https://insality.github.io/druid/modules/Timer.html)** | Logic over GUI Text. Handle basic timer functions. | ❌ | <img src="media/preview/timer.gif" width="200" height="100"> |
|
||||
| **[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=timer) | <img src="media/preview/timer.gif" width="200" height="100"> |
|
||||
| **[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=general_hotkey) | <img src="media/preview/hotkey.gif" width="200" height="100"> |
|
||||
| **[Layout](https://insality.github.io/druid/modules/Layout.html)** | Logic over GUI Node. Handle node size depends on layout mode and screen aspect ratio. Contains helpers to build more complex UI layout. | [Layout Example](https://insality.github.io/druid/druid/?example=general_layout) | <img src="media/preview/layout.gif" width="200" height="100"> |
|
||||
| **[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=general_layout) | <img src="media/preview/layout.gif" width="200" height="100"> |
|
||||
| **[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=general_rich_input) | <img src="media/preview/rich_input.gif" width="200" height="100"> |
|
||||
| **[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=general_rich_text) | <img src="media/preview/rich_text.gif" width="200" height="100"> |
|
||||
|
||||
For a complete overview, see: **_[components.md](docs_md/01-components.md)_**.
|
||||
|
||||
@@ -173,8 +183,6 @@ Each example page provides a direct link to the corresponding example code, maki
|
||||
|
||||
Or refer directly to the [**example folder**](https://github.com/Insality/druid/tree/develop/example) for code examples demonstrating how to use **Druid**.
|
||||
|
||||
If you want to see examples of GUIs created with Druid, please refer to the [game_examples.md](docs_md/game_examples.md) file.
|
||||
|
||||
## Documentation
|
||||
|
||||
To better understand **Druid**, read the following documentation:
|
||||
@@ -203,6 +211,13 @@ If you have any issues, questions or suggestions please [create an issue](https:
|
||||
For a complete history of the development of **Druid**, please check the [changelog](docs_md/changelog.md).
|
||||
|
||||
|
||||
## 👏 Contributors
|
||||
|
||||
<a href="https://github.com/Insality/druid/graphs/contributors">
|
||||
<img src="https://contributors-img.web.app/image?repo=insality/druid"/>
|
||||
</a>
|
||||
|
||||
|
||||
## ❤️ Support project ❤️
|
||||
|
||||
Your donation helps me stay engaged in creating valuable projects for **Defold**. If you appreciate what I'm doing, please consider supporting me!
|
||||
|
||||
@@ -4,7 +4,6 @@ description='Documentation for Druid Framework'
|
||||
file={"./druid",
|
||||
exclude = {
|
||||
"./druid/styles/",
|
||||
"./druid/system/middleclass.lua",
|
||||
"./druid/templates/",
|
||||
"./druid/annotations.lua",
|
||||
"./druid/custom/rich_text/module",
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
date,sha,version,build_size,build_time,platform,mode,is_cache_using,commits_count
|
||||
2022-02-28T19:06:43Z,3b329f9c25c9672e4030edb039b0225fa46f7ce1,0.8.521,4356,68,armv7-android,debug,true,521
|
||||
2022-02-28T19:14:56Z,3b329f9c25c9672e4030edb039b0225fa46f7ce1,0.8.521,4356,51,armv7-android,debug,true,521
|
||||
2022-02-28T19:16:23Z,3b329f9c25c9672e4030edb039b0225fa46f7ce1,0.8.521,4356,11,armv7-android,debug,true,521
|
||||
2022-02-28T19:19:46Z,3b329f9c25c9672e4030edb039b0225fa46f7ce1,0.8.521,4356,11,armv7-android,debug,true,521
|
||||
2022-02-28T19:22:51Z,3b329f9c25c9672e4030edb039b0225fa46f7ce1,0.8.521,4356,11,armv7-android,debug,true,521
|
||||
2022-03-12T10:01:30Z,d0f3d6641a08b0d6b719b13017aa85907d1667e5,0.8.564,2200,44,js-web,release,true,564
|
||||
2022-08-29T18:27:58Z,b2643ebd268b15884363efd17724e689279946f1,0.9.589,2316,45,js-web,release,true,589
|
||||
2022-08-29T18:46:47Z,13003e472169cbd261e703eca7b133adf64a24f7,0.9.592,2316,40,js-web,release,true,592
|
||||
2022-09-09T17:55:42Z,072507cc9e715541bdee7636d2e5eeeb3c22a57d,0.10.603,2340,43,js-web,release,true,603
|
||||
2022-09-09T18:00:07Z,072507cc9e715541bdee7636d2e5eeeb3c22a57d,0.10.603,2340,5,js-web,release,true,603
|
||||
2023-07-05T20:19:22Z,d0062c2a78e618871ebb4c8ee66b1509b763f069,0.10.671,3292,12,x86_64-linux,headless,true,671
|
||||
2023-07-13T18:37:07Z,1cbe57376397a8352bbafcc67de0b6f95ae37b35,0.10.682,2496,53,js-web,release,true,682
|
||||
2023-07-13T19:31:47Z,ea185622702e6691275187741b1e2ee0c7f079ec,0.11.686,2452,51,js-web,release,true,686
|
||||
2023-07-15T12:56:18Z,556e1a9bae620e2df290b10287fa8d0f64d47293,0.11.690,2468,51,js-web,release,true,690
|
||||
2023-08-05T16:02:55Z,628723386eb3875f7190d079a2e7c510d044a311,0.11.692,2456,40,js-web,release,true,692
|
||||
2023-08-05T16:31:19Z,37fff52aa59feb20f761ef4d340d9f677743d54b,0.11.693,2456,43,js-web,release,true,693
|
||||
2023-08-05T16:41:25Z,d7dd4a86b81d73d345ad7e136de9c2c488bc4d8b,0.11.694,2452,43,js-web,release,true,694
|
||||
|
@@ -1 +1 @@
|
||||
{"content":[{"name":"game.projectc","size":4114,"pieces":[{"name":"game.projectc0","offset":0}]},{"name":"game.arci","size":23008,"pieces":[{"name":"game.arci0","offset":0}]},{"name":"game.arcd","size":607568,"pieces":[{"name":"game.arcd0","offset":0}]},{"name":"game.dmanifest","size":24253,"pieces":[{"name":"game.dmanifest0","offset":0}]},{"name":"game.public.der","size":162,"pieces":[{"name":"game.public.der0","offset":0}]}]}
|
||||
{"content":[{"name":"game.projectc","size":4489,"pieces":[{"name":"game0.projectc","offset":0}]},{"name":"game.arci","size":12368,"pieces":[{"name":"game0.arci","offset":0}]},{"name":"game.arcd","size":3557359,"pieces":[{"name":"game0.arcd","offset":0},{"name":"game1.arcd","offset":2097152}]},{"name":"game.dmanifest","size":13892,"pieces":[{"name":"game0.dmanifest","offset":0}]},{"name":"game.public.der","size":162,"pieces":[{"name":"game0.public.der","offset":0}]}],"total_size":3588270}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
docs/druid/archive/game0.arcd
Normal file
BIN
docs/druid/archive/game0.arcd
Normal file
Binary file not shown.
BIN
docs/druid/archive/game0.arci
Normal file
BIN
docs/druid/archive/game0.arci
Normal file
Binary file not shown.
BIN
docs/druid/archive/game0.dmanifest
Normal file
BIN
docs/druid/archive/game0.dmanifest
Normal file
Binary file not shown.
@@ -1,24 +1,25 @@
|
||||
[project]
|
||||
title = druid
|
||||
version = 0.11.694
|
||||
version = 1.0
|
||||
write_log = 0
|
||||
compress_archive = 1
|
||||
publisher = Insality
|
||||
developer = Insality
|
||||
commit_sha = d7dd4a86b81d73d345ad7e136de9c2c488bc4d8b
|
||||
build_date = 2023-08-05T16:41:25Z
|
||||
developer = Maksim Tuprikov
|
||||
custom_resources = /example/locales
|
||||
commit_sha = 13fb109ef09e1590fc14a96c2c4d2c900fb517cc
|
||||
build_date = 2024-10-19T08:21:03Z
|
||||
title_as_file_name = druid
|
||||
|
||||
[display]
|
||||
width = 600
|
||||
height = 900
|
||||
width = 1920
|
||||
height = 1080
|
||||
high_dpi = 1
|
||||
samples = 0
|
||||
fullscreen = 0
|
||||
update_frequency = 0
|
||||
swap_interval = 1
|
||||
vsync = 1
|
||||
display_profiles = /example/custom.display_profilesc
|
||||
display_profiles = /builtins/render/default.display_profilesc
|
||||
dynamic_orientation = 1
|
||||
display_device_info = 0
|
||||
|
||||
@@ -51,7 +52,7 @@ velocity_threshold = 1
|
||||
max_fixed_timesteps = 2
|
||||
|
||||
[bootstrap]
|
||||
main_collection = /example/example.collectionc
|
||||
main_collection = /example/druid.collectionc
|
||||
render = /builtins/render/default.renderc
|
||||
|
||||
[graphics]
|
||||
@@ -59,8 +60,9 @@ default_texture_min_filter = linear
|
||||
default_texture_mag_filter = linear
|
||||
max_draw_calls = 128
|
||||
max_characters = 8192
|
||||
max_font_batches = 128
|
||||
max_debug_vertices = 10000
|
||||
texture_profiles = /example/custom.texture_profiles
|
||||
texture_profiles = /builtins/graphics/default.texture_profiles
|
||||
verify_graphics_calls = 0
|
||||
memory_size = 512
|
||||
|
||||
@@ -84,7 +86,7 @@ max_resources = 1024
|
||||
repeat_delay = 0.5
|
||||
repeat_interval = 0.2
|
||||
gamepads = /builtins/input/default.gamepadsc
|
||||
game_binding = /input/game.input_bindingc
|
||||
game_binding = /builtins/input/all.input_bindingc
|
||||
use_accelerometer = 0
|
||||
|
||||
[sprite]
|
||||
@@ -102,6 +104,7 @@ max_count = 0
|
||||
max_count = 64
|
||||
max_particlefx_count = 64
|
||||
max_particle_count = 1024
|
||||
max_animation_count = 1024
|
||||
|
||||
[collection]
|
||||
max_instances = 128
|
||||
@@ -122,13 +125,14 @@ pre_renderered_icons = 0
|
||||
bundle_identifier = example.unnamed
|
||||
bundle_name =
|
||||
infoplist = /builtins/manifests/ios/Info.plist
|
||||
privacymanifest = /builtins/manifests/ios/PrivacyInfo.xcprivacy
|
||||
default_language = en
|
||||
localizations = en
|
||||
|
||||
[android]
|
||||
version_code = 694
|
||||
version_code = 817
|
||||
minimum_sdk_version = 19
|
||||
target_sdk_version = 33
|
||||
target_sdk_version = 34
|
||||
package = com.insality.druid
|
||||
gcm_sender_id =
|
||||
manifest = /builtins/manifests/android/AndroidManifest.xml
|
||||
@@ -138,10 +142,12 @@ immersive_mode = 0
|
||||
display_cutout = 1
|
||||
debuggable = 0
|
||||
proguard =
|
||||
extract_native_libs = 1
|
||||
|
||||
[osx]
|
||||
app_icon =
|
||||
infoplist = /builtins/manifests/osx/Info.plist
|
||||
privacymanifest = /builtins/manifests/osx/PrivacyInfo.xcprivacy
|
||||
bundle_identifier = example.unnamed
|
||||
bundle_name =
|
||||
bundle_version = 1
|
||||
@@ -155,7 +161,7 @@ app_icon =
|
||||
custom_heap_size = 0
|
||||
heap_size = 64
|
||||
htmlfile = /builtins/manifests/web/engine_template.html
|
||||
cssfile = /example/light_theme.css
|
||||
cssfile = /builtins/manifests/web/dark_theme.css
|
||||
splash_image = /media/druid_logo.png
|
||||
archive_location_prefix = archive
|
||||
archive_location_suffix =
|
||||
@@ -163,17 +169,14 @@ engine_arguments = --verify-graphics-calls=false
|
||||
wasm_streaming = 0
|
||||
show_fullscreen_button = 0
|
||||
show_made_with_defold = 0
|
||||
show_console_banner = 1
|
||||
scale_mode = fit
|
||||
show_console_banner = 0
|
||||
scale_mode = stretch
|
||||
|
||||
[particle_fx]
|
||||
max_count = 0
|
||||
max_emitter_count = 0
|
||||
max_particle_count = 0
|
||||
|
||||
[iap]
|
||||
auto_finish_transactions = 1
|
||||
|
||||
[network]
|
||||
http_timeout = 0
|
||||
ssl_certificates =
|
||||
@@ -197,6 +200,7 @@ sleep_between_server_updates = 0
|
||||
[liveupdate]
|
||||
settings = /liveupdate.settings
|
||||
enabled = 1
|
||||
mount_on_start = 1
|
||||
|
||||
[tilemap]
|
||||
max_count = 0
|
||||
@@ -205,6 +209,7 @@ max_tile_count = 0
|
||||
[engine]
|
||||
run_while_iconified = 0
|
||||
fixed_update_frequency = 60
|
||||
max_time_step = 0.5
|
||||
|
||||
[druid]
|
||||
no_auto_input = 0
|
||||
@@ -222,5 +227,13 @@ input_scroll_up = mouse_wheel_up
|
||||
input_scroll_down = mouse_wheel_down
|
||||
|
||||
[native_extension]
|
||||
app_manifest = /example/game.appmanifest
|
||||
app_manifest =
|
||||
|
||||
[saver]
|
||||
autosave_timer = 2
|
||||
|
||||
[lang]
|
||||
path = /example/locales
|
||||
langs = en,ru,es,de,fr,ja,pt,it,kr,zh
|
||||
default = es
|
||||
|
||||
BIN
docs/druid/archive/game1.arcd
Normal file
BIN
docs/druid/archive/game1.arcd
Normal file
Binary file not shown.
@@ -1,3 +1,93 @@
|
||||
/*
|
||||
* 'archive_location_filter':
|
||||
* Filter function that will run for each archive path.
|
||||
*
|
||||
* 'unsupported_webgl_callback':
|
||||
* Function that is called if WebGL is not supported.
|
||||
*
|
||||
* 'engine_arguments':
|
||||
* List of arguments (strings) that will be passed to the engine.
|
||||
*
|
||||
* 'custom_heap_size':
|
||||
* Number of bytes specifying the memory heap size.
|
||||
*
|
||||
* 'disable_context_menu':
|
||||
* Disables the right-click context menu on the canvas element if true.
|
||||
*
|
||||
* 'retry_time':
|
||||
* Pause before retry file loading after error.
|
||||
*
|
||||
* 'retry_count':
|
||||
* How many attempts we do when trying to download a file.
|
||||
*
|
||||
* 'can_not_download_file_callback':
|
||||
* Function that is called if you can't download file after 'retry_count' attempts.
|
||||
*
|
||||
* 'exe_name':
|
||||
* Executable name which used for find right binary to load
|
||||
*
|
||||
* 'resize_window_callback':
|
||||
* Function that is called when resize/orientationchanges/focus events happened
|
||||
*/
|
||||
var CUSTOM_PARAMETERS = {
|
||||
archive_location_filter: function( path ) {
|
||||
return ("archive" + path + "");
|
||||
},
|
||||
engine_arguments: ["--verify-graphics-calls=false",],
|
||||
custom_heap_size: 67108864,
|
||||
full_screen_container: "#canvas-container",
|
||||
disable_context_menu: true,
|
||||
retry_time:1.0,
|
||||
retry_count:10,
|
||||
unsupported_webgl_callback: function() {
|
||||
var e = document.getElementById("webgl-not-supported");
|
||||
e.style.display = "block";
|
||||
},
|
||||
resize_window_callback: function() {
|
||||
var is_iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
||||
var buttonHeight = 0;
|
||||
var prevInnerWidth = -1;
|
||||
var prevInnerHeight = -1;
|
||||
|
||||
|
||||
// Hack for iOS when exit from Fullscreen mode
|
||||
if (is_iOS) {
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
|
||||
var app_container = document.getElementById('app-container');
|
||||
var game_canvas = document.getElementById('canvas');
|
||||
var innerWidth = window.innerWidth;
|
||||
var innerHeight = window.innerHeight - buttonHeight;
|
||||
if (prevInnerWidth == innerWidth && prevInnerHeight == innerHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
prevInnerWidth = innerWidth;
|
||||
prevInnerHeight = innerHeight;
|
||||
var width = 1920;
|
||||
var height = 1080;
|
||||
var targetRatio = width / height;
|
||||
var actualRatio = innerWidth / innerHeight;
|
||||
|
||||
|
||||
//Stretch
|
||||
width = innerWidth;
|
||||
height = innerHeight;
|
||||
|
||||
|
||||
|
||||
var dpi = 1;
|
||||
|
||||
dpi = window.devicePixelRatio || 1;
|
||||
|
||||
app_container.style.width = width + "px";
|
||||
app_container.style.height = height + buttonHeight + "px";
|
||||
game_canvas.width = Math.floor(width * dpi);
|
||||
game_canvas.height = Math.floor(height * dpi);
|
||||
}
|
||||
}
|
||||
|
||||
// file downloader
|
||||
// wraps XMLHttpRequest and adds retry support and progress updates when the
|
||||
// content is gzipped (gzipped content doesn't report a computable content length
|
||||
@@ -9,31 +99,36 @@ var FileLoader = {
|
||||
},
|
||||
// do xhr request with retries
|
||||
request: function(url, method, responseType, currentAttempt) {
|
||||
if (typeof method === 'undefined') throw "No method specified";
|
||||
if (typeof method === 'responseType') throw "No responseType specified";
|
||||
if (typeof method === 'undefined') throw TypeError("No method specified");
|
||||
if (typeof method === 'responseType') throw TypeError("No responseType specified");
|
||||
if (typeof currentAttempt === 'undefined') currentAttempt = 0;
|
||||
var obj = {
|
||||
send: function() {
|
||||
var onprogress = this.onprogress;
|
||||
var onload = this.onload;
|
||||
var onerror = this.onerror;
|
||||
var onretry = this.onretry;
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr._loadedSize = 0;
|
||||
xhr.open(method, url, true);
|
||||
xhr.responseType = responseType;
|
||||
xhr.onprogress = function(e) {
|
||||
if (onprogress) onprogress(xhr, e);
|
||||
xhr.onprogress = function(event) {
|
||||
if (onprogress) onprogress(xhr, event, xhr._loadedSize);
|
||||
xhr._loadedSize = event.loaded;
|
||||
};
|
||||
xhr.onerror = function(e) {
|
||||
xhr.onerror = function(event) {
|
||||
if (currentAttempt == FileLoader.options.retryCount) {
|
||||
if (onerror) onerror(xhr, e);
|
||||
if (onerror) onerror(xhr, event);
|
||||
return;
|
||||
}
|
||||
currentAttempt = currentAttempt + 1;
|
||||
if (onretry) onretry(xhr, event, xhr._loadedSize, currentAttempt);
|
||||
xhr._loadedSize = 0;
|
||||
currentAttempt += 1;
|
||||
setTimeout(obj.send.bind(obj), FileLoader.options.retryInterval);
|
||||
};
|
||||
xhr.onload = function(e) {
|
||||
if (onload) onload(xhr, e);
|
||||
xhr.onload = function(event) {
|
||||
if (onload) onload(xhr, event);
|
||||
};
|
||||
xhr.send(null);
|
||||
}
|
||||
@@ -60,29 +155,21 @@ var FileLoader = {
|
||||
request.send();
|
||||
},
|
||||
// Do HTTP GET request
|
||||
// onprogress(loaded, total)
|
||||
// onprogress(loadedDelta)
|
||||
// onerror(error)
|
||||
// onload(response)
|
||||
load: function(url, responseType, estimatedSize, onprogress, onerror, onload) {
|
||||
// onretry(loadedSize, currentAttempt)
|
||||
load: function(url, responseType, onprogress, onerror, onload, onretry) {
|
||||
var request = FileLoader.request(url, "GET", responseType);
|
||||
request.onprogress = function(xhr, e) {
|
||||
if (e.lengthComputable) {
|
||||
onprogress(e.loaded, e.total);
|
||||
return;
|
||||
}
|
||||
var contentLength = xhr.getResponseHeader('content-length');
|
||||
var size = contentLength != undefined ? contentLength : estimatedSize;
|
||||
if (size) {
|
||||
onprogress(e.loaded, size);
|
||||
} else {
|
||||
onprogress(e.loaded, e.loaded);
|
||||
}
|
||||
request.onprogress = function(xhr, e, ls) {
|
||||
var delta = e.loaded - ls;
|
||||
onprogress(delta);
|
||||
};
|
||||
request.onerror = function(xhr, e) {
|
||||
onerror("Error loading '" + url + "' (" + e + ")");
|
||||
};
|
||||
request.onload = function(xhr, e) {
|
||||
if (xhr.readyState === 4) {
|
||||
if (xhr.readyState === XMLHttpRequest.DONE) {
|
||||
if (xhr.status === 200) {
|
||||
var res = xhr.response;
|
||||
if (responseType == "json" && typeof res === "string") {
|
||||
@@ -95,109 +182,144 @@ var FileLoader = {
|
||||
}
|
||||
}
|
||||
};
|
||||
request.onretry = function(xhr, event, loadedSize, currentAttempt) {
|
||||
onretry(loadedSize, currentAttempt);
|
||||
}
|
||||
request.send();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var EngineLoader = {
|
||||
wasm_size: 2000000,
|
||||
wasmjs_size: 250000,
|
||||
wasm_size: 2374239,
|
||||
wasmjs_size: 340441,
|
||||
asmjs_size: 4000000,
|
||||
wasm_instantiate_progress: 0,
|
||||
|
||||
stream_wasm: false,
|
||||
stream_wasm: "false" === "true",
|
||||
|
||||
loadAndInstantiateWasmAsync: function(src, fromProgress, toProgress, callback) {
|
||||
FileLoader.load(src, "arraybuffer", EngineLoader.wasm_size,
|
||||
function(loaded, total) { Progress.calculateProgress(fromProgress, toProgress, loaded, total); },
|
||||
updateWasmInstantiateProgress: function(totalDownloadedSize) {
|
||||
EngineLoader.wasm_instantiate_progress = totalDownloadedSize * 0.1;
|
||||
},
|
||||
|
||||
// load and instantiate .wasm file using XMLHttpRequest
|
||||
loadAndInstantiateWasmAsync: function(src, imports, successCallback) {
|
||||
FileLoader.load(src, "arraybuffer",
|
||||
function(delta) {
|
||||
ProgressUpdater.updateCurrent(delta);
|
||||
},
|
||||
function(error) { throw error; },
|
||||
function(wasm) {
|
||||
Module.instantiateWasm = function(imports, successCallback) {
|
||||
var wasmInstantiate = WebAssembly.instantiate(new Uint8Array(wasm), imports).then(function(output) {
|
||||
successCallback(output.instance);
|
||||
}).catch(function(e) {
|
||||
console.log('wasm instantiation failed! ' + e);
|
||||
throw e;
|
||||
});
|
||||
return {}; // Compiling asynchronously, no exports.
|
||||
if (wasm.byteLength != EngineLoader.wasm_size) {
|
||||
throw "Invalid wasm size. Expected: " + EngineLoader.wasm_size + ", actual: " + wasm.byteLength;
|
||||
}
|
||||
callback();
|
||||
var wasmInstantiate = WebAssembly.instantiate(new Uint8Array(wasm), imports).then(function(output) {
|
||||
successCallback(output.instance);
|
||||
}).catch(function(e) {
|
||||
console.log('wasm instantiation failed! ' + e);
|
||||
throw e;
|
||||
});
|
||||
},
|
||||
function(loadedDelta, currentAttempt){
|
||||
ProgressUpdater.updateCurrent(-loadedDelta);
|
||||
});
|
||||
},
|
||||
|
||||
setupWasmStreamAsync: async function(src, fromProgress, toProgress) {
|
||||
// stream and instantiate .wasm file
|
||||
streamAndInstantiateWasmAsync: async function(src, imports, successCallback) {
|
||||
// https://stackoverflow.com/a/69179454
|
||||
var fetchFn = fetch;
|
||||
if (typeof TransformStream === "function" && ReadableStream.prototype.pipeThrough) {
|
||||
async function fetchWithProgress(path) {
|
||||
const response = await fetch(path);
|
||||
// May be incorrect if compressed
|
||||
const contentLength = response.headers.get("Content-Length");
|
||||
const total = parseInt(contentLength, 10);
|
||||
if (response.ok) {
|
||||
const ts = new TransformStream({
|
||||
transform (chunk, controller) {
|
||||
ProgressUpdater.updateCurrent(chunk.byteLength);
|
||||
controller.enqueue(chunk);
|
||||
}
|
||||
});
|
||||
|
||||
let bytesLoaded = 0;
|
||||
const ts = new TransformStream({
|
||||
transform (chunk, controller) {
|
||||
bytesLoaded += chunk.byteLength;
|
||||
Progress.calculateProgress(fromProgress, toProgress, bytesLoaded, total);
|
||||
controller.enqueue(chunk)
|
||||
}
|
||||
});
|
||||
|
||||
return new Response(response.body.pipeThrough(ts), response);
|
||||
return new Response(response.body.pipeThrough(ts), response);
|
||||
} else {
|
||||
return new Response(null, response);
|
||||
}
|
||||
}
|
||||
fetchFn = fetchWithProgress;
|
||||
}
|
||||
|
||||
Module.instantiateWasm = function(imports, successCallback) {
|
||||
WebAssembly.instantiateStreaming(fetchFn(src), imports).then(function(output) {
|
||||
Progress.calculateProgress(fromProgress, toProgress, 1, 1);
|
||||
successCallback(output.instance);
|
||||
}).catch(function(e) {
|
||||
console.log('wasm streaming instantiation failed! ' + e);
|
||||
throw e;
|
||||
});
|
||||
return {}; // Compiling asynchronously, no exports.
|
||||
}
|
||||
WebAssembly.instantiateStreaming(fetchFn(src), imports).then(function(output) {
|
||||
ProgressUpdater.updateCurrent(EngineLoader.wasm_instantiate_progress);
|
||||
successCallback(output.instance);
|
||||
}).catch(function(e) {
|
||||
console.log('wasm streaming instantiation failed! ' + e);
|
||||
console.log('Fallback to wasm loading');
|
||||
EngineLoader.loadAndInstantiateWasmAsync(src, imports, successCallback);
|
||||
});
|
||||
},
|
||||
|
||||
// instantiate the .wasm file either by streaming it or first loading and then instantiate it
|
||||
// https://github.com/emscripten-core/emscripten/blob/master/tests/manual_wasm_instantiate.html#L170
|
||||
// https://github.com/emscripten-core/emscripten/blob/main/test/manual_wasm_instantiate.html
|
||||
loadWasmAsync: function(exeName) {
|
||||
if (EngineLoader.stream_wasm && (typeof WebAssembly.instantiateStreaming === "function")) {
|
||||
EngineLoader.setupWasmStreamAsync(exeName + ".wasm", 10, 50);
|
||||
EngineLoader.loadAndRunScriptAsync(exeName + '_wasm.js', EngineLoader.wasmjs_size, 0, 10);
|
||||
}
|
||||
else {
|
||||
EngineLoader.loadAndInstantiateWasmAsync(exeName + ".wasm", 0, 40, function() {
|
||||
EngineLoader.loadAndRunScriptAsync(exeName + '_wasm.js', EngineLoader.wasmjs_size, 40, 50);
|
||||
});
|
||||
}
|
||||
Module.instantiateWasm = function(imports, successCallback) {
|
||||
if (EngineLoader.stream_wasm && (typeof WebAssembly.instantiateStreaming === "function")) {
|
||||
EngineLoader.streamAndInstantiateWasmAsync(exeName + ".wasm", imports, successCallback);
|
||||
}
|
||||
else {
|
||||
EngineLoader.loadAndInstantiateWasmAsync(exeName + ".wasm", imports, successCallback);
|
||||
}
|
||||
return {}; // Compiling asynchronously, no exports.
|
||||
};
|
||||
EngineLoader.loadAndRunScriptAsync(exeName + '_wasm.js');
|
||||
},
|
||||
|
||||
loadAsmJsAsync: function(exeName) {
|
||||
EngineLoader.loadAndRunScriptAsync(exeName + '_asmjs.js', EngineLoader.asmjs_size, 0, 50);
|
||||
EngineLoader.loadAndRunScriptAsync(exeName + '_asmjs.js');
|
||||
},
|
||||
|
||||
// load and start engine script (asm.js or wasm.js)
|
||||
loadAndRunScriptAsync: function(src, estimatedSize, fromProgress, toProgress) {
|
||||
FileLoader.load(src, "text", estimatedSize,
|
||||
function(loaded, total) { Progress.calculateProgress(fromProgress, toProgress, loaded, total); },
|
||||
loadAndRunScriptAsync: function(src) {
|
||||
FileLoader.load(src, "text",
|
||||
function(delta) {
|
||||
ProgressUpdater.updateCurrent(delta);
|
||||
},
|
||||
function(error) { throw error; },
|
||||
function(response) {
|
||||
var tag = document.createElement("script");
|
||||
tag.text = response;
|
||||
document.body.appendChild(tag);
|
||||
},
|
||||
function(loadedDelta, currentAttempt){
|
||||
ProgressUpdater.updateCurrent(-loadedDelta);
|
||||
});
|
||||
},
|
||||
|
||||
// load engine (asm.js or wasm.js + wasm)
|
||||
// left as entrypoint for backward capability
|
||||
// start loading archive_files.json
|
||||
// after receiving it - start loading engine and data concurrently
|
||||
load: function(appCanvasId, exeName) {
|
||||
Progress.addProgress(Module.setupCanvas(appCanvasId));
|
||||
if (Module['isWASMSupported']) {
|
||||
EngineLoader.loadWasmAsync(exeName);
|
||||
} else {
|
||||
EngineLoader.loadAsmJsAsync(exeName);
|
||||
ProgressView.addProgress(Module.setupCanvas(appCanvasId));
|
||||
CUSTOM_PARAMETERS['exe_name'] = exeName;
|
||||
|
||||
FileLoader.options.retryCount = CUSTOM_PARAMETERS["retry_count"];
|
||||
FileLoader.options.retryInterval = CUSTOM_PARAMETERS["retry_time"] * 1000;
|
||||
if (typeof CUSTOM_PARAMETERS["can_not_download_file_callback"] === "function") {
|
||||
GameArchiveLoader.addFileDownloadErrorListener(CUSTOM_PARAMETERS["can_not_download_file_callback"]);
|
||||
}
|
||||
// Load and assemble archive
|
||||
GameArchiveLoader.addFileLoadedListener(Module.onArchiveFileLoaded);
|
||||
GameArchiveLoader.addArchiveLoadedListener(Module.onArchiveLoaded);
|
||||
GameArchiveLoader.setFileLocationFilter(CUSTOM_PARAMETERS["archive_location_filter"]);
|
||||
GameArchiveLoader.loadArchiveDescription('/archive_files.json');
|
||||
|
||||
// move resize callback setup here to make possible to override callback
|
||||
// from outside of dmloader.js
|
||||
if (typeof CUSTOM_PARAMETERS["resize_window_callback"] === "function") {
|
||||
var callback = CUSTOM_PARAMETERS["resize_window_callback"]
|
||||
callback();
|
||||
window.addEventListener('resize', callback, false);
|
||||
window.addEventListener('orientationchange', callback, false);
|
||||
window.addEventListener('focus', callback, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -229,9 +351,6 @@ var GameArchiveLoader = {
|
||||
_onArchiveLoadedListeners:[], // signature: void
|
||||
_onFileDownloadErrorListeners: [], // signature: name
|
||||
|
||||
_currentDownloadBytes: 0,
|
||||
_totalDownloadBytes: 0,
|
||||
|
||||
_archiveLocationFilter: function(path) { return "split" + path; },
|
||||
|
||||
cleanUp: function() {
|
||||
@@ -241,13 +360,10 @@ var GameArchiveLoader = {
|
||||
this._onGameArchiveLoaderCompletedListeners = [];
|
||||
this._onAllTargetsBuiltListeners = [];
|
||||
this._onFileDownloadErrorListeners = [];
|
||||
|
||||
this._currentDownloadBytes = 0;
|
||||
this._totalDownloadBytes = 0;
|
||||
},
|
||||
|
||||
addListener: function(list, callback) {
|
||||
if (typeof callback !== 'function') throw "Invalid callback registration";
|
||||
if (typeof callback !== 'function') throw TypeError("Invalid callback registration");
|
||||
list.push(callback);
|
||||
},
|
||||
notifyListeners: function(list, data) {
|
||||
@@ -289,22 +405,31 @@ var GameArchiveLoader = {
|
||||
FileLoader.load(
|
||||
this._archiveLocationFilter(descriptionUrl),
|
||||
"json",
|
||||
undefined,
|
||||
function (loaded, total) { },
|
||||
function (delta) { },
|
||||
function (error) { GameArchiveLoader.notifyFileDownloadError(descriptionUrl); },
|
||||
function (json) { GameArchiveLoader.onReceiveDescription(json); });
|
||||
function (json) { GameArchiveLoader.onReceiveDescription(json); },
|
||||
function (loadedDelta, currentAttempt) { });
|
||||
},
|
||||
|
||||
onReceiveDescription: function(json) {
|
||||
var totalSize = json.total_size;
|
||||
var exeName = CUSTOM_PARAMETERS['exe_name'];
|
||||
this._files = json.content;
|
||||
this._totalDownloadBytes = 0;
|
||||
this._currentDownloadBytes = 0;
|
||||
|
||||
// calculate total download size of all files
|
||||
for(var i=0; i<this._files.length; ++i) {
|
||||
this._totalDownloadBytes += this._files[i].size;
|
||||
var isWASMSupported = Module['isWASMSupported'];
|
||||
if (isWASMSupported) {
|
||||
EngineLoader.loadWasmAsync(exeName);
|
||||
totalSize += EngineLoader.wasm_size + EngineLoader.wasmjs_size;
|
||||
} else {
|
||||
EngineLoader.loadAsmJsAsync(exeName);
|
||||
totalSize += EngineLoader.asmjs_size;
|
||||
}
|
||||
this.downloadContent();
|
||||
ProgressUpdater.resetCurrent();
|
||||
if (isWASMSupported) {
|
||||
EngineLoader.updateWasmInstantiateProgress(totalSize);
|
||||
}
|
||||
ProgressUpdater.setupTotal(totalSize + EngineLoader.wasm_instantiate_progress);
|
||||
},
|
||||
|
||||
downloadContent: function() {
|
||||
@@ -324,30 +449,25 @@ var GameArchiveLoader = {
|
||||
}
|
||||
},
|
||||
|
||||
notifyDownloadProgress: function() {
|
||||
Progress.calculateProgress(50, 100, this._currentDownloadBytes, this._totalDownloadBytes);
|
||||
notifyDownloadProgress: function(delta) {
|
||||
ProgressUpdater.updateCurrent(delta);
|
||||
},
|
||||
|
||||
downloadPiece: function(file, index) {
|
||||
if (index < file.lastRequestedPiece) {
|
||||
throw "Request out of order";
|
||||
throw RangeError("Request out of order: " + file.name + ", index: " + index + ", last requested piece: " + file.lastRequestedPiece);
|
||||
}
|
||||
|
||||
var piece = file.pieces[index];
|
||||
file.lastRequestedPiece = index;
|
||||
file.totalLoadedPieces = 0;
|
||||
|
||||
var total = 0;
|
||||
var downloaded = 0;
|
||||
var url = this._archiveLocationFilter('/' + piece.name);
|
||||
|
||||
FileLoader.load(
|
||||
url, "arraybuffer", undefined,
|
||||
function (loaded, total) {
|
||||
var delta = loaded - downloaded;
|
||||
downloaded = loaded;
|
||||
GameArchiveLoader._currentDownloadBytes += delta;
|
||||
GameArchiveLoader.notifyDownloadProgress();
|
||||
url, "arraybuffer",
|
||||
function (delta) {
|
||||
GameArchiveLoader.notifyDownloadProgress(delta);
|
||||
},
|
||||
function (error) {
|
||||
GameArchiveLoader.notifyFileDownloadError(error);
|
||||
@@ -358,8 +478,10 @@ var GameArchiveLoader = {
|
||||
total = piece.dataLength;
|
||||
downloaded = piece.dataLength;
|
||||
GameArchiveLoader.onPieceLoaded(file, piece);
|
||||
GameArchiveLoader.notifyDownloadProgress();
|
||||
piece.data = undefined;
|
||||
},
|
||||
function(loadedDelta, currentAttempt){
|
||||
ProgressUpdater.updateCurrent(-loadedDelta);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -370,10 +492,10 @@ var GameArchiveLoader = {
|
||||
var start = piece.offset;
|
||||
var end = start + piece.data.length;
|
||||
if (0 > start) {
|
||||
throw "Buffer underflow";
|
||||
throw RangeError("Buffer underflow. Start: " + start);
|
||||
}
|
||||
if (end > file.data.length) {
|
||||
throw "Buffer overflow";
|
||||
throw RangeError("Buffer overflow. End : " + end + ", data length: " + file.data.length);
|
||||
}
|
||||
file.data.set(piece.data, piece.offset);
|
||||
}
|
||||
@@ -404,12 +526,11 @@ var GameArchiveLoader = {
|
||||
actualSize += file.pieces[i].dataLength;
|
||||
}
|
||||
if (actualSize != file.size) {
|
||||
throw "Unexpected data size";
|
||||
throw "Unexpected data size: " + file.name + ", expected size: " + file.size + ", actual size: " + actualSize;
|
||||
}
|
||||
|
||||
// verify the pieces
|
||||
if (file.pieces.length > 1) {
|
||||
var output = file.data;
|
||||
var pieces = file.pieces;
|
||||
for (i=0; i<pieces.length; ++i) {
|
||||
var item = pieces[i];
|
||||
@@ -419,13 +540,13 @@ var GameArchiveLoader = {
|
||||
if (0 < i) {
|
||||
var previous = pieces[i - 1];
|
||||
if (previous.offset + previous.dataLength > start) {
|
||||
throw "Segment underflow";
|
||||
throw RangeError("Segment underflow in file: " + file.name + ", offset: " + (previous.offset + previous.dataLength) + " , start: " + start);
|
||||
}
|
||||
}
|
||||
if (pieces.length - 2 > i) {
|
||||
var next = pieces[i + 1];
|
||||
if (end > next.offset) {
|
||||
throw "Segment overflow";
|
||||
throw RangeError("Segment overflow in file: " + file.name + ", offset: " + next.offset + ", end: " + end);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -453,14 +574,42 @@ var GameArchiveLoader = {
|
||||
/* Default splash and progress visualisation */
|
||||
/* ********************************************************************* */
|
||||
|
||||
var Progress = {
|
||||
var ProgressView = {
|
||||
progress_id: "defold-progress",
|
||||
bar_id: "defold-progress-bar",
|
||||
|
||||
addProgress : function (canvas) {
|
||||
/* Insert default progress bar below canvas */
|
||||
canvas.insertAdjacentHTML('afterend', '<div id="' + ProgressView.progress_id + '" class="canvas-app-progress"><div id="' + ProgressView.bar_id + '" class="canvas-app-progress-bar" style="transform: scaleX(0.0);"></div></div>');
|
||||
ProgressView.bar = document.getElementById(ProgressView.bar_id);
|
||||
ProgressView.progress = document.getElementById(ProgressView.progress_id);
|
||||
},
|
||||
|
||||
updateProgress: function(percentage) {
|
||||
if (ProgressView.bar) {
|
||||
ProgressView.bar.style.transform = "scaleX(" + Math.min(percentage, 100) / 100 + ")";
|
||||
}
|
||||
},
|
||||
|
||||
removeProgress: function () {
|
||||
if (ProgressView.progress.parentElement !== null) {
|
||||
ProgressView.progress.parentElement.removeChild(ProgressView.progress);
|
||||
|
||||
// Remove any background/splash image that was set in runApp().
|
||||
// Workaround for Safari bug DEF-3061.
|
||||
Module.canvas.style.background = "";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var ProgressUpdater = {
|
||||
current: 0,
|
||||
total: 1,
|
||||
|
||||
listeners: [],
|
||||
|
||||
addListener: function(callback) {
|
||||
if (typeof callback !== 'function') throw "Invalid callback registration";
|
||||
if (typeof callback !== 'function') throw TypeError("Invalid callback registration");
|
||||
this.listeners.push(callback);
|
||||
},
|
||||
|
||||
@@ -470,32 +619,64 @@ var Progress = {
|
||||
}
|
||||
},
|
||||
|
||||
setupTotal: function (total) {
|
||||
this.total = total;
|
||||
},
|
||||
|
||||
setCurrent: function (current) {
|
||||
this.current = current;
|
||||
var percentage = this.calculateProgress();
|
||||
ProgressView.updateProgress(percentage);
|
||||
this.notifyListeners(percentage);
|
||||
},
|
||||
|
||||
updateCurrent: function (diff) {
|
||||
this.current += diff;
|
||||
var percentage = this.calculateProgress();
|
||||
ProgressView.updateProgress(percentage);
|
||||
this.notifyListeners(percentage);
|
||||
},
|
||||
|
||||
resetCurrent: function () {
|
||||
this.current = 0;
|
||||
},
|
||||
|
||||
complete: function () {
|
||||
this.setCurrent(this.total);
|
||||
},
|
||||
|
||||
calculateProgress: function () {
|
||||
return this.current / this.total * 100;
|
||||
}
|
||||
};
|
||||
|
||||
/* DEPRECATED!
|
||||
* Use ProgressUpdater and ProgressView instead.
|
||||
* Left for backward compatability.
|
||||
*/
|
||||
var Progress = {
|
||||
addListener: function(callback) {
|
||||
ProgressUpdater.addListener(callback);
|
||||
},
|
||||
|
||||
notifyListeners: function(percentage) {
|
||||
// no-op
|
||||
},
|
||||
|
||||
addProgress : function (canvas) {
|
||||
/* Insert default progress bar below canvas */
|
||||
canvas.insertAdjacentHTML('afterend', '<div id="' + Progress.progress_id + '" class="canvas-app-progress"><div id="' + Progress.bar_id + '" class="canvas-app-progress-bar" style="width: 0%;"></div></div>');
|
||||
Progress.bar = document.getElementById(Progress.bar_id);
|
||||
Progress.progress = document.getElementById(Progress.progress_id);
|
||||
ProgressView.addProgress(canvas);
|
||||
},
|
||||
|
||||
updateProgress: function(percentage) {
|
||||
if (Progress.bar) {
|
||||
Progress.bar.style.width = percentage + "%";
|
||||
}
|
||||
Progress.notifyListeners(percentage);
|
||||
// no-op
|
||||
},
|
||||
|
||||
calculateProgress: function (from, to, current, total) {
|
||||
this.updateProgress(from + (current / total) * (to - from));
|
||||
// no-op
|
||||
},
|
||||
|
||||
removeProgress: function () {
|
||||
if (Progress.progress.parentElement !== null) {
|
||||
Progress.progress.parentElement.removeChild(Progress.progress);
|
||||
|
||||
// Remove any background/splash image that was set in runApp().
|
||||
// Workaround for Safari bug DEF-3061.
|
||||
Module.canvas.style.background = "";
|
||||
}
|
||||
ProgressView.removeProgress();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -509,7 +690,7 @@ var Module = {
|
||||
_filesToPreload: [],
|
||||
_archiveLoaded: false,
|
||||
_preLoadDone: false,
|
||||
_waitingForArchive: false,
|
||||
_isEngineLoaded: false,
|
||||
|
||||
// Persistent storage
|
||||
persistentStorage: true,
|
||||
@@ -547,7 +728,6 @@ var Module = {
|
||||
var error = errObj || (typeof window.event != "undefined" ? window.event.error : "" ) || err || "Undefined Error";
|
||||
var message = "";
|
||||
var stack = "";
|
||||
var backtrace = "";
|
||||
|
||||
if (typeof error == "object" && typeof error.stack != "undefined" && typeof error.message != "undefined") {
|
||||
stack = String(error.stack);
|
||||
@@ -600,61 +780,14 @@ var Module = {
|
||||
|
||||
/**
|
||||
* Module.runApp - Starts the application given a canvas element id
|
||||
*
|
||||
* 'extra_params' is an optional object that can have the following fields:
|
||||
*
|
||||
* 'archive_location_filter':
|
||||
* Filter function that will run for each archive path.
|
||||
*
|
||||
* 'unsupported_webgl_callback':
|
||||
* Function that is called if WebGL is not supported.
|
||||
*
|
||||
* 'engine_arguments':
|
||||
* List of arguments (strings) that will be passed to the engine.
|
||||
*
|
||||
* 'persistent_storage':
|
||||
* Boolean toggling the usage of persistent storage.
|
||||
*
|
||||
* 'custom_heap_size':
|
||||
* Number of bytes specifying the memory heap size.
|
||||
*
|
||||
* 'disable_context_menu':
|
||||
* Disables the right-click context menu on the canvas element if true.
|
||||
*
|
||||
* 'retry_time':
|
||||
* Pause before retry file loading after error.
|
||||
*
|
||||
* 'retry_count':
|
||||
* How many attempts we do when trying to download a file.
|
||||
*
|
||||
* 'can_not_download_file_callback':
|
||||
* Function that is called if you can't download file after 'retry_count' attempts.
|
||||
**/
|
||||
runApp: function(appCanvasId, extra_params) {
|
||||
runApp: function(appCanvasId, _) {
|
||||
Module._isEngineLoaded = true;
|
||||
Module.setupCanvas(appCanvasId);
|
||||
|
||||
var params = {
|
||||
archive_location_filter: function(path) { return 'split' + path; },
|
||||
unsupported_webgl_callback: undefined,
|
||||
engine_arguments: [],
|
||||
persistent_storage: true,
|
||||
custom_heap_size: undefined,
|
||||
disable_context_menu: true,
|
||||
retry_time: 1,
|
||||
retry_count: 10,
|
||||
can_not_download_file_callback: undefined,
|
||||
};
|
||||
Module.arguments = CUSTOM_PARAMETERS["engine_arguments"];
|
||||
|
||||
for (var k in extra_params) {
|
||||
if (extra_params.hasOwnProperty(k)) {
|
||||
params[k] = extra_params[k];
|
||||
}
|
||||
}
|
||||
|
||||
Module.arguments = params["engine_arguments"];
|
||||
Module.persistentStorage = params["persistent_storage"];
|
||||
|
||||
var fullScreenContainer = params["full_screen_container"];
|
||||
var fullScreenContainer = CUSTOM_PARAMETERS["full_screen_container"];
|
||||
if (typeof fullScreenContainer === "string") {
|
||||
fullScreenContainer = document.querySelector(fullScreenContainer);
|
||||
}
|
||||
@@ -664,31 +797,22 @@ var Module = {
|
||||
Module.canvas.focus();
|
||||
|
||||
// Add context menu hide-handler if requested
|
||||
if (params["disable_context_menu"])
|
||||
if (CUSTOM_PARAMETERS["disable_context_menu"])
|
||||
{
|
||||
Module.canvas.oncontextmenu = function(e) {
|
||||
e.preventDefault();
|
||||
};
|
||||
}
|
||||
|
||||
FileLoader.options.retryCount = params["retry_count"];
|
||||
FileLoader.options.retryInterval = params["retry_time"] * 1000;
|
||||
if (typeof params["can_not_download_file_callback"] === "function") {
|
||||
GameArchiveLoader.addFileDownloadErrorListener(params["can_not_download_file_callback"]);
|
||||
}
|
||||
// Load and assemble archive
|
||||
GameArchiveLoader.addFileLoadedListener(Module.onArchiveFileLoaded);
|
||||
GameArchiveLoader.addArchiveLoadedListener(Module.onArchiveLoaded);
|
||||
GameArchiveLoader.setFileLocationFilter(params["archive_location_filter"]);
|
||||
GameArchiveLoader.loadArchiveDescription('/archive_files.json');
|
||||
Module._preloadAndCallMain();
|
||||
} else {
|
||||
Progress.updateProgress(100, "Unable to start game, WebGL not supported");
|
||||
// "Unable to start game, WebGL not supported"
|
||||
ProgressUpdater.complete();
|
||||
Module.setStatus = function(text) {
|
||||
if (text) Module.printErr('[missing WebGL] ' + text);
|
||||
};
|
||||
|
||||
if (typeof params["unsupported_webgl_callback"] === "function") {
|
||||
params["unsupported_webgl_callback"]();
|
||||
if (typeof CUSTOM_PARAMETERS["unsupported_webgl_callback"] === "function") {
|
||||
CUSTOM_PARAMETERS["unsupported_webgl_callback"]();
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -700,11 +824,7 @@ var Module = {
|
||||
onArchiveLoaded: function() {
|
||||
GameArchiveLoader.cleanUp();
|
||||
Module._archiveLoaded = true;
|
||||
Progress.updateProgress(100, "Starting...");
|
||||
|
||||
if (Module._waitingForArchive) {
|
||||
Module._preloadAndCallMain();
|
||||
}
|
||||
Module._preloadAndCallMain();
|
||||
},
|
||||
|
||||
toggleFullscreen: function(element) {
|
||||
@@ -717,7 +837,6 @@ var Module = {
|
||||
|
||||
preSync: function(done) {
|
||||
if (Module.persistentStorage != true) {
|
||||
Module._syncInitial = true;
|
||||
done();
|
||||
return;
|
||||
}
|
||||
@@ -725,7 +844,7 @@ var Module = {
|
||||
FS.syncfs(true, function(err) {
|
||||
if (err) {
|
||||
Module._syncTries += 1;
|
||||
console.error("FS syncfs error: " + err);
|
||||
console.warn("Unable to synchronize mounted file systems: " + err);
|
||||
if (Module._syncMaxTries > Module._syncTries) {
|
||||
Module.preSync(done);
|
||||
} else {
|
||||
@@ -817,26 +936,33 @@ var Module = {
|
||||
|
||||
postRun: [function() {
|
||||
if(Module._archiveLoaded) {
|
||||
Progress.removeProgress();
|
||||
ProgressView.removeProgress();
|
||||
}
|
||||
}],
|
||||
|
||||
_preloadAndCallMain: function() {
|
||||
// If the archive isn't loaded,
|
||||
// we will have to wait with calling main.
|
||||
if (!Module._archiveLoaded) {
|
||||
Module._waitingForArchive = true;
|
||||
} else {
|
||||
Module.preloadAll();
|
||||
Progress.removeProgress();
|
||||
if (Module.callMain === undefined) {
|
||||
Module.noInitialRun = false;
|
||||
} else {
|
||||
Module.callMain(Module.arguments);
|
||||
if (Module._syncInitial || Module.persistentStorage != true) {
|
||||
// If the archive isn't loaded,
|
||||
// we will have to wait with calling main.
|
||||
if (Module._archiveLoaded) {
|
||||
Module.preloadAll();
|
||||
if (Module._isEngineLoaded) {
|
||||
// "Starting...."
|
||||
ProgressUpdater.complete();
|
||||
Module._callMain();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_callMain: function() {
|
||||
ProgressView.removeProgress();
|
||||
if (Module.callMain === undefined) {
|
||||
Module.noInitialRun = false;
|
||||
} else {
|
||||
Module.callMain(Module.arguments);
|
||||
}
|
||||
},
|
||||
// Wrap IDBFS syncfs call with logic to avoid multiple syncs
|
||||
// running at the same time.
|
||||
_startSyncFS: function() {
|
||||
@@ -847,7 +973,7 @@ var Module = {
|
||||
Module._syncInProgress = false;
|
||||
|
||||
if (err) {
|
||||
console.error("Module._startSyncFS error: " + err);
|
||||
console.warn("Unable to synchronize mounted file systems: " + err);
|
||||
Module._syncTries += 1;
|
||||
}
|
||||
|
||||
@@ -861,6 +987,26 @@ var Module = {
|
||||
},
|
||||
};
|
||||
|
||||
// common engine setup
|
||||
Module['persistentStorage'] = (typeof window !== 'undefined') && !!(window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
|
||||
|
||||
Module['INITIAL_MEMORY'] = CUSTOM_PARAMETERS.custom_heap_size;
|
||||
|
||||
Module['onRuntimeInitialized'] = function() {
|
||||
Module.runApp("canvas");
|
||||
};
|
||||
|
||||
Module["locateFile"] = function(path, scriptDirectory)
|
||||
{
|
||||
// dmengine*.wasm is hardcoded in the built JS loader for WASM,
|
||||
// we need to replace it here with the correct project name.
|
||||
if (path == "dmengine.wasm" || path == "dmengine_release.wasm" || path == "dmengine_headless.wasm") {
|
||||
path = "druid.wasm";
|
||||
}
|
||||
return scriptDirectory + path;
|
||||
};
|
||||
|
||||
|
||||
window.onerror = function(err, url, line, column, errObj) {
|
||||
if (typeof Module.ccall !== 'undefined') {
|
||||
var errorObject = Module.prepareErrorObject(err, url, line, column, errObj);
|
||||
|
||||
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 492 KiB |
10099
docs/druid/druid_wasm.js
10099
docs/druid/druid_wasm.js
File diff suppressed because one or more lines are too long
@@ -7,7 +7,7 @@
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<!-- The above 4 meta tags *must* come first in the head; any other head content must come *after* these tags -->
|
||||
|
||||
<title>druid 0.11.694</title>
|
||||
<title>druid 1.0</title>
|
||||
<style type='text/css'>
|
||||
/* Disable user selection to avoid strange bug in Chrome on Windows:
|
||||
* Selecting a text outside the canvas, then clicking+draging would
|
||||
@@ -54,7 +54,7 @@
|
||||
-moz-outline-style: none;
|
||||
}
|
||||
|
||||
div {
|
||||
body, div {
|
||||
-webkit-tap-highlight-color: rgba(0,0,0,0);
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
@@ -66,7 +66,7 @@
|
||||
|
||||
.canvas-app-progress {
|
||||
position: absolute;
|
||||
background-color: #d1dbeb;
|
||||
background-color: #394046;
|
||||
height: 6px;
|
||||
margin-top: -6px;
|
||||
width: 100%;
|
||||
@@ -79,6 +79,9 @@
|
||||
background-color: #1a72eb;
|
||||
text-align: center;
|
||||
line-height: 20px;
|
||||
transition: transform 1s ease;
|
||||
transform-origin: left;
|
||||
transform: scaleX(1.0);
|
||||
}
|
||||
.link, .button {
|
||||
font-family: sans-serif;
|
||||
@@ -92,131 +95,54 @@
|
||||
}
|
||||
|
||||
.buttons-background {
|
||||
background-color: #ffffff;
|
||||
background-color: #1e2226;
|
||||
width: 100%;
|
||||
height: 42px;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #ffffff;
|
||||
background-color: #1e2226;
|
||||
}
|
||||
|
||||
.canvas-app-container {
|
||||
background: rgba(250,252,255,1);
|
||||
background: -moz-linear-gradient(-45deg, rgba(250,252,255,1) 0%, rgba(250,252,255,1) 50%, rgba(245,249,255,1) 50%, rgba(245,249,255,1) 100%);
|
||||
background: -webkit-gradient(left top, right bottom, color-stop(0%, rgba(250,252,255,1)), color-stop(50%, rgba(250,252,255,1)), color-stop(50%, rgba(245,249,255,1)), color-stop(100%, rgba(245,249,255,1)));
|
||||
background: -webkit-linear-gradient(-45deg, rgba(250,252,255,1) 0%, rgba(250,252,255,1) 50%, rgba(245,249,255,1) 50%, rgba(245,249,255,1) 100%);
|
||||
background: -o-linear-gradient(-45deg, rgba(250,252,255,1) 0%, rgba(250,252,255,1) 50%, rgba(245,249,255,1) 50%, rgba(245,249,255,1) 100%);
|
||||
background: -ms-linear-gradient(-45deg, rgba(250,252,255,1) 0%, rgba(250,252,255,1) 50%, rgba(245,249,255,1) 50%, rgba(245,249,255,1) 100%);
|
||||
background: linear-gradient(135deg, rgba(250,252,255,1) 0%, rgba(250,252,255,1) 50%, rgba(245,249,255,1) 50%, rgba(245,249,255,1) 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fafcff', endColorstr='#f5f9ff', GradientType=1 );
|
||||
background: rgba(36,41,46,1);
|
||||
background: -moz-linear-gradient(-45deg, rgba(36,41,46,1) 0%, rgba(36,41,46,1) 49%, rgba(38,43,49,1) 50%, rgba(38,43,49,1) 100%);
|
||||
background: -webkit-gradient(left top, right bottom, color-stop(0%, rgba(36,41,46,1)), color-stop(49%, rgba(36,41,46,1)), color-stop(50%, rgba(38,43,49,1)), color-stop(100%, rgba(38,43,49,1)));
|
||||
background: -webkit-linear-gradient(-45deg, rgba(36,41,46,1) 0%, rgba(36,41,46,1) 49%, rgba(38,43,49,1) 50%, rgba(38,43,49,1) 100%);
|
||||
background: -o-linear-gradient(-45deg, rgba(36,41,46,1) 0%, rgba(36,41,46,1) 49%, rgba(38,43,49,1) 50%, rgba(38,43,49,1) 100%);
|
||||
background: -ms-linear-gradient(-45deg, rgba(36,41,46,1) 0%, rgba(36,41,46,1) 49%, rgba(38,43,49,1) 50%, rgba(38,43,49,1) 100%);
|
||||
background: linear-gradient(135deg, rgba(36,41,46,1) 0%, rgba(36,41,46,1) 49%, rgba(38,43,49,1) 50%, rgba(38,43,49,1) 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#24292e', endColorstr='#262b31', GradientType=1 );
|
||||
}
|
||||
|
||||
.canvas-app-canvas {
|
||||
background-repeat:no-repeat;
|
||||
background-position: center center;
|
||||
background-size: contain;
|
||||
background-image: url("druid_logo.png");
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="running-from-file-warning" style="display: none; margin: 3em;">
|
||||
<h1>Running from local file ⚠️</h1>
|
||||
<p>It seems like you have opened this file by double-clicking on it. In order to test your build in a browser <b>you need to load this file from a web server</b>. You can either upload this file and the rest of the files from a Defold HTML5 bundle to a web hosting service OR host them using a local web server on your home network.</p>
|
||||
<p><a href="https://defold.com/manuals/html5/#testing-html5-build" target="_blank">Learn more about running a local web server in the Defold HTML5 manual</a>.</p>
|
||||
</div>
|
||||
|
||||
<div id="app-container" class="canvas-app-container">
|
||||
<div id="running-from-file-warning" style="display: none; margin: 3em;">
|
||||
<h1>Running from local file ⚠️</h1>
|
||||
<p>It seems like you have opened this file by double-clicking on it. In order to test your build in a browser <b>you need to load this file from a web server</b>. You can either upload this file and the rest of the files from a Defold HTML5 bundle to a web hosting service OR host them using a local web server on your home network.</p>
|
||||
<p><a href="https://defold.com/manuals/html5/#testing-html5-build" target="_blank">Learn more about running a local web server in the Defold HTML5 manual</a>.</p>
|
||||
</div>
|
||||
<div id="webgl-not-supported" style="display: none; margin: 3em;">
|
||||
<h1>WebGL not supported ⚠️</h1>
|
||||
<p>WebGL is not supported by your browser - visit <a href="https://get.webgl.org/">https://get.webgl.org/</a> to learn more.</p>
|
||||
</div>
|
||||
<div id="canvas-container" class="canvas-app-canvas-container">
|
||||
<canvas id="canvas" class="canvas-app-canvas" tabindex="1" width="600" height="900"></canvas>
|
||||
<canvas id="canvas" class="canvas-app-canvas" tabindex="1" width="1920" height="1080"></canvas>
|
||||
</div>
|
||||
<div class="buttons-background">
|
||||
</div>
|
||||
</div>
|
||||
<!-- -->
|
||||
<script id='engine-loader' type='text/javascript' src="dmloader.js"></script>
|
||||
<!-- -->
|
||||
<script id='engine-setup' type='text/javascript'>
|
||||
var extra_params = {
|
||||
archive_location_filter: function( path ) {
|
||||
return ("archive" + path + "");
|
||||
},
|
||||
engine_arguments: ["--verify-graphics-calls=false",],
|
||||
custom_heap_size: 67108864,
|
||||
full_screen_container: "#canvas-container",
|
||||
disable_context_menu: true
|
||||
}
|
||||
|
||||
Module['INITIAL_MEMORY'] = extra_params.custom_heap_size;
|
||||
|
||||
Module['onRuntimeInitialized'] = function() {
|
||||
Module.runApp("canvas", extra_params);
|
||||
};
|
||||
|
||||
Module["locateFile"] = function(path, scriptDirectory)
|
||||
{
|
||||
// dmengine*.wasm is hardcoded in the built JS loader for WASM,
|
||||
// we need to replace it here with the correct project name.
|
||||
if (path == "dmengine.wasm" || path == "dmengine_release.wasm" || path == "dmengine_headless.wasm") {
|
||||
path = "druid.wasm";
|
||||
}
|
||||
return scriptDirectory + path;
|
||||
};
|
||||
|
||||
var is_iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
||||
var buttonHeight = 0;
|
||||
var prevInnerWidth = -1;
|
||||
var prevInnerHeight = -1;
|
||||
function resize_game_canvas() {
|
||||
// Hack for iOS when exit from Fullscreen mode
|
||||
if (is_iOS) {
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
|
||||
var app_container = document.getElementById('app-container');
|
||||
var game_canvas = document.getElementById('canvas');
|
||||
var innerWidth = window.innerWidth;
|
||||
var innerHeight = window.innerHeight - buttonHeight;
|
||||
if (prevInnerWidth == innerWidth && prevInnerHeight == innerHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
prevInnerWidth = innerWidth;
|
||||
prevInnerHeight = innerHeight;
|
||||
var width = 600;
|
||||
var height = 900;
|
||||
var targetRatio = width / height;
|
||||
var actualRatio = innerWidth / innerHeight;
|
||||
|
||||
|
||||
|
||||
//Fit
|
||||
if (actualRatio > targetRatio) {
|
||||
width = innerHeight * targetRatio;
|
||||
height = innerHeight;
|
||||
app_container.style.marginLeft = ((innerWidth - width) / 2) + "px";
|
||||
app_container.style.marginTop = "0px";
|
||||
}
|
||||
else {
|
||||
width = innerWidth;
|
||||
height = innerWidth / targetRatio;
|
||||
app_container.style.marginLeft = "0px";
|
||||
app_container.style.marginTop = ((innerHeight - height) / 2) + "px";
|
||||
}
|
||||
|
||||
|
||||
app_container.style.width = width + "px";
|
||||
app_container.style.height = height + buttonHeight + "px";
|
||||
game_canvas.width = width;
|
||||
game_canvas.height = height;
|
||||
}
|
||||
resize_game_canvas();
|
||||
window.addEventListener('resize', resize_game_canvas, false);
|
||||
window.addEventListener('orientationchange', resize_game_canvas, false);
|
||||
window.addEventListener('focus', resize_game_canvas, false);
|
||||
</script>
|
||||
|
||||
<script id='engine-start' type='text/javascript'>
|
||||
var runningFromFileWarning = document.getElementById("running-from-file-warning");
|
||||
@@ -224,7 +150,6 @@
|
||||
runningFromFileWarning.style.display = "block";
|
||||
}
|
||||
else {
|
||||
EngineLoader.stream_wasm = "false" === "true";
|
||||
EngineLoader.load("canvas", "druid");
|
||||
runningFromFileWarning.parentNode.removeChild(runningFromFileWarning);
|
||||
}
|
||||
|
||||
@@ -40,13 +40,10 @@
|
||||
<li><a href="modules/StaticGrid.html">StaticGrid</a></li>
|
||||
<li><a href="modules/Text.html">Text</a></li>
|
||||
<li><a href="modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="modules/RichText.html">RichText</a></li>
|
||||
<li><a href="modules/Druid.html">Druid</a></li>
|
||||
<li><a href="modules/DruidEvent.html">DruidEvent</a></li>
|
||||
<li><a href="modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="modules/DataList.html">DataList</a></li>
|
||||
<li><a href="modules/DynamicGrid.html">DynamicGrid</a></li>
|
||||
<li><a href="modules/Hotkey.html">Hotkey</a></li>
|
||||
@@ -54,7 +51,6 @@
|
||||
<li><a href="modules/LangText.html">LangText</a></li>
|
||||
<li><a href="modules/Layout.html">Layout</a></li>
|
||||
<li><a href="modules/Progress.html">Progress</a></li>
|
||||
<li><a href="modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="modules/Slider.html">Slider</a></li>
|
||||
<li><a href="modules/Swipe.html">Swipe</a></li>
|
||||
<li><a href="modules/Timer.html">Timer</a></li>
|
||||
@@ -109,10 +105,6 @@
|
||||
<td class="name" nowrap><a href="modules/BaseComponent.html">BaseComponent</a></td>
|
||||
<td class="summary">Basic class for all Druid components.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/PinKnob.html">PinKnob</a></td>
|
||||
<td class="summary">Druid pin knob custom component.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/RichInput.html">RichInput</a></td>
|
||||
<td class="summary">Druid Rich Input custom component.</td>
|
||||
@@ -130,14 +122,6 @@
|
||||
<td class="summary">Druid Event Module
|
||||
<p> The Event module provides a simple class for handling callbacks.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/Checkbox.html">Checkbox</a></td>
|
||||
<td class="summary">Druid checkbox component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/CheckboxGroup.html">CheckboxGroup</a></td>
|
||||
<td class="summary">Checkbox group module</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/DataList.html">DataList</a></td>
|
||||
<td class="summary">Component to manage data for huge dataset in scroll.</td>
|
||||
@@ -169,10 +153,6 @@
|
||||
<td class="name" nowrap><a href="modules/Progress.html">Progress</a></td>
|
||||
<td class="summary">Druid component to handle the progress bars.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/RadioGroup.html">RadioGroup</a></td>
|
||||
<td class="summary">Radio group module</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/Slider.html">Slider</a></td>
|
||||
<td class="summary">Druid slider component</td>
|
||||
|
||||
@@ -42,8 +42,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -56,9 +54,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -147,9 +143,8 @@ local back_handler = self.druid:new_back_handler(callback, [params])
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">params</span>
|
||||
<span class="types"><span class="type">any</span></span>
|
||||
<span class="types"><span class="type">any</span> or <span class="type">nil</span></span>
|
||||
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -42,8 +42,6 @@
|
||||
<li><strong>BaseComponent</strong></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -56,9 +54,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -98,67 +94,67 @@ return AwesomeComponent
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#component:get_childrens">component:get_childrens(self)</a></td>
|
||||
<td class="name" nowrap><a href="#get_childrens">get_childrens(self)</a></td>
|
||||
<td class="summary">Return all children components, recursive</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#component:get_context">component:get_context(self)</a></td>
|
||||
<td class="name" nowrap><a href="#get_context">get_context(self)</a></td>
|
||||
<td class="summary">Context used as first arg in all Druid events</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#component:get_druid">component:get_druid(self)</a></td>
|
||||
<td class="name" nowrap><a href="#get_druid">get_druid(self, template, nodes)</a></td>
|
||||
<td class="summary">Get Druid instance for inner component creation.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#component:get_input_priority">component:get_input_priority(self)</a></td>
|
||||
<td class="name" nowrap><a href="#get_input_priority">get_input_priority(self)</a></td>
|
||||
<td class="summary">Return component input priority</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#component:get_name">component:get_name(self)</a></td>
|
||||
<td class="name" nowrap><a href="#get_name">get_name(self)</a></td>
|
||||
<td class="summary">Return component name</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#component:get_node">component:get_node(self, node_or_name)</a></td>
|
||||
<td class="name" nowrap><a href="#get_node">get_node(self, node_or_name)</a></td>
|
||||
<td class="summary">Get component node by name.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#component:get_parent_component">component:get_parent_component(self)</a></td>
|
||||
<td class="name" nowrap><a href="#get_parent_component">get_parent_component(self)</a></td>
|
||||
<td class="summary">Return the parent component if exist</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#component:get_parent_name">component:get_parent_name(self)</a></td>
|
||||
<td class="name" nowrap><a href="#get_parent_name">get_parent_name(self)</a></td>
|
||||
<td class="summary">Return parent component name</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#component:get_template">component:get_template(self)</a></td>
|
||||
<td class="name" nowrap><a href="#get_template">get_template(self)</a></td>
|
||||
<td class="summary">Get current component template name.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#component:get_uid">component:get_uid(self)</a></td>
|
||||
<td class="name" nowrap><a href="#get_uid">get_uid(self)</a></td>
|
||||
<td class="summary">Return component UID.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#component:reset_input_priority">component:reset_input_priority(self)</a></td>
|
||||
<td class="name" nowrap><a href="#reset_input_priority">reset_input_priority(self)</a></td>
|
||||
<td class="summary">Reset component input priority to default value</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#component:set_input_enabled">component:set_input_enabled(self, state)</a></td>
|
||||
<td class="name" nowrap><a href="#set_input_enabled">set_input_enabled(self, state)</a></td>
|
||||
<td class="summary">Set component input state.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#component:set_input_priority">component:set_input_priority(self, value, is_temporary)</a></td>
|
||||
<td class="name" nowrap><a href="#set_input_priority">set_input_priority(self, value, is_temporary)</a></td>
|
||||
<td class="summary">Set component input priority</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#component:set_nodes">component:set_nodes(self, nodes)</a></td>
|
||||
<td class="name" nowrap><a href="#set_nodes">set_nodes(self, nodes)</a></td>
|
||||
<td class="summary">Set current component nodes.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#component:set_style">component:set_style(self, druid_style)</a></td>
|
||||
<td class="name" nowrap><a href="#set_style">set_style(self, druid_style)</a></td>
|
||||
<td class="summary">Set current component style table.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#component:set_template">component:set_template(self, template)</a></td>
|
||||
<td class="name" nowrap><a href="#set_template">set_template(self, template)</a></td>
|
||||
<td class="summary">Set component template name.</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -171,8 +167,8 @@ return AwesomeComponent
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "component:get_childrens"></a>
|
||||
<strong>component:get_childrens(self)</strong>
|
||||
<a name = "get_childrens"></a>
|
||||
<strong>get_childrens(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Return all children components, recursive
|
||||
@@ -198,8 +194,8 @@ return AwesomeComponent
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "component:get_context"></a>
|
||||
<strong>component:get_context(self)</strong>
|
||||
<a name = "get_context"></a>
|
||||
<strong>get_context(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Context used as first arg in all Druid events Context is usually self of gui_script.
|
||||
@@ -225,8 +221,8 @@ return AwesomeComponent
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "component:get_druid"></a>
|
||||
<strong>component:get_druid(self)</strong>
|
||||
<a name = "get_druid"></a>
|
||||
<strong>get_druid(self, template, nodes)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Get Druid instance for inner component creation.
|
||||
@@ -238,12 +234,20 @@ return AwesomeComponent
|
||||
<span class="types"><span class="type">BaseComponent</span></span>
|
||||
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
||||
</li>
|
||||
<li><span class="parameter">template</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
The template name
|
||||
</li>
|
||||
<li><span class="parameter">nodes</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a> or <span class="type">nil</span></span>
|
||||
The nodes table
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Druid</span></span>
|
||||
<span class="types"><span class="type">DruidInstance</span></span>
|
||||
Druid instance with component context
|
||||
</ol>
|
||||
|
||||
@@ -252,8 +256,8 @@ return AwesomeComponent
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "component:get_input_priority"></a>
|
||||
<strong>component:get_input_priority(self)</strong>
|
||||
<a name = "get_input_priority"></a>
|
||||
<strong>get_input_priority(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Return component input priority
|
||||
@@ -279,8 +283,8 @@ return AwesomeComponent
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "component:get_name"></a>
|
||||
<strong>component:get_name(self)</strong>
|
||||
<a name = "get_name"></a>
|
||||
<strong>get_name(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Return component name
|
||||
@@ -306,8 +310,8 @@ return AwesomeComponent
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "component:get_node"></a>
|
||||
<strong>component:get_node(self, node_or_name)</strong>
|
||||
<a name = "get_node"></a>
|
||||
<strong>get_node(self, node_or_name)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Get component node by name.
|
||||
@@ -341,8 +345,8 @@ return AwesomeComponent
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "component:get_parent_component"></a>
|
||||
<strong>component:get_parent_component(self)</strong>
|
||||
<a name = "get_parent_component"></a>
|
||||
<strong>get_parent_component(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Return the parent component if exist
|
||||
@@ -368,8 +372,8 @@ return AwesomeComponent
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "component:get_parent_name"></a>
|
||||
<strong>component:get_parent_name(self)</strong>
|
||||
<a name = "get_parent_name"></a>
|
||||
<strong>get_parent_name(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Return parent component name
|
||||
@@ -395,8 +399,8 @@ return AwesomeComponent
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "component:get_template"></a>
|
||||
<strong>component:get_template(self)</strong>
|
||||
<a name = "get_template"></a>
|
||||
<strong>get_template(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Get current component template name.
|
||||
@@ -422,8 +426,8 @@ return AwesomeComponent
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "component:get_uid"></a>
|
||||
<strong>component:get_uid(self)</strong>
|
||||
<a name = "get_uid"></a>
|
||||
<strong>get_uid(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Return component UID.
|
||||
@@ -450,8 +454,8 @@ return AwesomeComponent
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "component:reset_input_priority"></a>
|
||||
<strong>component:reset_input_priority(self)</strong>
|
||||
<a name = "reset_input_priority"></a>
|
||||
<strong>reset_input_priority(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Reset component input priority to default value
|
||||
@@ -477,8 +481,8 @@ return AwesomeComponent
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "component:set_input_enabled"></a>
|
||||
<strong>component:set_input_enabled(self, state)</strong>
|
||||
<a name = "set_input_enabled"></a>
|
||||
<strong>set_input_enabled(self, state)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set component input state. By default it enabled
|
||||
@@ -492,7 +496,7 @@ return AwesomeComponent
|
||||
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
||||
</li>
|
||||
<li><span class="parameter">state</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
The component input state
|
||||
</li>
|
||||
</ul>
|
||||
@@ -509,8 +513,8 @@ return AwesomeComponent
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "component:set_input_priority"></a>
|
||||
<strong>component:set_input_priority(self, value, is_temporary)</strong>
|
||||
<a name = "set_input_priority"></a>
|
||||
<strong>set_input_priority(self, value, is_temporary)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set component input priority Default value: 10
|
||||
@@ -527,7 +531,7 @@ return AwesomeComponent
|
||||
The new input priority value
|
||||
</li>
|
||||
<li><span class="parameter">is_temporary</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
If true, the reset input priority will return to previous value
|
||||
</li>
|
||||
</ul>
|
||||
@@ -544,8 +548,8 @@ return AwesomeComponent
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "component:set_nodes"></a>
|
||||
<strong>component:set_nodes(self, nodes)</strong>
|
||||
<a name = "set_nodes"></a>
|
||||
<strong>set_nodes(self, nodes)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set current component nodes.
|
||||
@@ -582,8 +586,8 @@ self:set_nodes(nodes)</pre>
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "component:set_style"></a>
|
||||
<strong>component:set_style(self, druid_style)</strong>
|
||||
<a name = "set_style"></a>
|
||||
<strong>set_style(self, druid_style)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set current component style table.
|
||||
@@ -598,7 +602,7 @@ self:set_nodes(nodes)</pre>
|
||||
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
||||
</li>
|
||||
<li><span class="parameter">druid_style</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a> or <span class="type">nil</span></span>
|
||||
Druid style module
|
||||
</li>
|
||||
</ul>
|
||||
@@ -615,8 +619,8 @@ self:set_nodes(nodes)</pre>
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "component:set_template"></a>
|
||||
<strong>component:set_template(self, template)</strong>
|
||||
<a name = "set_template"></a>
|
||||
<strong>set_template(self, template)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set component template name.
|
||||
|
||||
@@ -43,8 +43,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><strong>Blocker</strong></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -57,9 +55,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -95,7 +91,7 @@ local blocker = self.druid:new_blocker(node)
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, node)</a></td>
|
||||
<td class="summary"><a href="../modules/Blocker.html#">Blocker</a> constructor</td>
|
||||
<td class="summary">The <a href="../modules/Blocker.html#">Blocker</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#is_enabled">is_enabled(self)</a></td>
|
||||
@@ -126,7 +122,7 @@ local blocker = self.druid:new_blocker(node)
|
||||
<strong>init(self, node)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
<a href="../modules/Blocker.html#">Blocker</a> constructor
|
||||
The <a href="../modules/Blocker.html#">Blocker</a> constructor
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -165,8 +161,8 @@ local blocker = self.druid:new_blocker(node)
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
True, if blocker is enabled
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
@True, if blocker is enabled
|
||||
</ol>
|
||||
|
||||
|
||||
@@ -189,7 +185,7 @@ local blocker = self.druid:new_blocker(node)
|
||||
<a href="../modules/Blocker.html#">Blocker</a>
|
||||
</li>
|
||||
<li><span class="parameter">state</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
Enabled state
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -44,8 +44,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><strong>Button</strong></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -58,9 +56,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -110,7 +106,7 @@ local button = self.druid:new_button("button_name", on_button_click, c
|
||||
<td class="summary">Get current key name to trigger this button.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, callback[, custom_args[, anim_node]])</a></td>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, callback, custom_args, anim_node)</a></td>
|
||||
<td class="summary">The <a href="../modules/Button.html#">Button</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -118,7 +114,7 @@ local button = self.druid:new_button("button_name", on_button_click, c
|
||||
<td class="summary">Get button enabled state.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_check_function">set_check_function(self[, check_function[, failure_callback]])</a></td>
|
||||
<td class="name" nowrap><a href="#set_check_function">set_check_function(self, check_function, failure_callback)</a></td>
|
||||
<td class="summary">Set function for additional check for button click availability</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -134,7 +130,7 @@ local button = self.druid:new_button("button_name", on_button_click, c
|
||||
<td class="summary">Set key name to trigger this button by keyboard.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_web_user_interaction">set_web_user_interaction(self[, is_web_mode])</a></td>
|
||||
<td class="name" nowrap><a href="#set_web_user_interaction">set_web_user_interaction(self, is_web_mode)</a></td>
|
||||
<td class="summary">Set Button mode to work inside user HTML5 interaction event.</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -153,7 +149,7 @@ local button = self.druid:new_button("button_name", on_button_click, c
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#click_zone">click_zone</a></td>
|
||||
<td class="summary">Additional button click area, defined by another GUI Node</td>
|
||||
<td class="summary">Additional button click area, defined by another GUI node</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#hover">hover</a></td>
|
||||
@@ -241,7 +237,7 @@ local button = self.druid:new_button("button_name", on_button_click, c
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, node, callback[, custom_args[, anim_node]])</strong>
|
||||
<strong>init(self, node, callback, custom_args, anim_node)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The <a href="../modules/Button.html#">Button</a> constructor
|
||||
@@ -254,22 +250,20 @@ local button = self.druid:new_button("button_name", on_button_click, c
|
||||
<a href="../modules/Button.html#">Button</a>
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">Node</span></span>
|
||||
Node name or GUI Node itself
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <a class="type" href="../modules/Button.html#node">node</a></span>
|
||||
The node_id or gui.get_node(node_id)
|
||||
</li>
|
||||
<li><span class="parameter">callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
On click button callback
|
||||
</li>
|
||||
<li><span class="parameter">custom_args</span>
|
||||
<span class="types"><span class="type">any</span></span>
|
||||
<span class="types"><span class="type">any</span> or <span class="type">nil</span></span>
|
||||
Button events custom arguments
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">anim_node</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">Node</span></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a>, <a class="type" href="../modules/Button.html#node">node</a> or <span class="type">nil</span></span>
|
||||
Node to animate instead of trigger node.
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -298,8 +292,8 @@ local button = self.druid:new_button("button_name", on_button_click, c
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
True, if button is enabled now, False overwise
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
@True, if button is enabled now, False overwise
|
||||
</ol>
|
||||
|
||||
|
||||
@@ -312,7 +306,7 @@ local button = self.druid:new_button("button_name", on_button_click, c
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_check_function"></a>
|
||||
<strong>set_check_function(self[, check_function[, failure_callback]])</strong>
|
||||
<strong>set_check_function(self, check_function, failure_callback)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set function for additional check for button click availability
|
||||
@@ -325,14 +319,12 @@ local button = self.druid:new_button("button_name", on_button_click, c
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">check_function</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
<span class="types"><span class="type">function</span> or <span class="type">nil</span></span>
|
||||
Should return true or false. If true - button can be pressed.
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">failure_callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
<span class="types"><span class="type">function</span> or <span class="type">nil</span></span>
|
||||
Function will be called on button click, if check function return false
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -364,7 +356,7 @@ local button = self.druid:new_button("button_name", on_button_click, c
|
||||
<a href="../modules/Button.html#">Button</a>
|
||||
</li>
|
||||
<li><span class="parameter">zone</span>
|
||||
<span class="types"><a class="type" href="../modules/Button.html#node">node</a></span>
|
||||
<span class="types"><a class="type" href="../modules/Button.html#node">node</a>, <a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Gui node
|
||||
</li>
|
||||
</ul>
|
||||
@@ -401,7 +393,7 @@ local button = self.druid:new_button("button_name", on_button_click, c
|
||||
<a href="../modules/Button.html#">Button</a>
|
||||
</li>
|
||||
<li><span class="parameter">state</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
Enabled state
|
||||
</li>
|
||||
</ul>
|
||||
@@ -437,7 +429,7 @@ button:set_enabled(<span class="keyword">true</span>)</pre>
|
||||
<a href="../modules/Button.html#">Button</a>
|
||||
</li>
|
||||
<li><span class="parameter">key</span>
|
||||
<span class="types"><span class="type">hash</span></span>
|
||||
<span class="types"><span class="type">hash</span> or <a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
The action_id of the input key
|
||||
</li>
|
||||
</ul>
|
||||
@@ -459,7 +451,7 @@ button:set_enabled(<span class="keyword">true</span>)</pre>
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_web_user_interaction"></a>
|
||||
<strong>set_web_user_interaction(self[, is_web_mode])</strong>
|
||||
<strong>set_web_user_interaction(self, is_web_mode)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set Button mode to work inside user HTML5 interaction event.
|
||||
@@ -475,9 +467,8 @@ button:set_enabled(<span class="keyword">true</span>)</pre>
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">is_web_mode</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
If true - button will be called inside html5 callback
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -513,39 +504,36 @@ button:set_enabled(<span class="keyword">true</span>)</pre>
|
||||
<h3>Fields:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">LONGTAP_TIME</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Minimum time to trigger on_hold_callback
|
||||
(<em>default</em> 0.4)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Minimum time to trigger on_hold_callback. Default: 0.4
|
||||
</li>
|
||||
<li><span class="parameter">AUTOHOLD_TRIGGER</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Maximum hold time to trigger button release while holding
|
||||
(<em>default</em> 0.8)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Maximum hold time to trigger button release while holding. Default: 0.8
|
||||
</li>
|
||||
<li><span class="parameter">DOUBLETAP_TIME</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Time between double taps
|
||||
(<em>default</em> 0.4)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Time between double taps. Default: 0.4
|
||||
</li>
|
||||
<li><span class="parameter">on_click</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
(self, node)
|
||||
function(self, node)
|
||||
</li>
|
||||
<li><span class="parameter">on_click_disabled</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
(self, node)
|
||||
function(self, node)
|
||||
</li>
|
||||
<li><span class="parameter">on_hover</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
(self, node, hover_state)
|
||||
function(self, node, hover_state)
|
||||
</li>
|
||||
<li><span class="parameter">on_mouse_hover</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
(self, node, hover_state)
|
||||
function(self, node, hover_state)
|
||||
</li>
|
||||
<li><span class="parameter">on_set_enabled</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
(self, node, enabled_state)
|
||||
function(self, node, enabled_state)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -570,9 +558,8 @@ button:set_enabled(<span class="keyword">true</span>)</pre>
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">anim_node</span>
|
||||
<span class="types"><a class="type" href="../modules/Button.html#node">node</a></span>
|
||||
|
||||
(<em>default</em> node)
|
||||
<span class="types"><a class="type" href="../modules/Button.html#node">node</a> or <span class="type">nil</span></span>
|
||||
Default node
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -586,14 +573,13 @@ button:set_enabled(<span class="keyword">true</span>)</pre>
|
||||
<strong>click_zone</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Additional button click area, defined by another GUI Node
|
||||
Additional button click area, defined by another GUI node
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">click_zone</span>
|
||||
<span class="types"><a class="type" href="../modules/Button.html#node">node</a></span>
|
||||
<span class="types"><a class="type" href="../modules/Button.html#node">node</a> or <span class="type">nil</span></span>
|
||||
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -632,7 +618,7 @@ button:set_enabled(<span class="keyword">true</span>)</pre>
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><span class="type">Node</span></span>
|
||||
<span class="types"><a class="type" href="../modules/Button.html#node">node</a></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -58,7 +58,6 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
@@ -87,8 +86,8 @@
|
||||
<td class="summary">Return checkbox state</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, callback[, click_node=node[, initial_state=false]])</a></td>
|
||||
<td class="summary">Component init function</td>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, callback, click_node, initial_state)</a></td>
|
||||
<td class="summary">The <a href="../modules/Checkbox.html#">Checkbox</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_state">set_state(self, state, is_silent, is_instant)</a></td>
|
||||
@@ -148,7 +147,7 @@
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
Checkbox state
|
||||
</ol>
|
||||
|
||||
@@ -158,10 +157,10 @@
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, node, callback[, click_node=node[, initial_state=false]])</strong>
|
||||
<strong>init(self, node, callback, click_node, initial_state)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Component init function
|
||||
The <a href="../modules/Checkbox.html#">Checkbox</a> constructor
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -179,14 +178,12 @@
|
||||
Checkbox callback
|
||||
</li>
|
||||
<li><span class="parameter">click_node</span>
|
||||
<span class="types"><a class="type" href="../modules/Checkbox.html#node">node</a></span>
|
||||
Trigger node, by default equals to node
|
||||
(<em>default</em> node)
|
||||
<span class="types"><a class="type" href="../modules/Checkbox.html#node">node</a> or <span class="type">nil</span></span>
|
||||
Trigger node, by default equals to node. Default: node
|
||||
</li>
|
||||
<li><span class="parameter">initial_state</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
The initial state of checkbox, default - false
|
||||
(<em>default</em> false)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -210,15 +207,15 @@
|
||||
<a href="../modules/Checkbox.html#">Checkbox</a>
|
||||
</li>
|
||||
<li><span class="parameter">state</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
Checkbox state
|
||||
</li>
|
||||
<li><span class="parameter">is_silent</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
Don't trigger on_change_state if true
|
||||
</li>
|
||||
<li><span class="parameter">is_instant</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
If instant checkbox change
|
||||
</li>
|
||||
</ul>
|
||||
@@ -289,9 +286,8 @@
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">click_node</span>
|
||||
<span class="types"><a class="type" href="../modules/Checkbox.html#node">node</a></span>
|
||||
<span class="types"><a class="type" href="../modules/Checkbox.html#node">node</a> or <span class="type">nil</span></span>
|
||||
|
||||
(<em>default</em> node)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -57,7 +57,6 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
@@ -86,8 +85,8 @@
|
||||
<td class="summary">Return checkbox group state</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, nodes, callback[, click_nodes=node])</a></td>
|
||||
<td class="summary">Component init function</td>
|
||||
<td class="name" nowrap><a href="#init">init(self, nodes, callback, click_nodes)</a></td>
|
||||
<td class="summary">The <a href="../modules/CheckboxGroup.html#">CheckboxGroup</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_state">set_state(self, indexes, is_instant)</a></td>
|
||||
@@ -132,7 +131,7 @@
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">bool[]</span></span>
|
||||
<span class="types"><span class="type">boolean[]</span></span>
|
||||
Array if checkboxes state
|
||||
</ol>
|
||||
|
||||
@@ -142,10 +141,10 @@
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, nodes, callback[, click_nodes=node])</strong>
|
||||
<strong>init(self, nodes, callback, click_nodes)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Component init function
|
||||
The <a href="../modules/CheckboxGroup.html#">CheckboxGroup</a> constructor
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -163,9 +162,8 @@
|
||||
Checkbox callback
|
||||
</li>
|
||||
<li><span class="parameter">click_nodes</span>
|
||||
<span class="types"><span class="type">node[]</span></span>
|
||||
<span class="types"><span class="type">node[]</span> or <span class="type">nil</span></span>
|
||||
Array of trigger nodes, by default equals to nodes
|
||||
(<em>default</em> node)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -189,11 +187,11 @@
|
||||
<a href="../modules/CheckboxGroup.html#">CheckboxGroup</a>
|
||||
</li>
|
||||
<li><span class="parameter">indexes</span>
|
||||
<span class="types"><span class="type">bool[]</span></span>
|
||||
<span class="types"><span class="type">boolean[]</span></span>
|
||||
Array of checkbox state
|
||||
</li>
|
||||
<li><span class="parameter">is_instant</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
If instant state change
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -43,8 +43,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><strong>DataList</strong></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -57,9 +55,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -83,6 +79,10 @@
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#add">add(self, data, index, shift_policy)</a></td>
|
||||
<td class="summary">Add element to DataList.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#clear">clear(self)</a></td>
|
||||
<td class="summary">Clear the DataList and refresh visuals</td>
|
||||
@@ -100,30 +100,26 @@
|
||||
<td class="summary">Return current data from DataList component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_first_index">get_first_index(self)</a></td>
|
||||
<td class="summary">Return first index from data.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_index">get_index(self, data)</a></td>
|
||||
<td class="summary">Return index for data value</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_last_index">get_last_index(self)</a></td>
|
||||
<td class="summary">Return last index from data</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_length">get_length(self)</a></td>
|
||||
<td class="summary">Return amount of data</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, scroll, grid, create_function)</a></td>
|
||||
<td class="summary">Data list constructor</td>
|
||||
<td class="summary">The <a href="../modules/DataList.html#">DataList</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_remove">on_remove(self)</a></td>
|
||||
<td class="summary">Druid System on_remove function</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#remove">remove(self, index, shift_policy)</a></td>
|
||||
<td class="summary">Remove element from DataList.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#remove_by_data">remove_by_data(self, data, shift_policy)</a></td>
|
||||
<td class="summary">Remove element from DataList by data value.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#scroll_to_index">scroll_to_index(self, index)</a></td>
|
||||
<td class="summary">Instant scroll to element with passed index</td>
|
||||
</tr>
|
||||
@@ -131,6 +127,10 @@
|
||||
<td class="name" nowrap><a href="#set_data">set_data(self, data)</a></td>
|
||||
<td class="summary">Set new data set for DataList component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_use_cache">set_use_cache(self, is_use_cache)</a></td>
|
||||
<td class="summary">Set refresh function for DataList component</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Fields">Fields</a></h2>
|
||||
<table class="function_list">
|
||||
@@ -140,7 +140,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#last_index">last_index</a></td>
|
||||
<td class="summary">The current visual last data index</td>
|
||||
<td class="summary">The current last index of visual elements</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_element_add">on_element_add</a></td>
|
||||
@@ -164,7 +164,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#top_index">top_index</a></td>
|
||||
<td class="summary">The current visual top data index</td>
|
||||
<td class="summary">The current top index of visual elements</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -175,6 +175,39 @@
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "add"></a>
|
||||
<strong>add(self, data, index, shift_policy)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Add element to DataList. Currenly untested
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">DataList</span></span>
|
||||
<a href="../modules/DataList.html#">DataList</a>
|
||||
</li>
|
||||
<li><span class="parameter">data</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">index</span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">shift_policy</span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
The constant from const.SHIFT.*
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "clear"></a>
|
||||
<strong>clear(self)</strong>
|
||||
@@ -242,7 +275,7 @@
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Node[]</span></span>
|
||||
<span class="types"><span class="type">node[]</span></span>
|
||||
List of created nodes
|
||||
</ol>
|
||||
|
||||
@@ -276,27 +309,6 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_first_index"></a>
|
||||
<strong>get_first_index(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Return first index from data. It not always equals to 1
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">DataList</span></span>
|
||||
<a href="../modules/DataList.html#">DataList</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_index"></a>
|
||||
@@ -322,55 +334,13 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_last_index"></a>
|
||||
<strong>get_last_index(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Return last index from data
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">DataList</span></span>
|
||||
<a href="../modules/DataList.html#">DataList</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_length"></a>
|
||||
<strong>get_length(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Return amount of data
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">DataList</span></span>
|
||||
<a href="../modules/DataList.html#">DataList</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, scroll, grid, create_function)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Data list constructor
|
||||
The <a href="../modules/DataList.html#">DataList</a> constructor
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -384,7 +354,7 @@
|
||||
The <a href="../modules/Scroll.html#">Scroll</a> instance for Data List component
|
||||
</li>
|
||||
<li><span class="parameter">grid</span>
|
||||
<span class="types"><span class="type">StaticGrid</span> or <span class="type">DynamicGrid</span></span>
|
||||
<span class="types"><span class="type">StaticGrid</span></span>
|
||||
The <a href="../modules/StaticGrid.html#">StaticGrid</a> or <a href="../modules/DynamicGrid.html#">DynamicGrid</a> instance for Data List component
|
||||
</li>
|
||||
<li><span class="parameter">create_function</span>
|
||||
@@ -418,6 +388,64 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "remove"></a>
|
||||
<strong>remove(self, index, shift_policy)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Remove element from DataList. Currenly untested
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">DataList</span></span>
|
||||
<a href="../modules/DataList.html#">DataList</a>
|
||||
</li>
|
||||
<li><span class="parameter">index</span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">shift_policy</span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
The constant from const.SHIFT.*
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "remove_by_data"></a>
|
||||
<strong>remove_by_data(self, data, shift_policy)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Remove element from DataList by data value. Currenly untested
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">DataList</span></span>
|
||||
<a href="../modules/DataList.html#">DataList</a>
|
||||
</li>
|
||||
<li><span class="parameter">data</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">shift_policy</span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
The constant from const.SHIFT.*
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "scroll_to_index"></a>
|
||||
@@ -474,6 +502,37 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_use_cache"></a>
|
||||
<strong>set_use_cache(self, is_use_cache)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set refresh function for DataList component
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">DataList</span></span>
|
||||
<a href="../modules/DataList.html#">DataList</a>
|
||||
</li>
|
||||
<li><span class="parameter">is_use_cache</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
Use cache version of DataList. Requires make setup of components in on_element_add callback and clean in on_element_remove
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">druid.data_list</span></span>
|
||||
Current DataList instance
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
|
||||
@@ -489,7 +548,7 @@
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">grid</span>
|
||||
<span class="types"><span class="type">StaticGrid</span> or <span class="type">DynamicGrid</span></span>
|
||||
<span class="types"><span class="type">StaticGrid</span></span>
|
||||
<a href="../modules/StaticGrid.html#">StaticGrid</a>, <a href="../modules/DynamicGrid.html#">DynamicGrid</a>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -504,7 +563,7 @@
|
||||
<strong>last_index</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The current visual last data index
|
||||
The current last index of visual elements
|
||||
|
||||
|
||||
<ul>
|
||||
@@ -624,7 +683,7 @@
|
||||
<strong>top_index</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The current visual top data index
|
||||
The current top index of visual elements
|
||||
|
||||
|
||||
<ul>
|
||||
|
||||
@@ -44,8 +44,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><strong>Drag</strong></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -58,9 +56,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -88,7 +84,7 @@
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, on_drag_callback)</a></td>
|
||||
<td class="summary">Drag component constructor</td>
|
||||
<td class="summary">The <a href="../modules/Drag.html#">Drag</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#is_enabled">is_enabled(self)</a></td>
|
||||
@@ -129,16 +125,20 @@
|
||||
<td class="summary">Is component now touching</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#node">node</a></td>
|
||||
<td class="summary">Drag node</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_drag">on_drag</a></td>
|
||||
<td class="summary">on drag progress callback(self, dx, dy, total_x, total_y)</td>
|
||||
<td class="summary">on drag progress callback(self, dx, dy, total_x, total_y, touch)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_drag_end">on_drag_end</a></td>
|
||||
<td class="summary">Event on drag end callback(self, total_x, total_y)</td>
|
||||
<td class="summary">Event on drag end callback(self, total_x, total_y, touch)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_drag_start">on_drag_start</a></td>
|
||||
<td class="summary">Event on drag start callback(self)</td>
|
||||
<td class="summary">Event on drag start callback(self, touch)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_touch_end">on_touch_end</a></td>
|
||||
@@ -149,6 +149,14 @@
|
||||
<td class="summary">Event on touch start callback(self)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#screen_x">screen_x</a></td>
|
||||
<td class="summary">Current touch x screen position</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#screen_y">screen_y</a></td>
|
||||
<td class="summary">Current touch y screen position</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#touch_start_pos">touch_start_pos</a></td>
|
||||
<td class="summary">Touch start position</td>
|
||||
</tr>
|
||||
@@ -174,7 +182,7 @@
|
||||
<strong>init(self, node, on_drag_callback)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Drag component constructor
|
||||
The <a href="../modules/Drag.html#">Drag</a> constructor
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -184,7 +192,7 @@
|
||||
<a href="../modules/Drag.html#">Drag</a>
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
<span class="types"><a class="type" href="../modules/Drag.html#node">node</a></span>
|
||||
GUI node to detect dragging
|
||||
</li>
|
||||
<li><span class="parameter">on_drag_callback</span>
|
||||
@@ -217,7 +225,7 @@
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
|
||||
</ol>
|
||||
|
||||
@@ -241,7 +249,7 @@
|
||||
<a href="../modules/Drag.html#">Drag</a>
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
<span class="types"><a class="type" href="../modules/Drag.html#node">node</a>, <a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Gui node
|
||||
</li>
|
||||
</ul>
|
||||
@@ -266,7 +274,7 @@
|
||||
<a href="../modules/Drag.html#">Drag</a>
|
||||
</li>
|
||||
<li><span class="parameter">is_enabled</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
@@ -293,14 +301,12 @@
|
||||
<h3>Fields:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">DRAG_DEADZONE</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Distance in pixels to start dragging
|
||||
(<em>default</em> 10)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Distance in pixels to start dragging. Default: 10
|
||||
</li>
|
||||
<li><span class="parameter">NO_USE_SCREEN_KOEF</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
If screen aspect ratio affects on drag values
|
||||
(<em>default</em> false)
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
If screen aspect ratio affects on drag values. Default: false
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -323,7 +329,7 @@
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">can_x</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
@@ -343,7 +349,7 @@
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">can_y</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
@@ -363,7 +369,7 @@
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">is_drag</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
@@ -383,7 +389,27 @@
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">is_touch</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "node"></a>
|
||||
<strong>node</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Drag node
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><a class="type" href="../modules/Drag.html#node">node</a></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
@@ -398,7 +424,7 @@
|
||||
<strong>on_drag</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
on drag progress callback(self, dx, dy, total_x, total_y)
|
||||
on drag progress callback(self, dx, dy, total_x, total_y, touch)
|
||||
|
||||
|
||||
<ul>
|
||||
@@ -418,7 +444,7 @@
|
||||
<strong>on_drag_end</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Event on drag end callback(self, total_x, total_y)
|
||||
Event on drag end callback(self, total_x, total_y, touch)
|
||||
|
||||
|
||||
<ul>
|
||||
@@ -438,7 +464,7 @@
|
||||
<strong>on_drag_start</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Event on drag start callback(self)
|
||||
Event on drag start callback(self, touch)
|
||||
|
||||
|
||||
<ul>
|
||||
@@ -492,6 +518,46 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "screen_x"></a>
|
||||
<strong>screen_x</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Current touch x screen position
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">screen_x</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "screen_y"></a>
|
||||
<strong>screen_y</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Current touch y screen position
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">screen_y</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "touch_start_pos"></a>
|
||||
|
||||
@@ -42,8 +42,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><strong>Druid</strong></li>
|
||||
@@ -56,9 +54,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -120,7 +116,7 @@ end
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#druid.new">druid.new(context[, style])</a></td>
|
||||
<td class="name" nowrap><a href="#druid.new">druid.new(context, style)</a></td>
|
||||
<td class="summary">Create a new Druid instance for creating GUI components.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -158,7 +154,7 @@ end
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "druid.new"></a>
|
||||
<strong>druid.new(context[, style])</strong>
|
||||
<strong>druid.new(context, style)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create a new Druid instance for creating GUI components.
|
||||
@@ -171,9 +167,8 @@ end
|
||||
The Druid context. Usually, this is the self of the gui_script. It is passed into all Druid callbacks.
|
||||
</li>
|
||||
<li><span class="parameter">style</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a> or <span class="type">nil</span></span>
|
||||
The Druid style table to override style parameters for this Druid instance.
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -42,8 +42,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -56,9 +54,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -87,15 +83,23 @@
|
||||
<td class="summary">Clear the all event handlers</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#initialize">initialize(self[, initial_callback])</a></td>
|
||||
<td class="name" nowrap><a href="#create">create(callback, callback_context)</a></td>
|
||||
<td class="summary">DruidEvent constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#is_empty">is_empty(self)</a></td>
|
||||
<td class="summary">Return true, if event not have handler</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#is_exist">is_exist(self)</a></td>
|
||||
<td class="summary">Return true, if event have at lease one handler</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#subscribe">subscribe(self, callback[, context])</a></td>
|
||||
<td class="name" nowrap><a href="#is_subscribed">is_subscribed(self, callback, callback_context)</a></td>
|
||||
<td class="summary">Check is event subscribed.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#subscribe">subscribe(self, callback, callback_context)</a></td>
|
||||
<td class="summary">Subscribe callback on event</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -103,7 +107,7 @@
|
||||
<td class="summary">Trigger the event and call all subscribed callbacks</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#unsubscribe">unsubscribe(self, callback[, context])</a></td>
|
||||
<td class="name" nowrap><a href="#unsubscribe">unsubscribe(self, callback, callback_context)</a></td>
|
||||
<td class="summary">Unsubscribe callback on event</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -141,8 +145,8 @@
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "initialize"></a>
|
||||
<strong>initialize(self[, initial_callback])</strong>
|
||||
<a name = "create"></a>
|
||||
<strong>create(callback, callback_context)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
DruidEvent constructor
|
||||
@@ -150,14 +154,13 @@
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">DruidEvent</span></span>
|
||||
<a href="../modules/DruidEvent.html#">DruidEvent</a>
|
||||
</li>
|
||||
<li><span class="parameter">initial_callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
<li><span class="parameter">callback</span>
|
||||
<span class="types"><span class="type">function</span> or <span class="type">nil</span></span>
|
||||
Subscribe the callback on new event, if callback exist
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">callback_context</span>
|
||||
<span class="types"><span class="type">any</span> or <span class="type">nil</span></span>
|
||||
Additional context as first param to callback call
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -168,7 +171,38 @@
|
||||
<ul>
|
||||
<pre class="example"><span class="keyword">local</span> Event = <span class="global">require</span>(<span class="string">"druid.event"</span>)
|
||||
...
|
||||
<span class="keyword">local</span> event = Event(initial_callback)</pre>
|
||||
<span class="keyword">local</span> event = Event(callback)</pre>
|
||||
</ul>
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "is_empty"></a>
|
||||
<strong>is_empty(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Return true, if event not have handler
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">DruidEvent</span></span>
|
||||
<a href="../modules/DruidEvent.html#">DruidEvent</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
True if event not have handlers
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
<h3>Usage:</h3>
|
||||
<ul>
|
||||
<pre class="example"><span class="keyword">local</span> is_long_click_handler_not_exists = button.on_long_click:is_empty()</pre>
|
||||
</ul>
|
||||
|
||||
</dd>
|
||||
@@ -191,7 +225,7 @@
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
True if event have handlers
|
||||
</ol>
|
||||
|
||||
@@ -202,10 +236,45 @@
|
||||
<pre class="example"><span class="keyword">local</span> is_long_click_handler_exists = button.on_long_click:is_exist()</pre>
|
||||
</ul>
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "is_subscribed"></a>
|
||||
<strong>is_subscribed(self, callback, callback_context)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Check is event subscribed.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">DruidEvent</span></span>
|
||||
<a href="../modules/DruidEvent.html#">DruidEvent</a>
|
||||
</li>
|
||||
<li><span class="parameter">callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
Callback itself
|
||||
</li>
|
||||
<li><span class="parameter">callback_context</span>
|
||||
<span class="types"><span class="type">any</span> or <span class="type">nil</span></span>
|
||||
Additional context as first param to callback call
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">boolean,</span></span>
|
||||
number|nil @Is event subscribed, return index of callback in event as second param
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "subscribe"></a>
|
||||
<strong>subscribe(self, callback[, context])</strong>
|
||||
<strong>subscribe(self, callback, callback_context)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Subscribe callback on event
|
||||
@@ -221,13 +290,18 @@
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
Callback itself
|
||||
</li>
|
||||
<li><span class="parameter">context</span>
|
||||
<span class="types"><span class="type">Any</span></span>
|
||||
<li><span class="parameter">callback_context</span>
|
||||
<span class="types"><span class="type">any</span> or <span class="type">nil</span></span>
|
||||
Additional context as first param to callback call, usually it's self
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
True if callback was subscribed
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
@@ -257,7 +331,7 @@ button.on_long_click:subscribe(on_long_callback, self)</pre>
|
||||
<a href="../modules/DruidEvent.html#">DruidEvent</a>
|
||||
</li>
|
||||
<li><span class="parameter">...</span>
|
||||
<span class="types"><span class="type">Any</span></span>
|
||||
<span class="types"><span class="type">any</span></span>
|
||||
All event params
|
||||
</li>
|
||||
</ul>
|
||||
@@ -276,7 +350,7 @@ event:trigger(<span class="string">"Param1"</span>, <span class="string">"Param2
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "unsubscribe"></a>
|
||||
<strong>unsubscribe(self, callback[, context])</strong>
|
||||
<strong>unsubscribe(self, callback, callback_context)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Unsubscribe callback on event
|
||||
@@ -292,10 +366,9 @@ event:trigger(<span class="string">"Param1"</span>, <span class="string">"Param2
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
Callback itself
|
||||
</li>
|
||||
<li><span class="parameter">context</span>
|
||||
<span class="types"><span class="type">Any</span></span>
|
||||
<li><span class="parameter">callback_context</span>
|
||||
<span class="types"><span class="type">any</span> or <span class="type">nil</span></span>
|
||||
Additional context as first param to callback call
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -42,8 +42,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -56,9 +54,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -92,8 +88,6 @@
|
||||
<li><a href="../modules/BackHandler.html#">BackHandler</a></li>
|
||||
<li><a href="../modules/Blocker.html#">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html#">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html#">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html#">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html#">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html#">Drag</a></li>
|
||||
<li><a href="../modules/DynamicGrid.html#">DynamicGrid</a></li>
|
||||
@@ -103,7 +97,6 @@
|
||||
<li><a href="../modules/LangText.html#">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html#">Layout</a></li>
|
||||
<li><a href="../modules/Progress.html#">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html#">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html#">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html#">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html#">Scroll</a></li>
|
||||
@@ -142,11 +135,7 @@ end
|
||||
<td class="summary">Call this in gui_script final function.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new">new(self, component, ...)</a></td>
|
||||
<td class="summary">Create new component.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new_back_handler">new_back_handler(self, callback[, params])</a></td>
|
||||
<td class="name" nowrap><a href="#new_back_handler">new_back_handler(self, callback, params)</a></td>
|
||||
<td class="summary">Create <a href="../modules/BackHandler.html#">BackHandler</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -154,18 +143,10 @@ end
|
||||
<td class="summary">Create <a href="../modules/Blocker.html#">Blocker</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new_button">new_button(self, node, callback[, params[, anim_node]])</a></td>
|
||||
<td class="name" nowrap><a href="#new_button">new_button(self, node, callback, params, anim_node)</a></td>
|
||||
<td class="summary">Create <a href="../modules/Button.html#">Button</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new_checkbox">new_checkbox(self, node, callback[, click_node=node[, initial_state=false]])</a></td>
|
||||
<td class="summary">Create <a href="../modules/Checkbox.html#">Checkbox</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new_checkbox_group">new_checkbox_group(self, nodes, callback[, click_nodes=node])</a></td>
|
||||
<td class="summary">Create <a href="../modules/CheckboxGroup.html#">CheckboxGroup</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new_data_list">new_data_list(self, druid_scroll, druid_grid, create_function)</a></td>
|
||||
<td class="summary">Create <a href="../modules/DataList.html#">DataList</a> component</td>
|
||||
</tr>
|
||||
@@ -174,23 +155,24 @@ end
|
||||
<td class="summary">Create <a href="../modules/Drag.html#">Drag</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new_dynamic_grid">new_dynamic_grid(self, parent)</a></td>
|
||||
<td class="summary">Create <a href="../modules/DynamicGrid.html#">DynamicGrid</a> component</td>
|
||||
<td class="name" nowrap><a href="#new_dynamic_grid">new_dynamic_grid(self, parent_node)</a></td>
|
||||
<td class="summary">Create <a href="../modules/DynamicGrid.html#">DynamicGrid</a> component
|
||||
Deprecated</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new_hotkey">new_hotkey(self, keys_array, callback[, params])</a></td>
|
||||
<td class="name" nowrap><a href="#new_hotkey">new_hotkey(self, keys_array, callback, callback_argument)</a></td>
|
||||
<td class="summary">Create <a href="../modules/Hotkey.html#">Hotkey</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new_hover">new_hover(self, node, on_hover_callback)</a></td>
|
||||
<td class="name" nowrap><a href="#new_hover">new_hover(self, node, on_hover_callback, on_mouse_hover_callback)</a></td>
|
||||
<td class="summary">Create <a href="../modules/Hover.html#">Hover</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new_input">new_input(self, click_node, text_node[, keyboard_type])</a></td>
|
||||
<td class="name" nowrap><a href="#new_input">new_input(self, click_node, text_node, keyboard_type)</a></td>
|
||||
<td class="summary">Create <a href="../modules/Input.html#">Input</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new_lang_text">new_lang_text(self, node, locale_id, no_adjust)</a></td>
|
||||
<td class="name" nowrap><a href="#new_lang_text">new_lang_text(self, node, locale_id, adjust_type)</a></td>
|
||||
<td class="summary">Create <a href="../modules/LangText.html#">LangText</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -198,15 +180,15 @@ end
|
||||
<td class="summary">Create <a href="../modules/Layout.html#">Layout</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new_progress">new_progress(self, node, key[, init_value=1])</a></td>
|
||||
<td class="name" nowrap><a href="#new_progress">new_progress(self, node, key, init_value)</a></td>
|
||||
<td class="summary">Create <a href="../modules/Progress.html#">Progress</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new_radio_group">new_radio_group(self, nodes, callback[, click_nodes=node])</a></td>
|
||||
<td class="summary">Create <a href="../modules/RadioGroup.html#">RadioGroup</a> component</td>
|
||||
<td class="name" nowrap><a href="#new_rich_input">new_rich_input(self, template, nodes)</a></td>
|
||||
<td class="summary">Create <a href="../modules/RichInput.html#">RichInput</a> component.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new_rich_text">new_rich_text(self[, template[, nodes]])</a></td>
|
||||
<td class="name" nowrap><a href="#new_rich_text">new_rich_text(self, text_node, value)</a></td>
|
||||
<td class="summary">Create <a href="../modules/RichText.html#">RichText</a> component.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -214,11 +196,11 @@ end
|
||||
<td class="summary">Create <a href="../modules/Scroll.html#">Scroll</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new_slider">new_slider(self, node, end_pos[, callback])</a></td>
|
||||
<td class="name" nowrap><a href="#new_slider">new_slider(self, pin_node, end_pos, callback)</a></td>
|
||||
<td class="summary">Create <a href="../modules/Slider.html#">Slider</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new_static_grid">new_static_grid(self, parent, element[, in_row=1])</a></td>
|
||||
<td class="name" nowrap><a href="#new_static_grid">new_static_grid(self, parent_node, item, in_row)</a></td>
|
||||
<td class="summary">Create <a href="../modules/StaticGrid.html#">StaticGrid</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -226,11 +208,11 @@ end
|
||||
<td class="summary">Create <a href="../modules/Swipe.html#">Swipe</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new_text">new_text(self, node[, value[, no_adjust]])</a></td>
|
||||
<td class="name" nowrap><a href="#new_text">new_text(self, node, value, no_adjust)</a></td>
|
||||
<td class="summary">Create <a href="../modules/Text.html#">Text</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new_timer">new_timer(self, node, seconds_from[, seconds_to=0[, callback]])</a></td>
|
||||
<td class="name" nowrap><a href="#new_timer">new_timer(self, node, seconds_from, seconds_to, callback)</a></td>
|
||||
<td class="summary">Create <a href="../modules/Timer.html#">Timer</a> component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -246,11 +228,11 @@ end
|
||||
<td class="summary">Remove created component from Druid instance.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_blacklist">set_blacklist(self[, blacklist_components=nil])</a></td>
|
||||
<td class="name" nowrap><a href="#set_blacklist">set_blacklist(self, blacklist_components)</a></td>
|
||||
<td class="summary">Set blacklist components for input processing.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_whitelist">set_whitelist(self[, whitelist_components=nil])</a></td>
|
||||
<td class="name" nowrap><a href="#set_whitelist">set_whitelist(self, whitelist_components)</a></td>
|
||||
<td class="summary">Set whitelist components for input processing.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -286,39 +268,10 @@ end
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new"></a>
|
||||
<strong>new(self, component, ...)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create new component.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">DruidInstance</span></span>
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">component</span>
|
||||
<span class="types"><span class="type">Component</span></span>
|
||||
Component module
|
||||
</li>
|
||||
<li><span class="parameter">...</span>
|
||||
<span class="types"><span class="type">args</span></span>
|
||||
Other component params to pass it to component:init function
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_back_handler"></a>
|
||||
<strong>new_back_handler(self, callback[, params])</strong>
|
||||
<strong>new_back_handler(self, callback, params)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create <a href="../modules/BackHandler.html#">BackHandler</a> component
|
||||
@@ -331,13 +284,12 @@ end
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">callback</span>
|
||||
<span class="types"><span class="type">callback</span></span>
|
||||
On back button
|
||||
<span class="types"><span class="type">function</span> or <span class="type">nil</span></span>
|
||||
@The callback(self, custom_args) to call on back event
|
||||
</li>
|
||||
<li><span class="parameter">params</span>
|
||||
<span class="types"><span class="type">any</span></span>
|
||||
<span class="types"><span class="type">any</span> or <span class="type">nil</span></span>
|
||||
Callback argument
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -367,8 +319,8 @@ end
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
Gui node
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
|
||||
The node_id or gui.get_node(node_id)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -385,7 +337,7 @@ end
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_button"></a>
|
||||
<strong>new_button(self, node, callback[, params[, anim_node]])</strong>
|
||||
<strong>new_button(self, node, callback, params, anim_node)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create <a href="../modules/Button.html#">Button</a> component
|
||||
@@ -398,22 +350,20 @@ end
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
GUI node
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
|
||||
The node_id or gui.get_node(node_id)
|
||||
</li>
|
||||
<li><span class="parameter">callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
<span class="types"><span class="type">function</span> or <span class="type">nil</span></span>
|
||||
Button callback
|
||||
</li>
|
||||
<li><span class="parameter">params</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
||||
<span class="types"><span class="type">any</span> or <span class="type">nil</span></span>
|
||||
Button callback params
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">anim_node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
<span class="types"><span class="type">node</span>, <a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Button anim node (node, if not provided)
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -427,91 +377,6 @@ end
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_checkbox"></a>
|
||||
<strong>new_checkbox(self, node, callback[, click_node=node[, initial_state=false]])</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create <a href="../modules/Checkbox.html#">Checkbox</a> component
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">DruidInstance</span></span>
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
Gui node
|
||||
</li>
|
||||
<li><span class="parameter">callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
Checkbox callback
|
||||
</li>
|
||||
<li><span class="parameter">click_node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
Trigger node, by default equals to node
|
||||
(<em>default</em> node)
|
||||
</li>
|
||||
<li><span class="parameter">initial_state</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
The initial state of checkbox, default - false
|
||||
(<em>default</em> false)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Checkbox</span></span>
|
||||
<a href="../modules/Checkbox.html#">Checkbox</a> component
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_checkbox_group"></a>
|
||||
<strong>new_checkbox_group(self, nodes, callback[, click_nodes=node])</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create <a href="../modules/CheckboxGroup.html#">CheckboxGroup</a> component
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">DruidInstance</span></span>
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">nodes</span>
|
||||
<span class="types"><span class="type">node[]</span></span>
|
||||
Array of gui node
|
||||
</li>
|
||||
<li><span class="parameter">callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
Checkbox callback
|
||||
</li>
|
||||
<li><span class="parameter">click_nodes</span>
|
||||
<span class="types"><span class="type">node[]</span></span>
|
||||
Array of trigger nodes, by default equals to nodes
|
||||
(<em>default</em> node)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">CheckboxGroup</span></span>
|
||||
<a href="../modules/CheckboxGroup.html#">CheckboxGroup</a> component
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_data_list"></a>
|
||||
@@ -532,8 +397,8 @@ end
|
||||
The Scroll instance for Data List component
|
||||
</li>
|
||||
<li><span class="parameter">druid_grid</span>
|
||||
<span class="types"><span class="type">Grid</span></span>
|
||||
The Grid instance for Data List component
|
||||
<span class="types"><span class="type">StaticGrid</span></span>
|
||||
The <a href="../modules/StaticGrid.html#">StaticGrid</a> or <a href="../modules/DynamicGrid.html#">DynamicGrid</a> instance for Data List component
|
||||
</li>
|
||||
<li><span class="parameter">create_function</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
@@ -567,11 +432,11 @@ end
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
GUI node to detect dragging
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
|
||||
The node_id or gui.get_node(node_id). Will used as user input node.
|
||||
</li>
|
||||
<li><span class="parameter">on_drag_callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
<span class="types"><span class="type">function</span> or <span class="type">nil</span></span>
|
||||
Callback for on_drag_event(self, dx, dy)
|
||||
</li>
|
||||
</ul>
|
||||
@@ -589,10 +454,11 @@ end
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_dynamic_grid"></a>
|
||||
<strong>new_dynamic_grid(self, parent)</strong>
|
||||
<strong>new_dynamic_grid(self, parent_node)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create <a href="../modules/DynamicGrid.html#">DynamicGrid</a> component
|
||||
Deprecated
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -601,9 +467,9 @@ end
|
||||
<span class="types"><span class="type">DruidInstance</span></span>
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">parent</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
The gui node parent, where items will be placed
|
||||
<li><span class="parameter">parent_node</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
|
||||
The node_id or gui.get_node(node_id). Parent of all Grid items.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -620,7 +486,7 @@ end
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_hotkey"></a>
|
||||
<strong>new_hotkey(self, keys_array, callback[, params])</strong>
|
||||
<strong>new_hotkey(self, keys_array, callback, callback_argument)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create <a href="../modules/Hotkey.html#">Hotkey</a> component
|
||||
@@ -638,12 +504,11 @@ end
|
||||
</li>
|
||||
<li><span class="parameter">callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
Button callback
|
||||
The callback function
|
||||
</li>
|
||||
<li><span class="parameter">params</span>
|
||||
<span class="types"><span class="type">value</span></span>
|
||||
Button callback params
|
||||
(<em>optional</em>)
|
||||
<li><span class="parameter">callback_argument</span>
|
||||
<span class="types"><span class="type">any</span> or <span class="type">nil</span></span>
|
||||
The argument to pass into the callback function
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -660,7 +525,7 @@ end
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_hover"></a>
|
||||
<strong>new_hover(self, node, on_hover_callback)</strong>
|
||||
<strong>new_hover(self, node, on_hover_callback, on_mouse_hover_callback)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create <a href="../modules/Hover.html#">Hover</a> component
|
||||
@@ -673,13 +538,17 @@ end
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
Gui node
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
|
||||
The node_id or gui.get_node(node_id)
|
||||
</li>
|
||||
<li><span class="parameter">on_hover_callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
<span class="types"><span class="type">function</span> or <span class="type">nil</span></span>
|
||||
Hover callback
|
||||
</li>
|
||||
<li><span class="parameter">on_mouse_hover_callback</span>
|
||||
<span class="types"><span class="type">function</span> or <span class="type">nil</span></span>
|
||||
Mouse hover callback
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
@@ -695,7 +564,7 @@ end
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_input"></a>
|
||||
<strong>new_input(self, click_node, text_node[, keyboard_type])</strong>
|
||||
<strong>new_input(self, click_node, text_node, keyboard_type)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create <a href="../modules/Input.html#">Input</a> component
|
||||
@@ -708,17 +577,16 @@ end
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">click_node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
|
||||
Button node to enabled input component
|
||||
</li>
|
||||
<li><span class="parameter">text_node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a>, <span class="type">node</span> or <span class="type">druid.text</span></span>
|
||||
Text node what will be changed on user input
|
||||
</li>
|
||||
<li><span class="parameter">keyboard_type</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Gui keyboard type for input field
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -735,7 +603,7 @@ end
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_lang_text"></a>
|
||||
<strong>new_lang_text(self, node, locale_id, no_adjust)</strong>
|
||||
<strong>new_lang_text(self, node, locale_id, adjust_type)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create <a href="../modules/LangText.html#">LangText</a> component
|
||||
@@ -748,16 +616,16 @@ end
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
The text node
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
|
||||
The_node id or gui.get_node(node_id)
|
||||
</li>
|
||||
<li><span class="parameter">locale_id</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
Default locale id
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Default locale id or text from node as default
|
||||
</li>
|
||||
<li><span class="parameter">no_adjust</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
If true, will not correct text size
|
||||
<li><span class="parameter">adjust_type</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Adjust type for text node. Default: const.TEXT_ADJUST.DOWNSCALE
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -788,7 +656,7 @@ end
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
|
||||
Layout node
|
||||
The_node id or gui.get_node(node_id).
|
||||
</li>
|
||||
<li><span class="parameter">mode</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
@@ -809,7 +677,7 @@ end
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_progress"></a>
|
||||
<strong>new_progress(self, node, key[, init_value=1])</strong>
|
||||
<strong>new_progress(self, node, key, init_value)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create <a href="../modules/Progress.html#">Progress</a> component
|
||||
@@ -830,9 +698,8 @@ end
|
||||
Progress bar direction: const.SIDE.X or const.SIDE.Y
|
||||
</li>
|
||||
<li><span class="parameter">init_value</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Initial value of progress bar
|
||||
(<em>default</em> 1)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Initial value of progress bar. Default: 1
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -848,52 +715,12 @@ end
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_radio_group"></a>
|
||||
<strong>new_radio_group(self, nodes, callback[, click_nodes=node])</strong>
|
||||
<a name = "new_rich_input"></a>
|
||||
<strong>new_rich_input(self, template, nodes)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create <a href="../modules/RadioGroup.html#">RadioGroup</a> component
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">DruidInstance</span></span>
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">nodes</span>
|
||||
<span class="types"><span class="type">node[]</span></span>
|
||||
Array of gui node
|
||||
</li>
|
||||
<li><span class="parameter">callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
Radio callback
|
||||
</li>
|
||||
<li><span class="parameter">click_nodes</span>
|
||||
<span class="types"><span class="type">node[]</span></span>
|
||||
Array of trigger nodes, by default equals to nodes
|
||||
(<em>default</em> node)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">RadioGroup</span></span>
|
||||
<a href="../modules/RadioGroup.html#">RadioGroup</a> component
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_rich_text"></a>
|
||||
<strong>new_rich_text(self[, template[, nodes]])</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create <a href="../modules/RichText.html#">RichText</a> component.
|
||||
As a template please check rich_text.gui layout.
|
||||
Create <a href="../modules/RichInput.html#">RichInput</a> component.
|
||||
As a template please check rich_input.gui layout.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -904,13 +731,46 @@ end
|
||||
</li>
|
||||
<li><span class="parameter">template</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
Template name if used
|
||||
(<em>optional</em>)
|
||||
The template string name
|
||||
</li>
|
||||
<li><span class="parameter">nodes</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
||||
Nodes table from gui.clone_tree
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">RichInput</span></span>
|
||||
<a href="../modules/RichInput.html#">RichInput</a> component
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_rich_text"></a>
|
||||
<strong>new_rich_text(self, text_node, value)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create <a href="../modules/RichText.html#">RichText</a> component.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">DruidInstance</span></span>
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">text_node</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
|
||||
The text node to make Rich Text
|
||||
</li>
|
||||
<li><span class="parameter">value</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
The initial text value. Default will be gui.get_text(text_node)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -940,12 +800,12 @@ end
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">view_node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
GUI view scroll node
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
|
||||
The node_id or gui.get_node(node_id). Will used as user input node.
|
||||
</li>
|
||||
<li><span class="parameter">content_node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
GUI content scroll node
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
|
||||
The node_id or gui.get_node(node_id). Will used as scrollable node inside view_node.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -962,7 +822,7 @@ end
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_slider"></a>
|
||||
<strong>new_slider(self, node, end_pos[, callback])</strong>
|
||||
<strong>new_slider(self, pin_node, end_pos, callback)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create <a href="../modules/Slider.html#">Slider</a> component
|
||||
@@ -974,18 +834,17 @@ end
|
||||
<span class="types"><span class="type">DruidInstance</span></span>
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
Gui pin node
|
||||
<li><span class="parameter">pin_node</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
|
||||
The_node id or gui.get_node(node_id).
|
||||
</li>
|
||||
<li><span class="parameter">end_pos</span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
The end position of slider
|
||||
</li>
|
||||
<li><span class="parameter">callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
<span class="types"><span class="type">function</span> or <span class="type">nil</span></span>
|
||||
On slider change callback
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -1002,7 +861,7 @@ end
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_static_grid"></a>
|
||||
<strong>new_static_grid(self, parent, element[, in_row=1])</strong>
|
||||
<strong>new_static_grid(self, parent_node, item, in_row)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create <a href="../modules/StaticGrid.html#">StaticGrid</a> component
|
||||
@@ -1014,18 +873,17 @@ end
|
||||
<span class="types"><span class="type">DruidInstance</span></span>
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">parent</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
The gui node parent, where items will be placed
|
||||
<li><span class="parameter">parent_node</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
|
||||
The node_id or gui.get_node(node_id). Parent of all Grid items.
|
||||
</li>
|
||||
<li><span class="parameter">element</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
Element prefab. Need to get it size
|
||||
<li><span class="parameter">item</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
|
||||
Item prefab. Required to get grid's item size. Can be adjusted separately.
|
||||
</li>
|
||||
<li><span class="parameter">in_row</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
How many nodes in row can be placed
|
||||
(<em>default</em> 1)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -1055,11 +913,11 @@ end
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
Gui node
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
|
||||
The node_id or gui.get_node(node_id). Will used as user input node.
|
||||
</li>
|
||||
<li><span class="parameter">on_swipe_callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
<span class="types"><span class="type">function</span> or <span class="type">nil</span></span>
|
||||
Swipe callback for on_swipe_end event
|
||||
</li>
|
||||
</ul>
|
||||
@@ -1077,7 +935,7 @@ end
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_text"></a>
|
||||
<strong>new_text(self, node[, value[, no_adjust]])</strong>
|
||||
<strong>new_text(self, node, value, no_adjust)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create <a href="../modules/Text.html#">Text</a> component
|
||||
@@ -1090,18 +948,16 @@ end
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
Gui text node
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
|
||||
The node_id or gui.get_node(node_id)
|
||||
</li>
|
||||
<li><span class="parameter">value</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Initial text. Default value is node text from GUI scene.
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">no_adjust</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
If true, text will be not auto-adjust size
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -1118,7 +974,7 @@ end
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "new_timer"></a>
|
||||
<strong>new_timer(self, node, seconds_from[, seconds_to=0[, callback]])</strong>
|
||||
<strong>new_timer(self, node, seconds_from, seconds_to, callback)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create <a href="../modules/Timer.html#">Timer</a> component
|
||||
@@ -1131,7 +987,7 @@ end
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
|
||||
Gui text node
|
||||
</li>
|
||||
<li><span class="parameter">seconds_from</span>
|
||||
@@ -1139,14 +995,12 @@ end
|
||||
Start timer value in seconds
|
||||
</li>
|
||||
<li><span class="parameter">seconds_to</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
End timer value in seconds
|
||||
(<em>default</em> 0)
|
||||
</li>
|
||||
<li><span class="parameter">callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
<span class="types"><span class="type">function</span> or <span class="type">nil</span></span>
|
||||
Function on timer end
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -1189,7 +1043,7 @@ end
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
The boolean value is input was consumed
|
||||
</ol>
|
||||
|
||||
@@ -1221,7 +1075,7 @@ end
|
||||
Message from on_message
|
||||
</li>
|
||||
<li><span class="parameter">sender</span>
|
||||
<span class="types"><span class="type">hash</span></span>
|
||||
<span class="types"><span class="type">url</span></span>
|
||||
Sender from on_message
|
||||
</li>
|
||||
</ul>
|
||||
@@ -1247,11 +1101,17 @@ end
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">component</span>
|
||||
<span class="types"><span class="type">Component</span></span>
|
||||
<span class="types"><span class="type">BaseComponent</span></span>
|
||||
Component instance
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
True if component was removed
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
@@ -1259,7 +1119,7 @@ end
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_blacklist"></a>
|
||||
<strong>set_blacklist(self[, blacklist_components=nil])</strong>
|
||||
<strong>set_blacklist(self, blacklist_components)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set blacklist components for input processing.
|
||||
@@ -1274,9 +1134,8 @@ end
|
||||
<a href="../modules/DruidInstance.html#">DruidInstance</a>
|
||||
</li>
|
||||
<li><span class="parameter">blacklist_components</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a> or <span class="type">Component</span></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a>, <span class="type">BaseComponent</span> or <span class="type">nil</span></span>
|
||||
The array of component to blacklist
|
||||
(<em>default</em> nil)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -1293,7 +1152,7 @@ end
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_whitelist"></a>
|
||||
<strong>set_whitelist(self[, whitelist_components=nil])</strong>
|
||||
<strong>set_whitelist(self, whitelist_components)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set whitelist components for input processing.
|
||||
@@ -1308,9 +1167,8 @@ end
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">whitelist_components</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a> or <span class="type">Component</span></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a>, <span class="type">BaseComponent</span> or <span class="type">nil</span></span>
|
||||
The array of component to whitelist
|
||||
(<em>default</em> nil)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -43,8 +43,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -57,9 +55,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -86,7 +82,7 @@
|
||||
<td class="summary">Return side vector to correct node shifting</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#add">add(self, node[, index[, shift_policy=SHIFT.RIGHT[, is_instant=false]]])</a></td>
|
||||
<td class="name" nowrap><a href="#add">add(self, node, index, shift_policy, is_instant)</a></td>
|
||||
<td class="summary">Add new node to the grid</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -110,7 +106,7 @@
|
||||
<td class="summary">Return DynamicGrid offset, where DynamicGrid content starts.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_pos">get_pos(self, index, node[, origin_index])</a></td>
|
||||
<td class="name" nowrap><a href="#get_pos">get_pos(self, index, node, origin_index)</a></td>
|
||||
<td class="summary">Return pos for grid node index</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -119,10 +115,10 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, parent)</a></td>
|
||||
<td class="summary">Component init function</td>
|
||||
<td class="summary">The <a href="../modules/DynamicGrid.html#">DynamicGrid</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#remove">remove(self, index[, shift_policy=SHIFT.RIGHT[, is_instant=false]])</a></td>
|
||||
<td class="name" nowrap><a href="#remove">remove(self, index, shift_policy, is_instant)</a></td>
|
||||
<td class="summary">Remove the item from the grid.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -213,7 +209,7 @@
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "add"></a>
|
||||
<strong>add(self, node[, index[, shift_policy=SHIFT.RIGHT[, is_instant=false]]])</strong>
|
||||
<strong>add(self, node, index, shift_policy, is_instant)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Add new node to the grid
|
||||
@@ -230,19 +226,16 @@
|
||||
Gui node
|
||||
</li>
|
||||
<li><span class="parameter">index</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
The node position. By default add as last node
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">shift_policy</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
How shift nodes, if required. See const.SHIFT
|
||||
(<em>default</em> SHIFT.RIGHT)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
How shift nodes, if required. Default: const.SHIFT.RIGHT
|
||||
</li>
|
||||
<li><span class="parameter">is_instant</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
If true, update node positions instantly
|
||||
(<em>default</em> false)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -393,7 +386,7 @@
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_pos"></a>
|
||||
<strong>get_pos(self, index, node[, origin_index])</strong>
|
||||
<strong>get_pos(self, index, node, origin_index)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Return pos for grid node index
|
||||
@@ -414,9 +407,8 @@
|
||||
The node to be placed
|
||||
</li>
|
||||
<li><span class="parameter">origin_index</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Index of nearby node
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -424,7 +416,7 @@
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
Node position
|
||||
node position
|
||||
</ol>
|
||||
|
||||
|
||||
@@ -467,7 +459,7 @@
|
||||
<strong>init(self, parent)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Component init function
|
||||
The <a href="../modules/DynamicGrid.html#">DynamicGrid</a> constructor
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -489,7 +481,7 @@
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "remove"></a>
|
||||
<strong>remove(self, index[, shift_policy=SHIFT.RIGHT[, is_instant=false]])</strong>
|
||||
<strong>remove(self, index, shift_policy, is_instant)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Remove the item from the grid. Note that gui node will be not deleted
|
||||
@@ -506,14 +498,12 @@
|
||||
The grid node index to remove
|
||||
</li>
|
||||
<li><span class="parameter">shift_policy</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
How shift nodes, if required. See const.SHIFT
|
||||
(<em>default</em> SHIFT.RIGHT)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
How shift nodes, if required. Default: const.SHIFT.RIGHT
|
||||
</li>
|
||||
<li><span class="parameter">is_instant</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
If true, update node positions instantly
|
||||
(<em>default</em> false)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -42,8 +42,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -56,9 +54,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -87,11 +83,11 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#helper.add_array">helper.add_array(target[, source])</a></td>
|
||||
<td class="name" nowrap><a href="#helper.add_array">helper.add_array(target, source)</a></td>
|
||||
<td class="summary">Add all elements from source array to the target array</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#helper.centrate_nodes">helper.centrate_nodes([margin=0], ...)</a></td>
|
||||
<td class="name" nowrap><a href="#helper.centrate_nodes">helper.centrate_nodes(margin, ...)</a></td>
|
||||
<td class="summary">Centerate nodes by x position with margin.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -111,7 +107,7 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
<td class="summary">Calculate distance between two points</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#helper.get_border">helper.get_border(node[, offset])</a></td>
|
||||
<td class="name" nowrap><a href="#helper.get_border">helper.get_border(node, offset)</a></td>
|
||||
<td class="summary">Distance from node position to his borders</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -143,7 +139,7 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
<td class="summary">Get text metric from GUI node.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#helper.insert_with_shift">helper.insert_with_shift(array, item[, index[, shift_policy]])</a></td>
|
||||
<td class="name" nowrap><a href="#helper.insert_with_shift">helper.insert_with_shift(array, any, index, shift_policy)</a></td>
|
||||
<td class="summary">Add value to array with shift policy</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -151,19 +147,27 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
<td class="summary">Check if device is native mobile (Android or iOS)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#helper.is_multitouch_supported">helper.is_multitouch_supported()</a></td>
|
||||
<td class="summary">Check if device is mobile and can support multitouch</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#helper.is_web">helper.is_web()</a></td>
|
||||
<td class="summary">Check if device is HTML5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#helper.is_web_mobile">helper.is_web_mobile()</a></td>
|
||||
<td class="summary">Check if device is HTML5 mobile</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#helper.lerp">helper.lerp(a, b, t)</a></td>
|
||||
<td class="summary">Lerp between two values</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#helper.remove_with_shift">helper.remove_with_shift(array[, index[, shift_policy]])</a></td>
|
||||
<td class="name" nowrap><a href="#helper.remove_with_shift">helper.remove_with_shift(array, index, shift_policy)</a></td>
|
||||
<td class="summary">Remove value from array with shift policy</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#helper.round">helper.round(num[, num_decimal_places=0])</a></td>
|
||||
<td class="name" nowrap><a href="#helper.round">helper.round(num, num_decimal_places)</a></td>
|
||||
<td class="summary">Round number to specified decimal places</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -189,7 +193,7 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "helper.add_array"></a>
|
||||
<strong>helper.add_array(target[, source])</strong>
|
||||
<strong>helper.add_array(target, source)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Add all elements from source array to the target array
|
||||
@@ -198,20 +202,19 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">target</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
||||
<span class="types"><span class="type">any[]</span></span>
|
||||
Array to put elements from source
|
||||
</li>
|
||||
<li><span class="parameter">source</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
||||
<span class="types"><span class="type">any[]</span> or <span class="type">nil</span></span>
|
||||
The source array to get elements from
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">array</span></span>
|
||||
<span class="types"><span class="type">any[]</span></span>
|
||||
The target array
|
||||
</ol>
|
||||
|
||||
@@ -221,7 +224,7 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "helper.centrate_nodes"></a>
|
||||
<strong>helper.centrate_nodes([margin=0], ...)</strong>
|
||||
<strong>helper.centrate_nodes(margin, ...)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Centerate nodes by x position with margin.
|
||||
@@ -232,9 +235,8 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">margin</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Offset between nodes
|
||||
(<em>default</em> 0)
|
||||
</li>
|
||||
<li><span class="parameter">...</span>
|
||||
Gui nodes
|
||||
@@ -379,7 +381,7 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "helper.get_border"></a>
|
||||
<strong>helper.get_border(node[, offset])</strong>
|
||||
<strong>helper.get_border(node, offset)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Distance from node position to his borders
|
||||
@@ -392,9 +394,8 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
GUI node
|
||||
</li>
|
||||
<li><span class="parameter">offset</span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
<span class="types"><span class="type">vector3</span> or <span class="type">nil</span></span>
|
||||
Offset from node position. Pass current node position to get non relative border values
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -471,8 +472,8 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">pivot</span>
|
||||
<span class="types"><span class="type">gui.pivot</span></span>
|
||||
The node pivot
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
The gui.PIVOT_* constant
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -529,7 +530,7 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
Gui node
|
||||
</li>
|
||||
<li><span class="parameter">include_passed_node_scale</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
True if add current node scale to result
|
||||
</li>
|
||||
</ul>
|
||||
@@ -579,7 +580,7 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">text_node</span>
|
||||
<span class="types"><span class="type">Node</span></span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
@@ -606,7 +607,7 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "helper.insert_with_shift"></a>
|
||||
<strong>helper.insert_with_shift(array, item[, index[, shift_policy]])</strong>
|
||||
<strong>helper.insert_with_shift(array, any, index, shift_policy)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Add value to array with shift policy Shift policy can be: left, right, no_shift
|
||||
@@ -618,25 +619,23 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
||||
Array
|
||||
</li>
|
||||
<li><span class="parameter">item</span>
|
||||
<li><span class="parameter">any</span>
|
||||
Item to insert
|
||||
</li>
|
||||
<li><span class="parameter">index</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Index to insert. If nil, item will be inserted at the end of array
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">shift_policy</span>
|
||||
<span class="types"><span class="type">const.SHIFT</span></span>
|
||||
Shift policy
|
||||
(<em>optional</em>)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
The druid_const.SHIFT.* constant
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">item</span></span>
|
||||
<span class="types"><span class="type">any</span></span>
|
||||
Inserted item
|
||||
</ol>
|
||||
|
||||
@@ -656,13 +655,33 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
Is mobile
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "helper.is_multitouch_supported"></a>
|
||||
<strong>helper.is_multitouch_supported()</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Check if device is mobile and can support multitouch
|
||||
|
||||
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
Is multitouch supported
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "helper.is_web"></a>
|
||||
@@ -676,13 +695,33 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
Is web
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "helper.is_web_mobile"></a>
|
||||
<strong>helper.is_web_mobile()</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Check if device is HTML5 mobile
|
||||
|
||||
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
Is web mobile
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "helper.lerp"></a>
|
||||
@@ -721,7 +760,7 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "helper.remove_with_shift"></a>
|
||||
<strong>helper.remove_with_shift(array[, index[, shift_policy]])</strong>
|
||||
<strong>helper.remove_with_shift(array, index, shift_policy)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Remove value from array with shift policy Shift policy can be: left, right, no_shift
|
||||
@@ -734,21 +773,19 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
Array
|
||||
</li>
|
||||
<li><span class="parameter">index</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Index to remove. If nil, item will be removed from the end of array
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">shift_policy</span>
|
||||
<span class="types"><span class="type">const.SHIFT</span></span>
|
||||
Shift policy
|
||||
(<em>optional</em>)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
The druid_const.SHIFT.* constant
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">item</span></span>
|
||||
<span class="types"><span class="type">any</span></span>
|
||||
Removed item
|
||||
</ol>
|
||||
|
||||
@@ -758,7 +795,7 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "helper.round"></a>
|
||||
<strong>helper.round(num[, num_decimal_places=0])</strong>
|
||||
<strong>helper.round(num, num_decimal_places)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Round number to specified decimal places
|
||||
@@ -771,9 +808,8 @@ helper.centrate_nodes(0, node_1, node_2)
|
||||
Number
|
||||
</li>
|
||||
<li><span class="parameter">num_decimal_places</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Decimal places
|
||||
(<em>default</em> 0)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -44,8 +44,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -58,9 +56,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -83,12 +79,16 @@
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#add_hotkey">add_hotkey(self, keys[, callback_argument])</a></td>
|
||||
<td class="name" nowrap><a href="#add_hotkey">add_hotkey(self, keys, callback_argument)</a></td>
|
||||
<td class="summary">Add hotkey for component callback</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, keys, callback[, callback_argument])</a></td>
|
||||
<td class="summary">Component init function</td>
|
||||
<td class="name" nowrap><a href="#init">init(self, keys, callback, callback_argument)</a></td>
|
||||
<td class="summary">The <a href="../modules/Hotkey.html#">Hotkey</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_repeat">set_repeat(self, is_enabled_repeated)</a></td>
|
||||
<td class="summary">If true, the callback will be triggered on action.repeated</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Tables">Tables</a></h2>
|
||||
@@ -113,8 +113,12 @@
|
||||
<td class="summary">Visual node</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_change_state">on_change_state</a></td>
|
||||
<td class="summary">On change state callback(self, state)</td>
|
||||
<td class="name" nowrap><a href="#on_hotkey_pressed">on_hotkey_pressed</a></td>
|
||||
<td class="summary">On hotkey released callback(self, argument)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_hotkey_released">on_hotkey_released</a></td>
|
||||
<td class="summary">On hotkey released callback(self, argument)</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -127,7 +131,7 @@
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "add_hotkey"></a>
|
||||
<strong>add_hotkey(self, keys[, callback_argument])</strong>
|
||||
<strong>add_hotkey(self, keys, callback_argument)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Add hotkey for component callback
|
||||
@@ -144,12 +148,17 @@
|
||||
that have to be pressed before key pressed to activate
|
||||
</li>
|
||||
<li><span class="parameter">callback_argument</span>
|
||||
<span class="types"><span class="type">value</span></span>
|
||||
<span class="types"><span class="type">any</span> or <span class="type">nil</span></span>
|
||||
The argument to pass into the callback function
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Hotkey</span></span>
|
||||
Current instance
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
@@ -157,10 +166,10 @@
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, keys, callback[, callback_argument])</strong>
|
||||
<strong>init(self, keys, callback, callback_argument)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Component init function
|
||||
The <a href="../modules/Hotkey.html#">Hotkey</a> constructor
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -178,9 +187,8 @@
|
||||
The callback function
|
||||
</li>
|
||||
<li><span class="parameter">callback_argument</span>
|
||||
<span class="types"><span class="type">value</span></span>
|
||||
<span class="types"><span class="type">any</span> or <span class="type">nil</span></span>
|
||||
The argument to pass into the callback function
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -188,6 +196,37 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_repeat"></a>
|
||||
<strong>set_repeat(self, is_enabled_repeated)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
If true, the callback will be triggered on action.repeated
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Hotkey</span></span>
|
||||
<a href="../modules/Hotkey.html#">Hotkey</a>
|
||||
</li>
|
||||
<li><span class="parameter">is_enabled_repeated</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
The flag value
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Hotkey</span></span>
|
||||
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
|
||||
@@ -250,9 +289,8 @@
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">click_node</span>
|
||||
<span class="types"><a class="type" href="../modules/Hotkey.html#node">node</a></span>
|
||||
<span class="types"><a class="type" href="../modules/Hotkey.html#node">node</a> or <span class="type">nil</span></span>
|
||||
|
||||
(<em>default</em> node)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -282,15 +320,35 @@
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "on_change_state"></a>
|
||||
<strong>on_change_state</strong>
|
||||
<a name = "on_hotkey_pressed"></a>
|
||||
<strong>on_hotkey_pressed</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
On change state callback(self, state)
|
||||
On hotkey released callback(self, argument)
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">on_change_state</span>
|
||||
<li><span class="parameter">on_hotkey_pressed</span>
|
||||
<span class="types"><span class="type">DruidEvent</span></span>
|
||||
<a href="../modules/DruidEvent.html#">DruidEvent</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "on_hotkey_released"></a>
|
||||
<strong>on_hotkey_released</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
On hotkey released callback(self, argument)
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">on_hotkey_released</span>
|
||||
<span class="types"><span class="type">DruidEvent</span></span>
|
||||
<a href="../modules/DruidEvent.html#">DruidEvent</a>
|
||||
</li>
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
<li><a href="#Tables">Tables</a></li>
|
||||
<li><a href="#Fields">Fields</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -43,8 +44,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -57,9 +56,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -82,8 +79,8 @@
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, on_hover_callback)</a></td>
|
||||
<td class="summary">Component init function</td>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, on_hover_callback, on_mouse_hover)</a></td>
|
||||
<td class="summary">The <a href="../modules/Hover.html#">Hover</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#is_enabled">is_enabled(self)</a></td>
|
||||
@@ -114,8 +111,19 @@
|
||||
<td class="summary">Set mouse hover state</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Tables">Tables</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#style">style</a></td>
|
||||
<td class="summary">Component style params.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Fields">Fields</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#node">node</a></td>
|
||||
<td class="summary">Hover node</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_hover">on_hover</a></td>
|
||||
<td class="summary">On hover callback(self, state, hover_instance)</td>
|
||||
@@ -135,10 +143,10 @@
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, node, on_hover_callback)</strong>
|
||||
<strong>init(self, node, on_hover_callback, on_mouse_hover)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Component init function
|
||||
The <a href="../modules/Hover.html#">Hover</a> constructor
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -148,13 +156,17 @@
|
||||
<a href="../modules/Hover.html#">Hover</a>
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
<span class="types"><a class="type" href="../modules/Hover.html#node">node</a></span>
|
||||
Gui node
|
||||
</li>
|
||||
<li><span class="parameter">on_hover_callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
Hover callback
|
||||
</li>
|
||||
<li><span class="parameter">on_mouse_hover</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
On mouse hover callback
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -181,7 +193,7 @@
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
The hover enabled state
|
||||
</ol>
|
||||
|
||||
@@ -208,7 +220,7 @@
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
The current hovered state
|
||||
</ol>
|
||||
|
||||
@@ -235,7 +247,7 @@
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
The current hovered state
|
||||
</ol>
|
||||
|
||||
@@ -259,7 +271,7 @@
|
||||
<a href="../modules/Hover.html#">Hover</a>
|
||||
</li>
|
||||
<li><span class="parameter">zone</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
<span class="types"><a class="type" href="../modules/Hover.html#node">node</a>, <a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Gui node
|
||||
</li>
|
||||
</ul>
|
||||
@@ -286,7 +298,7 @@
|
||||
<a href="../modules/Hover.html#">Hover</a>
|
||||
</li>
|
||||
<li><span class="parameter">state</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
The hover enabled state
|
||||
</li>
|
||||
</ul>
|
||||
@@ -311,7 +323,7 @@
|
||||
<a href="../modules/Hover.html#">Hover</a>
|
||||
</li>
|
||||
<li><span class="parameter">state</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
The hover state
|
||||
</li>
|
||||
</ul>
|
||||
@@ -336,7 +348,7 @@
|
||||
<a href="../modules/Hover.html#">Hover</a>
|
||||
</li>
|
||||
<li><span class="parameter">state</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
The mouse hover state
|
||||
</li>
|
||||
</ul>
|
||||
@@ -345,11 +357,64 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "style"></a>
|
||||
<strong>style</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Component style params.
|
||||
You can override this component styles params in druid styles table
|
||||
or create your own style
|
||||
|
||||
|
||||
<h3>Fields:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">ON_HOVER_CURSOR</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
Mouse hover style on node hover
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">ON_MOUSE_HOVER_CURSOR</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
Mouse hover style on node mouse hover
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "node"></a>
|
||||
<strong>node</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Hover node
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><a class="type" href="../modules/Hover.html#node">node</a></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "on_hover"></a>
|
||||
<strong>on_hover</strong>
|
||||
|
||||
@@ -44,8 +44,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -58,9 +56,7 @@
|
||||
<li><strong>Input</strong></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -93,8 +89,16 @@
|
||||
<td class="summary">Return current input field text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, click_node, text_node[, keyboard_type])</a></td>
|
||||
<td class="summary">Component init function</td>
|
||||
<td class="name" nowrap><a href="#get_text_selected_replaced">get_text_selected_replaced(self, text)</a></td>
|
||||
<td class="summary">Replace selected text with new text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, click_node, text_node, keyboard_type)</a></td>
|
||||
<td class="summary">The <a href="../modules/Input.html#">Input</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#move_selection">move_selection(self, delta, is_add_to_selection, is_move_to_end)</a></td>
|
||||
<td class="summary">Change cursor position by delta</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#reset_changes">reset_changes(self)</a></td>
|
||||
@@ -105,6 +109,10 @@
|
||||
<td class="summary">Select input field.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#select_cursor">select_cursor(self, cursor_index, start_index, end_index)</a></td>
|
||||
<td class="summary">Set cursor position in input field</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_allowed_characters">set_allowed_characters(self, characters)</a></td>
|
||||
<td class="summary">Set allowed charaters for input field.</td>
|
||||
</tr>
|
||||
@@ -139,6 +147,18 @@
|
||||
<td class="summary">Button component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#current_value">current_value</a></td>
|
||||
<td class="summary">Current input value with marked text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#cursor_index">cursor_index</a></td>
|
||||
<td class="summary">The cursor index.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#end_index">end_index</a></td>
|
||||
<td class="summary">Theselection end index.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#is_empty">is_empty</a></td>
|
||||
<td class="summary">Is current input is empty now</td>
|
||||
</tr>
|
||||
@@ -151,6 +171,14 @@
|
||||
<td class="summary">Gui keyboard type for input field</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#marked_text_width">marked_text_width</a></td>
|
||||
<td class="summary">Marked text width</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#marked_value">marked_value</a></td>
|
||||
<td class="summary">Marked text for input field.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#max_length">max_length</a></td>
|
||||
<td class="summary">Max length for input text</td>
|
||||
</tr>
|
||||
@@ -164,7 +192,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_input_select">on_input_select</a></td>
|
||||
<td class="summary">On input field select callback(self, button_node)</td>
|
||||
<td class="summary">On input field select callback(self, input_instance)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_input_text">on_input_text</a></td>
|
||||
@@ -172,16 +200,36 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_input_unselect">on_input_unselect</a></td>
|
||||
<td class="summary">On input field unselect callback(self, input_text)</td>
|
||||
<td class="summary">On input field unselect callback(self, input_text, input_instance)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_input_wrong">on_input_wrong</a></td>
|
||||
<td class="summary">On trying user input with not allowed character callback(self, params, button_instance)</td>
|
||||
<td class="summary">On trying user input with not allowed character callback(self, params, input_text)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_select_cursor_change">on_select_cursor_change</a></td>
|
||||
<td class="summary">On cursor position change callback(self, cursor_index, start_index, end_index)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#previous_value">previous_value</a></td>
|
||||
<td class="summary">Previous input value</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#start_index">start_index</a></td>
|
||||
<td class="summary">The selection start index.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#text">text</a></td>
|
||||
<td class="summary">Text component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#text_width">text_width</a></td>
|
||||
<td class="summary">Text width</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#value">value</a></td>
|
||||
<td class="summary">Current input value</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
@@ -219,11 +267,42 @@
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, click_node, text_node[, keyboard_type])</strong>
|
||||
<a name = "get_text_selected_replaced"></a>
|
||||
<strong>get_text_selected_replaced(self, text)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Component init function
|
||||
Replace selected text with new text
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Input</span></span>
|
||||
<a href="../modules/Input.html#">Input</a>
|
||||
</li>
|
||||
<li><span class="parameter">text</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
The text to replace selected text
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
New input text
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, click_node, text_node, keyboard_type)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The <a href="../modules/Input.html#">Input</a> constructor
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -241,9 +320,41 @@
|
||||
Text node what will be changed on user input. You can pass text component instead of text node name <a href="../modules/Text.html#">Text</a>
|
||||
</li>
|
||||
<li><span class="parameter">keyboard_type</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Gui keyboard type for input field
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "move_selection"></a>
|
||||
<strong>move_selection(self, delta, is_add_to_selection, is_move_to_end)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Change cursor position by delta
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Input</span></span>
|
||||
<a href="../modules/Input.html#">Input</a>
|
||||
</li>
|
||||
<li><span class="parameter">delta</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
side for cursor position, -1 for left, 1 for right
|
||||
</li>
|
||||
<li><span class="parameter">is_add_to_selection</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
(Shift key)
|
||||
</li>
|
||||
<li><span class="parameter">is_move_to_end</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
(Ctrl key)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -268,6 +379,12 @@
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">druid.input</span></span>
|
||||
Current input instance
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
@@ -293,6 +410,45 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "select_cursor"></a>
|
||||
<strong>select_cursor(self, cursor_index, start_index, end_index)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set cursor position in input field
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Input</span></span>
|
||||
<a href="../modules/Input.html#">Input</a>
|
||||
</li>
|
||||
<li><span class="parameter">cursor_index</span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Cursor index for cursor position, if nil - will be set to the end of the text
|
||||
</li>
|
||||
<li><span class="parameter">start_index</span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Start index for cursor position, if nil - will be set to the end of the text
|
||||
</li>
|
||||
<li><span class="parameter">end_index</span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
End index for cursor position, if nil - will be set to the start_index
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">druid.input</span></span>
|
||||
Current input instance
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_allowed_characters"></a>
|
||||
@@ -422,24 +578,16 @@
|
||||
<h3>Fields:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">IS_LONGTAP_ERASE</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
Is long tap will erase current input data
|
||||
(<em>default</em> false)
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
Is long tap will erase current input data. Default: false
|
||||
</li>
|
||||
<li><span class="parameter">MASK_DEFAULT_CHAR</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
Default character mask for password input
|
||||
(<em>default</em> *)
|
||||
Default character mask for password input. Default: *]
|
||||
</li>
|
||||
<li><span class="parameter">IS_UNSELECT_ON_RESELECT</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
If true, call unselect on select selected input
|
||||
(<em>default</em> false)
|
||||
</li>
|
||||
<li><span class="parameter">NO_CONSUME_INPUT_WHILE_SELECTED</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
If true, will not consume input while input is selected. It's allow to interact with other components while input is selected (text input still captured)
|
||||
(<em>default</em> false)
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
If true, call unselect on select selected input. Default: false
|
||||
</li>
|
||||
<li><span class="parameter">on_select</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
@@ -453,10 +601,6 @@
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
(self, button_node) Callback on wrong user input
|
||||
</li>
|
||||
<li><span class="parameter">button_style</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
||||
Custom button style for input node
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -478,9 +622,8 @@
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">allowerd_characters</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -508,6 +651,66 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "current_value"></a>
|
||||
<strong>current_value</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Current input value with marked text
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">current_value</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "cursor_index"></a>
|
||||
<strong>cursor_index</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The cursor index. The index of letter cursor after. Leftmost cursor - 0
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">cursor_index</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "end_index"></a>
|
||||
<strong>end_index</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Theselection end index. The index of letter cursor before. Rightmost selection - #text
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">end_index</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "is_empty"></a>
|
||||
@@ -519,7 +722,7 @@
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">is_empty</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
@@ -539,7 +742,7 @@
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">is_selected</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
@@ -568,6 +771,46 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "marked_text_width"></a>
|
||||
<strong>marked_text_width</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Marked text width
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">marked_text_width</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "marked_value"></a>
|
||||
<strong>marked_value</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Marked text for input field. Info: https://defold.com/manuals/input-key-and-text/#marked-text
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">marked_value</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "max_length"></a>
|
||||
@@ -579,9 +822,8 @@
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">max_length</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -635,7 +877,7 @@
|
||||
<strong>on_input_select</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
On input field select callback(self, button_node)
|
||||
On input field select callback(self, input_instance)
|
||||
|
||||
|
||||
<ul>
|
||||
@@ -675,7 +917,7 @@
|
||||
<strong>on_input_unselect</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
On input field unselect callback(self, input_text)
|
||||
On input field unselect callback(self, input_text, input_instance)
|
||||
|
||||
|
||||
<ul>
|
||||
@@ -695,7 +937,7 @@
|
||||
<strong>on_input_wrong</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
On trying user input with not allowed character callback(self, params, button_instance)
|
||||
On trying user input with not allowed character callback(self, params, input_text)
|
||||
|
||||
|
||||
<ul>
|
||||
@@ -709,6 +951,66 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "on_select_cursor_change"></a>
|
||||
<strong>on_select_cursor_change</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
On cursor position change callback(self, cursor_index, start_index, end_index)
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">on_select_cursor_change</span>
|
||||
<span class="types"><span class="type">DruidEvent</span></span>
|
||||
<a href="../modules/DruidEvent.html#">DruidEvent</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "previous_value"></a>
|
||||
<strong>previous_value</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Previous input value
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">previous_value</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "start_index"></a>
|
||||
<strong>start_index</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The selection start index. The index of letter cursor after. Leftmost selection - 0
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">start_index</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "text"></a>
|
||||
@@ -729,6 +1031,46 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "text_width"></a>
|
||||
<strong>text_width</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Text width
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">text_width</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "value"></a>
|
||||
<strong>value</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Current input value
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">value</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
@@ -43,8 +43,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -57,9 +55,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><strong>LangText</strong></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -89,11 +85,11 @@
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#format">format(self[, a[, b[, c[, d[, e[, f[, g]]]]]]])</a></td>
|
||||
<td class="name" nowrap><a href="#format">format(self, a, b, c, d, e, f, g)</a></td>
|
||||
<td class="summary">Format string with new text params on localized text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, locale_id[, adjust_type=downscale])</a></td>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, locale_id, adjust_type)</a></td>
|
||||
<td class="summary">The <a href="../modules/LangText.html#">LangText</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -101,12 +97,16 @@
|
||||
<td class="summary">Setup raw text to lang_text component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#translate">translate(self, locale_id[, a[, b[, c[, d[, e[, f[, g]]]]]]])</a></td>
|
||||
<td class="name" nowrap><a href="#translate">translate(self, locale_id, a, b, c, d, e, f, g)</a></td>
|
||||
<td class="summary">Translate the text by locale_id</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Fields">Fields</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#node">node</a></td>
|
||||
<td class="summary">Text node</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_change">on_change</a></td>
|
||||
<td class="summary">On change text callback</td>
|
||||
@@ -126,7 +126,7 @@
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "format"></a>
|
||||
<strong>format(self[, a[, b[, c[, d[, e[, f[, g]]]]]]])</strong>
|
||||
<strong>format(self, a, b, c, d, e, f, g)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Format string with new text params on localized text
|
||||
@@ -139,39 +139,32 @@
|
||||
<a href="../modules/LangText.html#">LangText</a>
|
||||
</li>
|
||||
<li><span class="parameter">a</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Optional param to string.format
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">b</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Optional param to string.format
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">c</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Optional param to string.format
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">d</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Optional param to string.format
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">e</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Optional param to string.format
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">f</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Optional param to string.format
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">g</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Optional param to string.format
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -188,7 +181,7 @@
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, node, locale_id[, adjust_type=downscale])</strong>
|
||||
<strong>init(self, node, locale_id, adjust_type)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The <a href="../modules/LangText.html#">LangText</a> constructor
|
||||
@@ -201,17 +194,16 @@
|
||||
<a href="../modules/LangText.html#">LangText</a>
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
|
||||
Node name or GUI Text Node itself
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <a class="type" href="../modules/LangText.html#node">node</a></span>
|
||||
The node_id or gui.get_node(node_id)
|
||||
</li>
|
||||
<li><span class="parameter">locale_id</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Default locale id or text from node as default
|
||||
</li>
|
||||
<li><span class="parameter">adjust_type</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference
|
||||
(<em>default</em> downscale)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -253,7 +245,7 @@
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "translate"></a>
|
||||
<strong>translate(self, locale_id[, a[, b[, c[, d[, e[, f[, g]]]]]]])</strong>
|
||||
<strong>translate(self, locale_id, a, b, c, d, e, f, g)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Translate the text by locale_id
|
||||
@@ -270,39 +262,32 @@
|
||||
Locale id
|
||||
</li>
|
||||
<li><span class="parameter">a</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Optional param to string.format
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">b</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Optional param to string.format
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">c</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Optional param to string.format
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">d</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Optional param to string.format
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">e</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Optional param to string.format
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">f</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Optional param to string.format
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">g</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Optional param to string.format
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -321,6 +306,26 @@
|
||||
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "node"></a>
|
||||
<strong>node</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Text node
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><a class="type" href="../modules/LangText.html#node">node</a></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "on_change"></a>
|
||||
<strong>on_change</strong>
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
<li><a href="#Fields">Fields</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -43,8 +42,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -57,9 +54,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><strong>Layout</strong></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -79,45 +74,6 @@
|
||||
<p> <a href="https://insality.github.io/druid/druid/index.html?example=general_layout" target="_blank"><b>Example Link</b></a></p>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#fit_into_node">fit_into_node(self[, node])</a></td>
|
||||
<td class="summary">Set node for layout node to fit inside it.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#fit_into_size">fit_into_size(self, target_size)</a></td>
|
||||
<td class="summary">Set size for layout node to fit inside it</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#fit_into_window">fit_into_window(self)</a></td>
|
||||
<td class="summary">Set current size for layout node to fit inside it</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, mode[, on_size_changed_callback])</a></td>
|
||||
<td class="summary">Component init function</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_max_gui_upscale">set_max_gui_upscale(self, max_gui_upscale)</a></td>
|
||||
<td class="summary">Set max gui upscale for FIT adjust mode (or side).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_max_size">set_max_size(self, max_size)</a></td>
|
||||
<td class="summary">Set maximum size of layout node</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_min_size">set_min_size(self, min_size)</a></td>
|
||||
<td class="summary">Set minimal size of layout node</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_origin_position">set_origin_position(self, new_origin_position)</a></td>
|
||||
<td class="summary">Set new origin position of layout node.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_origin_size">set_origin_size(self, new_origin_size)</a></td>
|
||||
<td class="summary">Set new origin size of layout node.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Fields">Fields</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
@@ -128,299 +84,12 @@
|
||||
<td class="name" nowrap><a href="#node">node</a></td>
|
||||
<td class="summary">Layout node</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_size_changed">on_size_changed</a></td>
|
||||
<td class="summary">On window resize callback(self, new_size)</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "fit_into_node"></a>
|
||||
<strong>fit_into_node(self[, node])</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set node for layout node to fit inside it. Pass nil to reset
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><span class="type">Node</span></span>
|
||||
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "fit_into_size"></a>
|
||||
<strong>fit_into_size(self, target_size)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set size for layout node to fit inside it
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</li>
|
||||
<li><span class="parameter">target_size</span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "fit_into_window"></a>
|
||||
<strong>fit_into_window(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set current size for layout node to fit inside it
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, node, mode[, on_size_changed_callback])</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Component init function
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><a class="type" href="../modules/Layout.html#node">node</a></span>
|
||||
Gui node
|
||||
</li>
|
||||
<li><span class="parameter">mode</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
The layout mode (from const.LAYOUT_MODE)
|
||||
</li>
|
||||
<li><span class="parameter">on_size_changed_callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
The callback on window resize
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_max_gui_upscale"></a>
|
||||
<strong>set_max_gui_upscale(self, max_gui_upscale)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set max gui upscale for FIT adjust mode (or side). It happens on bigger render gui screen
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</li>
|
||||
<li><span class="parameter">max_gui_upscale</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_max_size"></a>
|
||||
<strong>set_max_size(self, max_size)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set maximum size of layout node
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</li>
|
||||
<li><span class="parameter">max_size</span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_min_size"></a>
|
||||
<strong>set_min_size(self, min_size)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set minimal size of layout node
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</li>
|
||||
<li><span class="parameter">min_size</span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_origin_position"></a>
|
||||
<strong>set_origin_position(self, new_origin_position)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set new origin position of layout node. You should apply this on node movement
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</li>
|
||||
<li><span class="parameter">new_origin_position</span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_origin_size"></a>
|
||||
<strong>set_origin_size(self, new_origin_size)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set new origin size of layout node. You should apply this on node manual size change
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</li>
|
||||
<li><span class="parameter">new_origin_size</span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Layout</span></span>
|
||||
<a href="../modules/Layout.html#">Layout</a>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
|
||||
|
||||
<dl class="function">
|
||||
@@ -463,26 +132,6 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "on_size_changed"></a>
|
||||
<strong>on_size_changed</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
On window resize callback(self, new_size)
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">on_size_changed</span>
|
||||
<span class="types"><span class="type">DruidEvent</span></span>
|
||||
<a href="../modules/DruidEvent.html#">DruidEvent</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
@@ -84,14 +84,14 @@
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, callback, template, nodes)</a></td>
|
||||
<td class="summary">Component init function</td>
|
||||
<td class="summary">The <a href="../modules/PinKnob.html#">PinKnob</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_angle">set_angle(self, cur_value, min, max)</a></td>
|
||||
<td class="summary">Set current and min/max angles for component</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_friction">set_friction(self[, value=1])</a></td>
|
||||
<td class="name" nowrap><a href="#set_friction">set_friction(self, value)</a></td>
|
||||
<td class="summary">Set current and min/max angles for component</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -123,7 +123,7 @@
|
||||
<strong>init(self, callback, template, nodes)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Component init function
|
||||
The <a href="../modules/PinKnob.html#">PinKnob</a> constructor
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -192,7 +192,7 @@
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_friction"></a>
|
||||
<strong>set_friction(self[, value=1])</strong>
|
||||
<strong>set_friction(self, value)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set current and min/max angles for component
|
||||
@@ -205,9 +205,8 @@
|
||||
<a href="../modules/PinKnob.html#">PinKnob</a>
|
||||
</li>
|
||||
<li><span class="parameter">value</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
The spin speed multiplier
|
||||
(<em>default</em> 1)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
The spin speed multiplier. Default: 1
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -256,7 +255,7 @@
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">is_drag</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -44,8 +44,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -58,9 +56,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><strong>Progress</strong></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -103,8 +99,8 @@
|
||||
<td class="summary">Return current progress bar value</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, key[, init_value=1])</a></td>
|
||||
<td class="summary"><a href="../modules/Progress.html#">Progress</a> constructor</td>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, key, init_value)</a></td>
|
||||
<td class="summary">The <a href="../modules/Progress.html#">Progress</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_max_size">set_max_size(self, max_size)</a></td>
|
||||
@@ -119,7 +115,7 @@
|
||||
<td class="summary">Instant fill progress bar to value</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#to">to(self, to[, callback])</a></td>
|
||||
<td class="name" nowrap><a href="#to">to(self, to, callback)</a></td>
|
||||
<td class="summary">Start animation of a progress bar</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -234,10 +230,10 @@
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, node, key[, init_value=1])</strong>
|
||||
<strong>init(self, node, key, init_value)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
<a href="../modules/Progress.html#">Progress</a> constructor
|
||||
The <a href="../modules/Progress.html#">Progress</a> constructor
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -255,9 +251,8 @@
|
||||
Progress bar direction: const.SIDE.X or const.SIDE.Y
|
||||
</li>
|
||||
<li><span class="parameter">init_value</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Initial value of progress bar
|
||||
(<em>default</em> 1)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Initial value of progress bar. Default: 1
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -357,7 +352,7 @@
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "to"></a>
|
||||
<strong>to(self, to[, callback])</strong>
|
||||
<strong>to(self, to, callback)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Start animation of a progress bar
|
||||
@@ -374,9 +369,8 @@
|
||||
value between 0..1
|
||||
</li>
|
||||
<li><span class="parameter">callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
<span class="types"><span class="type">function</span> or <span class="type">nil</span></span>
|
||||
Callback on animation ends
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -402,14 +396,12 @@
|
||||
<h3>Fields:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">SPEED</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Progress bas fill rate. More -> faster
|
||||
(<em>default</em> 5)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Progress bas fill rate. More -> faster. Default: 5
|
||||
</li>
|
||||
<li><span class="parameter">MIN_DELTA</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Minimum step to fill progress bar
|
||||
(<em>default</em> 0.005)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Minimum step to fill progress bar. Default: 0.005
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -57,7 +57,6 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><strong>RadioGroup</strong></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
@@ -86,8 +85,8 @@
|
||||
<td class="summary">Return radio group state</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, nodes, callback[, click_nodes=node])</a></td>
|
||||
<td class="summary">Component init function</td>
|
||||
<td class="name" nowrap><a href="#init">init(self, nodes, callback, click_nodes)</a></td>
|
||||
<td class="summary">The <a href="../modules/RadioGroup.html#">RadioGroup</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_state">set_state(self, index, is_instant)</a></td>
|
||||
@@ -142,10 +141,10 @@
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, nodes, callback[, click_nodes=node])</strong>
|
||||
<strong>init(self, nodes, callback, click_nodes)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Component init function
|
||||
The <a href="../modules/RadioGroup.html#">RadioGroup</a> constructor
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -163,9 +162,8 @@
|
||||
Radio callback
|
||||
</li>
|
||||
<li><span class="parameter">click_nodes</span>
|
||||
<span class="types"><span class="type">node[]</span></span>
|
||||
Array of trigger nodes, by default equals to nodes
|
||||
(<em>default</em> node)
|
||||
<span class="types"><span class="type">node[]</span> or <span class="type">nil</span></span>
|
||||
Array of trigger nodes, by default equals to nodes. Default - nodes
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -193,7 +191,7 @@
|
||||
Index in radio group
|
||||
</li>
|
||||
<li><span class="parameter">is_instant</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
If is instant state change
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -43,8 +43,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -57,9 +55,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><strong>RichInput</strong></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -82,14 +78,34 @@
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_text">get_text(self)</a></td>
|
||||
<td class="summary">Set input field text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, template, nodes)</a></td>
|
||||
<td class="summary">Component init function</td>
|
||||
<td class="summary">The <a href="../modules/RichInput.html#">RichInput</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#select">select(self)</a></td>
|
||||
<td class="summary">Select input field</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_allowed_characters">set_allowed_characters(self, characters)</a></td>
|
||||
<td class="summary">Set allowed charaters for input field.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_font">set_font(self, font)</a></td>
|
||||
<td class="summary">Set input field font</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_placeholder">set_placeholder(self, placeholder_text)</a></td>
|
||||
<td class="summary">Set placeholder text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_text">set_text(self, text)</a></td>
|
||||
<td class="summary">Set input field text</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Fields">Fields</a></h2>
|
||||
<table class="function_list">
|
||||
@@ -98,6 +114,18 @@
|
||||
<td class="summary">On input field text change to empty string callback(self, input_text)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#cursor_position">cursor_position</a></td>
|
||||
<td class="summary">On input field text change to empty string callback(self, input_text)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#cursor_text">cursor_text</a></td>
|
||||
<td class="summary">On input field text change to empty string callback(self, input_text)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#drag">drag</a></td>
|
||||
<td class="summary">On input field text change to empty string callback(self, input_text)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#druid">druid</a></td>
|
||||
<td class="summary">The component druid instance</td>
|
||||
</tr>
|
||||
@@ -106,8 +134,20 @@
|
||||
<td class="summary">On input field text change callback(self, input_text)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#input_text">input_text</a></td>
|
||||
<td class="summary">On input field text change to empty string callback(self, input_text)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#placeholder">placeholder</a></td>
|
||||
<td class="summary">On input field text change to max length string callback(self, input_text)</td>
|
||||
<td class="summary">On input field text change to empty string callback(self, input_text)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#root">root</a></td>
|
||||
<td class="summary">Root node</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#text_position">text_position</a></td>
|
||||
<td class="summary">On input field text change to empty string callback(self, input_text)</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -118,12 +158,33 @@
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "get_text"></a>
|
||||
<strong>get_text(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set input field text
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">RichInput</span></span>
|
||||
<a href="../modules/RichInput.html#">RichInput</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, template, nodes)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Component init function
|
||||
The <a href="../modules/RichInput.html#">RichInput</a> constructor
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -146,6 +207,91 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "select"></a>
|
||||
<strong>select(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Select input field
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">RichInput</span></span>
|
||||
<a href="../modules/RichInput.html#">RichInput</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_allowed_characters"></a>
|
||||
<strong>set_allowed_characters(self, characters)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set allowed charaters for input field.
|
||||
See: https://defold.com/ref/stable/string/
|
||||
ex: [%a%d] for alpha and numeric
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">RichInput</span></span>
|
||||
<a href="../modules/RichInput.html#">RichInput</a>
|
||||
</li>
|
||||
<li><span class="parameter">characters</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
Regulax exp. for validate user input
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">RichInput</span></span>
|
||||
Current instance
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_font"></a>
|
||||
<strong>set_font(self, font)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set input field font
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">RichInput</span></span>
|
||||
<a href="../modules/RichInput.html#">RichInput</a>
|
||||
</li>
|
||||
<li><span class="parameter">font</span>
|
||||
<span class="types"><span class="type">hash</span></span>
|
||||
The font hash
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">druid.input</span></span>
|
||||
Current input instance
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_placeholder"></a>
|
||||
@@ -171,6 +317,37 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_text"></a>
|
||||
<strong>set_text(self, text)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set input field text
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">RichInput</span></span>
|
||||
<a href="../modules/RichInput.html#">RichInput</a>
|
||||
</li>
|
||||
<li><span class="parameter">text</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
The input text
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">druid.input</span></span>
|
||||
Current input instance
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
|
||||
@@ -195,6 +372,66 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "cursor_position"></a>
|
||||
<strong>cursor_position</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
On input field text change to empty string callback(self, input_text)
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">cursor_position</span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "cursor_text"></a>
|
||||
<strong>cursor_text</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
On input field text change to empty string callback(self, input_text)
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">cursor_text</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "drag"></a>
|
||||
<strong>drag</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
On input field text change to empty string callback(self, input_text)
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">drag</span>
|
||||
<span class="types"><span class="type">druid.drag</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "druid"></a>
|
||||
@@ -235,19 +472,79 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "input_text"></a>
|
||||
<strong>input_text</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
On input field text change to empty string callback(self, input_text)
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">input_text</span>
|
||||
<span class="types"><span class="type">druid.text</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "placeholder"></a>
|
||||
<strong>placeholder</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
On input field text change to max length string callback(self, input_text)
|
||||
On input field text change to empty string callback(self, input_text)
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">placeholder</span>
|
||||
<span class="types"><span class="type">druid.text</span></span>
|
||||
<a href="../modules/Text.html#">Text</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "root"></a>
|
||||
<strong>root</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Root node
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">root</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "text_position"></a>
|
||||
<strong>text_position</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
On input field text change to empty string callback(self, input_text)
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">text_position</span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
<li><a href="#Tables">Tables</a></li>
|
||||
<li><a href="#Fields">Fields</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -43,8 +44,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -57,9 +56,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><strong>RichText</strong></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -80,19 +77,7 @@
|
||||
<b># Overview #</b>
|
||||
<p> This custom component is inspired by <a href="https://github.com/britzl/defold-richtext" target="_blank">defold-richtext</a> by britzl.
|
||||
It uses a similar syntax for tags but currently supports fewer tags.
|
||||
<p> All parameters for the Rich Text component are adjusted in the GUI scene.
|
||||
<p> This component uses GUI component template. (/druid/custom/rich_text/rich_text.gui).
|
||||
<p> You able to customize it or make your own with the next node scructure:
|
||||
<p> root
|
||||
<p> - text_prefab
|
||||
<p> - icon_prefab
|
||||
<p> <b># Rich Text Setup #</b>
|
||||
<p> • Root node size: Set the maximum width and height of the text.
|
||||
<p> • Root anchor: Define the alignment of the Rich Text inside the root node size area.
|
||||
<p> • Text prefab: Configure all default text parameters for the text node.
|
||||
<p> • Text prefab anchor: Set the anchor for each text node (adjust this only if animating text).
|
||||
<p> • Icon prefab: Configure all default node parameters for the icon node.
|
||||
<p> • Icon prefab anchor: Set the anchor for each icon node (adjust this only if animating the icon).
|
||||
<p> Create Rich Text on your GUI Text Node. All properties of the text node will be used as default for the text.
|
||||
<p> <b># Notes #</b>
|
||||
<p> • Nested tags are supported
|
||||
<p> <a href="https://insality.github.io/druid/druid/index.html?example=custom_rich_text" target="_blank"><b>Example Link</b></a></p>
|
||||
@@ -118,7 +103,6 @@ self.rich_text:set_text("Hello, Druid Rich Text!")
|
||||
outline: vector4,
|
||||
font: string,
|
||||
image: druid.rich_text.image,
|
||||
default_animation: string,
|
||||
br: boolean,
|
||||
nobr: boolean,
|
||||
}
|
||||
@@ -149,6 +133,10 @@ type druid.rich_text.metrics = {
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#characters">characters(self, word)</a></td>
|
||||
<td class="summary">Split a word into it's characters</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#clear">clear()</a></td>
|
||||
<td class="summary">Clear all created words.</td>
|
||||
@@ -158,19 +146,23 @@ type druid.rich_text.metrics = {
|
||||
<td class="summary">Get current line metrics</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_text">get_text(self)</a></td>
|
||||
<td class="summary">Get current text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_words">get_words()</a></td>
|
||||
<td class="summary">Get all current words.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, template, nodes)</a></td>
|
||||
<td class="summary">Rich Text component constructor</td>
|
||||
<td class="name" nowrap><a href="#init">init(self, text_node, value)</a></td>
|
||||
<td class="summary">The <a href="../modules/RichText.html#">RichText</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_text">set_text(self, text)</a></td>
|
||||
<td class="summary">Set text for Rich Text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#tagged">tagged(tag)</a></td>
|
||||
<td class="name" nowrap><a href="#tagged">tagged(self, tag)</a></td>
|
||||
<td class="summary">Get all words, which has a passed tag.</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -181,6 +173,21 @@ type druid.rich_text.metrics = {
|
||||
<td class="summary">Component style params.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Fields">Fields</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#druid">druid</a></td>
|
||||
<td class="summary">The component druid instance</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#root">root</a></td>
|
||||
<td class="summary">The root node of the Rich Text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#text_prefab">text_prefab</a></td>
|
||||
<td class="summary">The text prefab node</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
@@ -189,6 +196,37 @@ type druid.rich_text.metrics = {
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "characters"></a>
|
||||
<strong>characters(self, word)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Split a word into it's characters
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">RichText</span></span>
|
||||
<a href="../modules/RichText.html#">RichText</a>
|
||||
</li>
|
||||
<li><span class="parameter">word</span>
|
||||
<span class="types"><span class="type">druid.rich_text.word</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">druid.rich_text.word[]</span></span>
|
||||
characters
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "clear"></a>
|
||||
<strong>clear()</strong>
|
||||
@@ -222,6 +260,33 @@ type druid.rich_text.metrics = {
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_text"></a>
|
||||
<strong>get_text(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Get current text
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">RichText</span></span>
|
||||
<a href="../modules/RichText.html#">RichText</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
text
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_words"></a>
|
||||
@@ -245,10 +310,10 @@ type druid.rich_text.metrics = {
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, template, nodes)</strong>
|
||||
<strong>init(self, text_node, value)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Rich Text component constructor
|
||||
The <a href="../modules/RichText.html#">RichText</a> constructor
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -257,13 +322,13 @@ type druid.rich_text.metrics = {
|
||||
<span class="types"><span class="type">RichText</span></span>
|
||||
<a href="../modules/RichText.html#">RichText</a>
|
||||
</li>
|
||||
<li><span class="parameter">template</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
The Rich Text template name
|
||||
<li><span class="parameter">text_node</span>
|
||||
<span class="types"><span class="type">node</span> or <a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
The text node to make Rich Text
|
||||
</li>
|
||||
<li><span class="parameter">nodes</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
||||
The node table, if prefab was copied by gui.clone_tree()
|
||||
<li><span class="parameter">value</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
The initial text value. Default will be gui.get_text(text_node)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -287,7 +352,7 @@ type druid.rich_text.metrics = {
|
||||
<a href="../modules/RichText.html#">RichText</a>
|
||||
</li>
|
||||
<li><span class="parameter">text</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
The text to set
|
||||
</li>
|
||||
</ul>
|
||||
@@ -353,7 +418,7 @@ Words <nobr>inside tag</nobr> won't <span class="keyword">break</spa
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "tagged"></a>
|
||||
<strong>tagged(tag)</strong>
|
||||
<strong>tagged(self, tag)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Get all words, which has a passed tag.
|
||||
@@ -361,6 +426,10 @@ Words <nobr>inside tag</nobr> won't <span class="keyword">break</spa
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">RichText</span></span>
|
||||
<a href="../modules/RichText.html#">RichText</a>
|
||||
</li>
|
||||
<li><span class="parameter">tag</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
|
||||
@@ -395,19 +464,80 @@ Words <nobr>inside tag</nobr> won't <span class="keyword">break</spa
|
||||
<h3>Fields:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">COLORS</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
||||
Rich Text color aliases
|
||||
(<em>default</em> {})
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a> or <span class="type">nil</span></span>
|
||||
Rich Text color aliases. Default: {}
|
||||
</li>
|
||||
<li><span class="parameter">ADJUST_STEPS</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Amount steps of attemps text adjust by height
|
||||
(<em>default</em> 20)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Amount steps of attemps text adjust by height. Default: 20
|
||||
</li>
|
||||
<li><span class="parameter">ADJUST_SCALE_DELTA</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Scale step on each height adjust step
|
||||
(<em>default</em> 0.02)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Scale step on each height adjust step. Default: 0.02
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "druid"></a>
|
||||
<strong>druid</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The component druid instance
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">druid</span>
|
||||
<span class="types"><span class="type">DruidInstance</span></span>
|
||||
<a href="../modules/DruidInstance.html#">DruidInstance</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "root"></a>
|
||||
<strong>root</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The root node of the Rich Text
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">root</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "text_prefab"></a>
|
||||
<strong>text_prefab</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The text prefab node
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">text_prefab</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -44,8 +44,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -58,9 +56,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><strong>Scroll</strong></li>
|
||||
@@ -117,7 +113,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, view_node, content_node)</a></td>
|
||||
<td class="summary"><a href="../modules/Scroll.html#">Scroll</a> constructor</td>
|
||||
<td class="summary">The <a href="../modules/Scroll.html#">Scroll</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#is_inert">is_inert(self)</a></td>
|
||||
@@ -128,15 +124,15 @@
|
||||
<td class="summary">Check node if it visible now on scroll.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#scroll_to">scroll_to(self, point[, is_instant])</a></td>
|
||||
<td class="name" nowrap><a href="#scroll_to">scroll_to(self, point, is_instant)</a></td>
|
||||
<td class="summary">Start scroll to target point.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#scroll_to_index">scroll_to_index(self, index[, skip_cb])</a></td>
|
||||
<td class="name" nowrap><a href="#scroll_to_index">scroll_to_index(self, index, skip_cb)</a></td>
|
||||
<td class="summary">Scroll to item in scroll by point index.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#scroll_to_percent">scroll_to_percent(self, percent[, is_instant])</a></td>
|
||||
<td class="name" nowrap><a href="#scroll_to_percent">scroll_to_percent(self, percent, is_instant)</a></td>
|
||||
<td class="summary">Start scroll to target scroll percent</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -144,7 +140,7 @@
|
||||
<td class="summary">Strict drag scroll area.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_extra_stretch_size">set_extra_stretch_size(self[, stretch_size=0])</a></td>
|
||||
<td class="name" nowrap><a href="#set_extra_stretch_size">set_extra_stretch_size(self, stretch_size)</a></td>
|
||||
<td class="summary">Set extra size for scroll stretching.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -167,6 +163,14 @@
|
||||
<td class="name" nowrap><a href="#set_vertical_scroll">set_vertical_scroll(self, state)</a></td>
|
||||
<td class="summary">Lock or unlock vertical scroll</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_view_size">set_view_size(self, size)</a></td>
|
||||
<td class="summary">Set new scroll view size in case the node size was changed.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#update_view_size">update_view_size(self)</a></td>
|
||||
<td class="summary">Refresh scroll view size</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Tables">Tables</a></h2>
|
||||
<table class="function_list">
|
||||
@@ -177,6 +181,10 @@
|
||||
</table>
|
||||
<h2><a href="#Fields">Fields</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#_is_inert">_is_inert</a></td>
|
||||
<td class="summary">Flag, if scroll now moving by inertion</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#available_pos">available_pos</a></td>
|
||||
<td class="summary">Available position for content node: (min_x, max_y, max_x, min_y)</td>
|
||||
@@ -202,10 +210,6 @@
|
||||
<td class="summary">Flag, if scroll now animating by gui.animate</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#is_inert">is_inert</a></td>
|
||||
<td class="summary">Flag, if scroll now moving by inertion</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#on_point_scroll">on_point_scroll</a></td>
|
||||
<td class="summary">On scroll_to_index function callback(self, index, point)</td>
|
||||
</tr>
|
||||
@@ -233,6 +237,10 @@
|
||||
<td class="name" nowrap><a href="#view_node">view_node</a></td>
|
||||
<td class="summary">Scroll view node</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#view_size">view_size</a></td>
|
||||
<td class="summary">Scroll view size</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
@@ -258,7 +266,7 @@
|
||||
<a href="../modules/Scroll.html#">Scroll</a>
|
||||
</li>
|
||||
<li><span class="parameter">grid</span>
|
||||
<span class="types"><span class="type">StaticGrid</span> or <span class="type">DynamicGrid</span></span>
|
||||
<span class="types"><span class="type">StaticGrid</span></span>
|
||||
Druid grid component
|
||||
</li>
|
||||
</ul>
|
||||
@@ -334,7 +342,7 @@
|
||||
<strong>init(self, view_node, content_node)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
<a href="../modules/Scroll.html#">Scroll</a> constructor
|
||||
The <a href="../modules/Scroll.html#">Scroll</a> constructor
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -377,8 +385,8 @@
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
If scroll have inertion
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
@If scroll have inertion
|
||||
</ol>
|
||||
|
||||
|
||||
@@ -419,7 +427,7 @@
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "scroll_to"></a>
|
||||
<strong>scroll_to(self, point[, is_instant])</strong>
|
||||
<strong>scroll_to(self, point, is_instant)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Start scroll to target point.
|
||||
@@ -436,9 +444,8 @@
|
||||
Target point
|
||||
</li>
|
||||
<li><span class="parameter">is_instant</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
Instant scroll flag
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -454,7 +461,7 @@
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "scroll_to_index"></a>
|
||||
<strong>scroll_to_index(self, index[, skip_cb])</strong>
|
||||
<strong>scroll_to_index(self, index, skip_cb)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Scroll to item in scroll by point index.
|
||||
@@ -471,9 +478,8 @@
|
||||
Point index
|
||||
</li>
|
||||
<li><span class="parameter">skip_cb</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
If true, skip the point callback
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -484,7 +490,7 @@
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "scroll_to_percent"></a>
|
||||
<strong>scroll_to_percent(self, percent[, is_instant])</strong>
|
||||
<strong>scroll_to_percent(self, percent, is_instant)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Start scroll to target scroll percent
|
||||
@@ -501,9 +507,8 @@
|
||||
target percent
|
||||
</li>
|
||||
<li><span class="parameter">is_instant</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
instant scroll flag
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -532,7 +537,7 @@
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">node</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
<span class="types"><span class="type">node</span> or <a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
Gui node
|
||||
</li>
|
||||
</ul>
|
||||
@@ -544,7 +549,7 @@
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_extra_stretch_size"></a>
|
||||
<strong>set_extra_stretch_size(self[, stretch_size=0])</strong>
|
||||
<strong>set_extra_stretch_size(self, stretch_size)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set extra size for scroll stretching.
|
||||
@@ -558,9 +563,8 @@
|
||||
<a href="../modules/Scroll.html#">Scroll</a>
|
||||
</li>
|
||||
<li><span class="parameter">stretch_size</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Size in pixels of additional scroll area
|
||||
(<em>default</em> 0)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -590,7 +594,7 @@
|
||||
<a href="../modules/Scroll.html#">Scroll</a>
|
||||
</li>
|
||||
<li><span class="parameter">state</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
True, if horizontal scroll is enabled
|
||||
</li>
|
||||
</ul>
|
||||
@@ -623,7 +627,7 @@
|
||||
<a href="../modules/Scroll.html#">Scroll</a>
|
||||
</li>
|
||||
<li><span class="parameter">state</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
Inert scroll state
|
||||
</li>
|
||||
</ul>
|
||||
@@ -691,7 +695,7 @@
|
||||
The new size for content node
|
||||
</li>
|
||||
<li><span class="parameter">offset</span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
<span class="types"><span class="type">vector3</span> or <span class="type">nil</span></span>
|
||||
Offset value to set, where content is starts
|
||||
</li>
|
||||
</ul>
|
||||
@@ -722,7 +726,7 @@
|
||||
<a href="../modules/Scroll.html#">Scroll</a>
|
||||
</li>
|
||||
<li><span class="parameter">state</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
True, if vertical scroll is enabled
|
||||
</li>
|
||||
</ul>
|
||||
@@ -737,6 +741,58 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_view_size"></a>
|
||||
<strong>set_view_size(self, size)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set new scroll view size in case the node size was changed.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Scroll</span></span>
|
||||
<a href="../modules/Scroll.html#">Scroll</a>
|
||||
</li>
|
||||
<li><span class="parameter">size</span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
The new size for view node
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">druid.scroll</span></span>
|
||||
Current scroll instance
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "update_view_size"></a>
|
||||
<strong>update_view_size(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Refresh scroll view size
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Scroll</span></span>
|
||||
<a href="../modules/Scroll.html#">Scroll</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
|
||||
@@ -755,64 +811,52 @@
|
||||
<h3>Fields:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">FRICT</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Multiplier for free inertion
|
||||
(<em>default</em> 0)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Multiplier for free inertion. Default: 0
|
||||
</li>
|
||||
<li><span class="parameter">FRICT_HOLD</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Multiplier for inertion, while touching
|
||||
(<em>default</em> 0)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Multiplier for inertion, while touching. Default: 0
|
||||
</li>
|
||||
<li><span class="parameter">INERT_THRESHOLD</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Scroll speed to stop inertion
|
||||
(<em>default</em> 3)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Scroll speed to stop inertion. Default: 3
|
||||
</li>
|
||||
<li><span class="parameter">INERT_SPEED</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Multiplier for inertion speed
|
||||
(<em>default</em> 30)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Multiplier for inertion speed. Default: 30
|
||||
</li>
|
||||
<li><span class="parameter">POINTS_DEADZONE</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Speed to check points of interests in no_inertion mode
|
||||
(<em>default</em> 20)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Speed to check points of interests in no_inertion mode. Default: 20
|
||||
</li>
|
||||
<li><span class="parameter">BACK_SPEED</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Scroll back returning lerp speed
|
||||
(<em>default</em> 0.35)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Scroll back returning lerp speed. Default: 35
|
||||
</li>
|
||||
<li><span class="parameter">ANIM_SPEED</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Scroll gui.animation speed for scroll_to function
|
||||
(<em>default</em> 0.2)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Scroll gui.animation speed for scroll_to function. Default: 2
|
||||
</li>
|
||||
<li><span class="parameter">EXTRA_STRETCH_SIZE</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
extra size in pixels outside of scroll (stretch effect)
|
||||
(<em>default</em> 0)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
extra size in pixels outside of scroll (stretch effect). Default: 0
|
||||
</li>
|
||||
<li><span class="parameter">SMALL_CONTENT_SCROLL</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
If true, content node with size less than view node size can be scrolled
|
||||
(<em>default</em> false)
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
If true, content node with size less than view node size can be scrolled. Default: false
|
||||
</li>
|
||||
<li><span class="parameter">WHEEL_SCROLL_SPEED</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
The scroll speed via mouse wheel scroll or touchpad. Set to 0 to disable wheel scrolling
|
||||
(<em>default</em> 0)
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
The scroll speed via mouse wheel scroll or touchpad. Set to 0 to disable wheel scrolling. Default: 0
|
||||
</li>
|
||||
<li><span class="parameter">WHEEL_SCROLL_INVERTED</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
If true, invert direction for touchpad and mouse wheel scroll
|
||||
(<em>default</em> false)
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
If true, invert direction for touchpad and mouse wheel scroll. Default: false
|
||||
</li>
|
||||
<li><span class="parameter">WHEEL_SCROLL_BY_INERTION</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
If true, wheel will add inertion to scroll. Direct set position otherwise.
|
||||
(<em>default</em> false)
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
If true, wheel will add inertion to scroll. Direct set position otherwise.. Default: false
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -825,6 +869,26 @@
|
||||
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "_is_inert"></a>
|
||||
<strong>_is_inert</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Flag, if scroll now moving by inertion
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">_is_inert</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "available_pos"></a>
|
||||
<strong>available_pos</strong>
|
||||
@@ -935,27 +999,7 @@
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">is_animate</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "is_inert"></a>
|
||||
<strong>is_inert</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Flag, if scroll now moving by inertion
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">is_inert</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
@@ -1055,9 +1099,8 @@
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">selected</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -1105,6 +1148,26 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "view_size"></a>
|
||||
<strong>view_size</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Scroll view size
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">view_size</span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
@@ -43,8 +43,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -57,9 +55,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -82,14 +78,22 @@
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, end_pos[, callback])</a></td>
|
||||
<td class="summary">Component init function</td>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, end_pos, callback)</a></td>
|
||||
<td class="summary">The <a href="../modules/Slider.html#">Slider</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set">set(self, value[, is_silent])</a></td>
|
||||
<td class="name" nowrap><a href="#is_enabled">is_enabled(self)</a></td>
|
||||
<td class="summary">Check if Slider component is enabled</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set">set(self, value, is_silent)</a></td>
|
||||
<td class="summary">Set value for slider</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_enabled">set_enabled(self, is_enabled)</a></td>
|
||||
<td class="summary">Set Slider input enabled or disabled</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_input_node">set_input_node(self, input_node)</a></td>
|
||||
<td class="summary">Set input zone for slider.</td>
|
||||
</tr>
|
||||
@@ -147,10 +151,10 @@
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, node, end_pos[, callback])</strong>
|
||||
<strong>init(self, node, end_pos, callback)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Component init function
|
||||
The <a href="../modules/Slider.html#">Slider</a> constructor
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -168,9 +172,8 @@
|
||||
The end position of slider
|
||||
</li>
|
||||
<li><span class="parameter">callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
<span class="types"><span class="type">function</span> or <span class="type">nil</span></span>
|
||||
On slider change callback
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -178,10 +181,37 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "is_enabled"></a>
|
||||
<strong>is_enabled(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Check if Slider component is enabled
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Slider</span></span>
|
||||
<a href="../modules/Slider.html#">Slider</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set"></a>
|
||||
<strong>set(self, value[, is_silent])</strong>
|
||||
<strong>set(self, value, is_silent)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set value for slider
|
||||
@@ -198,9 +228,33 @@
|
||||
Value from 0 to 1
|
||||
</li>
|
||||
<li><span class="parameter">is_silent</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
Don't trigger event if true
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_enabled"></a>
|
||||
<strong>set_enabled(self, is_enabled)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set Slider input enabled or disabled
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Slider</span></span>
|
||||
<a href="../modules/Slider.html#">Slider</a>
|
||||
</li>
|
||||
<li><span class="parameter">is_enabled</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -227,7 +281,7 @@
|
||||
<a href="../modules/Slider.html#">Slider</a>
|
||||
</li>
|
||||
<li><span class="parameter">input_node</span>
|
||||
<span class="types"><span class="type">Node</span></span>
|
||||
<span class="types"><a class="type" href="../modules/Slider.html#node">node</a>, <a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
@@ -293,7 +347,7 @@
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">dist</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
@@ -333,7 +387,7 @@
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">is_drag</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -44,8 +44,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -58,9 +56,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -102,7 +98,7 @@
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#add">add(self, item[, index[, shift_policy=SHIFT.RIGHT[, is_instant=false]]])</a></td>
|
||||
<td class="name" nowrap><a href="#add">add(self, item, index, shift_policy, is_instant)</a></td>
|
||||
<td class="summary">Add new item to the grid</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -138,11 +134,15 @@
|
||||
<td class="summary">Return grid content size</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, parent, element[, in_row=1])</a></td>
|
||||
<td class="name" nowrap><a href="#init">init(self, parent, element, in_row)</a></td>
|
||||
<td class="summary">The <a href="../modules/StaticGrid.html#">StaticGrid</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#remove">remove(self, index[, shift_policy=SHIFT.RIGHT[, is_instant=false]])</a></td>
|
||||
<td class="name" nowrap><a href="#refresh">refresh(self)</a></td>
|
||||
<td class="summary">Update grid content</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#remove">remove(self, index, shift_policy, is_instant)</a></td>
|
||||
<td class="summary">Remove the item from the grid.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -154,9 +154,21 @@
|
||||
<td class="summary">Set new in_row elements for grid</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_item_size">set_item_size(self[, width[, height]])</a></td>
|
||||
<td class="summary">Set new node size for grid</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_items">set_items(self, nodes[, is_instant=false])</a></td>
|
||||
<td class="summary">Set new items to the grid.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_position_function">set_position_function(self, callback)</a></td>
|
||||
<td class="summary">Change set position function for grid nodes.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#sort_nodes">sort_nodes(self, comparator)</a></td>
|
||||
<td class="summary">Sort grid nodes by custom comparator function</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Tables">Tables</a></h2>
|
||||
<table class="function_list">
|
||||
@@ -230,7 +242,7 @@
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "add"></a>
|
||||
<strong>add(self, item[, index[, shift_policy=SHIFT.RIGHT[, is_instant=false]]])</strong>
|
||||
<strong>add(self, item, index, shift_policy, is_instant)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Add new item to the grid
|
||||
@@ -244,22 +256,19 @@
|
||||
</li>
|
||||
<li><span class="parameter">item</span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
Gui node
|
||||
GUI node
|
||||
</li>
|
||||
<li><span class="parameter">index</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
The item position. By default add as last item
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">shift_policy</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
How shift nodes, if required. See const.SHIFT
|
||||
(<em>default</em> SHIFT.RIGHT)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
How shift nodes, if required. Default: const.SHIFT.RIGHT
|
||||
</li>
|
||||
<li><span class="parameter">is_instant</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
If true, update node positions instantly
|
||||
(<em>default</em> false)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -463,7 +472,7 @@
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
Node position
|
||||
@Node position
|
||||
</ol>
|
||||
|
||||
|
||||
@@ -499,7 +508,7 @@
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, parent, element[, in_row=1])</strong>
|
||||
<strong>init(self, parent, element, in_row)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The <a href="../modules/StaticGrid.html#">StaticGrid</a> constructor
|
||||
@@ -512,7 +521,7 @@
|
||||
<a href="../modules/StaticGrid.html#">StaticGrid</a>
|
||||
</li>
|
||||
<li><span class="parameter">parent</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">Node</span></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
|
||||
The GUI Node container, where grid's items will be placed
|
||||
</li>
|
||||
<li><span class="parameter">element</span>
|
||||
@@ -520,9 +529,29 @@
|
||||
Element prefab. Need to get it size
|
||||
</li>
|
||||
<li><span class="parameter">in_row</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
How many nodes in row can be placed
|
||||
(<em>default</em> 1)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
How many nodes in row can be placed. By default 1
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "refresh"></a>
|
||||
<strong>refresh(self)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Update grid content
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">StaticGrid</span></span>
|
||||
<a href="../modules/StaticGrid.html#">StaticGrid</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -533,7 +562,7 @@
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "remove"></a>
|
||||
<strong>remove(self, index[, shift_policy=SHIFT.RIGHT[, is_instant=false]])</strong>
|
||||
<strong>remove(self, index, shift_policy, is_instant)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Remove the item from the grid. Note that gui node will be not deleted
|
||||
@@ -550,21 +579,19 @@
|
||||
The grid node index to remove
|
||||
</li>
|
||||
<li><span class="parameter">shift_policy</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
How shift nodes, if required. See const.SHIFT
|
||||
(<em>default</em> SHIFT.RIGHT)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
How shift nodes, if required. Default: const.SHIFT.RIGHT
|
||||
</li>
|
||||
<li><span class="parameter">is_instant</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
If true, update node positions instantly
|
||||
(<em>default</em> false)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Node</span></span>
|
||||
<span class="types"><span class="type">node</span></span>
|
||||
The deleted gui node from grid
|
||||
</ol>
|
||||
|
||||
@@ -627,6 +654,73 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_item_size"></a>
|
||||
<strong>set_item_size(self[, width[, height]])</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set new node size for grid
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">StaticGrid</span></span>
|
||||
<a href="../modules/StaticGrid.html#">StaticGrid</a>
|
||||
</li>
|
||||
<li><span class="parameter">width</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
The new node width
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">height</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
The new node height
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">druid.static_grid</span></span>
|
||||
Current grid instance
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_items"></a>
|
||||
<strong>set_items(self, nodes[, is_instant=false])</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set new items to the grid. All previous items will be removed
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">StaticGrid</span></span>
|
||||
<a href="../modules/StaticGrid.html#">StaticGrid</a>
|
||||
</li>
|
||||
<li><span class="parameter">nodes</span>
|
||||
<span class="types"><span class="type">node[]</span></span>
|
||||
The new grid nodes
|
||||
</li>
|
||||
<li><span class="parameter">is_instant</span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
If true, update node positions instantly
|
||||
(<em>default</em> false)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_position_function"></a>
|
||||
@@ -659,6 +753,37 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "sort_nodes"></a>
|
||||
<strong>sort_nodes(self, comparator)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Sort grid nodes by custom comparator function
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">StaticGrid</span></span>
|
||||
<a href="../modules/StaticGrid.html#">StaticGrid</a>
|
||||
</li>
|
||||
<li><span class="parameter">comparator</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
The comparator function. (a, b) -> boolean
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">druid.static_grid</span></span>
|
||||
Current grid instance
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
|
||||
@@ -677,14 +802,12 @@
|
||||
<h3>Fields:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">IS_DYNAMIC_NODE_POSES</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
If true, always center grid content as grid pivot sets
|
||||
(<em>default</em> false)
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
If true, always center grid content as grid pivot sets. Default: false
|
||||
</li>
|
||||
<li><span class="parameter">IS_ALIGN_LAST_ROW</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
If true, always align last row of the grid as grid pivot sets
|
||||
(<em>default</em> false)
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
If true, always align last row of the grid as grid pivot sets. Default: false
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -44,8 +44,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -58,9 +56,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -87,7 +83,7 @@
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, on_swipe_callback)</a></td>
|
||||
<td class="summary">Component init function</td>
|
||||
<td class="summary">The <a href="../modules/Swipe.html#">Swipe</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_click_zone">set_click_zone(self, zone)</a></td>
|
||||
@@ -129,7 +125,7 @@
|
||||
<strong>init(self, node, on_swipe_callback)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Component init function
|
||||
The <a href="../modules/Swipe.html#">Swipe</a> constructor
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -169,7 +165,7 @@
|
||||
<a href="../modules/Swipe.html#">Swipe</a>
|
||||
</li>
|
||||
<li><span class="parameter">zone</span>
|
||||
<span class="types"><a class="type" href="../modules/Swipe.html#node">node</a></span>
|
||||
<span class="types"><a class="type" href="../modules/Swipe.html#node">node</a>, <a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Gui node
|
||||
</li>
|
||||
</ul>
|
||||
@@ -196,19 +192,16 @@
|
||||
<h3>Fields:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">SWIPE_TIME</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Maximum time for swipe trigger
|
||||
(<em>default</em> 0.4)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Maximum time for swipe trigger. Default: 0.4
|
||||
</li>
|
||||
<li><span class="parameter">SWIPE_THRESHOLD</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Minimum distance for swipe trigger
|
||||
(<em>default</em> 50)
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Minimum distance for swipe trigger. Default: 50
|
||||
</li>
|
||||
<li><span class="parameter">SWIPE_TRIGGER_ON_MOVE</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
If true, trigger on swipe moving, not only release action
|
||||
(<em>default</em> false)
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
If true, trigger on swipe moving, not only release action. Default: false
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -231,9 +224,8 @@
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">click_zone</span>
|
||||
<span class="types"><a class="type" href="../modules/Swipe.html#node">node</a></span>
|
||||
<span class="types"><a class="type" href="../modules/Swipe.html#node">node</a> or <span class="type">nil</span></span>
|
||||
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -44,8 +44,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -58,9 +56,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -105,12 +101,16 @@
|
||||
<td class="summary">Return current text adjust type</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_text_size">get_text_size(self[, text])</a></td>
|
||||
<td class="name" nowrap><a href="#get_text_index_by_width">get_text_index_by_width(self, width)</a></td>
|
||||
<td class="summary">Get chars count by width</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_text_size">get_text_size(self, text)</a></td>
|
||||
<td class="summary">Calculate text width with font with respect to trailing space</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, node[, value[, adjust_type=downscale]])</a></td>
|
||||
<td class="summary"><a href="../modules/Text.html#">Text</a> constructor</td>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, value, adjust_type)</a></td>
|
||||
<td class="summary">The <a href="../modules/Text.html#">Text</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#is_multiline">is_multiline(self)</a></td>
|
||||
@@ -137,7 +137,11 @@
|
||||
<td class="summary">Set scale</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_text_adjust">set_text_adjust(self[, adjust_type[, minimal_scale]])</a></td>
|
||||
<td class="name" nowrap><a href="#set_size">set_size(self, size)</a></td>
|
||||
<td class="summary">Set text area size</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_text_adjust">set_text_adjust(self, adjust_type, minimal_scale)</a></td>
|
||||
<td class="summary">Set text adjust, refresh the current text visuals, if needed</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -163,6 +167,10 @@
|
||||
<td class="summary">Current text color</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#last_value">last_value</a></td>
|
||||
<td class="summary">The last text value</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#node">node</a></td>
|
||||
<td class="summary">Text node</td>
|
||||
</tr>
|
||||
@@ -239,10 +247,41 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_text_index_by_width"></a>
|
||||
<strong>get_text_index_by_width(self, width)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Get chars count by width
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Text</span></span>
|
||||
<a href="../modules/Text.html#">Text</a>
|
||||
</li>
|
||||
<li><span class="parameter">width</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
Chars count
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_text_size"></a>
|
||||
<strong>get_text_size(self[, text])</strong>
|
||||
<strong>get_text_size(self, text)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Calculate text width with font with respect to trailing space
|
||||
@@ -256,8 +295,7 @@
|
||||
</li>
|
||||
<li><span class="parameter">text</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
|
||||
(<em>optional</em>)
|
||||
|nil
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -277,10 +315,10 @@
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, node[, value[, adjust_type=downscale]])</strong>
|
||||
<strong>init(self, node, value, adjust_type)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
<a href="../modules/Text.html#">Text</a> constructor
|
||||
The <a href="../modules/Text.html#">Text</a> constructor
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -294,14 +332,12 @@
|
||||
Node name or GUI Text Node itself
|
||||
</li>
|
||||
<li><span class="parameter">value</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
Initial text. Default value is node text from GUI scene.
|
||||
(<em>optional</em>)
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Initial text. Default value is node text from GUI scene. Default: nil
|
||||
</li>
|
||||
<li><span class="parameter">adjust_type</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference
|
||||
(<em>default</em> downscale)
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference. Default: DOWNSCALE
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -329,7 +365,7 @@
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
Is text node with line break
|
||||
</ol>
|
||||
|
||||
@@ -445,8 +481,8 @@
|
||||
<a href="../modules/Text.html#">Text</a>
|
||||
</li>
|
||||
<li><span class="parameter">pivot</span>
|
||||
<span class="types"><span class="type">gui.pivot</span></span>
|
||||
Gui pivot constant
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
The gui.PIVOT_* constant
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -491,10 +527,41 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_size"></a>
|
||||
<strong>set_size(self, size)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set text area size
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
<span class="types"><span class="type">Text</span></span>
|
||||
<a href="../modules/Text.html#">Text</a>
|
||||
</li>
|
||||
<li><span class="parameter">size</span>
|
||||
<span class="types"><span class="type">vector3</span></span>
|
||||
The new text area size
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">Text</span></span>
|
||||
Current text instance
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_text_adjust"></a>
|
||||
<strong>set_text_adjust(self[, adjust_type[, minimal_scale]])</strong>
|
||||
<strong>set_text_adjust(self, adjust_type, minimal_scale)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Set text adjust, refresh the current text visuals, if needed
|
||||
@@ -507,14 +574,12 @@
|
||||
<a href="../modules/Text.html#">Text</a>
|
||||
</li>
|
||||
<li><span class="parameter">adjust_type</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
See const.TEXT_ADJUST. If pass nil - use current adjust type
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
<li><span class="parameter">minimal_scale</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
If pass nil - not use minimal scale
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -577,14 +642,20 @@
|
||||
<h3>Fields:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">TRIM_POSTFIX</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
The postfix for TRIM adjust type
|
||||
(<em>default</em> ...)
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
The postfix for TRIM adjust type. Default: ...
|
||||
</li>
|
||||
<li><span class="parameter">DEFAULT_ADJUST</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
The default adjust type for any text component
|
||||
(<em>default</em> DOWNSCALE)
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
The default adjust type for any text component. Default: DOWNSCALE
|
||||
</li>
|
||||
<li><span class="parameter">ADJUST_STEPS</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Amount of iterations for text adjust by height. Default: 20
|
||||
</li>
|
||||
<li><span class="parameter">ADJUST_SCALE_DELTA</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
|
||||
Scale step on each height adjust step. Default: 0.02
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -636,6 +707,26 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "last_value"></a>
|
||||
<strong>last_value</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
The last text value
|
||||
|
||||
|
||||
<ul>
|
||||
<li><span class="parameter">last_value</span>
|
||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "node"></a>
|
||||
|
||||
@@ -43,8 +43,6 @@
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
@@ -57,9 +55,7 @@
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
@@ -84,8 +80,8 @@
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, seconds_from[, seconds_to=0[, callback]])</a></td>
|
||||
<td class="summary">Component init function</td>
|
||||
<td class="name" nowrap><a href="#init">init(self, node, seconds_from, seconds_to, callback)</a></td>
|
||||
<td class="summary">The <a href="../modules/Timer.html#">Timer</a> constructor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_interval">set_interval(self, from, to)</a></td>
|
||||
@@ -141,10 +137,10 @@
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "init"></a>
|
||||
<strong>init(self, node, seconds_from[, seconds_to=0[, callback]])</strong>
|
||||
<strong>init(self, node, seconds_from, seconds_to, callback)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Component init function
|
||||
The <a href="../modules/Timer.html#">Timer</a> constructor
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@@ -158,18 +154,16 @@
|
||||
Gui text node
|
||||
</li>
|
||||
<li><span class="parameter">seconds_from</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
Start timer value in seconds
|
||||
</li>
|
||||
<li><span class="parameter">seconds_to</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
<span class="types"><span class="type">number</span> or <span class="type">nil</span></span>
|
||||
End timer value in seconds
|
||||
(<em>default</em> 0)
|
||||
</li>
|
||||
<li><span class="parameter">callback</span>
|
||||
<span class="types"><span class="type">function</span></span>
|
||||
<span class="types"><span class="type">function</span> or <span class="type">nil</span></span>
|
||||
Function on timer end
|
||||
(<em>optional</em>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -222,7 +216,7 @@
|
||||
<a href="../modules/Timer.html#">Timer</a>
|
||||
</li>
|
||||
<li><span class="parameter">is_on</span>
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
<span class="types"><span class="type">boolean</span> or <span class="type">nil</span></span>
|
||||
Timer enable state
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
95
docs/modules/druid.extended.layout.html
Normal file
95
docs/modules/druid.extended.layout.html
Normal file
@@ -0,0 +1,95 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>Defold Druid UI Framework</title>
|
||||
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>Druid</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
|
||||
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
|
||||
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
|
||||
<li><a href="../modules/Helper.html">Helper</a></li>
|
||||
<li><a href="../modules/Hotkey.html">Hotkey</a></li>
|
||||
<li><a href="../modules/Hover.html">Hover</a></li>
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
<li><a href="../modules/Slider.html">Slider</a></li>
|
||||
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
|
||||
<li><a href="../modules/Swipe.html">Swipe</a></li>
|
||||
<li><a href="../modules/Text.html">Text</a></li>
|
||||
<li><a href="../modules/Timer.html">Timer</a></li>
|
||||
<li><strong>druid.extended.layout</strong></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>druid.extended.layout</code></h1>
|
||||
<p>Druid layout module
|
||||
<p> <b># Overview #</b>
|
||||
<p> Layout component works like Dynamic Grid before - for aligning elements in a row or column.</p>
|
||||
<p> Works like a Figma layout.
|
||||
<p> <b># Notes</p>
|
||||
|
||||
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc TESTING</a></i>
|
||||
<i style="float:right;">Last updated 2015-01-01 12:00:00 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
||||
93
docs/modules/druid.system.utf8.html
Normal file
93
docs/modules/druid.system.utf8.html
Normal file
@@ -0,0 +1,93 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>Defold Druid UI Framework</title>
|
||||
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>Druid</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
|
||||
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
|
||||
<li><a href="../modules/Blocker.html">Blocker</a></li>
|
||||
<li><a href="../modules/Button.html">Button</a></li>
|
||||
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
|
||||
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
|
||||
<li><a href="../modules/DataList.html">DataList</a></li>
|
||||
<li><a href="../modules/Drag.html">Drag</a></li>
|
||||
<li><a href="../modules/Druid.html">Druid</a></li>
|
||||
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
|
||||
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
|
||||
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
|
||||
<li><a href="../modules/Helper.html">Helper</a></li>
|
||||
<li><a href="../modules/Hotkey.html">Hotkey</a></li>
|
||||
<li><a href="../modules/Hover.html">Hover</a></li>
|
||||
<li><a href="../modules/Input.html">Input</a></li>
|
||||
<li><a href="../modules/LangText.html">LangText</a></li>
|
||||
<li><a href="../modules/Layout.html">Layout</a></li>
|
||||
<li><a href="../modules/PinKnob.html">PinKnob</a></li>
|
||||
<li><a href="../modules/Progress.html">Progress</a></li>
|
||||
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
|
||||
<li><a href="../modules/RichInput.html">RichInput</a></li>
|
||||
<li><a href="../modules/RichText.html">RichText</a></li>
|
||||
<li><a href="../modules/Scroll.html">Scroll</a></li>
|
||||
<li><a href="../modules/Slider.html">Slider</a></li>
|
||||
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
|
||||
<li><a href="../modules/Swipe.html">Swipe</a></li>
|
||||
<li><a href="../modules/Text.html">Text</a></li>
|
||||
<li><a href="../modules/Timer.html">Timer</a></li>
|
||||
<li><strong>druid.system.utf8</strong></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>druid.system.utf8</code></h1>
|
||||
<p></p>
|
||||
<p></p>
|
||||
|
||||
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc TESTING</a></i>
|
||||
<i style="float:right;">Last updated 2015-01-01 12:00:00 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
||||
@@ -192,49 +192,6 @@ Create input component with druid: `input = druid:new_input(button_node_name, te
|
||||
- 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)
|
||||
|
||||
|
||||
## Checkbox
|
||||
[Checkbox API here](https://insality.github.io/druid/modules/Checkbox.html)
|
||||
|
||||
### Overview
|
||||
Basic Druid checkbox component.
|
||||
|
||||
### Setup
|
||||
Create checkbox component with druid: `checkbox = druid:new_checkbox(node, callback)`
|
||||
|
||||
### Notes
|
||||
- Checkbox uses button to handle click
|
||||
- You can setup another node to handle input with click_node arg in component init: `druid:new_checkbox(node, callback, [click_node])`
|
||||
|
||||
|
||||
## Checkbox group
|
||||
[Checkbox group API here](https://insality.github.io/druid/modules/CheckboxGroup.html)
|
||||
|
||||
### Overview
|
||||
Several checkboxes in one group
|
||||
|
||||
### Setup
|
||||
Create checkbox_group component with druid: `group = druid:new_checkbox_group(nodes[], callback)`
|
||||
|
||||
### Notes
|
||||
- Callback arguments: `function(self, checkbox_index)`. Index is equals in _nodes[]_ array in component constructor
|
||||
- You can get/set checkbox_group state with `group:set_state()` and `group:get_state()`
|
||||
|
||||
|
||||
## Radio group
|
||||
[Radio group API here](https://insality.github.io/druid/modules/RadioGroup.html)
|
||||
|
||||
### Overview
|
||||
Several checkboxes in one group with single choice
|
||||
|
||||
### Setup
|
||||
Create radio_group component with druid: `group = druid:new_radio_group(nodes[], callback)`
|
||||
|
||||
### Notes
|
||||
- Callback arguments: `function(self, checkbox_index)`. Index is equals in _nodes[]_ array in component constructor
|
||||
- You can get/set radio_group state with `group:set_state()` and `group:get_state()`
|
||||
- Only different from checkbox_group: on click another checkboxes in this group will be unchecked
|
||||
|
||||
|
||||
## Timer
|
||||
[Timer API here](https://insality.github.io/druid/modules/Timer.html)
|
||||
|
||||
@@ -419,7 +376,7 @@ Create hotkey component with druid: `hotkey = druid:new_hotkey(keys_array, callb
|
||||
[Layout API here](https://insality.github.io/druid/modules/Layout.html)
|
||||
|
||||
### Overview
|
||||
Component to handle node size depends on layout mode. Unlike from Defold Adjust modes, you able to select node stretch by one size or zoom by minimum or maximum side
|
||||
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:
|
||||
@@ -428,17 +385,15 @@ 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, on_size_change_callback)`
|
||||
Create layout component with druid: `layout = druid:new_layout(node, layout_mode)`
|
||||
|
||||
|
||||
### Notes
|
||||
- Layout mode can be next:
|
||||
- `const.LAYOUT_MODE.STRETCH_X` - Stretch node only by X
|
||||
- `const.LAYOUT_MODE.STRETCH_Y` - Stretch node only by Y
|
||||
- `const.LAYOUT_MODE.ZOOM_MIN` - Zoom node by minimal stretch multiplier
|
||||
- `const.LAYOUT_MODE.ZOOM_MAX` - Zoom node by maximum stretch multiplier
|
||||
- `const.LAYOUT_MODE.FIT` - Usual Defold Fit mode
|
||||
- `const.LAYOUT_MODE.STRETCH` - Usual Defold Stretch Mode
|
||||
- The Layout component will change the node size property. So it's able to increase size of 9patch nodes without scaling issue
|
||||
- The Layout works even inside parent node with Fit adjust mode
|
||||
- `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
|
||||
|
||||
|
||||
@@ -14,26 +14,39 @@ A basic custom component template looks like this (you can copy it from `/druid/
|
||||
```lua
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class component_name : druid.base_component
|
||||
local Component = component.create("component_name")
|
||||
---@class component_name: druid.base_component
|
||||
local M = component.create("component_name")
|
||||
|
||||
local SCHEME = {
|
||||
ROOT = "root",
|
||||
BUTTON = "button",
|
||||
}
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
self.root = self:get_node("root")
|
||||
|
||||
function Component:init(template, nodes)
|
||||
self:set_template(template)
|
||||
self:set_nodes(nodes)
|
||||
self.root = self:get_node(SCHEME.ROOT)
|
||||
self.druid = self:get_druid()
|
||||
|
||||
self.button = self.druid:new_button(SCHEME.BUTTON, function() end)
|
||||
self.button = self.druid:new_button("button", function() end)
|
||||
end
|
||||
|
||||
function Component:on_remove() end
|
||||
function M:hello()
|
||||
print("Hello from custom component")
|
||||
end
|
||||
|
||||
return M
|
||||
```
|
||||
|
||||
Then you can create your custom component with Druid:
|
||||
```lua
|
||||
local druid = require("druid.druid")
|
||||
|
||||
local my_component = require("my.amazing.component")
|
||||
|
||||
function init(self)
|
||||
self.druid = druid.new(self)
|
||||
|
||||
-- We pass a GUI template "template_name" and skip nodes due it already on the scene
|
||||
self.my_component = self.druid:new(my_component, "template_name")
|
||||
self.my_component:hello() -- Hello from custom component
|
||||
|
||||
|
||||
end
|
||||
|
||||
return Component
|
||||
```
|
||||
|
||||
### Full Component Template
|
||||
@@ -43,43 +56,37 @@ A full custom component template looks like this (you can copy it from `/druid/t
|
||||
```lua
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class component_name : druid.base_component
|
||||
local Component = component.create("component_name")
|
||||
local SCHEME = {
|
||||
ROOT = "root",
|
||||
BUTTON = "button",
|
||||
}
|
||||
---@class component_name: druid.base_component
|
||||
local M = component.create("component_name")
|
||||
|
||||
function Component:init(template, nodes)
|
||||
self:set_template(template)
|
||||
self:set_nodes(nodes)
|
||||
self.root = self:get_node(SCHEME.ROOT)
|
||||
self.druid = self:get_druid()
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
self.root = self:get_node("root")
|
||||
end
|
||||
|
||||
function Component:update(dt) end
|
||||
function M:update(dt) end
|
||||
|
||||
function Component:on_input(action_id, action) return false end
|
||||
function M:on_input(action_id, action) return false end
|
||||
|
||||
function Component:on_style_change(style) end
|
||||
function M:on_style_change(style) end
|
||||
|
||||
function Component:on_message(message_id, message, sender) end
|
||||
function M:on_message(message_id, message, sender) end
|
||||
|
||||
function Component:on_language_change() end
|
||||
function M:on_language_change() end
|
||||
|
||||
function Component:on_layout_change() end
|
||||
function M:on_layout_change() end
|
||||
|
||||
function Component:on_window_resized() end
|
||||
function M:on_window_resized() end
|
||||
|
||||
function Component:on_input_interrupt() end
|
||||
function M:on_input_interrupt() end
|
||||
|
||||
function Component:on_focus_lost() end
|
||||
function M:on_focus_lost() end
|
||||
|
||||
function Component:on_focus_gained() end
|
||||
function M:on_focus_gained() end
|
||||
|
||||
function Component:on_remove() end
|
||||
function M:on_remove() end
|
||||
|
||||
return Component
|
||||
return M
|
||||
```
|
||||
|
||||
### Spawning a Custom Component
|
||||
@@ -92,7 +99,7 @@ local my_component = require("my.amazing.component")
|
||||
|
||||
function init(self)
|
||||
self.druid = druid.new(self)
|
||||
self.druid:new(my_component, "template_name", nodes)
|
||||
self.druid:new(my_component, "template_name")
|
||||
end
|
||||
```
|
||||
|
||||
@@ -107,6 +114,7 @@ local druid = require("druid.druid")
|
||||
local my_component = require("my.amazing.component")
|
||||
|
||||
function init(self)
|
||||
-- Register makes a "druid:new_{component_name}" function available
|
||||
druid.register("my_component", my_component)
|
||||
end
|
||||
```
|
||||
@@ -129,7 +137,7 @@ Druid provides an editor script to assist you in creating Lua files for your GUI
|
||||
|
||||
The script analyzes the current GUI scene and generates a Lua file with stubs for all Druid components found. The output file is named after the current GUI scene and placed in the same directory. Note that the script does not override any existing *.lua files. If you want to regenerate a file, delete the previous version first.
|
||||
|
||||
The script requires `python3` with `deftree` installed. If `deftree` is not installed, the instructions will be displayed in the console.
|
||||
The script requires `python` with `deftree` installed. If `deftree` is not installed, the instructions will be displayed in the console.
|
||||
|
||||
### Auto-Layout Components
|
||||
|
||||
@@ -145,36 +153,7 @@ Available keywords:
|
||||
- `blocker`: Adds a [Druid Blocker](01-components.md#blocker) component.
|
||||
- `slider`: Adds a [Druid Slider](01-components.md#slider) component. You should adjust the end position of the Slider after generating the file.
|
||||
- `progress`: Adds a [Druid Progress](01-components.md#progress) component.
|
||||
- `timer`: Adds a [Dr
|
||||
|
||||
uid Timer](01-components.md#timer) component.
|
||||
|
||||
## Best Practices for Custom Components
|
||||
|
||||
When working with each component, it's recommended to describe the component scheme in the following way:
|
||||
|
||||
```lua
|
||||
-- Component module
|
||||
local component = require("druid.component")
|
||||
|
||||
local M = component.create("your_component")
|
||||
|
||||
local SCHEME = {
|
||||
ROOT = "root",
|
||||
ITEM = "item",
|
||||
TITLE = "title"
|
||||
}
|
||||
|
||||
function M.init(self, template_name, node_table)
|
||||
self:set_template(template_name)
|
||||
self:set_nodes(node_table)
|
||||
|
||||
local root = self:get_node(SCHEME.ROOT)
|
||||
local druid = self:get_druid()
|
||||
|
||||
-- Create components inside this component using the inner druid instance
|
||||
end
|
||||
```
|
||||
- `timer`: Adds a [Druid Timer](01-components.md#timer) component.
|
||||
|
||||
## The Power of Using Templates
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ You can pass _nil_ or _empty_table_ to use default values for all components (no
|
||||
local druid = require("druid.druid")
|
||||
local my_style = require("my.amazing.style")
|
||||
|
||||
local function init(self)
|
||||
function init(self)
|
||||
druid.set_default_style(my_style)
|
||||
end
|
||||
```
|
||||
@@ -24,7 +24,7 @@ Setup custom style to specific druid instance:
|
||||
local druid = require("druid.druid")
|
||||
local my_style = require("my.amazing.style")
|
||||
|
||||
local function init(self)
|
||||
function init(self)
|
||||
-- This druid instance will be use my_style as default
|
||||
self.druid = druid.new(self, my_style)
|
||||
end
|
||||
@@ -35,7 +35,7 @@ Change component style with _set_style_ function
|
||||
local druid = require("druid.druid")
|
||||
local my_style = require("my.amazing.style")
|
||||
|
||||
local function init(self)
|
||||
function init(self)
|
||||
self.druid = druid.new(self)
|
||||
self.button = self.druid:new_button("node", function() end)
|
||||
-- Setup custom style for specific component
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
## Input Bindings
|
||||
|
||||
By default, **Druid** utilizes the `/builtins/input/all.input_binding` for input bindings.
|
||||
By default, **Druid** uses all key names from Defold's default `/builtins/input/all.input_binding` for input bindings.
|
||||
|
||||
**Druid** requires the following input bindings:
|
||||
|
||||
@@ -14,6 +14,11 @@ By default, **Druid** utilizes the `/builtins/input/all.input_binding` for input
|
||||
- Key trigger: `Back` -> `key_back` (for BackHandler component, Android back button, input component)
|
||||
- Key trigger: `Enter` -> `key_enter` (for Input component, optional)
|
||||
- Key trigger: `Esc` -> `key_esc` (for Input component, optional)
|
||||
- Key trigger: `Left` -> `key_left` (for Rich Input component, optional)
|
||||
- Key trigger: `Right` -> `key_right` (for Rich Input component, optional)
|
||||
- Key trigger: `Shift` -> `key_lshift` (for Rich Input component, optional)
|
||||
- Key trigger: `Ctrl` -> `key_lctrl` (for Rich Input component, optional)
|
||||
- Key trigger: `Super` -> `key_lsuper` (for Rich Input component, optional)
|
||||
- Touch triggers: `Touch multi` -> `touch_multi` (for Scroll component)
|
||||
|
||||

|
||||
@@ -37,6 +42,11 @@ input_key_backspace = key_backspace
|
||||
input_multitouch = touch_multi
|
||||
input_scroll_up = mouse_wheel_up
|
||||
input_scroll_down = mouse_wheel_down
|
||||
input_key_left = key_left
|
||||
input_key_right = key_right
|
||||
input_key_lshift = key_lshift
|
||||
input_key_lctrl = key_lctrl
|
||||
input_key_lsuper = key_lsuper
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -500,3 +500,91 @@ Thanks to the my supporters:
|
||||
Please support me if you like this project! It will help me keep engaged to update **Druid** and make it even better!
|
||||
|
||||
[](https://github.com/sponsors/insality) [](https://ko-fi.com/insality) [](https://www.buymeacoffee.com/insality)
|
||||
|
||||
|
||||
|
||||
### Druid 1.0
|
||||
|
||||
**Description**
|
||||
|
||||
Hello! The long-awaited update for Druid is finally here!
|
||||
|
||||
I'm releasing this version as 1.0, since Druid is pretty stable and packed with features.
|
||||
|
||||
This update brings a lot of improvements, so let's dive in:
|
||||
|
||||
**New Example Page**
|
||||
I’ve updated Druid's main examples page. Since Druid has become quite popular, I wanted to ensure the examples meet high standards of quality and aesthetics. The examples are now clearer and provide more information. I’ve also added many new examples. Check them out!
|
||||
|
||||
**Component Reworking**
|
||||
Several components have been reworked. While I generally avoid introducing breaking changes, sometimes they are necessary for progress.
|
||||
|
||||
- Rich Text is now applied directly to the text node, rather than using a Rich Text Template. This makes setup and usage much easier! I’m still working on figuring out how to apply this approach to Rich Input.
|
||||
|
||||
- The Layout component has been completely replaced. It now functions similarly to Dynamic Grid but is responsible for adjusting nodes in the GUI. It’s easier to use and offers more configuration options.
|
||||
|
||||
- Dynamic Grid will be deprecated in the future, with the new Layout component serving as its replacement.
|
||||
|
||||
- Data List now works exclusively with Static Grid, making it more stable and optimized. Additionally, a new "cached" version is available, which optimizes node reuse. However, the cached version requires using `on_add_element` and `on_remove_element` events to properly set up nodes.
|
||||
|
||||
**Code Cleanup**
|
||||
I’ve finally removed "middleclass" from Druid. If you were using it for some reason, you’ll need to copy the "middleclass" code into your project.
|
||||
|
||||
**Annotations**
|
||||
Druid’s annotations were originally created when there were no Lua language servers. These annotations are of the older LDoc type and not EmmyLua. In the future, I aim to eliminate annotations altogether and rely on annotated code, which is easier to read, maintain, and feature-rich. The Defold will support the LLS (Lua Language Server) as well as VSCode with amazing Defold-Kit extension.
|
||||
|
||||
---
|
||||
|
||||
**Milestone**: https://github.com/Insality/druid/milestone/12
|
||||
|
||||
**Changelog 1.0.0**
|
||||
|
||||
- New Druid logo!
|
||||
- **[Example]** New Example Page with 40+ examples.
|
||||
- **[Data List]** Reworked Data List to work only with **Static Grid**. It’s now more stable and has an extended API.
|
||||
- Added a **Cached Data List** option, which uses less memory (highly optimized) but requires `on_add_element` and `on_remove_element` events for node setup. All components must be of the same class in this case.
|
||||
- **[Rich Text]** Now applied directly to the text node instead of using a Rich Text Template (which previously contained three nodes: root, text, and image prefabs). This simplifies usage in the GUI.
|
||||
- **[Rich Input]** Updated with new features such as selection and cursor navigation. New input keys can be configured in Druid (arrows, ctrl, shift).
|
||||
- **[Input]** Users can now switch between text input areas with a single click, instead of needing to tap twice (once to close the focus and once to open the new input).
|
||||
- **[Layout]** Reworked the Layout component. The new version allows arranging nodes in various modes (vertical, horizontal, horizontal wrap) and includes more settings (margins, padding, justification, pivots, and content hugging options). This will replace Dynamic Grid in the future.
|
||||
- **[Dynamic Grid]** Deprecated in favor of the new Layout component.
|
||||
- **[Drag]** Added a touch parameter to Drag callbacks, making it easier to add custom logic with input action data.
|
||||
- **[Scroll]** Added `scroll.view_size`, `scroll:set_view_size(size)`, and `scroll:update_view_size()` functions for better management of the scroll input area and visible part.
|
||||
- **[Static Grid]** Added `grid:set_item_size(size)` and `grid:sort_nodes(comparator)` functions.
|
||||
- **[Text]** Adjustments for multiline text height seem to be working correctly now.
|
||||
- **[Progress Bar]** Improved accuracy when scaling progress bars for images with slice9 parameters.
|
||||
- **[Slider]** Fixed several slider setup issues.
|
||||
- **[System]** Updated and fixed annotations.
|
||||
- **[System]** Removed `middleclass.lua`.
|
||||
- **[System]** Removed: `checkbox`, `checkbox_group`, and `radio_button` components. These components can be easily created using the Button component. Check the examples for implementation.
|
||||
- **[System]** Removed: `pin_knob` custom component. It mostly was created as an example and now is not needed.
|
||||
- **[System]** Added `self:get_druid(template, nodes)` to replace `self:set_template(template)` and `self:set_nodes(nodes)` calls in custom components.
|
||||
- Various improvements and fixes.
|
||||
|
||||
|
||||
A big thanks to the my Github supporters:
|
||||
- [Defold Foundation](https://defold.com)
|
||||
- [Ragetto](https://forum.defold.com/u/ragetto)
|
||||
- [Pawel](https://forum.defold.com/u/pawel/summary)
|
||||
|
||||
And all my other supporters! Very appreciated!
|
||||
|
||||
❤️ Support ❤️
|
||||
|
||||
Please support me if you like this project! It will help me keep engaged to update **Druid** and make it even better!
|
||||
|
||||
[](https://github.com/sponsors/insality) [](https://ko-fi.com/insality) [](https://www.buymeacoffee.com/insality)
|
||||
|
||||
|
||||
---
|
||||
|
||||
**Postmortem**
|
||||
|
||||
Thoughts, wrong decisions, future plans, and how to update correctly:
|
||||
|
||||
- No styles should exist.
|
||||
- Annotations should be updated or removed.
|
||||
- Non-explicit event parameters can cause confusion, particularly with `self` parameters.
|
||||
- There is room for performance optimization. Memory usage is not optimized, though it can still handle heavy-load GUIs like Panthera.
|
||||
- Creating custom components could be made easier.
|
||||
- There can be a much less code bindings between elements. Like bind_grid, update_size after some changes etc.
|
||||
@@ -1,8 +0,0 @@
|
||||
# Game Examples
|
||||
|
||||
## Family Island
|
||||
|
||||
## Sea Battle: Universe
|
||||
|
||||
## Monkey Mart
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -32,7 +32,7 @@
|
||||
-- @usage
|
||||
-- -- Replace params on runtime:
|
||||
-- back_handler.params = { ... }
|
||||
-- @tfield[opt] any params
|
||||
-- @tfield any|nil params
|
||||
|
||||
---
|
||||
|
||||
@@ -45,8 +45,8 @@ local BackHandler = component.create("back_handler")
|
||||
|
||||
--- The @{BackHandler} constructor
|
||||
-- @tparam BackHandler self @{BackHandler}
|
||||
-- @tparam callback callback On back button
|
||||
-- @tparam[opt] any custom_args Button events custom arguments
|
||||
-- @tparam function callback @The callback(self, custom_args) to call on back event
|
||||
-- @tparam any|nil custom_args Button events custom arguments
|
||||
-- @local
|
||||
function BackHandler.init(self, callback, custom_args)
|
||||
self.params = custom_args
|
||||
|
||||
@@ -30,7 +30,7 @@ local component = require("druid.component")
|
||||
local Blocker = component.create("blocker")
|
||||
|
||||
|
||||
--- @{Blocker} constructor
|
||||
--- The @{Blocker} constructor
|
||||
-- @tparam Blocker self @{Blocker}
|
||||
-- @tparam node node Gui node
|
||||
function Blocker.init(self, node)
|
||||
@@ -51,7 +51,7 @@ function Blocker.on_input(self, action_id, action)
|
||||
return false
|
||||
end
|
||||
|
||||
if not self:is_enabled(self.node) then
|
||||
if not self:is_enabled() then
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -71,7 +71,7 @@ end
|
||||
--
|
||||
-- Don't change node enabled state itself.
|
||||
-- @tparam Blocker self @{Blocker}
|
||||
-- @tparam bool state Enabled state
|
||||
-- @tparam boolean|nil state Enabled state
|
||||
function Blocker.set_enabled(self, state)
|
||||
self._is_enabled = state
|
||||
end
|
||||
@@ -79,7 +79,7 @@ end
|
||||
|
||||
--- Return blocker enabled state
|
||||
-- @tparam Blocker self @{Blocker}
|
||||
-- @treturn bool True, if blocker is enabled
|
||||
-- @treturn boolean @True, if blocker is enabled
|
||||
function Blocker.is_enabled(self)
|
||||
return self._is_enabled
|
||||
end
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
-- @tfield DruidEvent on_pressed @{DruidEvent}
|
||||
|
||||
--- Button trigger node
|
||||
-- @tfield Node node
|
||||
-- @tfield node node
|
||||
|
||||
---The GUI node id from button node
|
||||
-- @tfield hash node_id
|
||||
@@ -123,7 +123,7 @@
|
||||
-- In default case equals to clickable node.
|
||||
--
|
||||
-- Usecase: You have the big clickable panel, but want to animate only one small icon on it.
|
||||
-- @tfield[opt=node] node anim_node
|
||||
-- @tfield node|nil anim_node Default node
|
||||
|
||||
---Custom args for any Button event. Setup in Button constructor
|
||||
-- @tfield any params
|
||||
@@ -131,8 +131,8 @@
|
||||
--- The @{Hover}: Button Hover component
|
||||
-- @tfield Hover hover @{Hover}
|
||||
|
||||
--- Additional button click area, defined by another GUI Node
|
||||
-- @tfield[opt] node click_zone
|
||||
--- Additional button click area, defined by another GUI node
|
||||
-- @tfield node|nil click_zone
|
||||
|
||||
---
|
||||
|
||||
@@ -240,7 +240,12 @@ local function on_button_release(self)
|
||||
is_double_click = is_double_click and self.on_double_click:is_exist()
|
||||
|
||||
if is_long_click then
|
||||
on_button_long_click(self)
|
||||
local is_hold_complete = (time - self.last_pressed_time) >= self.style.AUTOHOLD_TRIGGER
|
||||
if is_hold_complete then
|
||||
on_button_long_click(self)
|
||||
else
|
||||
self.on_click_outside:trigger(self:get_context(), self.params, self)
|
||||
end
|
||||
elseif is_double_click then
|
||||
on_button_double_click(self)
|
||||
else
|
||||
@@ -258,14 +263,14 @@ end
|
||||
-- You can override this component styles params in Druid styles table
|
||||
-- or create your own style
|
||||
-- @table style
|
||||
-- @tfield[opt=0.4] number LONGTAP_TIME Minimum time to trigger on_hold_callback
|
||||
-- @tfield[opt=0.8] number AUTOHOLD_TRIGGER Maximum hold time to trigger button release while holding
|
||||
-- @tfield[opt=0.4] number DOUBLETAP_TIME Time between double taps
|
||||
-- @tfield function on_click (self, node)
|
||||
-- @tfield function on_click_disabled (self, node)
|
||||
-- @tfield function on_hover (self, node, hover_state)
|
||||
-- @tfield function on_mouse_hover (self, node, hover_state)
|
||||
-- @tfield function on_set_enabled (self, node, enabled_state)
|
||||
-- @tfield number|nil LONGTAP_TIME Minimum time to trigger on_hold_callback. Default: 0.4
|
||||
-- @tfield number|nil AUTOHOLD_TRIGGER Maximum hold time to trigger button release while holding. Default: 0.8
|
||||
-- @tfield number|nil DOUBLETAP_TIME Time between double taps. Default: 0.4
|
||||
-- @tfield function on_click function(self, node)
|
||||
-- @tfield function on_click_disabled function(self, node)
|
||||
-- @tfield function on_hover function(self, node, hover_state)
|
||||
-- @tfield function on_mouse_hover function(self, node, hover_state)
|
||||
-- @tfield function on_set_enabled function(self, node, enabled_state)
|
||||
function Button.on_style_change(self, style)
|
||||
self.style = {}
|
||||
self.style.LONGTAP_TIME = style.LONGTAP_TIME or 0.4
|
||||
@@ -282,10 +287,10 @@ end
|
||||
|
||||
--- The @{Button} constructor
|
||||
-- @tparam Button self @{Button}
|
||||
-- @tparam string|Node node Node name or GUI Node itself
|
||||
-- @tparam string|node node The node_id or gui.get_node(node_id)
|
||||
-- @tparam function callback On click button callback
|
||||
-- @tparam[opt] any custom_args Button events custom arguments
|
||||
-- @tparam[opt] string|Node anim_node Node to animate instead of trigger node.
|
||||
-- @tparam any|nil custom_args Button events custom arguments
|
||||
-- @tparam string|node|nil anim_node Node to animate instead of trigger node.
|
||||
function Button.init(self, node, callback, custom_args, anim_node)
|
||||
self.druid = self:get_druid()
|
||||
self.node = self:get_node(node)
|
||||
@@ -339,10 +344,7 @@ function Button.on_input(self, action_id, action)
|
||||
return false
|
||||
end
|
||||
|
||||
if not self:is_enabled() then
|
||||
return false
|
||||
end
|
||||
|
||||
local is_consume = true
|
||||
local is_pick = true
|
||||
local is_key_trigger = (action_id == self.key_trigger)
|
||||
if not is_key_trigger then
|
||||
@@ -365,6 +367,7 @@ function Button.on_input(self, action_id, action)
|
||||
|
||||
if is_key_trigger then
|
||||
self.hover:set_hover(not action.released)
|
||||
is_consume = false
|
||||
end
|
||||
|
||||
if action.pressed then
|
||||
@@ -380,19 +383,19 @@ function Button.on_input(self, action_id, action)
|
||||
on_button_click(self)
|
||||
end)
|
||||
end
|
||||
return true
|
||||
return is_consume
|
||||
end
|
||||
|
||||
-- While hold button, repeat rate pick from input.repeat_interval
|
||||
if action.repeated then
|
||||
if self.on_repeated_click:is_exist() and self.can_action then
|
||||
on_button_repeated_click(self)
|
||||
return true
|
||||
return is_consume
|
||||
end
|
||||
end
|
||||
|
||||
if action.released then
|
||||
return on_button_release(self)
|
||||
return on_button_release(self) and is_consume
|
||||
end
|
||||
|
||||
if self.can_action and self.on_long_click:is_exist() then
|
||||
@@ -400,21 +403,23 @@ function Button.on_input(self, action_id, action)
|
||||
|
||||
if self.style.AUTOHOLD_TRIGGER <= press_time then
|
||||
on_button_release(self)
|
||||
return true
|
||||
return is_consume
|
||||
end
|
||||
|
||||
if press_time >= self.style.LONGTAP_TIME then
|
||||
on_button_hold(self, press_time)
|
||||
return true
|
||||
return is_consume
|
||||
end
|
||||
end
|
||||
|
||||
return not self.disabled
|
||||
return not self.disabled and is_consume
|
||||
end
|
||||
|
||||
|
||||
function Button.on_input_interrupt(self)
|
||||
self.can_action = false
|
||||
self.hover:set_hover(false)
|
||||
self.hover:set_mouse_hover(false)
|
||||
end
|
||||
|
||||
|
||||
@@ -447,7 +452,7 @@ end
|
||||
-- The style.on_set_enabled will be triggered.
|
||||
-- Disabled button is not clickable.
|
||||
-- @tparam Button self @{Button}
|
||||
-- @tparam bool state Enabled state
|
||||
-- @tparam boolean|nil state Enabled state
|
||||
-- @treturn Button Current button instance
|
||||
-- @usage
|
||||
-- button:set_enabled(false)
|
||||
@@ -465,7 +470,7 @@ end
|
||||
--
|
||||
-- By default all Buttons is enabled on creating.
|
||||
-- @tparam Button self @{Button}
|
||||
-- @treturn bool True, if button is enabled now, False overwise
|
||||
-- @treturn boolean @True, if button is enabled now, False overwise
|
||||
-- @usage
|
||||
-- local is_enabled = button:is_enabled()
|
||||
function Button.is_enabled(self)
|
||||
@@ -478,7 +483,7 @@ end
|
||||
--
|
||||
-- This functions calls automatically if you don't disable it in game.project: druid.no_stencil_check
|
||||
-- @tparam Button self @{Button}
|
||||
-- @tparam node zone Gui node
|
||||
-- @tparam node|string|nil zone Gui node
|
||||
-- @treturn Button Current button instance
|
||||
-- @usage
|
||||
-- button:set_click_zone("stencil_node")
|
||||
@@ -492,7 +497,7 @@ end
|
||||
|
||||
--- Set key name to trigger this button by keyboard.
|
||||
-- @tparam Button self @{Button}
|
||||
-- @tparam hash key The action_id of the input key
|
||||
-- @tparam hash|string key The action_id of the input key
|
||||
-- @treturn Button Current button instance
|
||||
-- @usage
|
||||
-- button:set_key_trigger("key_space")
|
||||
@@ -515,8 +520,8 @@ end
|
||||
|
||||
--- Set function for additional check for button click availability
|
||||
-- @tparam Button self
|
||||
-- @tparam[opt] function check_function Should return true or false. If true - button can be pressed.
|
||||
-- @tparam[opt] function failure_callback Function will be called on button click, if check function return false
|
||||
-- @tparam function|nil check_function Should return true or false. If true - button can be pressed.
|
||||
-- @tparam function|nil failure_callback Function will be called on button click, if check function return false
|
||||
-- @treturn Button Current button instance
|
||||
function Button.set_check_function(self, check_function, failure_callback)
|
||||
self._check_function = check_function
|
||||
@@ -531,7 +536,7 @@ end
|
||||
--
|
||||
-- If the game is not HTML, html mode will be not enabled
|
||||
-- @tparam Button self
|
||||
-- @tparam[opt] boolean is_web_mode If true - button will be called inside html5 callback
|
||||
-- @tparam boolean|nil is_web_mode If true - button will be called inside html5 callback
|
||||
-- @treturn Button Current button instance
|
||||
-- @usage
|
||||
-- button:set_web_user_interaction(true)
|
||||
|
||||
@@ -10,32 +10,35 @@
|
||||
-- @within BaseComponent
|
||||
-- @alias druid.drag
|
||||
|
||||
--- Drag node
|
||||
-- @tfield node node
|
||||
|
||||
--- Event on touch start callback(self)
|
||||
-- @tfield DruidEvent on_touch_start @{DruidEvent}
|
||||
|
||||
--- Event on touch end callback(self)
|
||||
-- @tfield DruidEvent on_touch_end @{DruidEvent}
|
||||
|
||||
--- Event on drag start callback(self)
|
||||
--- Event on drag start callback(self, touch)
|
||||
-- @tfield DruidEvent on_drag_start @{DruidEvent}
|
||||
|
||||
--- on drag progress callback(self, dx, dy, total_x, total_y)
|
||||
--- on drag progress callback(self, dx, dy, total_x, total_y, touch)
|
||||
-- @tfield DruidEvent on_drag Event @{DruidEvent}
|
||||
|
||||
--- Event on drag end callback(self, total_x, total_y)
|
||||
--- Event on drag end callback(self, total_x, total_y, touch)
|
||||
-- @tfield DruidEvent on_drag_end @{DruidEvent}
|
||||
|
||||
--- Is component now touching
|
||||
-- @tfield bool is_touch
|
||||
-- @tfield boolean is_touch
|
||||
|
||||
--- Is component now dragging
|
||||
-- @tfield bool is_drag
|
||||
-- @tfield boolean is_drag
|
||||
|
||||
--- Is drag component process vertical dragging. Default - true
|
||||
-- @tfield bool can_x
|
||||
-- @tfield boolean can_x
|
||||
|
||||
--- Is drag component process horizontal. Default - true
|
||||
-- @tfield bool can_y
|
||||
-- @tfield boolean can_y
|
||||
|
||||
--- Current touch x position
|
||||
-- @tfield number x
|
||||
@@ -43,6 +46,12 @@
|
||||
--- Current touch y position
|
||||
-- @tfield number y
|
||||
|
||||
--- Current touch x screen position
|
||||
-- @tfield number screen_x
|
||||
|
||||
--- Current touch y screen position
|
||||
-- @tfield number screen_y
|
||||
|
||||
--- Touch start position
|
||||
-- @tfield vector3 touch_start_pos
|
||||
|
||||
@@ -65,25 +74,30 @@ local function start_touch(self, touch)
|
||||
|
||||
self.x = touch.x
|
||||
self.y = touch.y
|
||||
|
||||
self.screen_x = touch.screen_x
|
||||
self.screen_y = touch.screen_y
|
||||
|
||||
self._scene_scale = helper.get_scene_scale(self.node)
|
||||
|
||||
self.on_touch_start:trigger(self:get_context())
|
||||
self.on_touch_start:trigger(self:get_context(), touch)
|
||||
end
|
||||
|
||||
|
||||
local function end_touch(self)
|
||||
local function end_touch(self, touch)
|
||||
if self.is_drag then
|
||||
self.on_drag_end:trigger(
|
||||
self:get_context(),
|
||||
self.x - self.touch_start_pos.x,
|
||||
self.y - self.touch_start_pos.y
|
||||
self.y - self.touch_start_pos.y,
|
||||
touch
|
||||
)
|
||||
end
|
||||
|
||||
self.is_drag = false
|
||||
if self.is_touch then
|
||||
self.is_touch = false
|
||||
self.on_touch_end:trigger(self:get_context())
|
||||
self.on_touch_end:trigger(self:get_context(), touch)
|
||||
end
|
||||
self:reset_input_priority()
|
||||
self.touch_id = 0
|
||||
@@ -102,7 +116,7 @@ local function process_touch(self, touch)
|
||||
local distance = helper.distance(touch.x, touch.y, self.touch_start_pos.x, self.touch_start_pos.y)
|
||||
if not self.is_drag and distance >= self.style.DRAG_DEADZONE then
|
||||
self.is_drag = true
|
||||
self.on_drag_start:trigger(self:get_context())
|
||||
self.on_drag_start:trigger(self:get_context(), touch)
|
||||
self:set_input_priority(const.PRIORITY_INPUT_MAX, true)
|
||||
end
|
||||
end
|
||||
@@ -161,8 +175,8 @@ end
|
||||
-- You can override this component styles params in druid styles table
|
||||
-- or create your own style
|
||||
-- @table style
|
||||
-- @tfield[opt=10] number DRAG_DEADZONE Distance in pixels to start dragging
|
||||
-- @tfield[opt=false] boolean NO_USE_SCREEN_KOEF If screen aspect ratio affects on drag values
|
||||
-- @tfield number|nil DRAG_DEADZONE Distance in pixels to start dragging. Default: 10
|
||||
-- @tfield boolean|nil NO_USE_SCREEN_KOEF If screen aspect ratio affects on drag values. Default: false
|
||||
function Drag.on_style_change(self, style)
|
||||
self.style = {}
|
||||
self.style.DRAG_DEADZONE = style.DRAG_DEADZONE or 10
|
||||
@@ -170,7 +184,7 @@ function Drag.on_style_change(self, style)
|
||||
end
|
||||
|
||||
|
||||
--- Drag component constructor
|
||||
--- The @{Drag} constructor
|
||||
-- @tparam Drag self @{Drag}
|
||||
-- @tparam node node GUI node to detect dragging
|
||||
-- @tparam function on_drag_callback Callback for on_drag_event(self, dx, dy)
|
||||
@@ -182,6 +196,8 @@ function Drag.init(self, node, on_drag_callback)
|
||||
self.touch_id = 0
|
||||
self.x = 0
|
||||
self.y = 0
|
||||
self.screen_x = 0
|
||||
self.screen_y = 0
|
||||
self.is_touch = false
|
||||
self.is_drag = false
|
||||
self.touch_start_pos = vmath.vector3(0)
|
||||
@@ -266,7 +282,7 @@ function Drag.on_input(self, action_id, action)
|
||||
on_touch_release(self, action_id, action)
|
||||
else
|
||||
-- PC
|
||||
end_touch(self)
|
||||
end_touch(self, touch)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -283,9 +299,12 @@ function Drag.on_input(self, action_id, action)
|
||||
if touch_modified then
|
||||
self.x = touch_modified.x
|
||||
self.y = touch_modified.y
|
||||
|
||||
self.screen_x = touch_modified.screen_x
|
||||
self.screen_y = touch_modified.screen_y
|
||||
end
|
||||
|
||||
if self.is_drag then
|
||||
if self.is_drag and (self.dx ~= 0 or self.dy ~= 0) then
|
||||
local x_koef, y_koef = self._x_koef, self._y_koef
|
||||
if self.style.NO_USE_SCREEN_KOEF then
|
||||
x_koef, y_koef = 1, 1
|
||||
@@ -295,7 +314,7 @@ function Drag.on_input(self, action_id, action)
|
||||
self.dx * x_koef / self._scene_scale.x,
|
||||
self.dy * y_koef / self._scene_scale.y,
|
||||
(self.x - self.touch_start_pos.x) * x_koef / self._scene_scale.x,
|
||||
(self.y - self.touch_start_pos.y) * y_koef / self._scene_scale.y)
|
||||
(self.y - self.touch_start_pos.y) * y_koef / self._scene_scale.y, touch_modified)
|
||||
end
|
||||
|
||||
return self.is_drag
|
||||
@@ -305,7 +324,7 @@ end
|
||||
--- Strict drag click area. Useful for
|
||||
-- restrict events outside stencil node
|
||||
-- @tparam Drag self @{Drag}
|
||||
-- @tparam node node Gui node
|
||||
-- @tparam node|string|nil node Gui node
|
||||
function Drag.set_click_zone(self, node)
|
||||
self.click_zone = self:get_node(node)
|
||||
end
|
||||
@@ -313,7 +332,7 @@ end
|
||||
|
||||
--- Set Drag input enabled or disabled
|
||||
-- @tparam Drag self @{Drag}
|
||||
-- @tparam bool is_enabled
|
||||
-- @tparam boolean|nil is_enabled
|
||||
function Drag.set_enabled(self, is_enabled)
|
||||
self._is_enabled = is_enabled
|
||||
end
|
||||
@@ -321,7 +340,7 @@ end
|
||||
|
||||
--- Check if Drag component is enabled
|
||||
-- @tparam Drag self @{Drag}
|
||||
-- @treturn bool
|
||||
-- @treturn boolean
|
||||
function Drag.is_enabled(self)
|
||||
return self._is_enabled
|
||||
end
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
-- @within BaseComponent
|
||||
-- @alias druid.hover
|
||||
|
||||
--- Hover node
|
||||
-- @tfield node node
|
||||
|
||||
--- On hover callback(self, state, hover_instance)
|
||||
-- @tfield DruidEvent on_hover @{DruidEvent}
|
||||
|
||||
@@ -21,11 +24,12 @@ local component = require("druid.component")
|
||||
local Hover = component.create("hover")
|
||||
|
||||
|
||||
--- Component init function
|
||||
--- The @{Hover} constructor
|
||||
-- @tparam Hover self @{Hover}
|
||||
-- @tparam node node Gui node
|
||||
-- @tparam function on_hover_callback Hover callback
|
||||
function Hover.init(self, node, on_hover_callback)
|
||||
-- @tparam function on_mouse_hover On mouse hover callback
|
||||
function Hover.init(self, node, on_hover_callback, on_mouse_hover)
|
||||
self.node = self:get_node(node)
|
||||
|
||||
self._is_hovered = false
|
||||
@@ -34,7 +38,7 @@ function Hover.init(self, node, on_hover_callback)
|
||||
self._is_mobile = helper.is_mobile()
|
||||
|
||||
self.on_hover = Event(on_hover_callback)
|
||||
self.on_mouse_hover = Event()
|
||||
self.on_mouse_hover = Event(on_mouse_hover)
|
||||
end
|
||||
|
||||
|
||||
@@ -48,6 +52,19 @@ function Hover.on_late_init(self)
|
||||
end
|
||||
|
||||
|
||||
--- Component style params.
|
||||
-- You can override this component styles params in druid styles table
|
||||
-- or create your own style
|
||||
-- @table style
|
||||
-- @tfield[opt] string ON_HOVER_CURSOR Mouse hover style on node hover
|
||||
-- @tfield[opt] string ON_MOUSE_HOVER_CURSOR Mouse hover style on node mouse hover
|
||||
function Hover.on_style_change(self, style)
|
||||
self.style = {}
|
||||
self.style.ON_HOVER_CURSOR = style.ON_HOVER_CURSOR or nil
|
||||
self.style.ON_MOUSE_HOVER_CURSOR = style.ON_MOUSE_HOVER_CURSOR or nil
|
||||
end
|
||||
|
||||
|
||||
function Hover.on_input(self, action_id, action)
|
||||
if action_id ~= const.ACTION_TOUCH and action_id ~= nil then
|
||||
return false
|
||||
@@ -89,18 +106,24 @@ end
|
||||
|
||||
--- Set hover state
|
||||
-- @tparam Hover self @{Hover}
|
||||
-- @tparam bool state The hover state
|
||||
-- @tparam boolean|nil state The hover state
|
||||
function Hover.set_hover(self, state)
|
||||
if self._is_hovered ~= state then
|
||||
self._is_hovered = state
|
||||
self.on_hover:trigger(self:get_context(), state, self)
|
||||
if self._is_hovered == state then
|
||||
return
|
||||
end
|
||||
|
||||
self._is_hovered = state
|
||||
self.on_hover:trigger(self:get_context(), state, self)
|
||||
|
||||
if defos and self.style.ON_HOVER_CURSOR then
|
||||
self:_set_cursor(3, state and self.style.ON_HOVER_CURSOR or nil)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Return current hover state. True if touch action was on the node at current time
|
||||
-- @tparam Hover self @{Hover}
|
||||
-- @treturn bool The current hovered state
|
||||
-- @treturn boolean The current hovered state
|
||||
function Hover.is_hovered(self)
|
||||
return self._is_hovered
|
||||
end
|
||||
@@ -108,18 +131,24 @@ end
|
||||
|
||||
--- Set mouse hover state
|
||||
-- @tparam Hover self @{Hover}
|
||||
-- @tparam bool state The mouse hover state
|
||||
-- @tparam boolean|nil state The mouse hover state
|
||||
function Hover.set_mouse_hover(self, state)
|
||||
if self._is_mouse_hovered ~= state then
|
||||
self._is_mouse_hovered = state
|
||||
self.on_mouse_hover:trigger(self:get_context(), state, self)
|
||||
if self._is_mouse_hovered == state then
|
||||
return
|
||||
end
|
||||
|
||||
self._is_mouse_hovered = state
|
||||
self.on_mouse_hover:trigger(self:get_context(), state, self)
|
||||
|
||||
if defos and self.style.ON_MOUSE_HOVER_CURSOR then
|
||||
self:_set_cursor(2, state and self.style.ON_MOUSE_HOVER_CURSOR or nil)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Return current hover state. True if nil action_id (usually desktop mouse) was on the node at current time
|
||||
-- @tparam Hover self @{Hover}
|
||||
-- @treturn bool The current hovered state
|
||||
-- @treturn boolean The current hovered state
|
||||
function Hover.is_mouse_hovered(self)
|
||||
return self._is_mouse_hovered
|
||||
end
|
||||
@@ -128,7 +157,7 @@ end
|
||||
--- Strict hover click area. Useful for
|
||||
-- no click events outside stencil node
|
||||
-- @tparam Hover self @{Hover}
|
||||
-- @tparam node zone Gui node
|
||||
-- @tparam node|string|nil zone Gui node
|
||||
function Hover.set_click_zone(self, zone)
|
||||
self.click_zone = self:get_node(zone)
|
||||
end
|
||||
@@ -138,7 +167,7 @@ end
|
||||
-- If hover is not enabled, it will not generate
|
||||
-- any hover events
|
||||
-- @tparam Hover self @{Hover}
|
||||
-- @tparam bool state The hover enabled state
|
||||
-- @tparam boolean|nil state The hover enabled state
|
||||
function Hover.set_enabled(self, state)
|
||||
self._is_enabled = state
|
||||
|
||||
@@ -155,10 +184,37 @@ end
|
||||
|
||||
--- Return current hover enabled state
|
||||
-- @tparam Hover self @{Hover}
|
||||
-- @treturn bool The hover enabled state
|
||||
-- @treturn boolean The hover enabled state
|
||||
function Hover.is_enabled(self)
|
||||
return self._is_enabled
|
||||
end
|
||||
|
||||
|
||||
-- Internal cursor stack
|
||||
local cursor_stack = {}
|
||||
function Hover:_set_cursor(priority, cursor)
|
||||
if not defos then
|
||||
return
|
||||
end
|
||||
|
||||
local uid = self:get_uid()
|
||||
cursor_stack[uid] = cursor_stack[uid] or {}
|
||||
cursor_stack[uid][priority] = cursor
|
||||
|
||||
-- set cursor with high priority via pairs
|
||||
local priority = nil
|
||||
local cursor_to_set = nil
|
||||
for _, stack in pairs(cursor_stack) do
|
||||
for pr, _ in pairs(stack) do
|
||||
if pr > (priority or 0) then
|
||||
priority = pr
|
||||
cursor_to_set = stack[priority]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defos.set_cursor(cursor_to_set)
|
||||
end
|
||||
|
||||
|
||||
return Hover
|
||||
|
||||
@@ -50,11 +50,14 @@
|
||||
--- Scroll view node
|
||||
-- @tfield node view_node
|
||||
|
||||
--- Scroll view size
|
||||
-- @tfield vector3 view_size
|
||||
|
||||
--- Scroll content node
|
||||
-- @tfield node content_node
|
||||
|
||||
--- Flag, if scroll now moving by inertion
|
||||
-- @tfield bool is_inert
|
||||
-- @tfield boolean _is_inert
|
||||
|
||||
--- Current inert speed
|
||||
-- @tfield vector3 inertion
|
||||
@@ -75,10 +78,10 @@
|
||||
-- @tfield Drag drag @{Drag}
|
||||
|
||||
--- Current index of points of interests
|
||||
-- @tfield[opt] number selected
|
||||
-- @tfield number|nil selected
|
||||
|
||||
--- Flag, if scroll now animating by gui.animate
|
||||
-- @tfield bool is_animate
|
||||
-- @tfield boolean is_animate
|
||||
|
||||
---
|
||||
|
||||
@@ -123,18 +126,18 @@ end
|
||||
-- You can override this component styles params in druid styles table
|
||||
-- or create your own style
|
||||
-- @table style
|
||||
-- @tfield[opt=0] number FRICT Multiplier for free inertion
|
||||
-- @tfield[opt=0] number FRICT_HOLD Multiplier for inertion, while touching
|
||||
-- @tfield[opt=3] number INERT_THRESHOLD Scroll speed to stop inertion
|
||||
-- @tfield[opt=30] number INERT_SPEED Multiplier for inertion speed
|
||||
-- @tfield[opt=20] number POINTS_DEADZONE Speed to check points of interests in no_inertion mode
|
||||
-- @tfield[opt=0.35] number BACK_SPEED Scroll back returning lerp speed
|
||||
-- @tfield[opt=0.2] number ANIM_SPEED Scroll gui.animation speed for scroll_to function
|
||||
-- @tfield[opt=0] number EXTRA_STRETCH_SIZE extra size in pixels outside of scroll (stretch effect)
|
||||
-- @tfield[opt=false] bool SMALL_CONTENT_SCROLL If true, content node with size less than view node size can be scrolled
|
||||
-- @tfield[opt=0] bool WHEEL_SCROLL_SPEED The scroll speed via mouse wheel scroll or touchpad. Set to 0 to disable wheel scrolling
|
||||
-- @tfield[opt=false] bool WHEEL_SCROLL_INVERTED If true, invert direction for touchpad and mouse wheel scroll
|
||||
-- @tfield[opt=false] bool WHEEL_SCROLL_BY_INERTION If true, wheel will add inertion to scroll. Direct set position otherwise.
|
||||
-- @tfield number|nil FRICT Multiplier for free inertion. Default: 0
|
||||
-- @tfield number|nil FRICT_HOLD Multiplier for inertion, while touching. Default: 0
|
||||
-- @tfield number|nil INERT_THRESHOLD Scroll speed to stop inertion. Default: 3
|
||||
-- @tfield number|nil INERT_SPEED Multiplier for inertion speed. Default: 30
|
||||
-- @tfield number|nil POINTS_DEADZONE Speed to check points of interests in no_inertion mode. Default: 20
|
||||
-- @tfield number|nil BACK_SPEED Scroll back returning lerp speed. Default: 35
|
||||
-- @tfield number|nil ANIM_SPEED Scroll gui.animation speed for scroll_to function. Default: 2
|
||||
-- @tfield number|nil EXTRA_STRETCH_SIZE extra size in pixels outside of scroll (stretch effect). Default: 0
|
||||
-- @tfield boolean|nil SMALL_CONTENT_SCROLL If true, content node with size less than view node size can be scrolled. Default: false
|
||||
-- @tfield boolean|nil WHEEL_SCROLL_SPEED The scroll speed via mouse wheel scroll or touchpad. Set to 0 to disable wheel scrolling. Default: 0
|
||||
-- @tfield boolean|nil WHEEL_SCROLL_INVERTED If true, invert direction for touchpad and mouse wheel scroll. Default: false
|
||||
-- @tfield boolean|nil WHEEL_SCROLL_BY_INERTION If true, wheel will add inertion to scroll. Direct set position otherwise.. Default: false
|
||||
function Scroll.on_style_change(self, style)
|
||||
self.style = {}
|
||||
self.style.EXTRA_STRETCH_SIZE = style.EXTRA_STRETCH_SIZE or 0
|
||||
@@ -158,7 +161,7 @@ function Scroll.on_style_change(self, style)
|
||||
end
|
||||
|
||||
|
||||
--- @{Scroll} constructor
|
||||
--- The @{Scroll} constructor
|
||||
-- @tparam Scroll self @{Scroll}
|
||||
-- @tparam string|node view_node GUI view scroll node
|
||||
-- @tparam string|node content_node GUI content scroll node
|
||||
@@ -216,6 +219,12 @@ end
|
||||
|
||||
|
||||
function Scroll.update(self, dt)
|
||||
if self.is_animate then
|
||||
self.position.x = gui.get(self.content_node, "position.x")
|
||||
self.position.y = gui.get(self.content_node, "position.y")
|
||||
self.on_scroll:trigger(self:get_context(), self.position)
|
||||
end
|
||||
|
||||
if self.drag.is_drag then
|
||||
self:_update_hand_scroll(dt)
|
||||
else
|
||||
@@ -237,7 +246,7 @@ end
|
||||
--- Start scroll to target point.
|
||||
-- @tparam Scroll self @{Scroll}
|
||||
-- @tparam vector3 point Target point
|
||||
-- @tparam[opt] bool is_instant Instant scroll flag
|
||||
-- @tparam boolean|nil is_instant Instant scroll flag
|
||||
-- @usage scroll:scroll_to(vmath.vector3(0, 50, 0))
|
||||
-- @usage scroll:scroll_to(vmath.vector3(0), true)
|
||||
function Scroll.scroll_to(self, point, is_instant)
|
||||
@@ -255,12 +264,12 @@ function Scroll.scroll_to(self, point, is_instant)
|
||||
|
||||
if is_instant then
|
||||
self.target_position = target
|
||||
self:_set_scroll_position(target)
|
||||
self:_set_scroll_position(target.x, target.y)
|
||||
else
|
||||
gui.animate(self.content_node, gui.PROP_POSITION, target, gui.EASING_OUTSINE, self.style.ANIM_SPEED, 0, function()
|
||||
self.is_animate = false
|
||||
self.target_position = target
|
||||
self:_set_scroll_position(target)
|
||||
self:_set_scroll_position(target.x, target.y)
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -271,7 +280,7 @@ end
|
||||
--- Scroll to item in scroll by point index.
|
||||
-- @tparam Scroll self @{Scroll}
|
||||
-- @tparam number index Point index
|
||||
-- @tparam[opt] bool skip_cb If true, skip the point callback
|
||||
-- @tparam boolean|nil skip_cb If true, skip the point callback
|
||||
function Scroll.scroll_to_index(self, index, skip_cb)
|
||||
if not self.points then
|
||||
return
|
||||
@@ -294,7 +303,7 @@ end
|
||||
--- Start scroll to target scroll percent
|
||||
-- @tparam Scroll self @{Scroll}
|
||||
-- @tparam vector3 percent target percent
|
||||
-- @tparam[opt] bool is_instant instant scroll flag
|
||||
-- @tparam boolean|nil is_instant instant scroll flag
|
||||
-- @usage scroll:scroll_to_percent(vmath.vector3(0.5, 0, 0))
|
||||
function Scroll.scroll_to_percent(self, percent, is_instant)
|
||||
local border = self.available_pos
|
||||
@@ -305,6 +314,13 @@ function Scroll.scroll_to_percent(self, percent, is_instant)
|
||||
0
|
||||
)
|
||||
|
||||
if not self.drag.can_x then
|
||||
pos.x = self.position.x
|
||||
end
|
||||
if not self.drag.can_y then
|
||||
pos.y = self.position.y
|
||||
end
|
||||
|
||||
self:scroll_to(pos, is_instant)
|
||||
end
|
||||
|
||||
@@ -325,7 +341,7 @@ end
|
||||
-- It will change content gui node size
|
||||
-- @tparam Scroll self @{Scroll}
|
||||
-- @tparam vector3 size The new size for content node
|
||||
-- @tparam vector3 offset Offset value to set, where content is starts
|
||||
-- @tparam vector3|nil offset Offset value to set, where content is starts
|
||||
-- @treturn druid.scroll Current scroll instance
|
||||
function Scroll.set_size(self, size, offset)
|
||||
if offset then
|
||||
@@ -338,11 +354,36 @@ function Scroll.set_size(self, size, offset)
|
||||
end
|
||||
|
||||
|
||||
--- Set new scroll view size in case the node size was changed.
|
||||
-- @tparam Scroll self @{Scroll}
|
||||
-- @tparam vector3 size The new size for view node
|
||||
-- @treturn druid.scroll Current scroll instance
|
||||
function Scroll.set_view_size(self, size)
|
||||
gui.set_size(self.view_node, size)
|
||||
self.view_size = size
|
||||
self.view_border = helper.get_border(self.view_node)
|
||||
self:_update_size()
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Refresh scroll view size
|
||||
-- @tparam Scroll self @{Scroll}
|
||||
function Scroll.update_view_size(self)
|
||||
self.view_size = helper.get_scaled_size(self.view_node)
|
||||
self.view_border = helper.get_border(self.view_node)
|
||||
self:_update_size()
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Enable or disable scroll inert.
|
||||
-- If disabled, scroll through points (if exist)
|
||||
-- If no points, just simple drag without inertion
|
||||
-- @tparam Scroll self @{Scroll}
|
||||
-- @tparam bool state Inert scroll state
|
||||
-- @tparam boolean|nil state Inert scroll state
|
||||
-- @treturn druid.scroll Current scroll instance
|
||||
function Scroll.set_inert(self, state)
|
||||
self._is_inert = state
|
||||
@@ -353,7 +394,7 @@ end
|
||||
|
||||
--- Return if scroll have inertion.
|
||||
-- @tparam Scroll self @{Scroll}
|
||||
-- @treturn bool If scroll have inertion
|
||||
-- @treturn boolean @If scroll have inertion
|
||||
function Scroll.is_inert(self)
|
||||
return self._is_inert
|
||||
end
|
||||
@@ -362,7 +403,7 @@ end
|
||||
--- Set extra size for scroll stretching.
|
||||
-- Set 0 to disable stretching effect
|
||||
-- @tparam Scroll self @{Scroll}
|
||||
-- @tparam[opt=0] number stretch_size Size in pixels of additional scroll area
|
||||
-- @tparam number|nil stretch_size Size in pixels of additional scroll area
|
||||
-- @treturn druid.scroll Current scroll instance
|
||||
function Scroll.set_extra_stretch_size(self, stretch_size)
|
||||
self.style.EXTRA_STRETCH_SIZE = stretch_size or 0
|
||||
@@ -400,7 +441,7 @@ end
|
||||
|
||||
--- Lock or unlock horizontal scroll
|
||||
-- @tparam Scroll self @{Scroll}
|
||||
-- @tparam bool state True, if horizontal scroll is enabled
|
||||
-- @tparam boolean|nil state True, if horizontal scroll is enabled
|
||||
-- @treturn druid.scroll Current scroll instance
|
||||
function Scroll.set_horizontal_scroll(self, state)
|
||||
self._is_horizontal_scroll = state
|
||||
@@ -411,7 +452,7 @@ end
|
||||
|
||||
--- Lock or unlock vertical scroll
|
||||
-- @tparam Scroll self @{Scroll}
|
||||
-- @tparam bool state True, if vertical scroll is enabled
|
||||
-- @tparam boolean|nil state True, if vertical scroll is enabled
|
||||
-- @treturn druid.scroll Current scroll instance
|
||||
function Scroll.set_vertical_scroll(self, state)
|
||||
self._is_vertical_scroll = state
|
||||
@@ -464,7 +505,7 @@ end
|
||||
--- Bind the grid component (Static or Dynamic) to recalculate
|
||||
-- scroll size on grid changes
|
||||
-- @tparam Scroll self @{Scroll}
|
||||
-- @tparam StaticGrid|DynamicGrid grid Druid grid component
|
||||
-- @tparam StaticGrid grid Druid grid component
|
||||
-- @treturn druid.scroll Current scroll instance
|
||||
function Scroll.bind_grid(self, grid)
|
||||
if self._grid_on_change then
|
||||
@@ -493,7 +534,7 @@ end
|
||||
--- Strict drag scroll area. Useful for
|
||||
-- restrict events outside stencil node
|
||||
-- @tparam Drag self
|
||||
-- @tparam node node Gui node
|
||||
-- @tparam node|string node Gui node
|
||||
function Scroll.set_click_zone(self, node)
|
||||
self.drag:set_click_zone(node)
|
||||
end
|
||||
@@ -583,14 +624,14 @@ function Scroll._cancel_animate(self)
|
||||
end
|
||||
|
||||
|
||||
function Scroll._set_scroll_position(self, position)
|
||||
function Scroll._set_scroll_position(self, position_x, position_y)
|
||||
local available_extra = self.available_pos_extra
|
||||
position.x = helper.clamp(position.x, available_extra.x, available_extra.z)
|
||||
position.y = helper.clamp(position.y, available_extra.w, available_extra.y)
|
||||
position_x = helper.clamp(position_x, available_extra.x, available_extra.z)
|
||||
position_y = helper.clamp(position_y, available_extra.w, available_extra.y)
|
||||
|
||||
if self.position.x ~= position.x or self.position.y ~= position.y then
|
||||
self.position.x = position.x
|
||||
self.position.y = position.y
|
||||
if self.position.x ~= position_x or self.position.y ~= position_y then
|
||||
self.position.x = position_x
|
||||
self.position.y = position_y
|
||||
gui.set_position(self.content_node, self.position)
|
||||
|
||||
self.on_scroll:trigger(self:get_context(), self.position)
|
||||
@@ -624,8 +665,8 @@ function Scroll._check_points(self)
|
||||
|
||||
local temp_dist = math.huge
|
||||
local temp_dist_on_inert = math.huge
|
||||
local index = false
|
||||
local index_on_inert = false
|
||||
local index = -1
|
||||
local index_on_inert = -1
|
||||
local pos = self.position
|
||||
|
||||
for i = 1, #self.points do
|
||||
@@ -650,7 +691,11 @@ function Scroll._check_points(self)
|
||||
end
|
||||
end
|
||||
|
||||
self:scroll_to_index(index_on_inert or index)
|
||||
if index_on_inert >= 0 then
|
||||
self:scroll_to_index(index_on_inert)
|
||||
else
|
||||
self:scroll_to_index(index)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -673,6 +718,10 @@ end
|
||||
|
||||
|
||||
function Scroll._update_free_scroll(self, dt)
|
||||
if self.is_animate then
|
||||
return
|
||||
end
|
||||
|
||||
local target = self.target_position
|
||||
|
||||
if self._is_inert and (self.inertion.x ~= 0 or self.inertion.y ~= 0) then
|
||||
@@ -688,19 +737,23 @@ function Scroll._update_free_scroll(self, dt)
|
||||
|
||||
self:_check_soft_zone()
|
||||
if self.position.x ~= target.x or self.position.y ~= target.y then
|
||||
self:_set_scroll_position(target)
|
||||
self:_set_scroll_position(target.x, target.y)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function Scroll._update_hand_scroll(self, dt)
|
||||
if self.is_animate then
|
||||
self:_cancel_animate()
|
||||
end
|
||||
|
||||
local dx = self.target_position.x - self.position.x
|
||||
local dy = self.target_position.y - self.position.y
|
||||
|
||||
self.inertion.x = (self.inertion.x + dx) * self.style.FRICT_HOLD
|
||||
self.inertion.y = (self.inertion.y + dy) * self.style.FRICT_HOLD
|
||||
|
||||
self:_set_scroll_position(self.target_position)
|
||||
self:_set_scroll_position(self.target_position.x, self.target_position.y)
|
||||
end
|
||||
|
||||
|
||||
@@ -742,14 +795,14 @@ function Scroll._update_size(self)
|
||||
content_border_extra.w = content_border_extra.w - stretch_size * sign_y
|
||||
|
||||
if not self.style.SMALL_CONTENT_SCROLL then
|
||||
self.drag.can_x = content_size.x > self.view_size.x
|
||||
self.drag.can_y = content_size.y > self.view_size.y
|
||||
self.drag.can_x = content_size.x > self.view_size.x and self._is_horizontal_scroll
|
||||
self.drag.can_y = content_size.y > self.view_size.y and self._is_vertical_scroll
|
||||
end
|
||||
|
||||
self.available_pos_extra = get_border_vector(self.view_border - content_border_extra, self._offset)
|
||||
self.available_size_extra = get_size_vector(self.available_pos_extra)
|
||||
|
||||
self:_set_scroll_position(self.position)
|
||||
self:_set_scroll_position(self.position.x, self.position.y)
|
||||
self.target_position.x = self.position.x
|
||||
self.target_position.y = self.position.y
|
||||
end
|
||||
@@ -784,7 +837,8 @@ function Scroll._process_scroll_wheel(self, action_id, action)
|
||||
self.inertion.x = 0
|
||||
end
|
||||
|
||||
self:_set_scroll_position(self.target_position)
|
||||
self:_set_scroll_position(self.target_position.x, self.target_position.y)
|
||||
self:_check_points()
|
||||
end
|
||||
|
||||
return true
|
||||
|
||||
@@ -102,8 +102,8 @@ end
|
||||
-- You can override this component styles params in druid styles table
|
||||
-- or create your own style
|
||||
-- @table style
|
||||
-- @tfield[opt=false] bool IS_DYNAMIC_NODE_POSES If true, always center grid content as grid pivot sets
|
||||
-- @tfield[opt=false] bool IS_ALIGN_LAST_ROW If true, always align last row of the grid as grid pivot sets
|
||||
-- @tfield boolean|nil IS_DYNAMIC_NODE_POSES If true, always center grid content as grid pivot sets. Default: false
|
||||
-- @tfield boolean|nil IS_ALIGN_LAST_ROW If true, always align last row of the grid as grid pivot sets. Default: false
|
||||
function StaticGrid.on_style_change(self, style)
|
||||
self.style = {}
|
||||
self.style.IS_DYNAMIC_NODE_POSES = style.IS_DYNAMIC_NODE_POSES or false
|
||||
@@ -113,9 +113,9 @@ end
|
||||
|
||||
--- The @{StaticGrid} constructor
|
||||
-- @tparam StaticGrid self @{StaticGrid}
|
||||
-- @tparam string|Node parent The GUI Node container, where grid's items will be placed
|
||||
-- @tparam string|node parent The GUI Node container, where grid's items will be placed
|
||||
-- @tparam node element Element prefab. Need to get it size
|
||||
-- @tparam[opt=1] number in_row How many nodes in row can be placed
|
||||
-- @tparam number|nil in_row How many nodes in row can be placed. By default 1
|
||||
function StaticGrid.init(self, parent, element, in_row)
|
||||
self.parent = self:get_node(parent)
|
||||
self.nodes = {}
|
||||
@@ -151,7 +151,7 @@ local _temp_pos = vmath.vector3(0)
|
||||
--- Return pos for grid node index
|
||||
-- @tparam StaticGrid self @{StaticGrid}
|
||||
-- @tparam number index The grid element index
|
||||
-- @treturn vector3 Node position
|
||||
-- @treturn vector3 @Node position
|
||||
function StaticGrid.get_pos(self, index)
|
||||
local row = math.ceil(index / self.in_row) - 1
|
||||
local col = (index - row * self.in_row) - 1
|
||||
@@ -171,8 +171,12 @@ end
|
||||
-- @tparam vector3 pos The node position in the grid
|
||||
-- @treturn number The node index
|
||||
function StaticGrid.get_index(self, pos)
|
||||
local col = pos.x / self.node_size.x + 1
|
||||
local row = -pos.y / self.node_size.y
|
||||
-- Offset to left-top corner from node pivot
|
||||
local node_offset_x = self.node_size.x * (-0.5 + self.node_pivot.x)
|
||||
local node_offset_y = self.node_size.y * (0.5 - self.node_pivot.y)
|
||||
|
||||
local col = (pos.x + node_offset_x) / self.node_size.x + 1
|
||||
local row = -(pos.y + node_offset_y) / self.node_size.y
|
||||
|
||||
col = helper.round(col)
|
||||
row = helper.round(row)
|
||||
@@ -211,12 +215,50 @@ function StaticGrid.set_anchor(self, anchor)
|
||||
end
|
||||
|
||||
|
||||
--- Update grid content
|
||||
-- @tparam StaticGrid self @{StaticGrid}
|
||||
function StaticGrid.refresh(self)
|
||||
self:_update(true)
|
||||
end
|
||||
|
||||
|
||||
function StaticGrid.set_pivot(self, pivot)
|
||||
local prev_pivot = helper.get_pivot_offset(gui.get_pivot(self.parent))
|
||||
self.pivot = helper.get_pivot_offset(pivot)
|
||||
|
||||
local width = gui.get(self.parent, "size.x")
|
||||
local height = gui.get(self.parent, "size.y")
|
||||
--local pos_offset = vmath.vector3(
|
||||
-- width * (self.pivot.x - prev_pivot.x),
|
||||
-- height * (self.pivot.y - prev_pivot.y),
|
||||
-- 0
|
||||
--)
|
||||
|
||||
local position = gui.get_position(self.parent)
|
||||
position.x = position.x + width * (self.pivot.x - prev_pivot.x)
|
||||
position.y = position.y + height * (self.pivot.y - prev_pivot.y)
|
||||
gui.set_position(self.parent, position)
|
||||
|
||||
gui.set_pivot(self.parent, pivot)
|
||||
|
||||
self.anchor = vmath.vector3(0.5 + self.pivot.x, 0.5 - self.pivot.y, 0)
|
||||
self._grid_horizonal_offset = self.node_size.x * (self.in_row - 1) * self.anchor.x
|
||||
self._zero_offset = vmath.vector3(
|
||||
self.node_size.x * self.node_pivot.x - self.node_size.x * self.pivot.x - self._grid_horizonal_offset,
|
||||
self.node_size.y * self.node_pivot.y - self.node_size.y * self.pivot.y,
|
||||
0
|
||||
)
|
||||
|
||||
self:_update(true)
|
||||
end
|
||||
|
||||
|
||||
--- Add new item to the grid
|
||||
-- @tparam StaticGrid self @{StaticGrid}
|
||||
-- @tparam node item Gui node
|
||||
-- @tparam[opt] number index The item position. By default add as last item
|
||||
-- @tparam[opt=SHIFT.RIGHT] number shift_policy How shift nodes, if required. See const.SHIFT
|
||||
-- @tparam[opt=false] boolean is_instant If true, update node positions instantly
|
||||
-- @tparam node item GUI node
|
||||
-- @tparam number|nil index The item position. By default add as last item
|
||||
-- @tparam number|nil shift_policy How shift nodes, if required. Default: const.SHIFT.RIGHT
|
||||
-- @tparam boolean|nil is_instant If true, update node positions instantly
|
||||
function StaticGrid.add(self, item, index, shift_policy, is_instant)
|
||||
index = index or ((self.last_index or 0) + 1)
|
||||
|
||||
@@ -236,12 +278,29 @@ function StaticGrid.add(self, item, index, shift_policy, is_instant)
|
||||
end
|
||||
|
||||
|
||||
--- Set new items to the grid. All previous items will be removed
|
||||
-- @tparam StaticGrid self @{StaticGrid}
|
||||
-- @tparam node[] nodes The new grid nodes
|
||||
-- @tparam[opt=false] boolean is_instant If true, update node positions instantly
|
||||
function StaticGrid.set_items(self, nodes, is_instant)
|
||||
self.nodes = nodes
|
||||
for index = 1, #nodes do
|
||||
local item = nodes[index]
|
||||
gui.set_parent(item, self.parent)
|
||||
end
|
||||
|
||||
self:_update(is_instant)
|
||||
|
||||
self.on_change_items:trigger(self:get_context())
|
||||
end
|
||||
|
||||
|
||||
--- Remove the item from the grid. Note that gui node will be not deleted
|
||||
-- @tparam StaticGrid self @{StaticGrid}
|
||||
-- @tparam number index The grid node index to remove
|
||||
-- @tparam[opt=SHIFT.RIGHT] number shift_policy How shift nodes, if required. See const.SHIFT
|
||||
-- @tparam[opt=false] boolean is_instant If true, update node positions instantly
|
||||
-- @treturn Node The deleted gui node from grid
|
||||
-- @tparam number|nil shift_policy How shift nodes, if required. Default: const.SHIFT.RIGHT
|
||||
-- @tparam boolean|nil is_instant If true, update node positions instantly
|
||||
-- @treturn node The deleted gui node from grid
|
||||
function StaticGrid.remove(self, index, shift_policy, is_instant)
|
||||
assert(self.nodes[index], "No grid item at given index " .. index)
|
||||
|
||||
@@ -337,6 +396,7 @@ function StaticGrid.clear(self)
|
||||
self:_update()
|
||||
|
||||
self.on_clear:trigger(self:get_context())
|
||||
self.on_change_items:trigger(self:get_context())
|
||||
|
||||
return self
|
||||
end
|
||||
@@ -377,9 +437,44 @@ function StaticGrid.set_in_row(self, in_row)
|
||||
end
|
||||
|
||||
|
||||
--- Set new node size for grid
|
||||
-- @tparam StaticGrid self @{StaticGrid}
|
||||
-- @tparam[opt] number width The new node width
|
||||
-- @tparam[opt] number height The new node height
|
||||
-- @treturn druid.static_grid Current grid instance
|
||||
function StaticGrid.set_item_size(self, width, height)
|
||||
if width then
|
||||
self.node_size.x = width
|
||||
end
|
||||
if height then
|
||||
self.node_size.y = height
|
||||
end
|
||||
self._grid_horizonal_offset = self.node_size.x * (self.in_row - 1) * self.anchor.x
|
||||
self._zero_offset = vmath.vector3(
|
||||
self.node_size.x * self.node_pivot.x - self.node_size.x * self.pivot.x - self._grid_horizonal_offset,
|
||||
self.node_size.y * self.node_pivot.y - self.node_size.y * self.pivot.y,
|
||||
0)
|
||||
|
||||
self:_update()
|
||||
self.on_change_items:trigger(self:get_context())
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Sort grid nodes by custom comparator function
|
||||
-- @tparam StaticGrid self @{StaticGrid}
|
||||
-- @tparam function comparator The comparator function. (a, b) -> boolean
|
||||
-- @treturn druid.static_grid Current grid instance
|
||||
function StaticGrid.sort_nodes(self, comparator)
|
||||
table.sort(self.nodes, comparator)
|
||||
self:_update(true)
|
||||
end
|
||||
|
||||
|
||||
--- Update grid inner state
|
||||
-- @tparam StaticGrid self @{StaticGrid}
|
||||
-- @tparam bool is_instant If true, node position update instantly, otherwise with set_position_function callback
|
||||
-- @tparam boolean|nil is_instant If true, node position update instantly, otherwise with set_position_function callback
|
||||
-- @local
|
||||
function StaticGrid._update(self, is_instant)
|
||||
self:_update_indexes()
|
||||
@@ -425,7 +520,7 @@ end
|
||||
|
||||
--- Update grid nodes position
|
||||
-- @tparam StaticGrid self @{StaticGrid}
|
||||
-- @tparam bool is_instant If true, node position update instantly, otherwise with set_position_function callback
|
||||
-- @tparam boolean|nil is_instant If true, node position update instantly, otherwise with set_position_function callback
|
||||
-- @local
|
||||
function StaticGrid._update_pos(self, is_instant)
|
||||
local zero_offset = self:_get_zero_offset()
|
||||
|
||||
@@ -53,6 +53,9 @@
|
||||
--- Current text position
|
||||
-- @tfield vector3 pos
|
||||
|
||||
--- The last text value
|
||||
-- @tfield string last_value
|
||||
|
||||
--- Initial text node scale
|
||||
-- @tfield vector3 start_scale
|
||||
|
||||
@@ -78,12 +81,18 @@ local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
local utf8_lua = require("druid.system.utf8")
|
||||
local component = require("druid.component")
|
||||
local utf8 = utf8 or utf8_lua
|
||||
local utf8 = utf8 or utf8_lua --[[@as utf8]]
|
||||
|
||||
local Text = component.create("text")
|
||||
|
||||
|
||||
local function update_text_size(self)
|
||||
if self.scale.x == 0 or self.scale.y == 0 then
|
||||
return
|
||||
end
|
||||
if self.start_scale.x == 0 or self.start_scale.y == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local size = vmath.vector3(
|
||||
self.start_size.x * (self.start_scale.x / self.scale.x),
|
||||
self.start_size.y * (self.start_scale.y / self.scale.y),
|
||||
@@ -95,29 +104,82 @@ end
|
||||
|
||||
--- Reset initial scale for text
|
||||
local function reset_default_scale(self)
|
||||
self.scale.x = self.start_scale.x
|
||||
self.scale.y = self.start_scale.y
|
||||
self.scale.z = self.start_scale.z
|
||||
gui.set_scale(self.node, self.start_scale)
|
||||
gui.set_size(self.node, self.start_size)
|
||||
end
|
||||
|
||||
|
||||
local function is_fit_info_area(self, metrics)
|
||||
return metrics.width * self.scale.x <= self.text_area.x and
|
||||
metrics.height * self.scale.y <= self.text_area.y
|
||||
end
|
||||
|
||||
|
||||
--- Setup scale x, but can only be smaller, than start text scale
|
||||
local function update_text_area_size(self)
|
||||
reset_default_scale(self)
|
||||
|
||||
local max_width = self.text_area.x
|
||||
local max_height = self.text_area.y
|
||||
|
||||
local metrics = helper.get_text_metrics_from_node(self.node)
|
||||
|
||||
local scale_modifier = max_width / metrics.width
|
||||
scale_modifier = math.min(scale_modifier, self.start_scale.x)
|
||||
if metrics.width == 0 then
|
||||
reset_default_scale(self)
|
||||
self.on_update_text_scale:trigger(self:get_context(), self.start_scale, metrics)
|
||||
return
|
||||
end
|
||||
|
||||
local text_area_width = self.text_area.x
|
||||
local text_area_height = self.text_area.y
|
||||
|
||||
-- Adjust by width
|
||||
local scale_modifier = text_area_width / metrics.width
|
||||
|
||||
-- Adjust by height
|
||||
if self:is_multiline() then
|
||||
local scale_modifier_by_height = math.sqrt(max_height / metrics.height)
|
||||
scale_modifier = math.min(self.start_scale.y, scale_modifier_by_height)
|
||||
-- Approximate scale by height to start adjust scale
|
||||
scale_modifier = math.sqrt(text_area_height / metrics.height)
|
||||
if metrics.width * scale_modifier > text_area_width then
|
||||
scale_modifier = text_area_width / metrics.width
|
||||
end
|
||||
|
||||
if metrics.width * scale_modifier > max_width then
|
||||
scale_modifier = math.min(max_width / metrics.width, self.start_scale.x)
|
||||
-- #RMME
|
||||
if self._minimal_scale then
|
||||
scale_modifier = math.max(scale_modifier, self._minimal_scale)
|
||||
end
|
||||
-- Limit max scale by initial scale
|
||||
scale_modifier = math.min(scale_modifier, self.start_scale.x)
|
||||
-- #RMME
|
||||
|
||||
local is_fit = is_fit_info_area(self, metrics)
|
||||
local step = is_fit and self.style.ADJUST_SCALE_DELTA or -self.style.ADJUST_SCALE_DELTA
|
||||
|
||||
for i = 1, self.style.ADJUST_STEPS do
|
||||
-- Grow down to check if we fit
|
||||
if step < 0 and is_fit then
|
||||
break
|
||||
end
|
||||
-- Grow up to check if we still fit
|
||||
if step > 0 and not is_fit then
|
||||
break
|
||||
end
|
||||
|
||||
scale_modifier = scale_modifier + step
|
||||
|
||||
if self._minimal_scale then
|
||||
scale_modifier = math.max(scale_modifier, self._minimal_scale)
|
||||
end
|
||||
-- Limit max scale by initial scale
|
||||
scale_modifier = math.min(scale_modifier, self.start_scale.x)
|
||||
|
||||
self.scale.x = scale_modifier
|
||||
self.scale.y = scale_modifier
|
||||
self.scale.z = self.start_scale.z
|
||||
gui.set_scale(self.node, self.scale)
|
||||
update_text_size(self)
|
||||
metrics = helper.get_text_metrics_from_node(self.node)
|
||||
is_fit = is_fit_info_area(self, metrics)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -125,13 +187,16 @@ local function update_text_area_size(self)
|
||||
scale_modifier = math.max(scale_modifier, self._minimal_scale)
|
||||
end
|
||||
|
||||
local new_scale = vmath.vector3(scale_modifier, scale_modifier, self.start_scale.z)
|
||||
gui.set_scale(self.node, new_scale)
|
||||
self.scale = new_scale
|
||||
-- Limit max scale by initial scale
|
||||
scale_modifier = math.min(scale_modifier, self.start_scale.x)
|
||||
|
||||
self.scale.x = scale_modifier
|
||||
self.scale.y = scale_modifier
|
||||
self.scale.z = self.start_scale.z
|
||||
gui.set_scale(self.node, self.scale)
|
||||
update_text_size(self)
|
||||
|
||||
self.on_update_text_scale:trigger(self:get_context(), new_scale, metrics)
|
||||
self.on_update_text_scale:trigger(self:get_context(), self.scale, metrics)
|
||||
end
|
||||
|
||||
|
||||
@@ -146,9 +211,14 @@ local function update_text_with_trim(self, trim_postfix)
|
||||
text_length = text_length - 1
|
||||
new_text = utf8.sub(self.last_value, 1, text_length)
|
||||
text_width = self:get_text_size(new_text .. trim_postfix)
|
||||
if text_length == 0 then
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
gui.set_text(self.node, new_text .. trim_postfix)
|
||||
else
|
||||
gui.set_text(self.node, self.last_value)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -162,18 +232,6 @@ local function update_text_with_anchor_shift(self)
|
||||
end
|
||||
|
||||
|
||||
-- calculate space width with font
|
||||
local function get_space_width(self, font)
|
||||
if not self._space_width[font] then
|
||||
local no_space = resource.get_text_metrics(font, "1").width
|
||||
local with_space = resource.get_text_metrics(font, " 1").width
|
||||
self._space_width[font] = with_space - no_space
|
||||
end
|
||||
|
||||
return self._space_width[font]
|
||||
end
|
||||
|
||||
|
||||
local function update_adjust(self)
|
||||
if not self.adjust_type or self.adjust_type == const.TEXT_ADJUST.NO_ADJUST then
|
||||
reset_default_scale(self)
|
||||
@@ -207,20 +265,24 @@ end
|
||||
-- You can override this component styles params in druid styles table
|
||||
-- or create your own style
|
||||
-- @table style
|
||||
-- @tfield[opt=...] string TRIM_POSTFIX The postfix for TRIM adjust type
|
||||
-- @tfield[opt=DOWNSCALE] string DEFAULT_ADJUST The default adjust type for any text component
|
||||
-- @tfield string|nil TRIM_POSTFIX The postfix for TRIM adjust type. Default: ...
|
||||
-- @tfield string|nil DEFAULT_ADJUST The default adjust type for any text component. Default: DOWNSCALE
|
||||
-- @tfield string|nil ADJUST_STEPS Amount of iterations for text adjust by height. Default: 20
|
||||
-- @tfield string|nil ADJUST_SCALE_DELTA Scale step on each height adjust step. Default: 0.02
|
||||
function Text.on_style_change(self, style)
|
||||
self.style = {}
|
||||
self.style.TRIM_POSTFIX = style.TRIM_POSTFIX or "..."
|
||||
self.style.DEFAULT_ADJUST = style.DEFAULT_ADJUST or const.TEXT_ADJUST.DOWNSCALE
|
||||
self.style.ADJUST_STEPS = style.ADJUST_STEPS or 20
|
||||
self.style.ADJUST_SCALE_DELTA = style.ADJUST_SCALE_DELTA or 0.02
|
||||
end
|
||||
|
||||
|
||||
--- @{Text} constructor
|
||||
--- The @{Text} constructor
|
||||
-- @tparam Text self @{Text}
|
||||
-- @tparam string|node node Node name or GUI Text Node itself
|
||||
-- @tparam[opt] string value Initial text. Default value is node text from GUI scene.
|
||||
-- @tparam[opt=downscale] string adjust_type Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference
|
||||
-- @tparam string|nil value Initial text. Default value is node text from GUI scene. Default: nil
|
||||
-- @tparam string|nil adjust_type Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference. Default: DOWNSCALE
|
||||
function Text.init(self, node, value, adjust_type)
|
||||
self.node = self:get_node(node)
|
||||
self.pos = gui.get_position(self.node)
|
||||
@@ -242,8 +304,6 @@ function Text.init(self, node, value, adjust_type)
|
||||
self.on_set_pivot = Event()
|
||||
self.on_update_text_scale = Event()
|
||||
|
||||
self._space_width = {}
|
||||
|
||||
self:set_to(value or gui.get_text(self.node))
|
||||
return self
|
||||
end
|
||||
@@ -267,32 +327,60 @@ end
|
||||
|
||||
--- Calculate text width with font with respect to trailing space
|
||||
-- @tparam Text self @{Text}
|
||||
-- @tparam[opt] string text
|
||||
-- @tparam string text|nil
|
||||
-- @treturn number Width
|
||||
-- @treturn number Height
|
||||
function Text.get_text_size(self, text)
|
||||
text = text or self.last_value
|
||||
local font_name = gui.get_font(self.node)
|
||||
local font = gui.get_font_resource(font_name)
|
||||
local scale = gui.get_scale(self.node)
|
||||
local scale = self.last_scale or gui.get_scale(self.node)
|
||||
local linebreak = gui.get_line_break(self.node)
|
||||
local metrics = resource.get_text_metrics(font, text, {
|
||||
local dot_width = resource.get_text_metrics(font, ".").width
|
||||
|
||||
local metrics = resource.get_text_metrics(font, text .. ".", {
|
||||
line_break = linebreak,
|
||||
leading = 1,
|
||||
tracking = 0,
|
||||
width = self.start_size.x
|
||||
})
|
||||
local width = metrics.width
|
||||
for i = #text, 1, -1 do
|
||||
local c = string.sub(text, i, i)
|
||||
if c ~= ' ' then
|
||||
|
||||
local width = metrics.width - dot_width
|
||||
return width * scale.x, metrics.height * scale.y
|
||||
end
|
||||
|
||||
|
||||
--- Get chars count by width
|
||||
-- @tparam Text self @{Text}
|
||||
-- @tparam number width
|
||||
-- @treturn number Chars count
|
||||
function Text.get_text_index_by_width(self, width)
|
||||
local text = self.last_value
|
||||
local font_name = gui.get_font(self.node)
|
||||
local font = gui.get_font_resource(font_name)
|
||||
local scale = self.last_scale or gui.get_scale(self.node)
|
||||
|
||||
local text_index = 0
|
||||
local text_width = 0
|
||||
local text_length = utf8.len(text)
|
||||
local dot_width = resource.get_text_metrics(font, ".").width
|
||||
local previous_width = 0
|
||||
for i = 1, text_length do
|
||||
local subtext = utf8.sub(text, 1, i) .. "."
|
||||
local subtext_width = resource.get_text_metrics(font, subtext).width
|
||||
subtext_width = subtext_width - dot_width
|
||||
text_width = subtext_width * scale.x
|
||||
local width_delta = text_width - previous_width
|
||||
previous_width = text_width
|
||||
|
||||
if (text_width - width_delta/2) < width then
|
||||
text_index = i
|
||||
else
|
||||
break
|
||||
end
|
||||
|
||||
width = width + get_space_width(self, font)
|
||||
end
|
||||
|
||||
return width * scale.x, metrics.height * scale.y
|
||||
return text_index
|
||||
end
|
||||
|
||||
|
||||
@@ -314,6 +402,19 @@ function Text.set_to(self, set_to)
|
||||
end
|
||||
|
||||
|
||||
--- Set text area size
|
||||
-- @tparam Text self @{Text}
|
||||
-- @tparam vector3 size The new text area size
|
||||
-- @treturn Text Current text instance
|
||||
function Text.set_size(self, size)
|
||||
self.start_size = size
|
||||
self.text_area = vmath.vector3(size)
|
||||
self.text_area.x = self.text_area.x * self.start_scale.x
|
||||
self.text_area.y = self.text_area.y * self.start_scale.y
|
||||
update_adjust(self)
|
||||
end
|
||||
|
||||
|
||||
--- Set color
|
||||
-- @tparam Text self @{Text}
|
||||
-- @tparam vector4 color Color for node
|
||||
@@ -352,7 +453,7 @@ end
|
||||
|
||||
--- Set text pivot. Text will re-anchor inside text area
|
||||
-- @tparam Text self @{Text}
|
||||
-- @tparam gui.pivot pivot Gui pivot constant
|
||||
-- @tparam number pivot The gui.PIVOT_* constant
|
||||
-- @treturn Text Current text instance
|
||||
function Text.set_pivot(self, pivot)
|
||||
local prev_pivot = gui.get_pivot(self.node)
|
||||
@@ -378,7 +479,7 @@ end
|
||||
|
||||
--- Return true, if text with line break
|
||||
-- @tparam Text self @{Text}
|
||||
-- @treturn bool Is text node with line break
|
||||
-- @treturn boolean Is text node with line break
|
||||
function Text.is_multiline(self)
|
||||
return gui.get_line_break(self.node)
|
||||
end
|
||||
@@ -386,8 +487,8 @@ end
|
||||
|
||||
--- Set text adjust, refresh the current text visuals, if needed
|
||||
-- @tparam Text self @{Text}
|
||||
-- @tparam[opt] number adjust_type See const.TEXT_ADJUST. If pass nil - use current adjust type
|
||||
-- @tparam[opt] number minimal_scale If pass nil - not use minimal scale
|
||||
-- @tparam string|nil adjust_type See const.TEXT_ADJUST. If pass nil - use current adjust type
|
||||
-- @tparam number|nil minimal_scale If pass nil - not use minimal scale
|
||||
-- @treturn Text Current text instance
|
||||
function Text.set_text_adjust(self, adjust_type, minimal_scale)
|
||||
self.adjust_type = adjust_type
|
||||
|
||||
@@ -19,13 +19,12 @@
|
||||
-- @alias druid.base_component
|
||||
|
||||
local const = require("druid.const")
|
||||
local class = require("druid.system.middleclass")
|
||||
local helper = require("druid.helper")
|
||||
|
||||
local BaseComponent = class("druid.component")
|
||||
local BaseComponent = {}
|
||||
|
||||
local INTERESTS = {} -- Cache interests per component class in runtime
|
||||
local IS_AUTO_TEMPLATE = not (sys.get_config("druid.no_auto_template") == "1")
|
||||
local IS_AUTO_TEMPLATE = not (sys.get_config_int("druid.no_auto_template", 0) == 1)
|
||||
|
||||
-- Component Interests
|
||||
BaseComponent.ON_INPUT = const.ON_INPUT
|
||||
@@ -74,9 +73,8 @@ end
|
||||
--
|
||||
-- Invoke `on_style_change` on component, if exist. Component should handle
|
||||
-- their style changing and store all style params
|
||||
-- @function component:set_style
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @tparam table druid_style Druid style module
|
||||
-- @tparam table|nil druid_style Druid style module
|
||||
-- @treturn BaseComponent @{BaseComponent}
|
||||
function BaseComponent.set_style(self, druid_style)
|
||||
self._meta.style = druid_style or {}
|
||||
@@ -94,7 +92,6 @@ end
|
||||
--
|
||||
-- Use on all your custom components with GUI layouts used as templates.
|
||||
-- It will check parent template name to build full template name in self:get_node()
|
||||
-- @function component:set_template
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @tparam string template BaseComponent template name
|
||||
-- @treturn BaseComponent @{BaseComponent}
|
||||
@@ -118,7 +115,6 @@ end
|
||||
|
||||
|
||||
--- Get current component template name.
|
||||
-- @function component:get_template
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @treturn string Component full template name
|
||||
function BaseComponent.get_template(self)
|
||||
@@ -128,7 +124,6 @@ end
|
||||
|
||||
--- Set current component nodes.
|
||||
-- Use if your component nodes was cloned with `gui.clone_tree` and you got the node tree.
|
||||
-- @function component:set_nodes
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @tparam table nodes BaseComponent nodes table
|
||||
-- @treturn BaseComponent @{BaseComponent}
|
||||
@@ -155,7 +150,6 @@ end
|
||||
--- Context used as first arg in all Druid events
|
||||
--
|
||||
-- Context is usually self of gui_script.
|
||||
-- @function component:get_context
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @treturn table BaseComponent context
|
||||
function BaseComponent.get_context(self)
|
||||
@@ -164,7 +158,6 @@ end
|
||||
|
||||
|
||||
--- Increase input priority in input stack
|
||||
-- @function component:increase_input_priority
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @local
|
||||
function BaseComponent.increase_input_priority(self)
|
||||
@@ -178,7 +171,6 @@ end
|
||||
-- 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
|
||||
-- @function component:get_node
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @tparam string|node node_or_name Node name or node itself
|
||||
-- @treturn node Gui node
|
||||
@@ -211,17 +203,27 @@ end
|
||||
|
||||
|
||||
--- Get Druid instance for inner component creation.
|
||||
-- @function component:get_druid
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @treturn Druid Druid instance with component context
|
||||
function BaseComponent.get_druid(self)
|
||||
-- @tparam string|nil template The template name
|
||||
-- @tparam table|nil nodes The nodes table
|
||||
-- @treturn DruidInstance Druid instance with component context
|
||||
function BaseComponent.get_druid(self, template, nodes)
|
||||
local context = { _context = self }
|
||||
return setmetatable(context, { __index = self._meta.druid })
|
||||
local druid_instance = setmetatable(context, { __index = self._meta.druid })
|
||||
|
||||
if template then
|
||||
self:set_template(template)
|
||||
end
|
||||
|
||||
if nodes then
|
||||
self:set_nodes(nodes)
|
||||
end
|
||||
|
||||
return druid_instance
|
||||
end
|
||||
|
||||
|
||||
--- Return component name
|
||||
-- @function component:get_name
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @treturn string The component name
|
||||
function BaseComponent.get_name(self)
|
||||
@@ -230,7 +232,6 @@ end
|
||||
|
||||
|
||||
--- Return parent component name
|
||||
-- @function component:get_parent_name
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @treturn string|nil The parent component name if exist or bil
|
||||
function BaseComponent.get_parent_name(self)
|
||||
@@ -240,7 +241,6 @@ end
|
||||
|
||||
|
||||
--- Return component input priority
|
||||
-- @function component:get_input_priority
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @treturn number The component input priority
|
||||
function BaseComponent.get_input_priority(self)
|
||||
@@ -251,10 +251,9 @@ end
|
||||
--- Set component input priority
|
||||
--
|
||||
-- Default value: 10
|
||||
-- @function component:set_input_priority
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @tparam number value The new input priority value
|
||||
-- @tparam boolean is_temporary If true, the reset input priority will return to previous value
|
||||
-- @tparam boolean|nil is_temporary If true, the reset input priority will return to previous value
|
||||
-- @treturn number The component input priority
|
||||
function BaseComponent.set_input_priority(self, value, is_temporary)
|
||||
assert(value)
|
||||
@@ -280,7 +279,6 @@ end
|
||||
|
||||
|
||||
--- Reset component input priority to default value
|
||||
-- @function component:reset_input_priority
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @treturn number The component input priority
|
||||
function BaseComponent.reset_input_priority(self)
|
||||
@@ -292,7 +290,6 @@ end
|
||||
--- Return component UID.
|
||||
--
|
||||
-- UID generated in component creation order.
|
||||
-- @function component:get_uid
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @treturn number The component uid
|
||||
function BaseComponent.get_uid(self)
|
||||
@@ -303,9 +300,8 @@ end
|
||||
--- Set component input state. By default it enabled
|
||||
--
|
||||
-- If input is disabled, the component will not receive input events
|
||||
-- @function component:set_input_enabled
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @tparam bool state The component input state
|
||||
-- @tparam boolean|nil state The component input state
|
||||
-- @treturn BaseComponent BaseComponent itself
|
||||
function BaseComponent.set_input_enabled(self, state)
|
||||
self._meta.input_enabled = state
|
||||
@@ -319,7 +315,6 @@ end
|
||||
|
||||
|
||||
--- Return the parent component if exist
|
||||
-- @function component:get_parent_component
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @treturn BaseComponent|nil The druid component instance or nil
|
||||
function BaseComponent.get_parent_component(self)
|
||||
@@ -328,7 +323,6 @@ end
|
||||
|
||||
|
||||
--- Setup component context and his style table
|
||||
-- @function component:setup_component
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @tparam table druid_instance The parent druid instance
|
||||
-- @tparam table context Druid context. Usually it is self of script
|
||||
@@ -353,34 +347,14 @@ function BaseComponent.setup_component(self, druid_instance, context, style, ins
|
||||
self:set_template("")
|
||||
|
||||
if self._meta.parent then
|
||||
self._meta.parent:__add_children(self)
|
||||
self._meta.parent:__add_child(self)
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Basic constructor of component. It will call automaticaly
|
||||
-- by `BaseComponent.create`
|
||||
-- @function component:initialize
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @tparam string name BaseComponent name
|
||||
-- @tparam[opt=DEFAULT] number input_priority The input priority. The bigger number processed first
|
||||
-- @local
|
||||
function BaseComponent.initialize(self, name, input_priority)
|
||||
self._component = {
|
||||
name = name,
|
||||
input_priority = input_priority or const.PRIORITY_INPUT,
|
||||
default_input_priority = input_priority or const.PRIORITY_INPUT,
|
||||
is_debug = false,
|
||||
_is_input_priority_changed = true, -- Default true for sort once time after GUI init
|
||||
_uid = BaseComponent.create_uid()
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
--- Print log information if debug mode is enabled
|
||||
-- @function component:log_message
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @tparam string message
|
||||
-- @tparam table context
|
||||
@@ -394,9 +368,8 @@ end
|
||||
|
||||
|
||||
--- Set debug logs for component enabled or disabled
|
||||
-- @function component:set_debug
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @tparam bool is_debug
|
||||
-- @tparam boolean|nil is_debug
|
||||
-- @local
|
||||
function BaseComponent.set_debug(self, is_debug)
|
||||
self._component.is_debug = is_debug
|
||||
@@ -404,7 +377,6 @@ end
|
||||
|
||||
|
||||
--- Return true, if input priority was changed
|
||||
-- @function component:_is_input_priority_changed
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @local
|
||||
function BaseComponent._is_input_priority_changed(self)
|
||||
@@ -413,7 +385,6 @@ end
|
||||
|
||||
|
||||
--- Reset is_input_priority_changed field
|
||||
-- @function component:_reset_input_priority_changed
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @local
|
||||
function BaseComponent._reset_input_priority_changed(self)
|
||||
@@ -427,7 +398,6 @@ end
|
||||
|
||||
|
||||
--- Get current component interests
|
||||
-- @function component:__get_interests
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @treturn table List of component interests
|
||||
-- @local
|
||||
@@ -451,7 +421,6 @@ end
|
||||
|
||||
|
||||
--- Get current component nodes
|
||||
-- @function component:__get_nodes
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @treturn table BaseComponent nodes table
|
||||
-- @local
|
||||
@@ -466,31 +435,29 @@ end
|
||||
|
||||
|
||||
--- Add child to component children list
|
||||
-- @function component:__add_children
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @tparam component children The druid component instance
|
||||
-- @tparam component child The druid component instance
|
||||
-- @local
|
||||
function BaseComponent.__add_children(self, children)
|
||||
table.insert(self._meta.children, children)
|
||||
function BaseComponent.__add_child(self, child)
|
||||
table.insert(self._meta.children, child)
|
||||
end
|
||||
|
||||
|
||||
--- Remove child from component children list
|
||||
-- @function component:__remove_children
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @tparam component children The druid component instance
|
||||
-- @tparam component child The druid component instance
|
||||
-- @local
|
||||
function BaseComponent.__remove_children(self, children)
|
||||
function BaseComponent.__remove_child(self, child)
|
||||
for i = #self._meta.children, 1, -1 do
|
||||
if self._meta.children[i] == children then
|
||||
if self._meta.children[i] == child then
|
||||
table.remove(self._meta.children, i)
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Return all children components, recursive
|
||||
-- @function component:get_childrens
|
||||
-- @tparam BaseComponent self @{BaseComponent}
|
||||
-- @treturn table Array of childrens if the Druid component instance
|
||||
function BaseComponent.get_childrens(self)
|
||||
@@ -510,15 +477,27 @@ end
|
||||
--- Create new component. It will inheritance from basic Druid component.
|
||||
-- @function BaseComponent.create
|
||||
-- @tparam string name BaseComponent name
|
||||
-- @tparam[opt=DEFAULT] number input_priority The input priority. The bigger number processed first
|
||||
-- @tparam number|nil input_priority The input priority. The bigger number processed first
|
||||
-- @local
|
||||
function BaseComponent.create(name, input_priority)
|
||||
-- Yea, inheritance here
|
||||
local new_class = class(name, BaseComponent)
|
||||
|
||||
new_class.initialize = function(self)
|
||||
BaseComponent.initialize(self, name, input_priority)
|
||||
end
|
||||
local new_class = setmetatable({}, {
|
||||
__index = BaseComponent,
|
||||
__call = function(cls, ...)
|
||||
local self = setmetatable({
|
||||
_component = {
|
||||
name = name,
|
||||
input_priority = input_priority or const.PRIORITY_INPUT,
|
||||
default_input_priority = input_priority or const.PRIORITY_INPUT,
|
||||
is_debug = false,
|
||||
_is_input_priority_changed = true, -- Default true for sort once time after GUI init
|
||||
_uid = BaseComponent.create_uid()
|
||||
}
|
||||
}, {
|
||||
__index = cls
|
||||
})
|
||||
return self
|
||||
end
|
||||
})
|
||||
|
||||
return new_class
|
||||
end
|
||||
|
||||
@@ -7,20 +7,25 @@
|
||||
|
||||
local M = {}
|
||||
|
||||
M.ACTION_TEXT = hash(sys.get_config("druid.input_text", "text"))
|
||||
M.ACTION_TOUCH = hash(sys.get_config("druid.input_touch", "touch"))
|
||||
M.ACTION_MARKED_TEXT = hash(sys.get_config("druid.input_marked_text", "marked_text"))
|
||||
M.ACTION_ESC = hash(sys.get_config("druid.input_key_esc", "key_esc"))
|
||||
M.ACTION_BACK = hash(sys.get_config("druid.input_key_back", "key_back"))
|
||||
M.ACTION_ENTER = hash(sys.get_config("druid.input_key_enter", "key_enter"))
|
||||
M.ACTION_MULTITOUCH = hash(sys.get_config("druid.input_multitouch", "touch_multi"))
|
||||
M.ACTION_BACKSPACE = hash(sys.get_config("druid.input_key_backspace", "key_backspace"))
|
||||
M.ACTION_SCROLL_UP = hash(sys.get_config("druid.input_scroll_up", "mouse_wheel_up"))
|
||||
M.ACTION_SCROLL_DOWN = hash(sys.get_config("druid.input_scroll_down", "mouse_wheel_down"))
|
||||
M.ACTION_TEXT = hash(sys.get_config_string("druid.input_text", "text"))
|
||||
M.ACTION_TOUCH = hash(sys.get_config_string("druid.input_touch", "touch"))
|
||||
M.ACTION_MARKED_TEXT = hash(sys.get_config_string("druid.input_marked_text", "marked_text"))
|
||||
M.ACTION_ESC = hash(sys.get_config_string("druid.input_key_esc", "key_esc"))
|
||||
M.ACTION_BACK = hash(sys.get_config_string("druid.input_key_back", "key_back"))
|
||||
M.ACTION_ENTER = hash(sys.get_config_string("druid.input_key_enter", "key_enter"))
|
||||
M.ACTION_MULTITOUCH = hash(sys.get_config_string("druid.input_multitouch", "touch_multi"))
|
||||
M.ACTION_BACKSPACE = hash(sys.get_config_string("druid.input_key_backspace", "key_backspace"))
|
||||
M.ACTION_SCROLL_UP = hash(sys.get_config_string("druid.input_scroll_up", "mouse_wheel_up"))
|
||||
M.ACTION_SCROLL_DOWN = hash(sys.get_config_string("druid.input_scroll_down", "mouse_wheel_down"))
|
||||
M.ACTION_LEFT = hash(sys.get_config_string("druid.input_key_left", "key_left"))
|
||||
M.ACTION_RIGHT = hash(sys.get_config_string("druid.input_key_right", "key_right"))
|
||||
M.ACTION_LSHIFT = hash(sys.get_config_string("druid.input_key_lshift", "key_lshift"))
|
||||
M.ACTION_LCTRL = hash(sys.get_config_string("druid.input_key_lctrl", "key_lctrl"))
|
||||
M.ACTION_LCMD = hash(sys.get_config_string("druid.input_key_lsuper", "key_lsuper"))
|
||||
|
||||
M.IS_STENCIL_CHECK = not (sys.get_config_int("druid.no_stencil_check", 0) == 1)
|
||||
|
||||
M.IS_STENCIL_CHECK = not (sys.get_config("druid.no_stencil_check") == "1")
|
||||
|
||||
--- Component Interests
|
||||
M.ON_INPUT = "on_input"
|
||||
M.ON_UPDATE = "update"
|
||||
M.ON_MESSAGE = "on_message"
|
||||
|
||||
@@ -1,182 +0,0 @@
|
||||
script: ""
|
||||
fonts {
|
||||
name: "game"
|
||||
font: "/example/assets/fonts/game.font"
|
||||
}
|
||||
textures {
|
||||
name: "kenney"
|
||||
texture: "/example/assets/images/kenney.atlas"
|
||||
}
|
||||
background_color {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
texture: "kenney/empty"
|
||||
id: "root"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_NONE
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
template_node_child: false
|
||||
size_mode: SIZE_MODE_AUTO
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 2.0
|
||||
y: 2.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 36.0
|
||||
y: 36.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
texture: "kenney/slider_move"
|
||||
id: "pin"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "root"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_NONE
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
template_node_child: false
|
||||
size_mode: SIZE_MODE_AUTO
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 0.0
|
||||
y: 13.5
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 0.2
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 17.0
|
||||
y: 17.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 0.101960786
|
||||
y: 0.101960786
|
||||
z: 0.101960786
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
texture: "kenney/tick"
|
||||
id: "notch"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "pin"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_NONE
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
template_node_child: false
|
||||
size_mode: SIZE_MODE_AUTO
|
||||
}
|
||||
material: "/builtins/materials/gui.material"
|
||||
adjust_reference: ADJUST_REFERENCE_PARENT
|
||||
max_nodes: 512
|
||||
@@ -1,123 +0,0 @@
|
||||
-- Copyright (c) 2022 Maksim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
|
||||
|
||||
--- Druid pin knob custom component.
|
||||
-- It's simple rotating input element
|
||||
-- @module PinKnob
|
||||
-- @within BaseComponent
|
||||
-- @alias druid.pin_knob
|
||||
|
||||
--- The component druid instance
|
||||
-- @tfield DruidInstance druid @{DruidInstance}
|
||||
|
||||
--- Is currently under user control
|
||||
-- @tfield bool is_drag
|
||||
|
||||
--- The pin node
|
||||
-- @tfield node node
|
||||
|
||||
---
|
||||
|
||||
local const = require("druid.const")
|
||||
local component = require("druid.component")
|
||||
|
||||
local PinKnob = component.create("druid.pin_knob", { const.ON_INPUT })
|
||||
|
||||
local SCHEME = {
|
||||
ROOT = "root",
|
||||
PIN = "pin",
|
||||
}
|
||||
|
||||
|
||||
local function update_visual(self)
|
||||
local rotation = vmath.vector3(0, 0, self.angle)
|
||||
gui.set_rotation(self.node, rotation)
|
||||
end
|
||||
|
||||
|
||||
local function set_angle(self, value)
|
||||
local prev_value = self.angle
|
||||
|
||||
self.angle = value
|
||||
self.angle = math.min(self.angle, self.angle_max)
|
||||
self.angle = math.max(self.angle, self.angle_min)
|
||||
update_visual(self)
|
||||
|
||||
if prev_value ~= self.angle and self.callback then
|
||||
local output_value = self.angle
|
||||
if output_value ~= 0 then
|
||||
output_value = -output_value
|
||||
end
|
||||
self.callback(self:get_context(), output_value)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Component init function
|
||||
-- @tparam PinKnob self @{PinKnob}
|
||||
-- @tparam function callback Callback(self, value) on value changed
|
||||
-- @tparam string template The template string name
|
||||
-- @tparam table nodes Nodes table from gui.clone_tree
|
||||
function PinKnob.init(self, callback, template, nodes)
|
||||
self:set_template(template)
|
||||
self:set_nodes(nodes)
|
||||
self.druid = self:get_druid()
|
||||
self.node = self:get_node(SCHEME.PIN)
|
||||
self.is_drag = false
|
||||
|
||||
self.callback = callback
|
||||
self:set_angle(0, -100, 100)
|
||||
self._friction = 0.75
|
||||
end
|
||||
|
||||
|
||||
--- Set current and min/max angles for component
|
||||
-- @tparam PinKnob self @{PinKnob}
|
||||
-- @tparam number cur_value The new value for pin knob
|
||||
-- @tparam number min The minimum value for pin knob
|
||||
-- @tparam number max The maximum value for pin knob
|
||||
-- @treturn PinKnob @{PinKnob}
|
||||
function PinKnob.set_angle(self, cur_value, min, max)
|
||||
self.angle_min = min or self.angle_min
|
||||
self.angle_max = max or self.angle_max
|
||||
set_angle(self, cur_value)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set current and min/max angles for component
|
||||
-- @tparam PinKnob self @{PinKnob}
|
||||
-- @tparam[opt=1] number value The spin speed multiplier
|
||||
-- @treturn PinKnob @{PinKnob}
|
||||
function PinKnob.set_friction(self, value)
|
||||
self._friction = value or 1
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
function PinKnob.on_input(self, action_id, action)
|
||||
if action_id ~= const.ACTION_TOUCH then
|
||||
return false
|
||||
end
|
||||
|
||||
if gui.pick_node(self.node, action.x, action.y) then
|
||||
if action.pressed then
|
||||
self.pos = gui.get_position(self.node)
|
||||
self.is_drag = true
|
||||
end
|
||||
end
|
||||
|
||||
if self.is_drag and not action.pressed then
|
||||
set_angle(self, self.angle - action.dx * self._friction - action.dy * self._friction)
|
||||
end
|
||||
|
||||
if action.released then
|
||||
self.is_drag = false
|
||||
end
|
||||
|
||||
return self.is_drag
|
||||
end
|
||||
|
||||
|
||||
return PinKnob
|
||||
@@ -3,25 +3,47 @@
|
||||
--- Druid Rich Input custom component.
|
||||
-- It's wrapper on Input component with cursor and placeholder text
|
||||
-- @module RichInput
|
||||
-- @within Input
|
||||
-- @alias druid.rich_input
|
||||
|
||||
--- The component druid instance
|
||||
-- @tfield DruidInstance druid @{DruidInstance}
|
||||
|
||||
--- Root node
|
||||
-- @tfield node root
|
||||
|
||||
--- On input field text change callback(self, input_text)
|
||||
-- @tfield Input input @{Input}
|
||||
|
||||
--- On input field text change to empty string callback(self, input_text)
|
||||
-- @tfield node cursor
|
||||
|
||||
--- On input field text change to max length string callback(self, input_text)
|
||||
-- @tfield druid.text placeholder @{Text}
|
||||
--- On input field text change to empty string callback(self, input_text)
|
||||
-- @tfield node cursor_text
|
||||
|
||||
--- On input field text change to empty string callback(self, input_text)
|
||||
-- @tfield vector3 cursor_position
|
||||
|
||||
--- On input field text change to empty string callback(self, input_text)
|
||||
-- @tfield druid.text input_text
|
||||
|
||||
--- On input field text change to empty string callback(self, input_text)
|
||||
-- @tfield druid.drag drag
|
||||
|
||||
--- On input field text change to empty string callback(self, input_text)
|
||||
-- @tfield druid.text placeholder
|
||||
|
||||
--- On input field text change to empty string callback(self, input_text)
|
||||
-- @tfield vector3 text_position
|
||||
|
||||
---
|
||||
|
||||
local component = require("druid.component")
|
||||
local helper = require("druid.helper")
|
||||
local const = require("druid.const")
|
||||
local utf8_lua = require("druid.system.utf8")
|
||||
local utf8 = utf8 or utf8_lua
|
||||
|
||||
local input = require("druid.extended.input")
|
||||
local RichInput = component.create("druid.rich_input")
|
||||
|
||||
local SCHEME = {
|
||||
@@ -30,56 +52,208 @@ local SCHEME = {
|
||||
PLACEHOLDER = "placeholder_text",
|
||||
INPUT = "input_text",
|
||||
CURSOR = "cursor_node",
|
||||
CURSOR_TEXT = "cursor_text",
|
||||
}
|
||||
|
||||
local DOUBLE_CLICK_TIME = 0.35
|
||||
|
||||
local function animate_cursor(self)
|
||||
gui.cancel_animation(self.cursor, gui.PROP_COLOR)
|
||||
gui.set_color(self.cursor, vmath.vector4(1))
|
||||
gui.animate(self.cursor, gui.PROP_COLOR, vmath.vector4(1,1,1,0), gui.EASING_INSINE, 0.8, 0, nil, gui.PLAYBACK_LOOP_PINGPONG)
|
||||
gui.cancel_animation(self.cursor_text, "color.w")
|
||||
gui.set_alpha(self.cursor_text, 1)
|
||||
gui.animate(self.cursor_text, "color.w", 0, gui.EASING_INSINE, 0.8, 0, nil, gui.PLAYBACK_LOOP_PINGPONG)
|
||||
end
|
||||
|
||||
|
||||
local function update_text(self, text)
|
||||
local text_width = self.input.total_width
|
||||
animate_cursor(self)
|
||||
gui.set_position(self.cursor, vmath.vector3(text_width/2, 0, 0))
|
||||
local function set_selection_width(self, selection_width)
|
||||
gui.set_visible(self.cursor, selection_width > 0)
|
||||
|
||||
local width = selection_width / self.input.text.scale.x
|
||||
local height = gui.get_size(self.cursor).y
|
||||
gui.set_size(self.cursor, vmath.vector3(width, height, 0))
|
||||
|
||||
local is_selection_to_right = self.input.cursor_index == self.input.end_index
|
||||
gui.set_pivot(self.cursor, is_selection_to_right and gui.PIVOT_E or gui.PIVOT_W)
|
||||
end
|
||||
|
||||
|
||||
local function update_text(self)
|
||||
local left_text_part = utf8.sub(self.input:get_text(), 0, self.input.cursor_index)
|
||||
local selected_text_part = utf8.sub(self.input:get_text(), self.input.start_index + 1, self.input.end_index)
|
||||
|
||||
local left_part_width = self.input.text:get_text_size(left_text_part)
|
||||
local selected_part_width = self.input.text:get_text_size(selected_text_part)
|
||||
|
||||
local pivot_text = gui.get_pivot(self.input.text.node)
|
||||
local pivot_offset = helper.get_pivot_offset(pivot_text)
|
||||
|
||||
self.cursor_position.x = self.text_position.x - self.input.total_width * (0.5 + pivot_offset.x) + left_part_width
|
||||
|
||||
gui.set_position(self.cursor, self.cursor_position)
|
||||
gui.set_scale(self.cursor, self.input.text.scale)
|
||||
|
||||
set_selection_width(self, selected_part_width)
|
||||
end
|
||||
|
||||
|
||||
local function on_select(self)
|
||||
gui.set_enabled(self.cursor, true)
|
||||
gui.set_enabled(self.placeholder.node, false)
|
||||
gui.set_enabled(self.input.button.node, true)
|
||||
|
||||
animate_cursor(self)
|
||||
self.drag:set_enabled(true)
|
||||
end
|
||||
|
||||
|
||||
local function on_unselect(self)
|
||||
gui.cancel_animation(self.cursor, gui.PROP_COLOR)
|
||||
gui.set_enabled(self.cursor, false)
|
||||
gui.set_enabled(self.input.button.node, self.is_button_input_enabled)
|
||||
gui.set_enabled(self.placeholder.node, true and #self.input:get_text() == 0)
|
||||
|
||||
self.drag:set_enabled(false)
|
||||
end
|
||||
|
||||
|
||||
--- Component init function
|
||||
--- Update selection
|
||||
local function update_selection(self)
|
||||
update_text(self)
|
||||
end
|
||||
|
||||
|
||||
local TEMP_VECTOR = vmath.vector3(0)
|
||||
local function get_index_by_touch(self, touch)
|
||||
local text_node = self.input.text.node
|
||||
TEMP_VECTOR.x = touch.screen_x
|
||||
TEMP_VECTOR.y = touch.screen_y
|
||||
|
||||
-- Distance to the text node position
|
||||
local scene_scale = helper.get_scene_scale(text_node)
|
||||
local local_pos = gui.screen_to_local(text_node, TEMP_VECTOR)
|
||||
local_pos.x = local_pos.x / scene_scale.x
|
||||
|
||||
-- Offset to the left side of the text node
|
||||
local pivot_offset = helper.get_pivot_offset(gui.get_pivot(text_node))
|
||||
local_pos.x = local_pos.x + self.input.total_width * (0.5 + pivot_offset.x)
|
||||
local_pos.x = local_pos.x - self.text_position.x
|
||||
|
||||
local cursor_index = self.input.text:get_text_index_by_width(local_pos.x)
|
||||
return cursor_index
|
||||
end
|
||||
|
||||
|
||||
local function on_touch_start_callback(self, touch)
|
||||
local cursor_index = get_index_by_touch(self, touch)
|
||||
|
||||
if self._last_touch_info.cursor_index == cursor_index then
|
||||
local time = socket.gettime()
|
||||
if time - self._last_touch_info.time < DOUBLE_CLICK_TIME then
|
||||
local len = utf8.len(self.input:get_text())
|
||||
self.input:select_cursor(len, 0, len)
|
||||
self._last_touch_info.cursor_index = nil
|
||||
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
self._last_touch_info.cursor_index = cursor_index
|
||||
self._last_touch_info.time = socket.gettime()
|
||||
|
||||
if self.input.is_lshift then
|
||||
local start_index = self.input.start_index
|
||||
local end_index = self.input.end_index
|
||||
|
||||
if cursor_index < start_index then
|
||||
self.input:select_cursor(cursor_index, cursor_index, end_index)
|
||||
elseif cursor_index > end_index then
|
||||
self.input:select_cursor(cursor_index, start_index, cursor_index)
|
||||
end
|
||||
else
|
||||
self.input:select_cursor(cursor_index)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function on_drag_callback(self, dx, dy, x, y, touch)
|
||||
if not self._last_touch_info.cursor_index then
|
||||
return
|
||||
end
|
||||
|
||||
local index = get_index_by_touch(self, touch)
|
||||
if self._last_touch_info.cursor_index <= index then
|
||||
self.input:select_cursor(index, self._last_touch_info.cursor_index, index)
|
||||
else
|
||||
self.input:select_cursor(index, index, self._last_touch_info.cursor_index)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- The @{RichInput} constructor
|
||||
-- @tparam RichInput self @{RichInput}
|
||||
-- @tparam string template The template string name
|
||||
-- @tparam table nodes Nodes table from gui.clone_tree
|
||||
function RichInput.init(self, template, nodes)
|
||||
self:set_template(template)
|
||||
self:set_nodes(nodes)
|
||||
self.druid = self:get_druid()
|
||||
self.input = self.druid:new_input(self:get_node(SCHEME.BUTTON), self:get_node(SCHEME.INPUT))
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
self.root = self:get_node(SCHEME.ROOT)
|
||||
|
||||
self._last_touch_info = {
|
||||
cursor_index = nil,
|
||||
time = 0,
|
||||
}
|
||||
self.is_lshift = false
|
||||
self.is_lctrl = false
|
||||
|
||||
self.input = self.druid:new(input, self:get_node(SCHEME.BUTTON), self:get_node(SCHEME.INPUT))
|
||||
self.is_button_input_enabled = gui.is_enabled(self.input.button.node)
|
||||
|
||||
self.cursor = self:get_node(SCHEME.CURSOR)
|
||||
self.cursor_position = gui.get_position(self.cursor)
|
||||
self.cursor_text = self:get_node(SCHEME.CURSOR_TEXT)
|
||||
|
||||
self.drag = self.druid:new_drag(self:get_node(SCHEME.BUTTON), on_drag_callback)
|
||||
self.drag.on_touch_start:subscribe(on_touch_start_callback)
|
||||
self.drag:set_input_priority(const.PRIORITY_INPUT_MAX + 1)
|
||||
self.drag:set_enabled(false)
|
||||
|
||||
self.input:set_text("")
|
||||
self.placeholder = self.druid:new_text(self:get_node(SCHEME.PLACEHOLDER))
|
||||
self.text_position = gui.get_position(self.input.text.node)
|
||||
|
||||
self.input.on_input_text:subscribe(update_text)
|
||||
self.input.on_input_select:subscribe(on_select)
|
||||
self.input.on_input_unselect:subscribe(on_unselect)
|
||||
self.input.on_select_cursor_change:subscribe(update_selection)
|
||||
|
||||
on_unselect(self)
|
||||
update_text(self, "")
|
||||
update_text(self)
|
||||
end
|
||||
|
||||
|
||||
function RichInput.on_input(self, action_id, action)
|
||||
if action_id == const.ACTION_LSHIFT then
|
||||
if action.pressed then
|
||||
self.is_lshift = true
|
||||
elseif action.released then
|
||||
self.is_lshift = false
|
||||
end
|
||||
end
|
||||
|
||||
if action_id == const.ACTION_LCTRL or action_id == const.ACTION_LCMD then
|
||||
if action.pressed then
|
||||
self.is_lctrl = true
|
||||
elseif action.released then
|
||||
self.is_lctrl = false
|
||||
end
|
||||
end
|
||||
|
||||
if action_id == const.ACTION_LEFT and (action.pressed or action.repeated) then
|
||||
self.input:move_selection(-1, self.is_lshift, self.is_lctrl)
|
||||
end
|
||||
|
||||
if action_id == const.ACTION_RIGHT and (action.pressed or action.repeated) then
|
||||
self.input:move_selection(1, self.is_lshift, self.is_lctrl)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -92,4 +266,55 @@ function RichInput.set_placeholder(self, placeholder_text)
|
||||
end
|
||||
|
||||
|
||||
--- Select input field
|
||||
-- @tparam RichInput self @{RichInput}
|
||||
function RichInput.select(self)
|
||||
self.input:select()
|
||||
end
|
||||
|
||||
|
||||
--- Set input field text
|
||||
-- @tparam RichInput self @{RichInput}
|
||||
-- @treturn druid.input Current input instance
|
||||
-- @tparam string text The input text
|
||||
function RichInput.set_text(self, text)
|
||||
self.input:set_text(text)
|
||||
gui.set_enabled(self.placeholder.node, true and #self.input:get_text() == 0)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set input field font
|
||||
-- @tparam RichInput self @{RichInput}
|
||||
-- @tparam hash font The font hash
|
||||
-- @treturn druid.input Current input instance
|
||||
function RichInput.set_font(self, font)
|
||||
gui.set_font(self.input.text.node, font)
|
||||
gui.set_font(self.placeholder.node, font)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set input field text
|
||||
-- @tparam RichInput self @{RichInput}
|
||||
function RichInput.get_text(self)
|
||||
return self.input:get_text()
|
||||
end
|
||||
|
||||
|
||||
--- Set allowed charaters for input field.
|
||||
-- See: https://defold.com/ref/stable/string/
|
||||
-- ex: [%a%d] for alpha and numeric
|
||||
-- @tparam RichInput self @{RichInput}
|
||||
-- @tparam string characters Regulax exp. for validate user input
|
||||
-- @treturn RichInput Current instance
|
||||
function RichInput.set_allowed_characters(self, characters)
|
||||
self.input:set_allowed_characters(characters)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
return RichInput
|
||||
|
||||
@@ -11,6 +11,9 @@ local parser = require("druid.custom.rich_text.module.rt_parse")
|
||||
local utf8_lua = require("druid.system.utf8")
|
||||
local utf8 = utf8 or utf8_lua
|
||||
|
||||
local VECTOR_ZERO = vmath.vector3(0)
|
||||
local COLOR_WHITE = vmath.vector4(1)
|
||||
|
||||
local M = {}
|
||||
|
||||
-- Trim spaces on string start
|
||||
@@ -71,18 +74,18 @@ function M.length(text)
|
||||
end
|
||||
|
||||
|
||||
---@param word rich_text.word
|
||||
---@param previous_word rich_text.word|nil
|
||||
---@param settings rich_text.settings
|
||||
---@return rich_text.metrics
|
||||
---@param word druid.rich_text.word
|
||||
---@param previous_word druid.rich_text.word|nil
|
||||
---@param settings druid.rich_text.settings
|
||||
---@return druid.rich_text.metrics
|
||||
local function get_text_metrics(word, previous_word, settings)
|
||||
local text = word.text
|
||||
local font_resource = gui.get_font_resource(word.font)
|
||||
|
||||
---@type druid.rich_text.metrics
|
||||
local metrics
|
||||
local word_scale_x = word.relative_scale * settings.text_scale.x * settings.adjust_scale
|
||||
local word_scale_y = word.relative_scale * settings.text_scale.y * settings.adjust_scale
|
||||
local word_scale_x = word.relative_scale * settings.scale.x * settings.adjust_scale
|
||||
local word_scale_y = word.relative_scale * settings.scale.y * settings.adjust_scale
|
||||
|
||||
if utf8.len(text) == 0 then
|
||||
metrics = resource.get_text_metrics(font_resource, "|")
|
||||
@@ -116,16 +119,17 @@ end
|
||||
---@param settings druid.rich_text.settings
|
||||
---@return druid.rich_text.metrics
|
||||
local function get_image_metrics(word, settings)
|
||||
local node_prefab = settings.node_prefab
|
||||
gui.play_flipbook(node_prefab, word.image.anim)
|
||||
local node_size = gui.get_size(node_prefab)
|
||||
local node = word.node
|
||||
gui.set_texture(node, word.image.texture)
|
||||
gui.play_flipbook(node, word.image.anim)
|
||||
local node_size = gui.get_size(node)
|
||||
local aspect = node_size.x / node_size.y
|
||||
node_size.x = word.image.width or node_size.x
|
||||
node_size.y = word.image.height or (node_size.x / aspect)
|
||||
|
||||
return {
|
||||
width = node_size.x * word.relative_scale * settings.node_scale.x * settings.adjust_scale,
|
||||
height = node_size.y * word.relative_scale * settings.node_scale.y * settings.adjust_scale,
|
||||
width = node_size.x * word.relative_scale * settings.scale.x * settings.adjust_scale,
|
||||
height = node_size.y * word.relative_scale * settings.scale.y * settings.adjust_scale,
|
||||
node_size = node_size,
|
||||
}
|
||||
end
|
||||
@@ -136,6 +140,16 @@ end
|
||||
---@param previous_word druid.rich_text.word|nil
|
||||
---@return druid.rich_text.metrics
|
||||
local function measure_node(word, settings, previous_word)
|
||||
do -- Clone node if required
|
||||
local node
|
||||
if word.image then
|
||||
node = word.node or gui.new_box_node(vmath.vector3(0), vmath.vector3(word.image.width, word.image.height, 0))
|
||||
else
|
||||
node = word.node or gui.clone(settings.text_prefab)
|
||||
end
|
||||
word.node = node
|
||||
end
|
||||
|
||||
local metrics = word.image and get_image_metrics(word, settings) or get_text_metrics(word, previous_word, settings)
|
||||
return metrics
|
||||
end
|
||||
@@ -145,14 +159,14 @@ end
|
||||
--- @param text string The text to create rich text nodes from
|
||||
--- @param settings table Optional settings table (refer to documentation for details)
|
||||
--- @param style druid.rich_text.style
|
||||
--- @return words
|
||||
--- @return metrics
|
||||
--- @return druid.rich_text.word[]
|
||||
--- @return druid.rich_text.settings
|
||||
--- @return druid.rich_text.lines_metrics
|
||||
function M.create(text, settings, style)
|
||||
assert(text, "You must provide a text")
|
||||
|
||||
-- default settings for a word
|
||||
-- will be assigned to each word unless tags override the values
|
||||
local font = gui.get_font(settings.text_prefab)
|
||||
local word_params = {
|
||||
node = nil, -- Autofill on node creation
|
||||
relative_scale = 1,
|
||||
@@ -169,12 +183,10 @@ function M.create(text, settings, style)
|
||||
text_color = gui.get_color(settings.text_prefab),
|
||||
shadow = settings.shadow,
|
||||
outline = settings.outline,
|
||||
font = font,
|
||||
font = gui.get_font(settings.text_prefab),
|
||||
-- Image params
|
||||
---@type rich_text.word.image
|
||||
---@type druid.rich_text.image
|
||||
image = nil,
|
||||
image_color = gui.get_color(settings.node_prefab),
|
||||
default_animation = nil,
|
||||
-- Tags
|
||||
br = nil,
|
||||
nobr = nil,
|
||||
@@ -203,8 +215,8 @@ function M._fill_properties(word, metrics, settings)
|
||||
|
||||
if word.image then
|
||||
-- Image properties
|
||||
word.scale = gui.get_scale(settings.node_prefab) * word.relative_scale * settings.adjust_scale
|
||||
word.pivot = gui.get_pivot(settings.node_prefab)
|
||||
word.scale = vmath.vector3(word.relative_scale * settings.adjust_scale)
|
||||
word.pivot = gui.PIVOT_CENTER
|
||||
word.size = metrics.node_size
|
||||
word.offset = vmath.vector3(0, 0, 0)
|
||||
if word.image.width then
|
||||
@@ -213,8 +225,8 @@ function M._fill_properties(word, metrics, settings)
|
||||
end
|
||||
else
|
||||
-- Text properties
|
||||
word.scale = gui.get_scale(settings.text_prefab) * word.relative_scale * settings.adjust_scale
|
||||
word.pivot = gui.get_pivot(settings.text_prefab)
|
||||
word.scale = settings.scale * word.relative_scale * settings.adjust_scale
|
||||
word.pivot = gui.PIVOT_SW -- With this pivot adjustments works more correctly than with other pivots
|
||||
word.size = vmath.vector3(metrics.width, metrics.height, 0)
|
||||
word.offset = vmath.vector3(metrics.offset_x, metrics.offset_y, 0)
|
||||
end
|
||||
@@ -234,8 +246,8 @@ function M._split_on_lines(words, settings)
|
||||
|
||||
repeat
|
||||
local word = words[i]
|
||||
if word.image then
|
||||
word.default_animation = settings.default_animation
|
||||
if word == nil then
|
||||
break
|
||||
end
|
||||
|
||||
-- Reset texts to start measure again
|
||||
@@ -305,9 +317,9 @@ function M._split_on_lines(words, settings)
|
||||
end
|
||||
|
||||
|
||||
---@param lines rich_text.word[][]
|
||||
---@param settings rich_text.settings
|
||||
---@return rich_text.lines_metrics
|
||||
---@param lines druid.rich_text.word[][]
|
||||
---@param settings druid.rich_text.settings
|
||||
---@return druid.rich_text.lines_metrics
|
||||
function M._position_lines(lines, settings)
|
||||
local lines_metrics = M._get_lines_metrics(lines, settings)
|
||||
-- current x-y is left top point of text spawn
|
||||
@@ -352,9 +364,9 @@ function M._position_lines(lines, settings)
|
||||
end
|
||||
|
||||
|
||||
---@param lines rich_text.word[][]
|
||||
---@param settings rich_text.settings
|
||||
---@return rich_text.lines_metrics
|
||||
---@param lines druid.rich_text.word[][]
|
||||
---@param settings druid.rich_text.settings
|
||||
---@return druid.rich_text.lines_metrics
|
||||
function M._get_lines_metrics(lines, settings)
|
||||
local metrics = {}
|
||||
local text_width = 0
|
||||
@@ -386,7 +398,7 @@ function M._get_lines_metrics(lines, settings)
|
||||
}
|
||||
end
|
||||
|
||||
---@type rich_text.lines_metrics
|
||||
---@type druid.rich_text.lines_metrics
|
||||
local lines_metrics = {
|
||||
text_width = text_width,
|
||||
text_height = text_height,
|
||||
@@ -397,8 +409,8 @@ function M._get_lines_metrics(lines, settings)
|
||||
end
|
||||
|
||||
|
||||
---@param lines rich_text.word[][]
|
||||
---@param settings rich_text.settings
|
||||
---@param lines druid.rich_text.word[][]
|
||||
---@param settings druid.rich_text.settings
|
||||
function M._update_nodes(lines, settings)
|
||||
for line_index = 1, #lines do
|
||||
local line = lines[line_index]
|
||||
@@ -406,10 +418,11 @@ function M._update_nodes(lines, settings)
|
||||
local word = line[word_index]
|
||||
local node
|
||||
if word.image then
|
||||
node = word.node or gui.clone(settings.node_prefab)
|
||||
node = word.node or gui.new_box_node(VECTOR_ZERO, word.size)
|
||||
gui.set_size_mode(node, gui.SIZE_MODE_MANUAL)
|
||||
gui.play_flipbook(node, hash(word.image.anim or word.default_animation))
|
||||
gui.set_color(node, word.color or word.image_color)
|
||||
gui.set_texture(node, word.image.texture)
|
||||
gui.play_flipbook(node, hash(word.image.anim))
|
||||
gui.set_color(node, word.color or COLOR_WHITE)
|
||||
else
|
||||
node = word.node or gui.clone(settings.text_prefab)
|
||||
gui.set_outline(node, word.outline)
|
||||
@@ -421,6 +434,7 @@ function M._update_nodes(lines, settings)
|
||||
word.node = node
|
||||
gui.set_enabled(node, true)
|
||||
gui.set_parent(node, settings.parent)
|
||||
gui.set_pivot(node, word.pivot)
|
||||
gui.set_size(node, word.size)
|
||||
gui.set_scale(node, word.scale)
|
||||
gui.set_position(node, word.position)
|
||||
@@ -429,10 +443,10 @@ function M._update_nodes(lines, settings)
|
||||
end
|
||||
|
||||
|
||||
---@param words rich_text.word[]
|
||||
---@param settings rich_text.settings
|
||||
---@param words druid.rich_text.word[]
|
||||
---@param settings druid.rich_text.settings
|
||||
---@param scale number
|
||||
---@return rich_text.lines_metrics
|
||||
---@return druid.rich_text.lines_metrics
|
||||
function M.set_text_scale(words, settings, scale)
|
||||
settings.adjust_scale = scale
|
||||
|
||||
@@ -463,7 +477,7 @@ function M.adjust_to_area(words, settings, lines_metrics, style)
|
||||
if lines_metrics.text_width * scale_koef > settings.width then
|
||||
scale_koef = math.sqrt(settings.width / lines_metrics.text_width)
|
||||
end
|
||||
local adjust_scale = math.min(scale_koef, 1)
|
||||
local adjust_scale = math.min(scale_koef, settings.scale.x)
|
||||
|
||||
local lines = M.apply_scale_without_update(words, settings, adjust_scale)
|
||||
local is_fit = M.is_fit_info_area(lines, settings)
|
||||
@@ -496,15 +510,15 @@ function M.adjust_to_area(words, settings, lines_metrics, style)
|
||||
end
|
||||
|
||||
|
||||
---@return boolean @If we fit into area size
|
||||
---@return druid.rich_text.word[][] lines
|
||||
function M.apply_scale_without_update(words, settings, scale)
|
||||
settings.adjust_scale = scale
|
||||
return M._split_on_lines(words, settings)
|
||||
end
|
||||
|
||||
|
||||
---@param lines rich_text.word[][]
|
||||
---@param settings rich_text.settings
|
||||
---@param lines druid.rich_text.word[][]
|
||||
---@param settings druid.rich_text.settings
|
||||
function M.is_fit_info_area(lines, settings)
|
||||
local lines_metrics = M._get_lines_metrics(lines, settings)
|
||||
local area_size = gui.get_size(settings.parent)
|
||||
|
||||
@@ -117,6 +117,10 @@ function M.parse(text, default_settings, style)
|
||||
assert(default_settings)
|
||||
|
||||
text = text:gsub("&zwsp;", "<zwsp>\226\128\139</zwsp>")
|
||||
|
||||
-- Replace all \n with <br/> to make it easier to split the text
|
||||
text = text:gsub("\n", "<br/>")
|
||||
|
||||
local all_words = {}
|
||||
local open_tags = {}
|
||||
|
||||
@@ -145,7 +149,7 @@ function M.parse(text, default_settings, style)
|
||||
end
|
||||
|
||||
-- parse the tag, split into name and optional parameters
|
||||
local endtag, name, params, empty = tag:match("<(/?)(%a+)=?(%S-)(/?)>")
|
||||
local endtag, name, params, empty = tag:match("<(/?)([%a_]+)=?(%S-)(/?)>")
|
||||
|
||||
local is_endtag = endtag == "/"
|
||||
local is_empty = empty == "/"
|
||||
|
||||
@@ -93,11 +93,6 @@ M.register("img", function(params, settings)
|
||||
width, params = split(params, ",")
|
||||
height = split(params, ",")
|
||||
local texture, anim = split(texture_and_anim, ":")
|
||||
if not anim then
|
||||
anim = texture
|
||||
texture = nil
|
||||
end
|
||||
|
||||
width = width and tonumber(width)
|
||||
height = height and tonumber(height)
|
||||
|
||||
@@ -105,7 +100,7 @@ M.register("img", function(params, settings)
|
||||
texture = texture,
|
||||
anim = anim,
|
||||
width = width,
|
||||
height = height
|
||||
height = height or width,
|
||||
}
|
||||
end)
|
||||
|
||||
|
||||
@@ -6,31 +6,7 @@
|
||||
-- This custom component is inspired by <a href="https://github.com/britzl/defold-richtext" target="_blank">defold-richtext</a> by britzl.
|
||||
-- It uses a similar syntax for tags but currently supports fewer tags.
|
||||
--
|
||||
-- All parameters for the Rich Text component are adjusted in the GUI scene.
|
||||
--
|
||||
-- This component uses GUI component template. (/druid/custom/rich_text/rich_text.gui).
|
||||
--
|
||||
-- You able to customize it or make your own with the next node scructure:
|
||||
--
|
||||
-- root
|
||||
--
|
||||
-- - text_prefab
|
||||
--
|
||||
-- - icon_prefab
|
||||
--
|
||||
-- <b># Rich Text Setup #</b>
|
||||
--
|
||||
-- • Root node size: Set the maximum width and height of the text.
|
||||
--
|
||||
-- • Root anchor: Define the alignment of the Rich Text inside the root node size area.
|
||||
--
|
||||
-- • Text prefab: Configure all default text parameters for the text node.
|
||||
--
|
||||
-- • Text prefab anchor: Set the anchor for each text node (adjust this only if animating text).
|
||||
--
|
||||
-- • Icon prefab: Configure all default node parameters for the icon node.
|
||||
--
|
||||
-- • Icon prefab anchor: Set the anchor for each icon node (adjust this only if animating the icon).
|
||||
-- Create Rich Text on your GUI Text Node. All properties of the text node will be used as default for the text.
|
||||
--
|
||||
-- <b># Notes #</b>
|
||||
--
|
||||
@@ -58,7 +34,6 @@
|
||||
-- outline: vector4,
|
||||
-- font: string,
|
||||
-- image: druid.rich_text.image,
|
||||
-- default_animation: string,
|
||||
-- br: boolean,
|
||||
-- nobr: boolean,
|
||||
-- }
|
||||
@@ -90,37 +65,43 @@
|
||||
--- The component druid instance
|
||||
-- @tfield DruidInstance druid @{DruidInstance}
|
||||
|
||||
--- The root node of the Rich Text
|
||||
-- @tfield node root
|
||||
|
||||
--- The text prefab node
|
||||
-- @tfield node text_prefab
|
||||
|
||||
--
|
||||
|
||||
local component = require("druid.component")
|
||||
local rich_text = require("druid.custom.rich_text.module.rt")
|
||||
|
||||
local RichText = component.create("rich_text")
|
||||
|
||||
local SCHEME = {
|
||||
ROOT = "root",
|
||||
TEXT_PREFAB = "text_prefab",
|
||||
ICON_PREFAB = "icon_prefab"
|
||||
}
|
||||
|
||||
|
||||
--- Rich Text component constructor
|
||||
--- The @{RichText} constructor
|
||||
-- @tparam RichText self @{RichText}
|
||||
-- @tparam string template The Rich Text template name
|
||||
-- @tparam table nodes The node table, if prefab was copied by gui.clone_tree()
|
||||
function RichText.init(self, template, nodes)
|
||||
self:set_template(template)
|
||||
self:set_nodes(nodes)
|
||||
|
||||
self.root = self:get_node(SCHEME.ROOT)
|
||||
self.druid = self:get_druid()
|
||||
|
||||
self.text_prefab = self:get_node(SCHEME.TEXT_PREFAB)
|
||||
self.icon_prefab = self:get_node(SCHEME.ICON_PREFAB)
|
||||
|
||||
gui.set_enabled(self.text_prefab, false)
|
||||
gui.set_enabled(self.icon_prefab, false)
|
||||
-- @tparam node|string text_node The text node to make Rich Text
|
||||
-- @tparam string|nil value The initial text value. Default will be gui.get_text(text_node)
|
||||
function RichText.init(self, text_node, value)
|
||||
self.root = self:get_node(text_node)
|
||||
self.text_prefab = self.root
|
||||
|
||||
self._last_value = value or gui.get_text(self.text_prefab)
|
||||
self._settings = self:_create_settings()
|
||||
|
||||
gui.set_text(self.root, "")
|
||||
|
||||
if value then
|
||||
self:set_text(value)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function RichText.on_layout_change(self)
|
||||
if self._last_value then
|
||||
self:set_text(self._last_value)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -128,9 +109,9 @@ end
|
||||
-- You can override this component styles params in Druid styles table
|
||||
-- or create your own style
|
||||
-- @table style
|
||||
-- @tfield[opt={}] table COLORS Rich Text color aliases
|
||||
-- @tfield[opt=20] number ADJUST_STEPS Amount steps of attemps text adjust by height
|
||||
-- @tfield[opt=0.02] number ADJUST_SCALE_DELTA Scale step on each height adjust step
|
||||
-- @tfield table|nil COLORS Rich Text color aliases. Default: {}
|
||||
-- @tfield number|nil ADJUST_STEPS Amount steps of attemps text adjust by height. Default: 20
|
||||
-- @tfield number|nil ADJUST_SCALE_DELTA Scale step on each height adjust step. Default: 0.02
|
||||
function RichText.on_style_change(self, style)
|
||||
self.style = {}
|
||||
self.style.COLORS = style.COLORS or {}
|
||||
@@ -141,7 +122,7 @@ end
|
||||
|
||||
--- Set text for Rich Text
|
||||
-- @tparam RichText self @{RichText}
|
||||
-- @tparam string text The text to set
|
||||
-- @tparam string|nil text The text to set
|
||||
-- @treturn druid.rich_text.word[] words
|
||||
-- @treturn druid.rich_text.lines_metrics line_metrics
|
||||
-- @usage
|
||||
@@ -188,7 +169,9 @@ end
|
||||
-- <img=texture:image,size/>
|
||||
-- <img=texture:image,width,height/>
|
||||
function RichText.set_text(self, text)
|
||||
text = text or ""
|
||||
self:clear()
|
||||
self._last_value = text
|
||||
|
||||
local words, settings, line_metrics = rich_text.create(text, self._settings, self.style)
|
||||
line_metrics = rich_text.adjust_to_area(words, settings, line_metrics, self.style)
|
||||
@@ -200,7 +183,17 @@ function RichText.set_text(self, text)
|
||||
end
|
||||
|
||||
|
||||
--- Get current text
|
||||
-- @tparam RichText self @{RichText}
|
||||
-- @treturn string text
|
||||
function RichText.get_text(self)
|
||||
return self._last_value
|
||||
end
|
||||
|
||||
|
||||
function RichText:on_remove()
|
||||
gui.set_scale(self.root, self._default_scale)
|
||||
gui.set_size(self.root, self._default_size)
|
||||
self:clear()
|
||||
end
|
||||
|
||||
@@ -211,13 +204,15 @@ function RichText:clear()
|
||||
rich_text.remove(self._words)
|
||||
self._words = nil
|
||||
end
|
||||
self._last_value = nil
|
||||
end
|
||||
|
||||
|
||||
--- Get all words, which has a passed tag.
|
||||
-- @tparam RichText self @{RichText}
|
||||
-- @tparam string tag
|
||||
-- @treturn druid.rich_text.word[] words
|
||||
function RichText:tagged(tag)
|
||||
function RichText.tagged(self, tag)
|
||||
if not self._words then
|
||||
return
|
||||
end
|
||||
@@ -226,6 +221,15 @@ function RichText:tagged(tag)
|
||||
end
|
||||
|
||||
|
||||
---Split a word into it's characters
|
||||
-- @tparam RichText self @{RichText}
|
||||
-- @tparam druid.rich_text.word word
|
||||
-- @treturn druid.rich_text.word[] characters
|
||||
function RichText.characters(self, word)
|
||||
return rich_text.characters(word)
|
||||
end
|
||||
|
||||
|
||||
--- Get all current words.
|
||||
-- @treturn table druid.rich_text.word[]
|
||||
function RichText:get_words()
|
||||
@@ -242,29 +246,36 @@ end
|
||||
|
||||
function RichText:_create_settings()
|
||||
local root_size = gui.get_size(self.root)
|
||||
local scale = gui.get_scale(self.root)
|
||||
|
||||
self._default_size = root_size
|
||||
self._default_scale = scale
|
||||
|
||||
root_size.x = root_size.x * scale.x
|
||||
root_size.y = root_size.y * scale.y
|
||||
gui.set_size(self.root, root_size)
|
||||
gui.set_scale(self.root, vmath.vector3(1))
|
||||
|
||||
return {
|
||||
-- General settings
|
||||
-- Adjust scale using to fit the text to the root node area
|
||||
adjust_scale = 1,
|
||||
parent = self.root,
|
||||
scale = scale,
|
||||
width = root_size.x,
|
||||
height = root_size.y,
|
||||
combine_words = false, -- disabled now
|
||||
text_prefab = self.text_prefab,
|
||||
node_prefab = self.icon_prefab,
|
||||
pivot = gui.get_pivot(self.root),
|
||||
|
||||
-- Text Settings
|
||||
shadow = gui.get_shadow(self.text_prefab),
|
||||
outline = gui.get_outline(self.text_prefab),
|
||||
text_scale = gui.get_scale(self.text_prefab),
|
||||
text_leading = gui.get_leading(self.text_prefab),
|
||||
is_multiline = gui.get_line_break(self.text_prefab),
|
||||
shadow = gui.get_shadow(self.root),
|
||||
outline = gui.get_outline(self.root),
|
||||
text_leading = gui.get_leading(self.root),
|
||||
is_multiline = gui.get_line_break(self.root),
|
||||
|
||||
-- Image settings
|
||||
image_pixel_grid_snap = false, -- disabled now
|
||||
node_scale = gui.get_scale(self.icon_prefab),
|
||||
image_scale = gui.get_scale(self.icon_prefab),
|
||||
default_animation = gui.get_flipbook(self.icon_prefab),
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
22
druid/druid.atlas
Normal file
22
druid/druid.atlas
Normal file
@@ -0,0 +1,22 @@
|
||||
images {
|
||||
image: "/druid/images/empty.png"
|
||||
}
|
||||
images {
|
||||
image: "/druid/images/panels/rect_round2_width1.png"
|
||||
}
|
||||
images {
|
||||
image: "/druid/images/panels/ui_circle_8.png"
|
||||
}
|
||||
images {
|
||||
image: "/druid/images/panels/ui_circle_16.png"
|
||||
}
|
||||
images {
|
||||
image: "/druid/images/panels/ui_circle_32.png"
|
||||
}
|
||||
images {
|
||||
image: "/druid/images/panels/ui_circle_64.png"
|
||||
}
|
||||
images {
|
||||
image: "/druid/images/pixel.png"
|
||||
}
|
||||
extrude_borders: 2
|
||||
@@ -56,13 +56,18 @@ local M = {}
|
||||
|
||||
local _instances = {}
|
||||
|
||||
local function get_druid_instances()
|
||||
|
||||
local function clean_deleted_druid_instances()
|
||||
for i = #_instances, 1, -1 do
|
||||
if _instances[i]._deleted then
|
||||
table.remove(_instances, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function get_druid_instances()
|
||||
clean_deleted_druid_instances()
|
||||
return _instances
|
||||
end
|
||||
|
||||
@@ -85,6 +90,8 @@ function M.register(name, module)
|
||||
druid_instance["new_" .. name] = function(self, ...)
|
||||
return druid_instance.new(self, module, ...)
|
||||
end
|
||||
|
||||
return druid_instance["new_" .. name]
|
||||
end
|
||||
|
||||
|
||||
@@ -92,7 +99,7 @@ end
|
||||
--
|
||||
-- @function druid.new
|
||||
-- @tparam table context The Druid context. Usually, this is the self of the gui_script. It is passed into all Druid callbacks.
|
||||
-- @tparam[opt] table style The Druid style table to override style parameters for this Druid instance.
|
||||
-- @tparam table|nil style The Druid style table to override style parameters for this Druid instance.
|
||||
-- @treturn druid_instance The Druid instance @{DruidInstance}.
|
||||
-- @usage
|
||||
-- local druid = require("druid.druid")
|
||||
@@ -101,11 +108,15 @@ end
|
||||
-- self.druid = druid.new(self)
|
||||
-- end
|
||||
function M.new(context, style)
|
||||
clean_deleted_druid_instances()
|
||||
|
||||
if settings.default_style == nil then
|
||||
M.set_default_style(default_style)
|
||||
end
|
||||
|
||||
local new_instance = druid_instance(context, style)
|
||||
local new_instance = setmetatable({}, { __index = druid_instance })
|
||||
new_instance:initialize(context, style)
|
||||
|
||||
table.insert(_instances, new_instance)
|
||||
return new_instance
|
||||
end
|
||||
|
||||
@@ -1,32 +1,22 @@
|
||||
--- For component interest functions
|
||||
--- see https://github.com/Insality/druid/blob/develop/docs_md/02-creating_custom_components.md
|
||||
--- see https://github.com/Insality/druid/blob/master/docs_md/02-creating_custom_components.md
|
||||
--- Require this component in you gui file:
|
||||
--- local {COMPONENT_NAME} = require("{COMPONENT_PATH}")
|
||||
--- $ local {COMPONENT_NAME} = require("{COMPONENT_PATH}")
|
||||
--- And create this component via:
|
||||
--- self.{COMPONENT_TYPE} = self.druid:new({COMPONENT_NAME}, template, nodes)
|
||||
--- $ self.{COMPONENT_TYPE} = self.druid:new({COMPONENT_NAME}, template, nodes)
|
||||
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class {COMPONENT_TYPE}: druid.base_component{COMPONENT_ANNOTATIONS}
|
||||
---@field druid druid_instance
|
||||
local {COMPONENT_NAME} = component.create("{COMPONENT_TYPE}")
|
||||
|
||||
local SCHEME = {
|
||||
{SCHEME_LIST}
|
||||
}
|
||||
---@class {COMPONENT_TYPE}: druid.component
|
||||
---@field druid druid_instance{COMPONENT_ANNOTATIONS}
|
||||
local M = component.create("{COMPONENT_TYPE}")
|
||||
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function {COMPONENT_NAME}:init(template, nodes)
|
||||
self:set_template(template)
|
||||
self:set_nodes(nodes)
|
||||
self.druid = self:get_druid(){COMPONENT_DEFINE}
|
||||
end
|
||||
|
||||
|
||||
function {COMPONENT_NAME}:on_remove()
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes){COMPONENT_DEFINE}
|
||||
end
|
||||
|
||||
{COMPONENT_FUNCTIONS}
|
||||
return {COMPONENT_NAME}
|
||||
return M
|
||||
|
||||
@@ -28,54 +28,54 @@ def process_component(node_name, component_name):
|
||||
|
||||
if node_name == "root":
|
||||
component_annotations += "\n---@field root node"
|
||||
component_define += "\n\tself.root = self:get_node(SCHEME.ROOT)"
|
||||
component_define += "\n\tself.root = self:get_node(\"root\")"
|
||||
|
||||
if node_name.startswith("button"):
|
||||
component_annotations += "\n---@field {0} druid.button".format(node_name)
|
||||
component_functions += "\nfunction {1}:_on_{0}()\n\tprint(\"Click on {0}\")\nend\n\n".format(node_name, component_name)
|
||||
component_define += "\n\tself.{0} = self.druid:new_button(SCHEME.{1}, self._on_{0})".format(node_name, get_id(node_name))
|
||||
component_functions += "\nfunction M:_on_{0}()\n\tprint(\"Click on {0}\")\nend\n\n".format(node_name)
|
||||
component_define += "\n\tself.{0} = self.druid:new_button(\"{1}\", self._on_{0})".format(node_name, node_name)
|
||||
|
||||
if node_name.startswith("text"):
|
||||
component_annotations += "\n---@field {0} druid.text".format(node_name)
|
||||
component_define += "\n\tself.{0} = self.druid:new_text(SCHEME.{1})".format(node_name, get_id(node_name))
|
||||
component_define += "\n\tself.{0} = self.druid:new_text(\"{1}\")".format(node_name, node_name)
|
||||
|
||||
if node_name.startswith("lang_text"):
|
||||
component_annotations += "\n---@field {0} druid.text".format(node_name)
|
||||
component_define += "\n\tself.{0} = self.druid:new_lang_text(SCHEME.{1}, \"lang_id\")".format(node_name, get_id(node_name))
|
||||
component_define += "\n\tself.{0} = self.druid:new_lang_text(\"{1}\", \"lang_id\")".format(node_name, node_name)
|
||||
|
||||
if node_name.startswith("grid") or node_name.startswith("static_grid"):
|
||||
component_annotations += "\n---@field {0} druid.static_grid".format(node_name)
|
||||
component_define += "\n--TODO: Replace prefab_name with grid element prefab"
|
||||
component_define += "\n\tself.{0} = self.druid:new_static_grid(SCHEME.{1}, \"prefab_name\", 1)".format(node_name, get_id(node_name))
|
||||
component_define += "\n\tself.{0} = self.druid:new_static_grid(\"{1}\", \"prefab_name\", 1)".format(node_name, node_name)
|
||||
|
||||
if node_name.startswith("dynamic_grid"):
|
||||
component_annotations += "\n---@field {0} druid.dynamic_grid".format(node_name)
|
||||
component_define += "\n\tself.{0} = self.druid:new_dynamic_grid(SCHEME.{1})".format(node_name, get_id(node_name))
|
||||
component_define += "\n\tself.{0} = self.druid:new_dynamic_grid(\"{1}\")".format(node_name, node_name)
|
||||
|
||||
if node_name.startswith("scroll_view"):
|
||||
field_name = node_name.replace("_view", "")
|
||||
content_name = node_name.replace("_view", "_content")
|
||||
component_annotations += "\n---@field {0} druid.scroll".format(field_name)
|
||||
component_define += "\n\tself.{0} = self.druid:new_scroll(SCHEME.{1}, SCHEME.{2})".format(field_name, get_id(node_name), get_id(content_name))
|
||||
component_define += "\n\tself.{0} = self.druid:new_scroll(\"{1}\", \"{2}\")".format(field_name, node_name, content_name)
|
||||
|
||||
if node_name.startswith("blocker"):
|
||||
component_annotations += "\n---@field {0} druid.blocker".format(node_name)
|
||||
component_define += "\n\tself.{0} = self.druid:new_blocker(SCHEME.{1})".format(node_name, get_id(node_name))
|
||||
component_define += "\n\tself.{0} = self.druid:new_blocker(\"{1}\")".format(node_name, node_name)
|
||||
|
||||
if node_name.startswith("slider"):
|
||||
component_annotations += "\n---@field {0} druid.slider".format(node_name)
|
||||
component_define += "\n--TODO: Replace slider end position. It should be only vertical or horizontal"
|
||||
component_define += "\n\tself.{0} = self.druid:new_slider(SCHEME.{1}, vmath.vector3(100, 0, 0), self._on_{0}_change)".format(node_name, get_id(node_name))
|
||||
component_functions += "\nfunction {1}:_on_{0}_change(value)\n\tprint(\"Slider change:\", value)\nend\n\n".format(node_name, component_name)
|
||||
component_define += "\n\tself.{0} = self.druid:new_slider(\"{1}\", vmath.vector3(100, 0, 0), self._on_{0}_change)".format(node_name, node_name)
|
||||
component_functions += "\nfunction M:_on_{0}_change(value)\n\tprint(\"Slider change:\", value)\nend\n\n".format(node_name)
|
||||
|
||||
if node_name.startswith("progress"):
|
||||
component_annotations += "\n---@field {0} druid.progress".format(node_name)
|
||||
component_define += "\n\tself.{0} = self.druid:new_progress(SCHEME.{1}, \"x\")".format(node_name, get_id(node_name))
|
||||
component_define += "\n\tself.{0} = self.druid:new_progress(\"{1}\", \"x\")".format(node_name, get_id(node_name))
|
||||
|
||||
if node_name.startswith("timer"):
|
||||
component_annotations += "\n---@field {0} druid.timer".format(node_name)
|
||||
component_define += "\n\tself.{0} = self.druid:new_timer(SCHEME.{1}, 59, 0, self._on_{0}_end)".format(node_name, get_id(node_name))
|
||||
component_functions += "\nfunction {1}:_on_{0}_end()\n\tprint(\"Timer {0} trigger\")\nend\n\n".format(node_name, component_name)
|
||||
component_define += "\n\tself.{0} = self.druid:new_timer(\"{1}\", 59, 0, self._on_{0}_end)".format(node_name, get_id(node_name))
|
||||
component_functions += "\nfunction M:_on_{0}_end()\n\tprint(\"Timer {0} trigger\")\nend\n\n".format(node_name)
|
||||
|
||||
|
||||
def main():
|
||||
@@ -126,7 +126,7 @@ def main():
|
||||
filedata = filedata.replace("{COMPONENT_DEFINE}", component_define)
|
||||
filedata = filedata.replace("{COMPONENT_FUNCTIONS}", component_functions)
|
||||
filedata = filedata.replace("{COMPONENT_ANNOTATIONS}", component_annotations)
|
||||
filedata = filedata.replace("{SCHEME_LIST}", ",\n".join(scheme_list))
|
||||
#filedata = filedata.replace("{SCHEME_LIST}", ",\n".join(scheme_list))
|
||||
|
||||
output_file = open(output_full_path, "w")
|
||||
output_file.write(filedata)
|
||||
|
||||
@@ -26,36 +26,7 @@ end
|
||||
function M.get_commands()
|
||||
return {
|
||||
{
|
||||
label = "Print gui scheme",
|
||||
|
||||
locations = { "Outline" },
|
||||
|
||||
query = {
|
||||
selection = {type = "outline", cardinality = "many"}
|
||||
},
|
||||
|
||||
active = function(opts)
|
||||
return true
|
||||
end,
|
||||
|
||||
run = function(opts)
|
||||
print("local SCHEME = {")
|
||||
|
||||
for i = 1, #opts.selection do
|
||||
local file = opts.selection[i]
|
||||
if editor.can_get(file, "id") then
|
||||
local id = editor.get(file, "id")
|
||||
print("\t" .. string.upper(id) .. " = \"" .. id .. "\",")
|
||||
end
|
||||
end
|
||||
|
||||
print("}")
|
||||
print("")
|
||||
end
|
||||
},
|
||||
|
||||
{
|
||||
label = "Assign layers",
|
||||
label = "Assign Layers",
|
||||
|
||||
locations = {"Edit"},
|
||||
|
||||
|
||||
@@ -5,11 +5,20 @@
|
||||
echo "Run bash for $1"
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
is_defree_installed=$(pip3 list --disable-pip-version-check | grep -E "deftree")
|
||||
# Check if pip3 is installed
|
||||
if command -v pip3 &> /dev/null; then
|
||||
PIP_CMD="pip3"
|
||||
PYTHON_CMD="python3"
|
||||
else
|
||||
PIP_CMD="pip"
|
||||
PYTHON_CMD="python"
|
||||
fi
|
||||
|
||||
is_defree_installed=$($PIP_CMD list --disable-pip-version-check | grep -E "deftree")
|
||||
if [ -z "$is_defree_installed" ]; then
|
||||
echo "The python deftree is not installed. Please install it via"
|
||||
echo "pip3 install deftree"
|
||||
echo "$ $PIP_CMD install deftree"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
python3 $1 $2
|
||||
$PYTHON_CMD $1 $2
|
||||
|
||||
173
druid/event.lua
173
druid/event.lua
@@ -8,31 +8,62 @@
|
||||
-- @module DruidEvent
|
||||
-- @alias druid.event
|
||||
|
||||
local class = require("druid.system.middleclass")
|
||||
local M = {}
|
||||
M.COUNTER = 0
|
||||
|
||||
local DruidEvent = class("druid.event")
|
||||
-- Forward declaration
|
||||
local EVENT_METATABLE
|
||||
|
||||
-- Local versions
|
||||
local pcall = pcall
|
||||
local tinsert = table.insert
|
||||
local tremove = table.remove
|
||||
|
||||
--- DruidEvent constructor
|
||||
-- @tparam DruidEvent self @{DruidEvent}
|
||||
-- @tparam[opt] function initial_callback Subscribe the callback on new event, if callback exist
|
||||
-- @tparam function|nil callback Subscribe the callback on new event, if callback exist
|
||||
-- @tparam any|nil callback_context Additional context as first param to callback call
|
||||
-- @usage
|
||||
-- local Event = require("druid.event")
|
||||
-- ...
|
||||
-- local event = Event(initial_callback)
|
||||
function DruidEvent.initialize(self, initial_callback)
|
||||
self._callbacks = nil -- initialize later
|
||||
-- local event = Event(callback)
|
||||
function M.create(callback, callback_context)
|
||||
local instance = setmetatable({}, EVENT_METATABLE)
|
||||
|
||||
if initial_callback then
|
||||
self:subscribe(initial_callback)
|
||||
if callback then
|
||||
instance:subscribe(callback, callback_context)
|
||||
end
|
||||
|
||||
M.COUNTER = M.COUNTER + 1
|
||||
return instance
|
||||
end
|
||||
|
||||
|
||||
--- Check is event subscribed.
|
||||
-- @tparam DruidEvent self @{DruidEvent}
|
||||
-- @tparam function callback Callback itself
|
||||
-- @tparam any|nil callback_context Additional context as first param to callback call
|
||||
-- @treturn boolean, number|nil @Is event subscribed, return index of callback in event as second param
|
||||
function M.is_subscribed(self, callback, callback_context)
|
||||
if #self == 0 then
|
||||
return false, nil
|
||||
end
|
||||
|
||||
for index = 1, #self do
|
||||
local cb = self[index]
|
||||
if cb[1] == callback and cb[2] == callback_context then
|
||||
return true, index
|
||||
end
|
||||
end
|
||||
|
||||
return false, nil
|
||||
end
|
||||
|
||||
|
||||
--- Subscribe callback on event
|
||||
-- @tparam DruidEvent self @{DruidEvent}
|
||||
-- @tparam function callback Callback itself
|
||||
-- @tparam[opt] Any context Additional context as first param to callback call, usually it's self
|
||||
-- @tparam any|nil callback_context Additional context as first param to callback call, usually it's self
|
||||
-- @treturn boolean True if callback was subscribed
|
||||
-- @usage
|
||||
-- local function on_long_callback(self)
|
||||
-- print("Long click!")
|
||||
@@ -40,54 +71,59 @@ end
|
||||
-- ...
|
||||
-- local button = self.druid:new_button("button", callback)
|
||||
-- button.on_long_click:subscribe(on_long_callback, self)
|
||||
function DruidEvent.subscribe(self, callback, context)
|
||||
function M.subscribe(self, callback, callback_context)
|
||||
assert(type(self) == "table", "You should subscribe to event with : syntax")
|
||||
assert(type(callback) == "function", "Callback should be function")
|
||||
assert(callback, "A function must be passed to subscribe to an event")
|
||||
|
||||
self._callbacks = self._callbacks or {}
|
||||
table.insert(self._callbacks, {
|
||||
callback = callback,
|
||||
context = context
|
||||
})
|
||||
if self:is_subscribed(callback, callback_context) then
|
||||
return false
|
||||
end
|
||||
|
||||
return callback
|
||||
tinsert(self, { callback, callback_context })
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
--- Unsubscribe callback on event
|
||||
-- @tparam DruidEvent self @{DruidEvent}
|
||||
-- @tparam function callback Callback itself
|
||||
-- @tparam[opt] Any context Additional context as first param to callback call
|
||||
-- @tparam any|nil callback_context 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)
|
||||
function DruidEvent.unsubscribe(self, callback, context)
|
||||
if not self._callbacks then
|
||||
return
|
||||
function M.unsubscribe(self, callback, callback_context)
|
||||
assert(callback, "A function must be passed to subscribe to an event")
|
||||
|
||||
local _, event_index = self:is_subscribed(callback, callback_context)
|
||||
if not event_index then
|
||||
return false
|
||||
end
|
||||
|
||||
for index, callback_info in ipairs(self._callbacks) do
|
||||
if callback_info.callback == callback and callback_info.context == context then
|
||||
table.remove(self._callbacks, index)
|
||||
return
|
||||
end
|
||||
end
|
||||
tremove(self, event_index)
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
--- Return true, if event have at lease one handler
|
||||
-- @tparam DruidEvent self @{DruidEvent}
|
||||
-- @treturn bool True if event have handlers
|
||||
-- @treturn boolean True if event have handlers
|
||||
-- @usage
|
||||
-- local is_long_click_handler_exists = button.on_long_click:is_exist()
|
||||
function DruidEvent.is_exist(self)
|
||||
if not self._callbacks then
|
||||
return false
|
||||
end
|
||||
return #self._callbacks > 0
|
||||
function M.is_exist(self)
|
||||
return #self > 0
|
||||
end
|
||||
|
||||
|
||||
--- Return true, if event not have handler
|
||||
--- @tparam DruidEvent self @{DruidEvent}
|
||||
--- @treturn boolean True if event not have handlers
|
||||
--- @usage
|
||||
--- local is_long_click_handler_not_exists = button.on_long_click:is_empty()
|
||||
function M:is_empty()
|
||||
return #self == 0
|
||||
end
|
||||
|
||||
|
||||
@@ -95,32 +131,75 @@ end
|
||||
-- @tparam DruidEvent self @{DruidEvent}
|
||||
-- @usage
|
||||
-- button.on_long_click:clear()
|
||||
function DruidEvent.clear(self)
|
||||
self._callbacks = nil
|
||||
function M.clear(self)
|
||||
for index = #self, 1, -1 do
|
||||
self[index] = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Trigger the event and call all subscribed callbacks
|
||||
-- @tparam DruidEvent self @{DruidEvent}
|
||||
-- @tparam Any ... All event params
|
||||
-- @tparam any ... All event params
|
||||
-- @usage
|
||||
-- local Event = require("druid.event")
|
||||
-- ...
|
||||
-- local event = Event()
|
||||
-- event:trigger("Param1", "Param2")
|
||||
function DruidEvent.trigger(self, ...)
|
||||
if not self._callbacks then
|
||||
return false
|
||||
function M.trigger(self, ...)
|
||||
if #self == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
for _, callback_info in ipairs(self._callbacks) do
|
||||
if callback_info.context then
|
||||
callback_info.callback(callback_info.context, ...)
|
||||
else
|
||||
callback_info.callback(...)
|
||||
end
|
||||
local result = nil
|
||||
|
||||
local call_callback = self.call_callback
|
||||
for index = 1, #self do
|
||||
result = call_callback(self, self[index], ...)
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
return DruidEvent
|
||||
-- @tparam table callback Callback data {function, context}
|
||||
-- @tparam any ... All event params
|
||||
-- @treturn any Result of the callback
|
||||
-- @local
|
||||
function M:call_callback(callback, ...)
|
||||
local event_callback = callback[1]
|
||||
local event_callback_context = callback[2]
|
||||
|
||||
-- Call callback
|
||||
local ok, result_or_error
|
||||
if event_callback_context then
|
||||
ok, result_or_error = pcall(event_callback, event_callback_context, ...)
|
||||
else
|
||||
ok, result_or_error = pcall(event_callback, ...)
|
||||
end
|
||||
|
||||
-- Handle errors
|
||||
if not ok then
|
||||
local caller_info = debug.getinfo(2)
|
||||
pprint("An error occurred during event processing", {
|
||||
trigger = caller_info.short_src .. ":" .. caller_info.currentline,
|
||||
error = result_or_error,
|
||||
})
|
||||
pprint("Traceback", debug.traceback())
|
||||
return nil
|
||||
end
|
||||
|
||||
return result_or_error
|
||||
end
|
||||
|
||||
-- Construct event metatable
|
||||
EVENT_METATABLE = {
|
||||
__index = M,
|
||||
__call = M.trigger,
|
||||
}
|
||||
|
||||
return setmetatable(M, {
|
||||
__call = function(_, callback)
|
||||
return M.create(callback)
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
-- Copyright (c) 2021 Maksim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
|
||||
|
||||
--- Druid checkbox component
|
||||
--
|
||||
-- <a href="https://insality.github.io/druid/druid/index.html?example=general_checkboxes" target="_blank"><b>Example Link</b></a>
|
||||
-- @module Checkbox
|
||||
-- @within BaseComponent
|
||||
-- @alias druid.checkbox
|
||||
|
||||
--- On change state callback(self, state)
|
||||
-- @tfield DruidEvent on_change_state @{DruidEvent}
|
||||
|
||||
--- Visual node
|
||||
-- @tfield node node
|
||||
|
||||
--- Button trigger node
|
||||
-- @tfield[opt=node] node click_node
|
||||
|
||||
--- Button component from click_node
|
||||
-- @tfield Button button @{Button}
|
||||
|
||||
---
|
||||
|
||||
local Event = require("druid.event")
|
||||
local component = require("druid.component")
|
||||
|
||||
local Checkbox = component.create("checkbox")
|
||||
|
||||
|
||||
local function on_click(self)
|
||||
self:set_state(not self.state)
|
||||
end
|
||||
|
||||
|
||||
--- Component style params.
|
||||
-- You can override this component styles params in druid styles table
|
||||
-- or create your own style
|
||||
-- @table style
|
||||
-- @tfield function on_change_state (self, node, state)
|
||||
function Checkbox.on_style_change(self, style)
|
||||
self.style = {}
|
||||
|
||||
self.style.on_change_state = style.on_change_state or function(_, node, state)
|
||||
gui.set_enabled(node, state)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Component init function
|
||||
-- @tparam Checkbox self @{Checkbox}
|
||||
-- @tparam node node Gui node
|
||||
-- @tparam function callback Checkbox callback
|
||||
-- @tparam[opt=node] node click_node Trigger node, by default equals to node
|
||||
-- @tparam[opt=false] boolean initial_state The initial state of checkbox, default - false
|
||||
function Checkbox.init(self, node, callback, click_node, initial_state)
|
||||
self.druid = self:get_druid()
|
||||
self.node = self:get_node(node)
|
||||
self.click_node = self:get_node(click_node or node)
|
||||
|
||||
self.button = self.druid:new_button(self.click_node or self.node, on_click)
|
||||
self:set_state(initial_state, true, true)
|
||||
|
||||
self.on_change_state = Event(callback)
|
||||
end
|
||||
|
||||
|
||||
function Checkbox.on_layout_change(self)
|
||||
self:set_state(self.state, true)
|
||||
end
|
||||
|
||||
|
||||
--- Set checkbox state
|
||||
-- @tparam Checkbox self @{Checkbox}
|
||||
-- @tparam bool state Checkbox state
|
||||
-- @tparam bool is_silent Don't trigger on_change_state if true
|
||||
-- @tparam bool is_instant If instant checkbox change
|
||||
function Checkbox.set_state(self, state, is_silent, is_instant)
|
||||
self.state = state
|
||||
self.style.on_change_state(self, self.node, state, is_instant)
|
||||
|
||||
if not is_silent then
|
||||
self.on_change_state:trigger(self:get_context(), state)
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Return checkbox state
|
||||
-- @tparam Checkbox self @{Checkbox}
|
||||
-- @treturn bool Checkbox state
|
||||
function Checkbox.get_state(self)
|
||||
return self.state
|
||||
end
|
||||
|
||||
|
||||
return Checkbox
|
||||
@@ -1,73 +0,0 @@
|
||||
-- Copyright (c) 2021 Maksim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
|
||||
|
||||
--- Checkbox group module
|
||||
--
|
||||
-- <a href="https://insality.github.io/druid/druid/index.html?example=general_checkboxes" target="_blank"><b>Example Link</b></a>
|
||||
-- @module CheckboxGroup
|
||||
-- @within BaseComponent
|
||||
-- @alias druid.checkbox_group
|
||||
|
||||
--- On any checkbox click callback(self, index)
|
||||
-- @tfield DruidEvent on_checkbox_click @{DruidEvent}
|
||||
|
||||
--- Array of checkbox components
|
||||
-- @tfield table checkboxes @{Checkbox}
|
||||
|
||||
---
|
||||
|
||||
local Event = require("druid.event")
|
||||
local component = require("druid.component")
|
||||
|
||||
local CheckboxGroup = component.create("checkbox_group")
|
||||
|
||||
|
||||
--- Component init function
|
||||
-- @tparam CheckboxGroup self @{CheckboxGroup}
|
||||
-- @tparam node[] nodes Array of gui node
|
||||
-- @tparam function callback Checkbox callback
|
||||
-- @tparam[opt=node] node[] click_nodes Array of trigger nodes, by default equals to nodes
|
||||
function CheckboxGroup.init(self, nodes, callback, click_nodes)
|
||||
self.druid = self:get_druid()
|
||||
self.checkboxes = {}
|
||||
|
||||
self.on_checkbox_click = Event(callback)
|
||||
|
||||
for i = 1, #nodes do
|
||||
local click_node = click_nodes and click_nodes[i] or nil
|
||||
local checkbox = self.druid:new_checkbox(nodes[i], function()
|
||||
self.on_checkbox_click:trigger(self:get_context(), i)
|
||||
end, click_node)
|
||||
|
||||
table.insert(self.checkboxes, checkbox)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Set checkbox group state
|
||||
-- @tparam CheckboxGroup self @{CheckboxGroup}
|
||||
-- @tparam bool[] indexes Array of checkbox state
|
||||
-- @tparam boolean is_instant If instant state change
|
||||
function CheckboxGroup.set_state(self, indexes, is_instant)
|
||||
for i = 1, #indexes do
|
||||
if self.checkboxes[i] then
|
||||
self.checkboxes[i]:set_state(indexes[i], true, is_instant)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Return checkbox group state
|
||||
-- @tparam CheckboxGroup self @{CheckboxGroup}
|
||||
-- @treturn bool[] Array if checkboxes state
|
||||
function CheckboxGroup.get_state(self)
|
||||
local result = {}
|
||||
|
||||
for i = 1, #self.checkboxes do
|
||||
table.insert(result, self.checkboxes[i]:get_state())
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
return CheckboxGroup
|
||||
@@ -13,17 +13,17 @@
|
||||
-- @tfield Scroll scroll @{Scroll}
|
||||
|
||||
--- The Druid Grid component
|
||||
-- @tfield StaticGrid|DynamicGrid grid @{StaticGrid}, @{DynamicGrid}
|
||||
|
||||
--- The current visual top data index
|
||||
-- @tfield number top_index
|
||||
|
||||
--- The current visual last data index
|
||||
-- @tfield number last_index
|
||||
-- @tfield StaticGrid grid @{StaticGrid}, @{DynamicGrid}
|
||||
|
||||
--- The current progress of scroll posititon
|
||||
-- @tfield number scroll_progress
|
||||
|
||||
--- The current top index of visual elements
|
||||
-- @tfield number top_index
|
||||
|
||||
--- The current last index of visual elements
|
||||
-- @tfield number last_index
|
||||
|
||||
--- Event triggered when scroll progress is changed; event(self, progress_value)
|
||||
-- @tfield DruidEvent on_scroll_progress_change @{DruidEvent}
|
||||
|
||||
@@ -43,19 +43,17 @@ local Event = require("druid.event")
|
||||
local DataList = component.create("data_list")
|
||||
|
||||
|
||||
--- Data list constructor
|
||||
--- The @{DataList} constructor
|
||||
-- @tparam DataList self @{DataList}
|
||||
-- @tparam Scroll scroll The @{Scroll} instance for Data List component
|
||||
-- @tparam StaticGrid|DynamicGrid grid The @{StaticGrid} or @{DynamicGrid} instance for Data List component
|
||||
-- @tparam StaticGrid grid The @{StaticGrid} or @{DynamicGrid} instance for Data List component
|
||||
-- @tparam function create_function The create function callback(self, data, index, data_list). Function should return (node, [component])
|
||||
function DataList.init(self, scroll, grid, create_function)
|
||||
self.druid = self:get_druid()
|
||||
self.scroll = scroll
|
||||
self.grid = grid
|
||||
if self.grid.style then
|
||||
self.grid.style.IS_DYNAMIC_NODE_POSES = false
|
||||
end
|
||||
self.scroll:bind_grid(grid)
|
||||
|
||||
-- Current visual elements indexes
|
||||
self.top_index = 1
|
||||
@@ -63,26 +61,34 @@ function DataList.init(self, scroll, grid, create_function)
|
||||
self.scroll_progress = 0
|
||||
|
||||
self._create_function = create_function
|
||||
self._is_use_cache = false
|
||||
self._cache = {}
|
||||
self._data = {}
|
||||
self._data_first_index = false
|
||||
self._data_last_index = false
|
||||
self._data_length = 0
|
||||
self._data_visual = {}
|
||||
|
||||
self.scroll.on_scroll:subscribe(self._check_elements, self)
|
||||
self.scroll.on_scroll:subscribe(self._refresh, self)
|
||||
|
||||
self.on_scroll_progress_change = Event()
|
||||
self.on_element_add = Event()
|
||||
self.on_element_remove = Event()
|
||||
|
||||
self:set_data()
|
||||
end
|
||||
|
||||
|
||||
--- Druid System on_remove function
|
||||
-- @tparam DataList self @{DataList}
|
||||
function DataList.on_remove(self)
|
||||
self.scroll.on_scroll:unsubscribe(self._check_elements, self)
|
||||
self:clear()
|
||||
self.scroll.on_scroll:unsubscribe(self._refresh, self)
|
||||
end
|
||||
|
||||
|
||||
--- Set refresh function for DataList component
|
||||
-- @tparam DataList self @{DataList}
|
||||
-- @tparam boolean is_use_cache Use cache version of DataList. Requires make setup of components in on_element_add callback and clean in on_element_remove
|
||||
-- @treturn druid.data_list Current DataList instance
|
||||
function DataList.set_use_cache(self, is_use_cache)
|
||||
self._is_use_cache = is_use_cache
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
@@ -92,7 +98,6 @@ end
|
||||
-- @treturn druid.data_list Current DataList instance
|
||||
function DataList.set_data(self, data)
|
||||
self._data = data or {}
|
||||
self:_update_data_info()
|
||||
self:_refresh()
|
||||
|
||||
return self
|
||||
@@ -110,42 +115,35 @@ end
|
||||
--- Add element to DataList. Currenly untested
|
||||
-- @tparam DataList self @{DataList}
|
||||
-- @tparam table data
|
||||
-- @tparam number index
|
||||
-- @tparam number shift_policy The constant from const.SHIFT.*
|
||||
-- @local
|
||||
-- @tparam number|nil index
|
||||
-- @tparam number|nil shift_policy The constant from const.SHIFT.*
|
||||
function DataList.add(self, data, index, shift_policy)
|
||||
index = index or self._data_last_index + 1
|
||||
index = index or #self._data + 1
|
||||
shift_policy = shift_policy or const.SHIFT.RIGHT
|
||||
|
||||
helper.insert_with_shift(self._data, data, index, shift_policy)
|
||||
self:_update_data_info()
|
||||
self:_check_elements()
|
||||
self:_refresh()
|
||||
end
|
||||
|
||||
|
||||
--- Remove element from DataList. Currenly untested
|
||||
-- @tparam DataList self @{DataList}
|
||||
-- @tparam number index
|
||||
-- @tparam number shift_policy The constant from const.SHIFT.*
|
||||
-- @local
|
||||
-- @tparam number|nil index
|
||||
-- @tparam number|nil shift_policy The constant from const.SHIFT.*
|
||||
function DataList.remove(self, index, shift_policy)
|
||||
--self:_refresh()
|
||||
|
||||
helper.remove_with_shift(self._data, index, shift_policy)
|
||||
self:_update_data_info()
|
||||
self:_refresh()
|
||||
end
|
||||
|
||||
|
||||
--- Remove element from DataList by data value. Currenly untested
|
||||
-- @tparam DataList self @{DataList}
|
||||
-- @tparam tabe data
|
||||
-- @tparam number shift_policy The constant from const.SHIFT.*
|
||||
-- @local
|
||||
-- @tparam table data
|
||||
-- @tparam number|nil shift_policy The constant from const.SHIFT.*
|
||||
function DataList.remove_by_data(self, data, shift_policy)
|
||||
local index = helper.contains(self._data, data)
|
||||
if index then
|
||||
helper.remove_with_shift(self._data, index, shift_policy)
|
||||
self:_update_data_info()
|
||||
self:_refresh()
|
||||
end
|
||||
end
|
||||
@@ -155,32 +153,10 @@ end
|
||||
-- @tparam DataList self @{DataList}
|
||||
function DataList.clear(self)
|
||||
self._data = {}
|
||||
self:_update_data_info()
|
||||
self:_refresh()
|
||||
end
|
||||
|
||||
|
||||
--- Return first index from data. It not always equals to 1
|
||||
-- @tparam DataList self @{DataList}
|
||||
function DataList.get_first_index(self)
|
||||
return self._data_first_index
|
||||
end
|
||||
|
||||
|
||||
--- Return last index from data
|
||||
-- @tparam DataList self @{DataList}
|
||||
function DataList.get_last_index(self)
|
||||
return self._data_last_index
|
||||
end
|
||||
|
||||
|
||||
--- Return amount of data
|
||||
-- @tparam DataList self @{DataList}
|
||||
function DataList.get_length(self)
|
||||
return self._data_length
|
||||
end
|
||||
|
||||
|
||||
--- Return index for data value
|
||||
-- @tparam DataList self @{DataList}
|
||||
-- @tparam table data
|
||||
@@ -197,7 +173,7 @@ end
|
||||
|
||||
--- Return all currenly created nodes in DataList
|
||||
-- @tparam DataList self @{DataList}
|
||||
-- @treturn Node[] List of created nodes
|
||||
-- @treturn node[] List of created nodes
|
||||
function DataList.get_created_nodes(self)
|
||||
local nodes = {}
|
||||
|
||||
@@ -227,17 +203,12 @@ end
|
||||
-- @tparam DataList self @{DataList}
|
||||
-- @tparam number index
|
||||
function DataList.scroll_to_index(self, index)
|
||||
local target = helper.clamp(index, self:get_first_index(), self:get_last_index())
|
||||
self.top_index = target
|
||||
self:_refresh()
|
||||
|
||||
if self._data_visual[target] then
|
||||
self.scroll:scroll_to(gui.get_position(self._data_visual[target].node), true)
|
||||
end
|
||||
local pos = self.grid:get_pos(index)
|
||||
self.scroll:scroll_to(pos)
|
||||
end
|
||||
|
||||
|
||||
--- Add element at passed index
|
||||
--- Add element at passed index using cache or create new
|
||||
-- @tparam DataList self @{DataList}
|
||||
-- @tparam number index
|
||||
-- @local
|
||||
@@ -246,137 +217,98 @@ function DataList._add_at(self, index)
|
||||
self:_remove_at(index)
|
||||
end
|
||||
|
||||
local node, instance = self._create_function(self:get_context(), self._data[index], index, self)
|
||||
self.grid:add(node, index, const.SHIFT.NO_SHIFT)
|
||||
self._data_visual[index] = {
|
||||
node = node,
|
||||
component = instance
|
||||
}
|
||||
local data = self._data[index]
|
||||
local node, instance
|
||||
|
||||
self.on_element_add:trigger(self:get_context(), index, node, instance)
|
||||
-- Use cache if available and is_use_cache is set
|
||||
if #self._cache > 0 and self._is_use_cache then
|
||||
local cached = table.remove(self._cache)
|
||||
node = cached.node
|
||||
instance = cached.component
|
||||
gui.set_enabled(node, true)
|
||||
else
|
||||
-- Create a new element if no cache or refresh function is not set
|
||||
node, instance = self._create_function(self:get_context(), data, index, self)
|
||||
end
|
||||
|
||||
self._data_visual[index] = {
|
||||
data = data,
|
||||
node = node,
|
||||
component = instance,
|
||||
}
|
||||
self.grid:add(node, index, const.SHIFT.NO_SHIFT)
|
||||
|
||||
self.on_element_add:trigger(self:get_context(), index, node, instance, data)
|
||||
end
|
||||
|
||||
|
||||
--- Remove element from passed index
|
||||
--- Remove element from passed index and add it to cache if applicable
|
||||
-- @tparam DataList self @{DataList}
|
||||
-- @tparam number index
|
||||
-- @local
|
||||
function DataList._remove_at(self, index)
|
||||
self.grid:remove(index, const.SHIFT.NO_SHIFT)
|
||||
|
||||
local node = self._data_visual[index].node
|
||||
gui.delete_node(node)
|
||||
local visual_data = self._data_visual[index]
|
||||
local node = visual_data.node
|
||||
local instance = visual_data.component
|
||||
local data = visual_data.data
|
||||
|
||||
local instance = self._data_visual[index].component
|
||||
if instance then
|
||||
self.druid:remove(instance)
|
||||
self.on_element_remove:trigger(self:get_context(), index, node, instance, data)
|
||||
|
||||
if self._is_use_cache then
|
||||
-- Disable the node and add it to the cache instead of deleting it
|
||||
gui.set_enabled(node, false)
|
||||
table.insert(self._cache, visual_data) -- Cache the removed element
|
||||
else
|
||||
-- If no refresh function, delete the node and component as usual
|
||||
gui.delete_node(node)
|
||||
if instance then
|
||||
instance._meta.druid:remove(instance)
|
||||
end
|
||||
end
|
||||
self._data_visual[index] = nil
|
||||
|
||||
self.on_element_remove:trigger(self:get_context(), index)
|
||||
self._data_visual[index] = nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
--- Refresh all elements in DataList
|
||||
-- @tparam DataList self @{DataList}
|
||||
-- @local
|
||||
function DataList._refresh(self)
|
||||
for index, _ in pairs(self._data_visual) do
|
||||
self:_remove_at(index)
|
||||
end
|
||||
self:_check_elements()
|
||||
end
|
||||
self.scroll:set_size(self.grid:get_size_for(#self._data))
|
||||
|
||||
local start_pos = -self.scroll.position --[[@as vector3]]
|
||||
local start_index = self.grid:get_index(start_pos)
|
||||
start_index = math.max(1, start_index)
|
||||
|
||||
--- Check elements which should be created
|
||||
-- @tparam DataList self @{DataList}
|
||||
-- @local
|
||||
function DataList._check_elements(self)
|
||||
local pivot = helper.get_pivot_offset(gui.get_pivot(self.scroll.view_node))
|
||||
local offset_x = self.scroll.view_size.x * (0.5 - pivot.x)
|
||||
local offset_y = self.scroll.view_size.y * (0.5 + pivot.y)
|
||||
local end_pos = vmath.vector3(start_pos.x + offset_x, start_pos.y - offset_y, 0)
|
||||
local end_index = self.grid:get_index(end_pos)
|
||||
end_index = math.min(#self._data, end_index)
|
||||
|
||||
self.top_index = start_index
|
||||
self.last_index = end_index
|
||||
|
||||
-- Clear from non range elements
|
||||
for index, data in pairs(self._data_visual) do
|
||||
if self.scroll:is_node_in_view(data.node) then
|
||||
self.top_index = index
|
||||
self.last_index = index
|
||||
if index < start_index or index > end_index then
|
||||
self:_remove_at(index)
|
||||
elseif self._data[index] ~= data.data then
|
||||
-- TODO We want to find currently created data instances and move them to new positions
|
||||
-- Now it will re-create them
|
||||
self:_remove_at(index)
|
||||
end
|
||||
end
|
||||
|
||||
self:_check_elements_from(self.top_index, -1)
|
||||
self:_check_elements_from(self.top_index + 1, 1)
|
||||
|
||||
for index, data in pairs(self._data_visual) do
|
||||
self.top_index = math.min(self.top_index or index, index)
|
||||
self.last_index = math.max(self.last_index or index, index)
|
||||
end
|
||||
|
||||
-- Progress report
|
||||
local middle_index = (self.last_index + self.top_index) / 2
|
||||
local progress = (middle_index - self._data_first_index) / (self._data_last_index - self._data_first_index)
|
||||
progress = helper.clamp(progress, 0, 1)
|
||||
if self.last_index == self:get_last_index() then
|
||||
progress = 1
|
||||
end
|
||||
if self.top_index == self:get_first_index() then
|
||||
progress = 0
|
||||
end
|
||||
|
||||
if self.scroll_progress ~= progress then
|
||||
self.scroll_progress = progress
|
||||
self.on_scroll_progress_change:trigger(self:get_context(), progress)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Check elements which should be created.
|
||||
-- Start from index with step until element is outside of scroll view
|
||||
-- @tparam DataList self @{DataList}
|
||||
-- @tparam number index
|
||||
-- @tparam number step
|
||||
-- @local
|
||||
function DataList._check_elements_from(self, index, step)
|
||||
local is_outside = false
|
||||
while not is_outside do
|
||||
if not self._data[index] then
|
||||
break
|
||||
end
|
||||
|
||||
if not self._data_visual[index] then
|
||||
-- Add new elements
|
||||
for index = start_index, end_index do
|
||||
if not self._data_visual[index] and self._data[index] then
|
||||
self:_add_at(index)
|
||||
end
|
||||
|
||||
if not self.scroll:is_node_in_view(self._data_visual[index].node) then
|
||||
is_outside = true
|
||||
|
||||
-- remove nexts:
|
||||
-- We add one more element, which is not in view to
|
||||
-- check what it's always outside to stop spawning
|
||||
local remove_index = index + step
|
||||
while self._data_visual[remove_index] do
|
||||
self:_remove_at(remove_index)
|
||||
remove_index = remove_index + step
|
||||
end
|
||||
end
|
||||
|
||||
index = index + step
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Update actual data params
|
||||
-- @tparam DataList self @{DataList}
|
||||
-- @local
|
||||
function DataList._update_data_info(self)
|
||||
self._data_first_index = false
|
||||
self._data_last_index = false
|
||||
self._data_length = 0
|
||||
|
||||
for index, data in pairs(self._data) do
|
||||
self._data_first_index = math.min(self._data_first_index or index, index)
|
||||
self._data_last_index = math.max(self._data_last_index or index, index)
|
||||
self._data_length = self._data_length + 1
|
||||
end
|
||||
|
||||
if self._data_length == 0 then
|
||||
self._data_first_index = 0
|
||||
self._data_last_index = 0
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ local AVAILABLE_PIVOTS = {
|
||||
}
|
||||
|
||||
|
||||
--- Component init function
|
||||
--- The @{DynamicGrid} constructor
|
||||
-- @tparam DynamicGrid self @{DynamicGrid}
|
||||
-- @tparam node parent The gui node parent, where items will be placed
|
||||
function DynamicGrid.init(self, parent)
|
||||
@@ -100,8 +100,8 @@ end
|
||||
-- @tparam DynamicGrid self @{DynamicGrid}
|
||||
-- @tparam number index The grid element index
|
||||
-- @tparam node node The node to be placed
|
||||
-- @tparam[opt] number origin_index Index of nearby node
|
||||
-- @treturn vector3 Node position
|
||||
-- @tparam number|nil origin_index Index of nearby node
|
||||
-- @treturn vector3 node position
|
||||
function DynamicGrid.get_pos(self, index, node, origin_index)
|
||||
local origin_node = self.nodes[origin_index]
|
||||
|
||||
@@ -140,9 +140,9 @@ end
|
||||
--- Add new node to the grid
|
||||
-- @tparam DynamicGrid self @{DynamicGrid}
|
||||
-- @tparam node node Gui node
|
||||
-- @tparam[opt] number index The node position. By default add as last node
|
||||
-- @tparam[opt=SHIFT.RIGHT] number shift_policy How shift nodes, if required. See const.SHIFT
|
||||
-- @tparam[opt=false] boolean is_instant If true, update node positions instantly
|
||||
-- @tparam number|nil index The node position. By default add as last node
|
||||
-- @tparam number|nil shift_policy How shift nodes, if required. Default: const.SHIFT.RIGHT
|
||||
-- @tparam boolean|nil is_instant If true, update node positions instantly
|
||||
function DynamicGrid.add(self, node, index, shift_policy, is_instant)
|
||||
shift_policy = shift_policy or const.SHIFT.RIGHT
|
||||
local delta = shift_policy -- -1 or 1 or 0
|
||||
@@ -183,8 +183,8 @@ end
|
||||
--- Remove the item from the grid. Note that gui node will be not deleted
|
||||
-- @tparam DynamicGrid self @{DynamicGrid}
|
||||
-- @tparam number index The grid node index to remove
|
||||
-- @tparam[opt=SHIFT.RIGHT] number shift_policy How shift nodes, if required. See const.SHIFT
|
||||
-- @tparam[opt=false] boolean is_instant If true, update node positions instantly
|
||||
-- @tparam number|nil shift_policy How shift nodes, if required. Default: const.SHIFT.RIGHT
|
||||
-- @tparam boolean|nil is_instant If true, update node positions instantly
|
||||
-- @treturn node The deleted gui node from grid
|
||||
function DynamicGrid.remove(self, index, shift_policy, is_instant)
|
||||
shift_policy = shift_policy or const.SHIFT.RIGHT
|
||||
@@ -274,7 +274,7 @@ end
|
||||
function DynamicGrid.get_all_pos(self)
|
||||
local result = {}
|
||||
for i, node in pairs(self.nodes) do
|
||||
table.insert(result, gui.get_position(node))
|
||||
table.insert(result, gui.get_position(node.node))
|
||||
end
|
||||
|
||||
return result
|
||||
@@ -322,7 +322,7 @@ end
|
||||
|
||||
--- Update grid inner state
|
||||
-- @tparam DynamicGrid self @{DynamicGrid}
|
||||
-- @tparam bool is_instant If true, node position update instantly, otherwise with set_position_function callback
|
||||
-- @tparam boolean|nil is_instant If true, node position update instantly, otherwise with set_position_function callback
|
||||
-- @local
|
||||
function DynamicGrid._update(self, is_instant)
|
||||
self:_update_indexes()
|
||||
@@ -378,7 +378,7 @@ end
|
||||
|
||||
--- Update grid nodes position
|
||||
-- @tparam DynamicGrid self @{DynamicGrid}
|
||||
-- @tparam bool is_instant If true, node position update instantly, otherwise with set_position_function callback
|
||||
-- @tparam boolean|nil is_instant If true, node position update instantly, otherwise with set_position_function callback
|
||||
-- @local
|
||||
function DynamicGrid._update_pos(self, is_instant)
|
||||
for index, node in pairs(self.nodes) do
|
||||
|
||||
@@ -7,14 +7,17 @@
|
||||
-- @within BaseComponent
|
||||
-- @alias druid.hotkey
|
||||
|
||||
--- On change state callback(self, state)
|
||||
-- @tfield DruidEvent on_change_state @{DruidEvent}
|
||||
--- On hotkey released callback(self, argument)
|
||||
-- @tfield DruidEvent on_hotkey_pressed @{DruidEvent}
|
||||
|
||||
--- On hotkey released callback(self, argument)
|
||||
-- @tfield DruidEvent on_hotkey_released @{DruidEvent}
|
||||
|
||||
--- Visual node
|
||||
-- @tfield node node
|
||||
|
||||
--- Button trigger node
|
||||
-- @tfield[opt=node] node click_node
|
||||
-- @tfield node|nil click_node
|
||||
|
||||
--- Button component from click_node
|
||||
-- @tfield Button button @{Button}
|
||||
@@ -23,21 +26,24 @@
|
||||
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
local Event = require("druid.event")
|
||||
|
||||
local Hotkey = component.create("hotkey")
|
||||
|
||||
|
||||
--- Component init function
|
||||
--- The @{Hotkey} constructor
|
||||
-- @tparam Hotkey self @{Hotkey}
|
||||
-- @tparam string[]|string keys The keys to be pressed for trigger callback. Should contains one key and any modificator keys
|
||||
-- @tparam function callback The callback function
|
||||
-- @tparam[opt] value callback_argument The argument to pass into the callback function
|
||||
-- @tparam any|nil callback_argument The argument to pass into the callback function
|
||||
function Hotkey.init(self, keys, callback, callback_argument)
|
||||
self.druid = self:get_druid()
|
||||
|
||||
self._hotkeys = {}
|
||||
self._modificators = {}
|
||||
self._callback = callback
|
||||
|
||||
self.on_hotkey_pressed = Event()
|
||||
self.on_hotkey_released = Event(callback)
|
||||
|
||||
if keys then
|
||||
self:add_hotkey(keys, callback_argument)
|
||||
@@ -63,7 +69,8 @@ end
|
||||
--- Add hotkey for component callback
|
||||
-- @tparam Hotkey self @{Hotkey}
|
||||
-- @tparam string[]|hash[]|string|hash keys that have to be pressed before key pressed to activate
|
||||
-- @tparam[opt] value callback_argument The argument to pass into the callback function
|
||||
-- @tparam any|nil callback_argument The argument to pass into the callback function
|
||||
-- @treturn Hotkey Current instance
|
||||
function Hotkey.add_hotkey(self, keys, callback_argument)
|
||||
keys = keys or {}
|
||||
if type(keys) == "string" then
|
||||
@@ -103,8 +110,15 @@ function Hotkey.add_hotkey(self, keys, callback_argument)
|
||||
end
|
||||
|
||||
|
||||
function Hotkey.on_focus_gained(self)
|
||||
for k, v in pairs(self._modificators) do
|
||||
self._modificators[k] = false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function Hotkey.on_input(self, action_id, action)
|
||||
if not action_id then
|
||||
if not action_id or #self._hotkeys == 0 then
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -135,16 +149,16 @@ function Hotkey.on_input(self, action_id, action)
|
||||
|
||||
if action.pressed and is_modificator_ok then
|
||||
hotkey.is_processing = true
|
||||
self.on_hotkey_pressed:trigger(self:get_context(), hotkey.callback_argument)
|
||||
end
|
||||
if not action.pressed and self._is_process_repeated and action.repeated and is_modificator_ok and hotkey.is_processing then
|
||||
self.on_hotkey_released:trigger(self:get_context(), hotkey.callback_argument)
|
||||
return true
|
||||
end
|
||||
if action.released and is_modificator_ok and hotkey.is_processing then
|
||||
hotkey.is_processing = false
|
||||
if hotkey.callback_argument then
|
||||
self._callback(self:get_context(), hotkey.callback_argument)
|
||||
return true
|
||||
else
|
||||
self._callback(self:get_context())
|
||||
return true
|
||||
end
|
||||
self.on_hotkey_released:trigger(self:get_context(), hotkey.callback_argument)
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -153,4 +167,14 @@ function Hotkey.on_input(self, action_id, action)
|
||||
end
|
||||
|
||||
|
||||
--- If true, the callback will be triggered on action.repeated
|
||||
-- @tparam Hotkey self @{Hotkey}
|
||||
-- @tparam bool is_enabled_repeated The flag value
|
||||
-- @treturn Hotkey
|
||||
function Hotkey.set_repeat(self, is_enabled_repeated)
|
||||
self._is_process_repeated = is_enabled_repeated
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
return Hotkey
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
-- @within BaseComponent
|
||||
-- @alias druid.input
|
||||
|
||||
--- On input field select callback(self, button_node)
|
||||
--- On input field select callback(self, input_instance)
|
||||
-- @tfield DruidEvent on_input_select @{DruidEvent}
|
||||
|
||||
--- On input field unselect callback(self, input_text)
|
||||
--- On input field unselect callback(self, input_text, input_instance)
|
||||
-- @tfield DruidEvent on_input_unselect @{DruidEvent}
|
||||
|
||||
--- On input field text change callback(self, input_text)
|
||||
@@ -24,26 +24,56 @@
|
||||
--- On input field text change to max length string callback(self, input_text)
|
||||
-- @tfield DruidEvent on_input_full @{DruidEvent}
|
||||
|
||||
--- On trying user input with not allowed character callback(self, params, button_instance)
|
||||
--- On trying user input with not allowed character callback(self, params, input_text)
|
||||
-- @tfield DruidEvent on_input_wrong @{DruidEvent}
|
||||
|
||||
--- On cursor position change callback(self, cursor_index, start_index, end_index)
|
||||
-- @tfield DruidEvent on_select_cursor_change @{DruidEvent}
|
||||
|
||||
--- The cursor index. The index of letter cursor after. Leftmost cursor - 0
|
||||
-- @tfield number cursor_index
|
||||
|
||||
--- The selection start index. The index of letter cursor after. Leftmost selection - 0
|
||||
-- @tfield number start_index
|
||||
|
||||
--- Theselection end index. The index of letter cursor before. Rightmost selection - #text
|
||||
-- @tfield number end_index
|
||||
|
||||
--- Text component
|
||||
-- @tfield Text text @{Text}
|
||||
|
||||
--- Current input value
|
||||
-- @tfield string value
|
||||
|
||||
--- Previous input value
|
||||
-- @tfield string previous_value
|
||||
|
||||
--- Current input value with marked text
|
||||
-- @tfield string current_value
|
||||
|
||||
--- Marked text for input field. Info: https://defold.com/manuals/input-key-and-text/#marked-text
|
||||
-- @tfield string marked_value
|
||||
|
||||
--- Text width
|
||||
-- @tfield number text_width
|
||||
|
||||
--- Marked text width
|
||||
-- @tfield number marked_text_width
|
||||
|
||||
--- Button component
|
||||
-- @tfield Button button @{Button}
|
||||
|
||||
--- Is current input selected now
|
||||
-- @tfield bool is_selected
|
||||
-- @tfield boolean is_selected
|
||||
|
||||
--- Is current input is empty now
|
||||
-- @tfield bool is_empty
|
||||
-- @tfield boolean is_empty
|
||||
|
||||
--- Max length for input text
|
||||
-- @tfield[opt] number max_length
|
||||
-- @tfield number|nil max_length
|
||||
|
||||
--- Pattern matching for user input
|
||||
-- @tfield[opt] string allowerd_characters
|
||||
-- @tfield string|nil allowerd_characters
|
||||
|
||||
--- Gui keyboard type for input field
|
||||
-- @tfield number keyboard_type
|
||||
@@ -52,12 +82,21 @@
|
||||
|
||||
local Event = require("druid.event")
|
||||
local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
local utf8_lua = require("druid.system.utf8")
|
||||
local utf8 = utf8 or utf8_lua
|
||||
|
||||
local Input = component.create("input")
|
||||
|
||||
Input.ALLOWED_ACTIONS = {
|
||||
[const.ACTION_TOUCH] = true,
|
||||
[const.ACTION_TEXT] = true,
|
||||
[const.ACTION_MARKED_TEXT] = true,
|
||||
[const.ACTION_BACKSPACE] = true,
|
||||
[const.ACTION_ENTER] = true,
|
||||
[const.ACTION_ESC] = true,
|
||||
}
|
||||
|
||||
--- Mask text by replacing every character with a mask character
|
||||
-- @tparam string text
|
||||
@@ -87,41 +126,32 @@ end
|
||||
-- You can override this component styles params in druid styles table
|
||||
-- or create your own style
|
||||
-- @table style
|
||||
-- @tfield[opt=false] bool IS_LONGTAP_ERASE Is long tap will erase current input data
|
||||
-- @tfield[opt=*] string MASK_DEFAULT_CHAR Default character mask for password input
|
||||
-- @tfield[opt=false] bool IS_UNSELECT_ON_RESELECT If true, call unselect on select selected input
|
||||
-- @tfield[opt=false] bool NO_CONSUME_INPUT_WHILE_SELECTED If true, will not consume input while input is selected. It's allow to interact with other components while input is selected (text input still captured)
|
||||
-- @tfield boolean IS_LONGTAP_ERASE Is long tap will erase current input data. Default: false
|
||||
-- @tfield string MASK_DEFAULT_CHAR Default character mask for password input. Default: *]
|
||||
-- @tfield boolean IS_UNSELECT_ON_RESELECT If true, call unselect on select selected input. Default: false
|
||||
-- @tfield function on_select (self, button_node) Callback on input field selecting
|
||||
-- @tfield function on_unselect (self, button_node) Callback on input field unselecting
|
||||
-- @tfield function on_input_wrong (self, button_node) Callback on wrong user input
|
||||
-- @tfield table button_style Custom button style for input node
|
||||
function Input.on_style_change(self, style)
|
||||
self.style = {}
|
||||
|
||||
self.style.IS_LONGTAP_ERASE = style.IS_LONGTAP_ERASE or false
|
||||
self.style.MASK_DEFAULT_CHAR = style.MASK_DEFAULT_CHAR or "*"
|
||||
self.style.IS_UNSELECT_ON_RESELECT = style.IS_UNSELECT_ON_RESELECT or false
|
||||
self.style.NO_CONSUME_INPUT_WHILE_SELECTED = style.NO_CONSUME_INPUT_WHILE_SELECTED or false
|
||||
|
||||
self.style.on_select = style.on_select or function(_, button_node) end
|
||||
self.style.on_unselect = style.on_unselect or function(_, button_node) end
|
||||
self.style.on_input_wrong = style.on_input_wrong or function(_, button_node) end
|
||||
|
||||
self.style.button_style = style.button_style or {
|
||||
LONGTAP_TIME = 0.4,
|
||||
AUTOHOLD_TRIGGER = 0.8,
|
||||
DOUBLETAP_TIME = 0.4
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
--- Component init function
|
||||
--- The @{Input} constructor
|
||||
-- @tparam Input self @{Input}
|
||||
-- @tparam node click_node Node to enabled input component
|
||||
-- @tparam node|Text text_node Text node what will be changed on user input. You can pass text component instead of text node name @{Text}
|
||||
-- @tparam[opt] number keyboard_type Gui keyboard type for input field
|
||||
-- @tparam number|nil keyboard_type Gui keyboard type for input field
|
||||
function Input.init(self, click_node, text_node, keyboard_type)
|
||||
self.druid = self:get_druid(self)
|
||||
self.druid = self:get_druid()
|
||||
|
||||
if type(text_node) == "table" then
|
||||
self.text = text_node
|
||||
@@ -139,6 +169,9 @@ function Input.init(self, click_node, text_node, keyboard_type)
|
||||
self.text_width = 0
|
||||
self.market_text_width = 0
|
||||
self.total_width = 0
|
||||
self.cursor_index = utf8.len(self.value)
|
||||
self.start_index = self.cursor_index
|
||||
self.end_index = self.cursor_index
|
||||
|
||||
self.max_length = nil
|
||||
self.allowed_characters = nil
|
||||
@@ -146,10 +179,14 @@ function Input.init(self, click_node, text_node, keyboard_type)
|
||||
self.keyboard_type = keyboard_type or gui.KEYBOARD_TYPE_DEFAULT
|
||||
|
||||
self.button = self.druid:new_button(click_node, self.select)
|
||||
self.button:set_style(self.button_style)
|
||||
self.button.on_click_outside:subscribe(self.unselect)
|
||||
self.button.on_long_click:subscribe(clear_and_select)
|
||||
|
||||
if defos then
|
||||
self.button.hover.style.ON_HOVER_CURSOR = defos.CURSOR_IBEAM
|
||||
self.button.hover.style.ON_MOUSE_HOVER_CURSOR = defos.CURSOR_IBEAM
|
||||
end
|
||||
|
||||
if html5 then
|
||||
self.button:set_web_user_interaction(true)
|
||||
end
|
||||
@@ -160,29 +197,36 @@ function Input.init(self, click_node, text_node, keyboard_type)
|
||||
self.on_input_empty = Event()
|
||||
self.on_input_full = Event()
|
||||
self.on_input_wrong = Event()
|
||||
self.on_select_cursor_change = Event()
|
||||
end
|
||||
|
||||
|
||||
function Input.on_input(self, action_id, action)
|
||||
if not (action_id == nil or Input.ALLOWED_ACTIONS[action_id]) then
|
||||
return false
|
||||
end
|
||||
|
||||
if self.is_selected then
|
||||
local input_text = nil
|
||||
local is_marked_text_changed = false
|
||||
local cursor_shift_indexes = nil
|
||||
|
||||
if action_id == const.ACTION_TEXT then
|
||||
-- ignore return key
|
||||
if action.text == "\n" or action.text == "\r" then
|
||||
return true
|
||||
end
|
||||
|
||||
local hex = string.gsub(action.text,"(.)", function (c)
|
||||
local hex = string.gsub(action.text, "(.)", function(c)
|
||||
return string.format("%02X%s",string.byte(c), "")
|
||||
end)
|
||||
|
||||
-- ignore arrow keys
|
||||
if not utf8.match(hex, "EF9C8[0-3]") then
|
||||
if not self.allowed_characters or utf8.match(action.text, self.allowed_characters) then
|
||||
input_text = self.value .. action.text
|
||||
if self.max_length then
|
||||
input_text = utf8.sub(input_text, 1, self.max_length)
|
||||
end
|
||||
local shift_offset = self.cursor_index - self.start_index
|
||||
input_text = self:get_text_selected_replaced(action.text)
|
||||
cursor_shift_indexes = utf8.len(action.text) - shift_offset
|
||||
else
|
||||
self.on_input_wrong:trigger(self:get_context(), action.text)
|
||||
self.style.on_input_wrong(self, self.button.node)
|
||||
@@ -196,10 +240,28 @@ function Input.on_input(self, action_id, action)
|
||||
if self.max_length then
|
||||
self.marked_value = utf8.sub(self.marked_value, 1, self.max_length)
|
||||
end
|
||||
is_marked_text_changed = true
|
||||
end
|
||||
|
||||
if action_id == const.ACTION_BACKSPACE and (action.pressed or action.repeated) then
|
||||
input_text = utf8.sub(self.value, 1, -2)
|
||||
local start_index = self.start_index or utf8.len(self.value)
|
||||
local end_index = self.end_index or utf8.len(self.value)
|
||||
|
||||
-- If start == end index, remove left of this selection letter, else delete all selection
|
||||
if start_index == end_index then
|
||||
local left_part = utf8.sub(self.value, 1, math.max(0, start_index - 1))
|
||||
local right_part = utf8.sub(self.value, end_index + 1, utf8.len(self.value))
|
||||
input_text = left_part .. right_part
|
||||
|
||||
cursor_shift_indexes = -1
|
||||
else
|
||||
local left_part = utf8.sub(self.value, 1, start_index)
|
||||
local right_part = utf8.sub(self.value, end_index + 1, utf8.len(self.value))
|
||||
input_text = left_part .. right_part
|
||||
|
||||
-- Calculate offsets from cursor pos to start index
|
||||
cursor_shift_indexes = start_index - self.cursor_index
|
||||
end
|
||||
end
|
||||
|
||||
if action_id == const.ACTION_ENTER and action.released then
|
||||
@@ -217,14 +279,23 @@ function Input.on_input(self, action_id, action)
|
||||
return true
|
||||
end
|
||||
|
||||
if input_text or #self.marked_value > 0 then
|
||||
if input_text or is_marked_text_changed then
|
||||
self:set_text(input_text)
|
||||
|
||||
if cursor_shift_indexes then
|
||||
self:select_cursor(self.cursor_index + cursor_shift_indexes)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
local is_consume_input = not self.style.NO_CONSUME_INPUT_WHILE_SELECTED and self.is_selected
|
||||
return is_consume_input
|
||||
local is_mouse_action = action_id == const.ACTION_TOUCH or not action_id
|
||||
if is_mouse_action then
|
||||
return false
|
||||
end
|
||||
|
||||
return self.is_selected
|
||||
end
|
||||
|
||||
|
||||
@@ -234,7 +305,33 @@ end
|
||||
|
||||
|
||||
function Input.on_input_interrupt(self)
|
||||
-- self:unselect()
|
||||
--self:unselect()
|
||||
end
|
||||
|
||||
|
||||
function Input.get_text_selected(self)
|
||||
if self.start_index == self.end_index then
|
||||
return self.value
|
||||
end
|
||||
|
||||
return utf8.sub(self.value, self.start_index + 1, self.end_index)
|
||||
end
|
||||
|
||||
--- Replace selected text with new text
|
||||
-- @tparam Input self @{Input}
|
||||
-- @tparam string text The text to replace selected text
|
||||
-- @treturn string New input text
|
||||
function Input.get_text_selected_replaced(self, text)
|
||||
local left_part = utf8.sub(self.value, 1, self.start_index)
|
||||
local right_part = utf8.sub(self.value, self.end_index + 1, utf8.len(self.value))
|
||||
local result = left_part .. text .. right_part
|
||||
|
||||
|
||||
if self.max_length then
|
||||
result = utf8.sub(result, 1, self.max_length)
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
@@ -242,6 +339,8 @@ end
|
||||
-- @tparam Input self @{Input}
|
||||
-- @tparam string input_text The string to apply for input field
|
||||
function Input.set_text(self, input_text)
|
||||
input_text = tostring(input_text or "")
|
||||
|
||||
-- Case when update with marked text
|
||||
if input_text then
|
||||
self.value = input_text
|
||||
@@ -297,12 +396,14 @@ function Input.select(self)
|
||||
self.is_selected = true
|
||||
|
||||
gui.show_keyboard(self.keyboard_type, false)
|
||||
self.on_input_select:trigger(self:get_context())
|
||||
|
||||
local len = utf8.len(self.value)
|
||||
self:select_cursor(len, len, len)
|
||||
self.on_input_select:trigger(self:get_context(), self)
|
||||
self.style.on_select(self, self.button.node)
|
||||
else
|
||||
if self.style.IS_UNSELECT_ON_RESELECT then
|
||||
self:unselect(self)
|
||||
self:unselect()
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -313,13 +414,14 @@ end
|
||||
function Input.unselect(self)
|
||||
gui.reset_keyboard()
|
||||
self.marked_value = ""
|
||||
self.value = self.current_value
|
||||
if self.is_selected then
|
||||
self:reset_input_priority()
|
||||
self.button:reset_input_priority()
|
||||
self.is_selected = false
|
||||
|
||||
gui.hide_keyboard()
|
||||
self.on_input_unselect:trigger(self:get_context(), self:get_text())
|
||||
self.on_input_unselect:trigger(self:get_context(), self:get_text(), self)
|
||||
|
||||
self.style.on_unselect(self, self.button.node)
|
||||
end
|
||||
@@ -330,7 +432,11 @@ end
|
||||
-- @tparam Input self @{Input}
|
||||
-- @treturn string The current input field text
|
||||
function Input.get_text(self)
|
||||
return self.value .. self.marked_value
|
||||
if self.marked_value ~= "" then
|
||||
return self.value .. self.marked_value
|
||||
end
|
||||
|
||||
return self.value
|
||||
end
|
||||
|
||||
|
||||
@@ -359,9 +465,97 @@ end
|
||||
|
||||
--- Reset current input selection and return previous value
|
||||
-- @tparam Input self @{Input}
|
||||
-- @treturn druid.input Current input instance
|
||||
function Input.reset_changes(self)
|
||||
self:set_text(self.previous_value)
|
||||
self:unselect()
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set cursor position in input field
|
||||
-- @tparam Input self @{Input}
|
||||
-- @tparam number|nil cursor_index Cursor index for cursor position, if nil - will be set to the end of the text
|
||||
-- @tparam number|nil start_index Start index for cursor position, if nil - will be set to the end of the text
|
||||
-- @tparam number|nil end_index End index for cursor position, if nil - will be set to the start_index
|
||||
-- @treturn druid.input Current input instance
|
||||
function Input.select_cursor(self, cursor_index, start_index, end_index)
|
||||
local len = utf8.len(self.value)
|
||||
|
||||
self.cursor_index = cursor_index or len
|
||||
self.start_index = start_index or self.cursor_index
|
||||
self.end_index = end_index or self.start_index
|
||||
|
||||
self.cursor_index = helper.clamp(self.cursor_index, 0, len)
|
||||
self.start_index = helper.clamp(self.start_index, 0, len)
|
||||
self.end_index = helper.clamp(self.end_index, 0, len)
|
||||
|
||||
self.on_select_cursor_change:trigger(self:get_context(), self.cursor_index, self.start_index, self.end_index)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Change cursor position by delta
|
||||
-- @tparam Input self @{Input}
|
||||
-- @tparam number delta side for cursor position, -1 for left, 1 for right
|
||||
-- @tparam boolean is_add_to_selection (Shift key)
|
||||
-- @tparam boolean is_move_to_end (Ctrl key)
|
||||
function Input.move_selection(self, delta, is_add_to_selection, is_move_to_end)
|
||||
local len = utf8.len(self.value)
|
||||
local cursor_index = self.cursor_index
|
||||
local start_index, end_index -- if nil, the selection will be 0 at cursor position
|
||||
local is_right = delta > 0
|
||||
|
||||
local target_index = cursor_index + delta
|
||||
if is_move_to_end then
|
||||
target_index = is_right and len or 0
|
||||
end
|
||||
|
||||
-- The Shift is not pressed
|
||||
if not is_add_to_selection then
|
||||
cursor_index = target_index
|
||||
|
||||
if self.start_index ~= self.end_index then
|
||||
-- Reset selection without moving cursor
|
||||
cursor_index = self.cursor_index
|
||||
end
|
||||
end
|
||||
|
||||
-- The Shift is pressed
|
||||
if is_add_to_selection then
|
||||
cursor_index = target_index
|
||||
start_index = self.start_index
|
||||
end_index = self.end_index
|
||||
|
||||
local is_cursor_extends_selection = (self.cursor_index == (is_right and end_index or start_index))
|
||||
|
||||
if is_cursor_extends_selection then
|
||||
if is_right then
|
||||
end_index = cursor_index
|
||||
else
|
||||
start_index = cursor_index
|
||||
end
|
||||
else
|
||||
if is_right then
|
||||
start_index = cursor_index
|
||||
|
||||
if is_move_to_end then
|
||||
start_index = end_index
|
||||
end_index = cursor_index
|
||||
end
|
||||
else
|
||||
end_index = cursor_index
|
||||
|
||||
if is_move_to_end then
|
||||
end_index = start_index
|
||||
start_index = cursor_index
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self:select_cursor(cursor_index, start_index, end_index)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
--- The text component
|
||||
-- @tfield Text text @{Text}
|
||||
|
||||
--- Text node
|
||||
-- @tfield node node
|
||||
|
||||
---
|
||||
|
||||
local Event = require("druid.event")
|
||||
@@ -34,9 +37,9 @@ local LangText = component.create("lang_text")
|
||||
|
||||
--- The @{LangText} constructor
|
||||
-- @tparam LangText self @{LangText}
|
||||
-- @tparam string|node node Node name or GUI Text Node itself
|
||||
-- @tparam string locale_id Default locale id or text from node as default
|
||||
-- @tparam[opt=downscale] string adjust_type Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference
|
||||
-- @tparam string|node node The node_id or gui.get_node(node_id)
|
||||
-- @tparam string|nil locale_id Default locale id or text from node as default
|
||||
-- @tparam string|nil adjust_type Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference
|
||||
function LangText.init(self, node, locale_id, adjust_type)
|
||||
self.druid = self:get_druid()
|
||||
self.text = self.druid:new_text(node, locale_id, adjust_type)
|
||||
@@ -46,6 +49,7 @@ function LangText.init(self, node, locale_id, adjust_type)
|
||||
self.on_change = Event()
|
||||
|
||||
self:translate(locale_id or gui.get_text(self.node))
|
||||
self.text.on_set_text:subscribe(self.on_change.trigger, self.on_change)
|
||||
|
||||
return self
|
||||
end
|
||||
@@ -74,13 +78,13 @@ end
|
||||
--- Translate the text by locale_id
|
||||
-- @tparam LangText self @{LangText}
|
||||
-- @tparam string locale_id Locale id
|
||||
-- @tparam[opt] string a Optional param to string.format
|
||||
-- @tparam[opt] string b Optional param to string.format
|
||||
-- @tparam[opt] string c Optional param to string.format
|
||||
-- @tparam[opt] string d Optional param to string.format
|
||||
-- @tparam[opt] string e Optional param to string.format
|
||||
-- @tparam[opt] string f Optional param to string.format
|
||||
-- @tparam[opt] string g Optional param to string.format
|
||||
-- @tparam string|nil a Optional param to string.format
|
||||
-- @tparam string|nil b Optional param to string.format
|
||||
-- @tparam string|nil c Optional param to string.format
|
||||
-- @tparam string|nil d Optional param to string.format
|
||||
-- @tparam string|nil e Optional param to string.format
|
||||
-- @tparam string|nil f Optional param to string.format
|
||||
-- @tparam string|nil g Optional param to string.format
|
||||
-- @treturn LangText Current instance
|
||||
function LangText.translate(self, locale_id, a, b, c, d, e, f, g)
|
||||
self.last_locale_args = { a, b, c, d, e, f, g }
|
||||
@@ -93,13 +97,13 @@ end
|
||||
|
||||
--- Format string with new text params on localized text
|
||||
-- @tparam LangText self @{LangText}
|
||||
-- @tparam[opt] string a Optional param to string.format
|
||||
-- @tparam[opt] string b Optional param to string.format
|
||||
-- @tparam[opt] string c Optional param to string.format
|
||||
-- @tparam[opt] string d Optional param to string.format
|
||||
-- @tparam[opt] string e Optional param to string.format
|
||||
-- @tparam[opt] string f Optional param to string.format
|
||||
-- @tparam[opt] string g Optional param to string.format
|
||||
-- @tparam string|nil a Optional param to string.format
|
||||
-- @tparam string|nil b Optional param to string.format
|
||||
-- @tparam string|nil c Optional param to string.format
|
||||
-- @tparam string|nil d Optional param to string.format
|
||||
-- @tparam string|nil e Optional param to string.format
|
||||
-- @tparam string|nil f Optional param to string.format
|
||||
-- @tparam string|nil g Optional param to string.format
|
||||
-- @treturn LangText Current instance
|
||||
function LangText.format(self, a, b, c, d, e, f, g)
|
||||
self.last_locale_args = { a, b, c, d, e, f, g }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
-- Copyright (c) 2021 Maksim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
|
||||
-- Copyright (c) 2024 Maksim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
|
||||
|
||||
--- Layout management on node
|
||||
--
|
||||
@@ -13,205 +13,413 @@
|
||||
--- Current layout mode
|
||||
-- @tfield string mode
|
||||
|
||||
---On window resize callback(self, new_size)
|
||||
-- @tfield DruidEvent on_size_changed @{DruidEvent}
|
||||
|
||||
---
|
||||
|
||||
|
||||
local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
local Event = require("druid.event")
|
||||
|
||||
-- @class druid.layout.row_data
|
||||
-- @tfield width number
|
||||
-- @tfield height number
|
||||
-- @tfield count number
|
||||
|
||||
local Layout = component.create("layout")
|
||||
-- @class druid.layout.rows_data
|
||||
-- @tfield total_width number
|
||||
-- @tfield total_height number
|
||||
-- @tfield nodes_width table<node, number>
|
||||
-- @tfield nodes_height table<node, number>
|
||||
-- @tfield rows druid.layout.row_data[]>
|
||||
|
||||
-- @class druid.layout: druid.base_component
|
||||
local M = component.create("layout")
|
||||
|
||||
--- Component init function
|
||||
-- The @{Layout} constructor
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @tparam node node Gui node
|
||||
-- @tparam string mode The layout mode (from const.LAYOUT_MODE)
|
||||
-- @tparam[opt] function on_size_changed_callback The callback on window resize
|
||||
function Layout.init(self, node, mode, on_size_changed_callback)
|
||||
-- @tparam string layout_type The layout mode (from const.LAYOUT_MODE)
|
||||
-- @tparam function|nil on_size_changed_callback The callback on window resize
|
||||
function M.init(self, node, layout_type)
|
||||
self.node = self:get_node(node)
|
||||
|
||||
self._min_size = nil
|
||||
self._max_size = nil
|
||||
self._current_size = vmath.vector3(0)
|
||||
self._inited = false
|
||||
self._max_gui_upscale = nil
|
||||
self._fit_node = nil
|
||||
|
||||
self._anchors = {}
|
||||
|
||||
self.mode = mode or const.LAYOUT_MODE.FIT
|
||||
|
||||
self.on_size_changed = Event(on_size_changed_callback)
|
||||
self.is_dirty = true
|
||||
self.entities = {}
|
||||
self.margin = { x = 0, y = 0 }
|
||||
self.padding = gui.get_slice9(self.node)
|
||||
self.type = layout_type or "horizontal"
|
||||
self.is_resize_width = false
|
||||
self.is_resize_height = false
|
||||
self.is_justify = false
|
||||
end
|
||||
|
||||
|
||||
function Layout.on_late_init(self)
|
||||
self._inited = true
|
||||
self.origin_size = self.origin_size or gui.get_size(self.node)
|
||||
self.fit_size = self.fit_size or vmath.vector3(self.origin_size)
|
||||
self.pivot = helper.get_pivot_offset(gui.get_pivot(self.node))
|
||||
self.origin_position = gui.get_position(self.node)
|
||||
self.position = vmath.vector3(self.origin_position)
|
||||
gui.set_size_mode(self.node, gui.SIZE_MODE_MANUAL)
|
||||
gui.set_adjust_mode(self.node, gui.ADJUST_FIT)
|
||||
self:on_window_resized()
|
||||
end
|
||||
|
||||
|
||||
function Layout.on_window_resized(self)
|
||||
if not self._inited then
|
||||
function M:update()
|
||||
if not self.is_dirty then
|
||||
return
|
||||
end
|
||||
|
||||
local x_koef, y_koef = helper.get_screen_aspect_koef()
|
||||
|
||||
local revert_scale = 1
|
||||
if self._max_gui_upscale then
|
||||
revert_scale = self._max_gui_upscale / helper.get_gui_scale()
|
||||
revert_scale = math.min(revert_scale, 1)
|
||||
end
|
||||
gui.set_scale(self.node, vmath.vector3(revert_scale))
|
||||
|
||||
if self._fit_node then
|
||||
self.fit_size = gui.get_size(self._fit_node)
|
||||
self.fit_size.x = self.fit_size.x / x_koef
|
||||
self.fit_size.y = self.fit_size.y / y_koef
|
||||
end
|
||||
|
||||
x_koef = self.fit_size.x / self.origin_size.x * x_koef
|
||||
y_koef = self.fit_size.y / self.origin_size.y * y_koef
|
||||
|
||||
local new_size = vmath.vector3(self.origin_size)
|
||||
|
||||
if self.mode == const.LAYOUT_MODE.STRETCH then
|
||||
new_size.x = new_size.x * x_koef / revert_scale
|
||||
new_size.y = new_size.y * y_koef / revert_scale
|
||||
end
|
||||
|
||||
if self.mode == const.LAYOUT_MODE.STRETCH_X then
|
||||
new_size.x = new_size.x * x_koef / revert_scale
|
||||
end
|
||||
|
||||
if self.mode == const.LAYOUT_MODE.STRETCH_Y then
|
||||
new_size.y = new_size.y * y_koef / revert_scale
|
||||
end
|
||||
|
||||
-- Fit to the stretched container (node size or other defined)
|
||||
if self.mode == const.LAYOUT_MODE.ZOOM_MIN then
|
||||
new_size = new_size * math.min(x_koef, y_koef)
|
||||
end
|
||||
if self.mode == const.LAYOUT_MODE.ZOOM_MAX then
|
||||
new_size = new_size * math.max(x_koef, y_koef)
|
||||
end
|
||||
|
||||
if self._min_size then
|
||||
new_size.x = math.max(new_size.x, self._min_size.x)
|
||||
new_size.y = math.max(new_size.y, self._min_size.y)
|
||||
end
|
||||
if self._max_size then
|
||||
new_size.x = math.min(new_size.x, self._max_size.x)
|
||||
new_size.y = math.min(new_size.y, self._max_size.y)
|
||||
end
|
||||
self._current_size = new_size
|
||||
gui.set_size(self.node, new_size)
|
||||
|
||||
self.position.x = self.origin_position.x + self.origin_position.x * (x_koef - 1)
|
||||
self.position.y = self.origin_position.y + self.origin_position.y * (y_koef - 1)
|
||||
gui.set_position(self.node, self.position)
|
||||
|
||||
self.on_size_changed:trigger(self:get_context(), new_size)
|
||||
self:refresh_layout()
|
||||
end
|
||||
|
||||
|
||||
--- Set minimal size of layout node
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @tparam vector3 min_size
|
||||
-- @treturn Layout @{Layout}
|
||||
function Layout.set_min_size(self, min_size)
|
||||
self._min_size = min_size
|
||||
-- @tparam number|nil margin_x
|
||||
-- @tparam number|nil margin_y
|
||||
-- @treturn druid.layout @{Layout}
|
||||
function M.set_margin(self, margin_x, margin_y)
|
||||
self.margin.x = margin_x or self.margin.x
|
||||
self.margin.y = margin_y or self.margin.y
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set maximum size of layout node
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @tparam vector3 max_size
|
||||
-- @treturn Layout @{Layout}
|
||||
function Layout.set_max_size(self, max_size)
|
||||
self._max_size = max_size
|
||||
-- @tparam vector4 padding The vector4 with padding values, where x - left, y - top, z - right, w - bottom
|
||||
-- @treturn druid.layout @{Layout}
|
||||
function M.set_padding(self, padding)
|
||||
self.padding = padding
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set new origin position of layout node. You should apply this on node movement
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @tparam vector3 new_origin_position
|
||||
-- @treturn Layout @{Layout}
|
||||
function Layout.set_origin_position(self, new_origin_position)
|
||||
self.origin_position = new_origin_position or self.origin_position
|
||||
self:on_window_resized()
|
||||
-- @treturn druid.layout @{Layout}
|
||||
function M.set_dirty(self)
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set new origin size of layout node. You should apply this on node manual size change
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @tparam vector3 new_origin_size
|
||||
-- @treturn Layout @{Layout}
|
||||
function Layout.set_origin_size(self, new_origin_size)
|
||||
self.origin_size = new_origin_size or self.origin_size
|
||||
self:on_window_resized()
|
||||
-- @tparam boolean is_justify
|
||||
-- @treturn druid.layout @{Layout}
|
||||
function M.set_justify(self, is_justify)
|
||||
self.is_justify = is_justify
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set max gui upscale for FIT adjust mode (or side). It happens on bigger render gui screen
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @tparam number max_gui_upscale
|
||||
-- @treturn Layout @{Layout}
|
||||
function Layout.set_max_gui_upscale(self, max_gui_upscale)
|
||||
self._max_gui_upscale = max_gui_upscale
|
||||
self:on_window_resized()
|
||||
end
|
||||
-- @tparam string type The layout type: "horizontal", "vertical", "horizontal_wrap"
|
||||
-- @treturn druid.layout @{Layout}
|
||||
function M.set_type(self, type)
|
||||
self.type = type
|
||||
self.is_dirty = true
|
||||
|
||||
|
||||
--- Set size for layout node to fit inside it
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @tparam vector3 target_size
|
||||
-- @treturn Layout @{Layout}
|
||||
function Layout.fit_into_size(self, target_size)
|
||||
self.fit_size = target_size
|
||||
self:on_window_resized()
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set node for layout node to fit inside it. Pass nil to reset
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @tparam[opt] Node node
|
||||
-- @treturn Layout @{Layout}
|
||||
function Layout.fit_into_node(self, node)
|
||||
self._fit_node = node
|
||||
self:on_window_resized()
|
||||
-- @tparam boolean is_hug_width
|
||||
-- @tparam boolean is_hug_height
|
||||
-- @treturn druid.layout @{Layout}
|
||||
function M.set_hug_content(self, is_hug_width, is_hug_height)
|
||||
self.is_resize_width = is_hug_width or false
|
||||
self.is_resize_height = is_hug_height or false
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set current size for layout node to fit inside it
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @treturn Layout @{Layout}
|
||||
function Layout.fit_into_window(self)
|
||||
return self:fit_into_size(vmath.vector3(
|
||||
gui.get_width(),
|
||||
gui.get_height(),
|
||||
0))
|
||||
-- @tparam string|node node_or_node_id
|
||||
-- @treturn druid.layout @{Layout}
|
||||
function M.add(self, node_or_node_id)
|
||||
-- Acquire node from entity or by id
|
||||
local node = node_or_node_id
|
||||
if type(node_or_node_id) == "table" then
|
||||
assert(node_or_node_id.node, "The entity should have a node")
|
||||
node = node_or_node_id.node
|
||||
else
|
||||
-- @cast node_or_node_id string|node
|
||||
node = self:get_node(node_or_node_id)
|
||||
end
|
||||
|
||||
-- @cast node node
|
||||
table.insert(self.entities, node)
|
||||
gui.set_parent(node, self.node)
|
||||
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
return Layout
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @treturn druid.layout @{Layout}
|
||||
function M.refresh_layout(self)
|
||||
local layout_node = self.node
|
||||
|
||||
local entities = self.entities
|
||||
local type = self.type -- vertical, horizontal, horizontal_wrap
|
||||
local margin = self.margin -- {x: horizontal, y: vertical} in pixels, between elements
|
||||
local padding = self.padding -- {x: left, y: top, z: right, w: bottom} in pixels
|
||||
local is_justify = self.is_justify
|
||||
local size = gui.get_size(layout_node)
|
||||
local max_width = size.x - padding.x - padding.z
|
||||
local max_height = size.y - padding.y - padding.w
|
||||
local layout_pivot_offset = helper.get_pivot_offset(gui.get_pivot(layout_node)) -- {x: -0.5, y: -0.5} - is left bot, {x: 0.5, y: 0.5} - is right top
|
||||
|
||||
local rows_data = self:calculate_rows_data()
|
||||
local rows = rows_data.rows
|
||||
local row_index = 1
|
||||
local row = rows[row_index]
|
||||
|
||||
-- Current x and Current y is a top left corner of the node
|
||||
local current_x = -row.width * (0.5 + layout_pivot_offset.x)
|
||||
local current_y = rows_data.total_height * (0.5 - layout_pivot_offset.y)
|
||||
|
||||
if is_justify then
|
||||
if (type == "horizontal" or type == "horizontal_wrap") and row.count > 1 then
|
||||
current_x = -max_width * (0.5 + layout_pivot_offset.x)
|
||||
end
|
||||
if type == "vertical" then
|
||||
current_y = max_height * (0.5 - layout_pivot_offset.y)
|
||||
end
|
||||
end
|
||||
|
||||
for index = 1, #entities do
|
||||
local node = entities[index]
|
||||
local node_width = rows_data.nodes_width[node]
|
||||
local node_height = rows_data.nodes_height[node]
|
||||
local pivot_offset = helper.get_pivot_offset(gui.get_pivot(node))
|
||||
|
||||
if node_width > 0 and node_height > 0 then
|
||||
-- Calculate position for current node
|
||||
local position_x, position_y
|
||||
|
||||
if type == "horizontal" then
|
||||
position_x = current_x + node_width * (0.5 + pivot_offset.x)
|
||||
position_y = current_y - row.height * (0.5 - pivot_offset.y)
|
||||
|
||||
local node_margin = margin.x
|
||||
if is_justify and row.count > 1 then
|
||||
node_margin = (max_width - row.width) / (row.count - 1) + margin.x
|
||||
end
|
||||
current_x = current_x + node_width + node_margin
|
||||
end
|
||||
|
||||
if type == "vertical" then
|
||||
local node_margin = margin.y
|
||||
if is_justify then
|
||||
node_margin = (max_height - rows_data.total_height) / (#rows - 1) + margin.y
|
||||
end
|
||||
|
||||
current_x = -row.width * (0.5 + layout_pivot_offset.x)
|
||||
|
||||
position_x = current_x + row.width * (0.5 + pivot_offset.x)
|
||||
position_y = current_y - node_height * (0.5 - pivot_offset.y)
|
||||
|
||||
current_y = current_y - node_height - node_margin
|
||||
|
||||
row_index = row_index + 1
|
||||
row = rows[row_index]
|
||||
end
|
||||
|
||||
if type == "horizontal_wrap" then
|
||||
local width = row.width
|
||||
if is_justify and row.count > 0 then
|
||||
width = math.max(row.width, max_width)
|
||||
end
|
||||
local new_row_width = width * (0.5 - layout_pivot_offset.x)
|
||||
|
||||
-- Compare with eps due the float loss and element flickering
|
||||
if current_x + node_width - new_row_width > 0.0001 then
|
||||
if row_index < #rows then
|
||||
row_index = row_index + 1
|
||||
row = rows[row_index]
|
||||
end
|
||||
|
||||
current_x = -row.width * (0.5 + layout_pivot_offset.x)
|
||||
current_y = current_y - row.height - margin.y
|
||||
if is_justify and row.count > 1 then
|
||||
current_x = -max_width * (0.5 + layout_pivot_offset.x)
|
||||
end
|
||||
end
|
||||
|
||||
position_x = current_x + node_width * (0.5 + pivot_offset.x)
|
||||
position_y = current_y - row.height * (0.5 - pivot_offset.y)
|
||||
|
||||
local node_margin = margin.x
|
||||
if is_justify and row.count > 1 then
|
||||
node_margin = (max_width - row.width) / (row.count - 1) + margin.x
|
||||
end
|
||||
current_x = current_x + node_width + node_margin
|
||||
end
|
||||
|
||||
do -- Padding offset
|
||||
if layout_pivot_offset.x == -0.5 then
|
||||
position_x = position_x + padding.x
|
||||
end
|
||||
if layout_pivot_offset.y == 0.5 then
|
||||
position_y = position_y - padding.y
|
||||
end
|
||||
if layout_pivot_offset.x == 0.5 then
|
||||
position_x = position_x - padding.z
|
||||
end
|
||||
if layout_pivot_offset.y == -0.5 then
|
||||
position_y = position_y + padding.w
|
||||
end
|
||||
end
|
||||
|
||||
self:set_node_position(node, position_x, position_y)
|
||||
end
|
||||
end
|
||||
|
||||
if self.is_resize_width or self.is_resize_height then
|
||||
if self.is_resize_width then
|
||||
size.x = rows_data.total_width + padding.x + padding.z
|
||||
end
|
||||
if self.is_resize_height then
|
||||
size.y = rows_data.total_height + padding.y + padding.w
|
||||
end
|
||||
gui.set_size(layout_node, size)
|
||||
end
|
||||
|
||||
self.is_dirty = false
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- @treturn druid.layout @{Layout}
|
||||
function M.clear_layout(self)
|
||||
for index = #self.entities, 1, -1 do
|
||||
self.entities[index] = nil
|
||||
end
|
||||
|
||||
self.is_dirty = true
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
-- @tparam node node
|
||||
-- @treturn number, number
|
||||
-- @local
|
||||
function M.get_node_size(node)
|
||||
if not gui.is_enabled(node, false) then
|
||||
return 0, 0
|
||||
end
|
||||
|
||||
local scale = gui.get_scale(node)
|
||||
|
||||
-- If node has text - get text size instead of node size
|
||||
if gui.get_text(node) then
|
||||
local text_metrics = helper.get_text_metrics_from_node(node)
|
||||
return text_metrics.width * scale.x, text_metrics.height * scale.y
|
||||
end
|
||||
|
||||
local size = gui.get_size(node)
|
||||
return size.x * scale.x, size.y * scale.y
|
||||
end
|
||||
|
||||
|
||||
-- @tparam Layout self @{Layout}
|
||||
-- Calculate rows data for layout. Contains total width, height and rows info (width, height, count of elements in row)
|
||||
-- @treturn druid.layout.rows_data
|
||||
-- @local
|
||||
function M.calculate_rows_data(self)
|
||||
local entities = self.entities
|
||||
local margin = self.margin
|
||||
local type = self.type
|
||||
local padding = self.padding
|
||||
|
||||
local size = gui.get_size(self.node)
|
||||
local max_width = size.x - padding.x - padding.z
|
||||
|
||||
-- Collect rows info about width, height and count of elements in row
|
||||
local current_row = { width = 0, height = 0, count = 0 }
|
||||
local rows_data = {
|
||||
total_width = 0,
|
||||
total_height = 0,
|
||||
nodes_width = {},
|
||||
nodes_height = {},
|
||||
rows = { current_row }
|
||||
}
|
||||
|
||||
for index = 1, #entities do
|
||||
local node = entities[index]
|
||||
local node_width = rows_data.nodes_width[node]
|
||||
local node_height = rows_data.nodes_height[node]
|
||||
|
||||
-- Get node size if it's not calculated yet
|
||||
if not node_width or not node_height then
|
||||
node_width, node_height = M.get_node_size(node)
|
||||
rows_data.nodes_width[node] = node_width
|
||||
rows_data.nodes_height[node] = node_height
|
||||
end
|
||||
|
||||
if node_width > 0 and node_height > 0 then
|
||||
if type == "horizontal" then
|
||||
current_row.width = current_row.width + node_width + margin.x
|
||||
current_row.height = math.max(current_row.height, node_height)
|
||||
current_row.count = current_row.count + 1
|
||||
end
|
||||
|
||||
if type == "vertical" then
|
||||
if current_row.count > 0 then
|
||||
current_row = { width = 0, height = 0, count = 0 }
|
||||
table.insert(rows_data.rows, current_row)
|
||||
end
|
||||
|
||||
current_row.width = math.max(current_row.width, node_width + margin.x)
|
||||
current_row.height = node_height
|
||||
current_row.count = current_row.count + 1
|
||||
end
|
||||
|
||||
if type == "horizontal_wrap" then
|
||||
if current_row.width + node_width > max_width and current_row.count > 0 then
|
||||
current_row = { width = 0, height = 0, count = 0 }
|
||||
table.insert(rows_data.rows, current_row)
|
||||
end
|
||||
|
||||
current_row.width = current_row.width + node_width + margin.x
|
||||
current_row.height = math.max(current_row.height, node_height)
|
||||
current_row.count = current_row.count + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Remove last margin of each row
|
||||
-- Calculate total width and height
|
||||
local rows_count = #rows_data.rows
|
||||
for index = 1, rows_count do
|
||||
local row = rows_data.rows[index]
|
||||
if row.width > 0 then
|
||||
row.width = row.width - margin.x
|
||||
end
|
||||
|
||||
rows_data.total_width = math.max(rows_data.total_width, row.width)
|
||||
rows_data.total_height = rows_data.total_height + row.height
|
||||
end
|
||||
|
||||
rows_data.total_height = rows_data.total_height + margin.y * (rows_count - 1)
|
||||
return rows_data
|
||||
end
|
||||
|
||||
|
||||
-- @tparam node node
|
||||
-- @tparam number x
|
||||
-- @tparam number y
|
||||
-- @treturn node
|
||||
-- @local
|
||||
function M:set_node_position(node, x, y)
|
||||
local position = gui.get_position(node)
|
||||
position.x = x
|
||||
position.y = y
|
||||
gui.set_position(node, position)
|
||||
|
||||
return node
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
|
||||
@@ -76,15 +76,29 @@ end
|
||||
|
||||
local function set_bar_to(self, set_to, is_silent)
|
||||
local prev_value = self.last_value
|
||||
local other_side = self.key == const.SIDE.X and const.SIDE.Y or const.SIDE.X
|
||||
self.last_value = set_to
|
||||
|
||||
local total_width = set_to * self.max_size
|
||||
local total_width = set_to * self.max_size[self.key]
|
||||
|
||||
local scale = math.min(total_width / self.slice_size, 1)
|
||||
local size = math.max(total_width, self.slice_size)
|
||||
local scale = 1
|
||||
if self.slice_size[self.key] > 0 then
|
||||
scale = math.min(total_width / self.slice_size[self.key], 1)
|
||||
end
|
||||
local size = math.max(total_width, self.slice_size[self.key])
|
||||
|
||||
do -- Scale other side
|
||||
-- Decrease other side of progress bar to match the oppotize slice_size
|
||||
local minimal_size = self.size[other_side] - self.slice_size[other_side]
|
||||
local maximum_size = self.size[other_side]
|
||||
local scale_diff = (maximum_size - minimal_size) / maximum_size
|
||||
local other_scale = 1 - (scale_diff * (1 - scale))
|
||||
self.scale[other_side] = other_scale
|
||||
end
|
||||
|
||||
self.scale[self.key] = scale
|
||||
gui.set_scale(self.node, self.scale)
|
||||
|
||||
self.size[self.key] = size
|
||||
gui.set_size(self.node, self.size)
|
||||
|
||||
@@ -101,8 +115,8 @@ end
|
||||
-- You can override this component styles params in druid styles table
|
||||
-- or create your own style
|
||||
-- @table style
|
||||
-- @tfield[opt=5] number SPEED Progress bas fill rate. More -> faster
|
||||
-- @tfield[opt=0.005] number MIN_DELTA Minimum step to fill progress bar
|
||||
-- @tfield number|nil SPEED Progress bas fill rate. More -> faster. Default: 5
|
||||
-- @tfield number|nil MIN_DELTA Minimum step to fill progress bar. Default: 0.005
|
||||
function Progress.on_style_change(self, style)
|
||||
self.style = {}
|
||||
self.style.SPEED = style.SPEED or 5
|
||||
@@ -110,11 +124,11 @@ function Progress.on_style_change(self, style)
|
||||
end
|
||||
|
||||
|
||||
--- @{Progress} constructor
|
||||
--- The @{Progress} constructor
|
||||
-- @tparam Progress self @{Progress}
|
||||
-- @tparam string|node node Node name or GUI Node itself.
|
||||
-- @tparam string key Progress bar direction: const.SIDE.X or const.SIDE.Y
|
||||
-- @tparam[opt=1] number init_value Initial value of progress bar
|
||||
-- @tparam number|nil init_value Initial value of progress bar. Default: 1
|
||||
function Progress.init(self, node, key, init_value)
|
||||
assert(key == const.SIDE.X or const.SIDE.Y, "Progress bar key should be 'x' or 'y'")
|
||||
|
||||
@@ -125,15 +139,15 @@ function Progress.init(self, node, key, init_value)
|
||||
self.node = self:get_node(node)
|
||||
self.scale = gui.get_scale(self.node)
|
||||
self.size = gui.get_size(self.node)
|
||||
self.max_size = self.size[self.key]
|
||||
self.max_size = gui.get_size(self.node)
|
||||
self.slice = gui.get_slice9(self.node)
|
||||
self.last_value = self._init_value
|
||||
|
||||
if self.key == const.SIDE.X then
|
||||
self.slice_size = self.slice.x + self.slice.z
|
||||
else
|
||||
self.slice_size = self.slice.y + self.slice.w
|
||||
end
|
||||
self.slice_size = vmath.vector3(
|
||||
self.slice.x + self.slice.z,
|
||||
self.slice.y + self.slice.w,
|
||||
0
|
||||
)
|
||||
|
||||
self.on_change = Event()
|
||||
|
||||
@@ -146,6 +160,12 @@ function Progress.on_layout_change(self)
|
||||
end
|
||||
|
||||
|
||||
function Progress.on_remove(self)
|
||||
-- Return default size
|
||||
gui.set_size(self.node, self.max_size)
|
||||
end
|
||||
|
||||
|
||||
function Progress.update(self, dt)
|
||||
if self.target then
|
||||
local prev_value = self.last_value
|
||||
@@ -210,7 +230,7 @@ end
|
||||
--- Start animation of a progress bar
|
||||
-- @tparam Progress self @{Progress}
|
||||
-- @tparam number to value between 0..1
|
||||
-- @tparam[opt] function callback Callback on animation ends
|
||||
-- @tparam function|nil callback Callback on animation ends
|
||||
function Progress.to(self, to, callback)
|
||||
to = helper.clamp(to, 0, 1)
|
||||
-- cause of float error
|
||||
@@ -231,7 +251,7 @@ end
|
||||
-- @tparam vector3 max_size The new node maximum (full) size
|
||||
-- @treturn Progress @{Progress}
|
||||
function Progress.set_max_size(self, max_size)
|
||||
self.max_size = max_size[self.key]
|
||||
self.max_size[self.key] = max_size[self.key]
|
||||
self:set_to(self.last_value)
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
-- Copyright (c) 2021 Maksim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
|
||||
|
||||
--- Radio group module
|
||||
--
|
||||
-- <a href="https://insality.github.io/druid/druid/index.html?example=general_checkboxes" target="_blank"><b>Example Link</b></a>
|
||||
-- @module RadioGroup
|
||||
-- @within BaseComponent
|
||||
-- @alias druid.radio_group
|
||||
|
||||
--- On any checkbox click
|
||||
-- @tfield DruidEvent on_radio_click @{DruidEvent}
|
||||
|
||||
--- Array of checkbox components
|
||||
-- @tfield Checkbox[] checkboxes
|
||||
|
||||
---
|
||||
|
||||
local Event = require("druid.event")
|
||||
local component = require("druid.component")
|
||||
|
||||
local RadioGroup = component.create("radio_group")
|
||||
|
||||
|
||||
local function on_checkbox_click(self, index, is_instant)
|
||||
for i = 1, #self.checkboxes do
|
||||
self.checkboxes[i]:set_state(i == index, true, is_instant)
|
||||
end
|
||||
|
||||
self.on_radio_click:trigger(self:get_context(), index)
|
||||
end
|
||||
|
||||
|
||||
--- Component init function
|
||||
-- @tparam RadioGroup self @{RadioGroup}
|
||||
-- @tparam node[] nodes Array of gui node
|
||||
-- @tparam function callback Radio callback
|
||||
-- @tparam[opt=node] node[] click_nodes Array of trigger nodes, by default equals to nodes
|
||||
function RadioGroup.init(self, nodes, callback, click_nodes)
|
||||
self.druid = self:get_druid()
|
||||
self.checkboxes = {}
|
||||
|
||||
self.on_radio_click = Event(callback)
|
||||
|
||||
for i = 1, #nodes do
|
||||
local click_node = click_nodes and click_nodes[i] or nil
|
||||
local checkbox = self.druid:new_checkbox(nodes[i], function()
|
||||
on_checkbox_click(self, i)
|
||||
end, click_node)
|
||||
|
||||
table.insert(self.checkboxes, checkbox)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Set radio group state
|
||||
-- @tparam RadioGroup self @{RadioGroup}
|
||||
-- @tparam number index Index in radio group
|
||||
-- @tparam boolean is_instant If is instant state change
|
||||
function RadioGroup.set_state(self, index, is_instant)
|
||||
on_checkbox_click(self, index, is_instant)
|
||||
end
|
||||
|
||||
|
||||
--- Return radio group state
|
||||
-- @tparam RadioGroup self @{RadioGroup}
|
||||
-- @treturn number Index in radio group
|
||||
function RadioGroup.get_state(self)
|
||||
local result = -1
|
||||
|
||||
for i = 1, #self.checkboxes do
|
||||
if self.checkboxes[i]:get_state() then
|
||||
result = i
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
return RadioGroup
|
||||
@@ -26,10 +26,10 @@
|
||||
-- @tfield vector3 end_pos
|
||||
|
||||
--- Length between start and end position
|
||||
-- @tfield number dist
|
||||
-- @tfield vector3 dist
|
||||
|
||||
--- Current drag state
|
||||
-- @tfield bool is_drag
|
||||
-- @tfield boolean is_drag
|
||||
|
||||
--- Current slider value
|
||||
-- @tfield number value
|
||||
@@ -56,11 +56,11 @@ local function set_position(self, value)
|
||||
end
|
||||
|
||||
|
||||
--- Component init function
|
||||
--- The @{Slider} constructor
|
||||
-- @tparam Slider self @{Slider}
|
||||
-- @tparam node node Gui pin node
|
||||
-- @tparam vector3 end_pos The end position of slider
|
||||
-- @tparam[opt] function callback On slider change callback
|
||||
-- @tparam function|nil callback On slider change callback
|
||||
function Slider.init(self, node, end_pos, callback)
|
||||
self.node = self:get_node(node)
|
||||
|
||||
@@ -68,6 +68,7 @@ function Slider.init(self, node, end_pos, callback)
|
||||
self.pos = gui.get_position(self.node)
|
||||
self.target_pos = vmath.vector3(self.pos)
|
||||
self.end_pos = end_pos
|
||||
self._is_enabled = true
|
||||
|
||||
self.dist = self.end_pos - self.start_pos
|
||||
self.is_drag = false
|
||||
@@ -85,6 +86,12 @@ function Slider.on_layout_change(self)
|
||||
end
|
||||
|
||||
|
||||
function Slider.on_remove(self)
|
||||
-- Return pin to start position
|
||||
gui.set_position(self.node, self.start_pos)
|
||||
end
|
||||
|
||||
|
||||
function Slider.on_window_resized(self)
|
||||
local x_koef, y_koef = helper.get_screen_aspect_koef()
|
||||
self._x_koef = x_koef
|
||||
@@ -98,6 +105,10 @@ function Slider.on_input(self, action_id, action)
|
||||
return false
|
||||
end
|
||||
|
||||
if not self._is_enabled or not gui.is_enabled(self.node, true) then
|
||||
return false
|
||||
end
|
||||
|
||||
if gui.pick_node(self.node, action.x, action.y) then
|
||||
if action.pressed then
|
||||
self.pos = gui.get_position(self.node)
|
||||
@@ -132,14 +143,16 @@ function Slider.on_input(self, action_id, action)
|
||||
if prev_x ~= self.target_pos.x or prev_y ~= self.target_pos.y then
|
||||
local prev_value = self.value
|
||||
|
||||
if self.dist.x > 0 then
|
||||
if math.abs(self.dist.x) > 0 then
|
||||
self.value = (self.target_pos.x - self.start_pos.x) / self.dist.x
|
||||
end
|
||||
|
||||
if self.dist.y > 0 then
|
||||
if math.abs(self.dist.y) > 0 then
|
||||
self.value = (self.target_pos.y - self.start_pos.y) / self.dist.y
|
||||
end
|
||||
|
||||
self.value = math.abs(self.value)
|
||||
|
||||
if self.steps then
|
||||
local closest_dist = 1000
|
||||
local closest = nil
|
||||
@@ -174,7 +187,7 @@ end
|
||||
--- Set value for slider
|
||||
-- @tparam Slider self @{Slider}
|
||||
-- @tparam number value Value from 0 to 1
|
||||
-- @tparam[opt] bool is_silent Don't trigger event if true
|
||||
-- @tparam boolean|nil is_silent Don't trigger event if true
|
||||
function Slider.set(self, value, is_silent)
|
||||
value = helper.clamp(value, 0, 1)
|
||||
set_position(self, value)
|
||||
@@ -202,7 +215,7 @@ end
|
||||
-- move at this position and node drag will start.
|
||||
-- This function require the Defold version 1.3.0+
|
||||
-- @tparam Slider self @{Slider}
|
||||
-- @tparam Node input_node
|
||||
-- @tparam node|string|nil input_node
|
||||
-- @treturn Slider @{Slider}
|
||||
function Slider.set_input_node(self, input_node)
|
||||
self._input_node = self:get_node(input_node)
|
||||
@@ -210,4 +223,20 @@ function Slider.set_input_node(self, input_node)
|
||||
end
|
||||
|
||||
|
||||
--- Set Slider input enabled or disabled
|
||||
-- @tparam Slider self @{Slider}
|
||||
-- @tparam boolean is_enabled
|
||||
function Slider.set_enabled(self, is_enabled)
|
||||
self._is_enabled = is_enabled
|
||||
end
|
||||
|
||||
|
||||
--- Check if Slider component is enabled
|
||||
-- @tparam Slider self @{Slider}
|
||||
-- @treturn boolean
|
||||
function Slider.is_enabled(self)
|
||||
return self._is_enabled
|
||||
end
|
||||
|
||||
|
||||
return Slider
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
-- @tparam node node
|
||||
|
||||
--- Restriction zone
|
||||
-- @tparam[opt] node click_zone
|
||||
-- @tparam node|nil click_zone
|
||||
|
||||
--- Trigger on swipe event(self, swipe_side, dist, delta_time)
|
||||
-- @tfield DruidEvent on_swipe) @{DruidEvent}
|
||||
@@ -74,9 +74,9 @@ end
|
||||
-- You can override this component styles params in druid styles table
|
||||
-- or create your own style
|
||||
-- @table style
|
||||
-- @tfield[opt=0.4] number SWIPE_TIME Maximum time for swipe trigger
|
||||
-- @tfield[opt=50] number SWIPE_THRESHOLD Minimum distance for swipe trigger
|
||||
-- @tfield[opt=false] bool SWIPE_TRIGGER_ON_MOVE If true, trigger on swipe moving, not only release action
|
||||
-- @tfield number|nil SWIPE_TIME Maximum time for swipe trigger. Default: 0.4
|
||||
-- @tfield number|nil SWIPE_THRESHOLD Minimum distance for swipe trigger. Default: 50
|
||||
-- @tfield boolean|nil SWIPE_TRIGGER_ON_MOVE If true, trigger on swipe moving, not only release action. Default: false
|
||||
function Swipe.on_style_change(self, style)
|
||||
self.style = {}
|
||||
self.style.SWIPE_TIME = style.SWIPE_TIME or 0.4
|
||||
@@ -85,7 +85,7 @@ function Swipe.on_style_change(self, style)
|
||||
end
|
||||
|
||||
|
||||
--- Component init function
|
||||
--- The @{Swipe} constructor
|
||||
-- @tparam Swipe self @{Swipe}
|
||||
-- @tparam node node Gui node
|
||||
-- @tparam function on_swipe_callback Swipe callback for on_swipe_end event
|
||||
@@ -150,7 +150,7 @@ end
|
||||
--- Strict swipe click area. Useful for
|
||||
-- restrict events outside stencil node
|
||||
-- @tparam Swipe self @{Swipe}
|
||||
-- @tparam node zone Gui node
|
||||
-- @tparam node|string|nil zone Gui node
|
||||
function Swipe.set_click_zone(self, zone)
|
||||
self.click_zone = self:get_node(zone)
|
||||
end
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user