From c85d66fdca64979780cd93d8cc02054c24f2abe9 Mon Sep 17 00:00:00 2001 From: Insality Date: Tue, 29 Oct 2024 20:31:45 +0200 Subject: [PATCH 01/50] Update annotations P.1 --- README.md | 48 +- docs_md/01-components.md | 27 - docs_md/02-creating_custom_components.md | 1 - docs_md/advanced-setup.md | 2 +- druid/annotations.lua | 1902 ----------------- druid/base/back_handler.lua | 69 +- druid/base/blocker.lua | 67 +- druid/base/button.lua | 104 +- druid/base/drag.lua | 90 +- druid/base/hover.lua | 63 +- druid/base/scroll.lua | 131 +- druid/base/static_grid.lua | 134 +- druid/base/text.lua | 77 +- druid/component.lua | 425 ++-- druid/const.lua | 13 +- druid/custom/rich_input/rich_input.gui | 146 +- druid/custom/rich_input/rich_input.lua | 77 +- druid/custom/rich_text/rich_text.lua | 47 +- druid/druid.lua | 107 +- .../editor_scripts/create_druid_component.py | 4 - druid/event.lua | 27 +- druid/extended/data_list.lua | 96 +- druid/extended/dynamic_grid.lua | 427 ---- druid/extended/hotkey.lua | 36 +- druid/extended/input.lua | 94 +- druid/extended/lang_text.lua | 34 +- druid/extended/layout.lua | 160 +- druid/extended/progress.lua | 56 +- druid/extended/slider.lua | 56 +- druid/extended/swipe.lua | 48 +- druid/extended/timer.lua | 96 +- druid/helper.lua | 237 +- druid/styles/default/style.lua | 2 - druid/system/druid_instance.lua | 407 ++-- druid/system/settings.lua | 16 +- druid/templates/component.template.lua | 17 +- druid/templates/component_full.template.lua | 28 +- example/components/container/container.lua | 14 +- .../examples/basic/blocker/basic_blocker.lua | 2 +- utils/annotations_manual.lua | 12 +- 40 files changed, 1458 insertions(+), 3941 deletions(-) delete mode 100644 druid/annotations.lua delete mode 100644 druid/extended/dynamic_grid.lua diff --git a/README.md b/README.md index 143999f..c0ba53a 100644 --- a/README.md +++ b/README.md @@ -17,13 +17,15 @@ In this example you can inspect a variety of **Druid** components and see how th ## Setup -### Dependency +### [Dependency](https://www.defold.com/manuals/libraries/) -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: +Open your `game.project` file and add the following line to the dependencies field under the project section: -**Druid v1.0** +**[Druid](https://github.com/Insality/druid/archive/refs/tags/1.0.zip)** -> [https://github.com/Insality/druid/archive/refs/tags/1.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). @@ -119,15 +121,15 @@ Here is full **Druid** components list. | Name | Description | Example |
Preview
| |------|-------------|---------|---------| -| **[Button](https://insality.github.io/druid/modules/Button.html)** | Logic over GUI Node. Handle the user click interactions: click, long click, double click, etc. | [Button Example](https://insality.github.io/druid/druid/?example=general_buttons) | | -| **[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) | | -| **[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) | | -| **[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) | | -| **[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) | | -| **[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) | | -| **[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) | | -| **[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) | | -| **[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) | | +| **[Button](https://insality.github.io/druid/modules/Button.html)** | Logic over GUI Node. Handle the user click interactions: click, long click, double click, etc. | [Button Example](https://insality.github.io/druid/druid/?example=ui_example_basic_button) | | +| **[Text](https://insality.github.io/druid/modules/Text.html)** | Logic over GUI Text. By default Text component fit the text inside text node size area with different adjust modes. | [Text Example](https://insality.github.io/druid/druid/?example=ui_example_basic_text) | | +| **[Scroll](https://insality.github.io/druid/modules/Scroll.html)** | Logic over two GUI Nodes: input and content. Provides basic behaviour for scrollable content. | [Scroll Example](https://insality.github.io/druid/druid/?example=ui_example_basic_scroll) | | +| **[Blocker](https://insality.github.io/druid/modules/Blocker.html)** | Logic over GUI Node. Don't pass any user input below node area size. | [Blocker Example](https://insality.github.io/druid/druid/?example=ui_example_basic_blocker) | | +| **[Back Handler](https://insality.github.io/druid/modules/BackHandler.html)** | Call callback on user "Back" action. It's a Android back button or keyboard backspace key | [Back Handler Example](https://insality.github.io/druid/druid/?example=ui_example_basic_back_handler) | | +| **[Static Grid](https://insality.github.io/druid/modules/StaticGrid.html)** | Logic over GUI Node. Component to manage node positions with all equal node sizes. | [Static Gid Example](https://insality.github.io/druid/druid/?example=ui_example_basic_grid) | | +| **[Hover](https://insality.github.io/druid/modules/Hover.html)** | Logic over GUI Node. Handle hover action over node. For both: mobile touch and mouse cursor. | [Hover Example](https://insality.github.io/druid/druid/?example=ui_example_basic_hover) | | +| **[Swipe](https://insality.github.io/druid/modules/Swipe.html)** | Logic over GUI Node. Handle swipe gestures over node. | [Swipe Example](https://insality.github.io/druid/druid/?example=ui_example_basic_swipe) | | +| **[Drag](https://insality.github.io/druid/modules/Drag.html)** | Logic over GUI Node. Handle drag input actions. Can be useful to make on screen controlls. | [Drag Example](https://insality.github.io/druid/druid/?example=ui_example_basic_drag) | | ### Extended components @@ -141,16 +143,16 @@ druid.register("data_list", data_list) | Name | Description | Example |
Preview
| |------|-------------|---------|---------| -| **[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) | | -| **[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) | | -| **[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) | | -| **[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) | | -| **[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) | | -| **[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) | | -| **[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) | | -| **[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) | | -| **[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) | | -| **[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) | | +| **[Data List](https://insality.github.io/druid/modules/DataList.html)** | Logic over Scroll and Grid components. Create only visible GUI nodes or components to make "infinity" scroll befaviour | [Data List Example](https://insality.github.io/druid/druid/?example=ui_example_data_list_basic) | | +| **[Input](https://insality.github.io/druid/modules/Input.html)** | Logic over GUI Node and GUI Text (or Text component). Provides basic user text input. | [Input Example](https://insality.github.io/druid/druid/?example=ui_example_basic_input) | | +| **[Lang text](https://insality.github.io/druid/modules/LangText.html)** | Logic over Text component to handle localization. Can be translated in real-time with `druid.on_language_change` | [Lang Text Example](https://insality.github.io/druid/druid/?example=ui_example_window_language) | | +| **[Progress](https://insality.github.io/druid/modules/Progress.html)** | Logic over GUI Node. Handle node size and scale to handle progress node size. | [Progress Example](https://insality.github.io/druid/druid/?example=ui_example_basic_progress_bar) | | +| **[Slider](https://insality.github.io/druid/modules/Slider.html)** | Logic over GUI Node. Handle draggable node with position restrictions. | [Slider Example](https://insality.github.io/druid/druid/?example=ui_example_basic_slider) | | +| **[Timer](https://insality.github.io/druid/modules/Timer.html)** | Logic over GUI Text. Handle basic timer functions. | [Timer Example](https://insality.github.io/druid/druid/?example=ui_example_basic_timer) | | +| **[Hotkey](https://insality.github.io/druid/modules/Hotkey.html)** | Allow to set callbacks for keyboard hotkeys with key modificators. | [Hotkey Example](https://insality.github.io/druid/druid/?example=ui_example_basic_hotkey) | | +| **[Layout](https://insality.github.io/druid/modules/Layout.html)** | Logic over GUI Node. Arrange nodes inside layout node with margin/paddings settings. | [Layout Example](https://insality.github.io/druid/druid/?example=ui_example_layout_basic) | | +| **[Rich Input](https://insality.github.io/druid/modules/RichInput.html)** | Logic over GUI Node and GUI Text (or Text component). Provides rich text input with different styles and text formatting. | [Rich Input Example](https://insality.github.io/druid/druid/?example=ui_example_basic_rich_input) | | +| **[Rich Text](https://insality.github.io/druid/modules/RichText.html)** | Logic over GUI Text. Provides rich text formatting with different styles and text formatting. | [Rich Text Example](https://insality.github.io/druid/druid/?example=ui_example_basic_rich_text) | | For a complete overview, see: **_[components.md](docs_md/01-components.md)_**. diff --git a/docs_md/01-components.md b/docs_md/01-components.md index 6aa0735..edb1fa3 100644 --- a/docs_md/01-components.md +++ b/docs_md/01-components.md @@ -227,33 +227,6 @@ Create component with druid: `grid = druid:new_static_grid(parent_node, prefab_ - _Prefab node_ used to get node size and anchor - You can point *position_function* for animations with _static_grid:set_position_function(node, pos)_ callback. Default - *gui.set_position()* - -## Dynamic Grid -[Dynamic Grid API here](https://insality.github.io/druid/modules/DynamicGrid.html) - -### Overview -Component for manage node positions with different node sizes. -Unlike Static Grid, Dynamic Grid can place nodes only in one row or in one column. -Dynamic Grid can't have gaps between elements -- you will get error, if try spawn element far away from others. -Dynamic Grid should have __West__, __East__, __South__ or __North__ pivot (vertical or horizontal element placement) - -### Setup -Create component with druid: `grid = druid:new_dynamic_grid(parent_node)` - -Check the _parent_node_ have correct pivot point. You will get the error otherwise. - -### Notes -- On _add node_ grid will set node parent to _parent_node_ -- You can get array of position of every element for setup points of interest in scroll component -- You can get size of all elements for setup size in scroll component -- You can also bind the grid to the scroll component for auto resize scroll content size -- Pivot of parent_node matter for node placement -- You can point *position_function* for animations with _static_grid:set_position_function(node, pos)_ callback. Default - *gui.set_position()* -- First node placed at Grid pivot point. Other nodes placed nearby of other nodes. -- On *add/remove* nodes always shifted. You can point the shift side in this functions (*is_shift_left* boolean argumentp - - ## Data List [Data List API here](https://insality.github.io/druid/modules/DataList.html) diff --git a/docs_md/02-creating_custom_components.md b/docs_md/02-creating_custom_components.md index 45e5a6b..bdb1ea9 100644 --- a/docs_md/02-creating_custom_components.md +++ b/docs_md/02-creating_custom_components.md @@ -148,7 +148,6 @@ Available keywords: - `text`: Adds a [Druid Text](01-components.md#text) component. - `lang_text`: Adds a [Druid Lang Text](01-components.md#lang-text) component. - `grid` or `static_grid`: Adds a [Druid Static Grid](01-components.md#static-grid) component. You should set up the Grid prefab for this component after generating the file. -- `dynamic_grid`: Adds a [Druid Dynamic Grid](01-components.md#dynamic-grid) component. - `scroll_view`: Adds a [Druid Scroll](01-components.md#scroll) component. It also adds a `scroll_content` node with the same postfix. Ensure that it's the correct node. - `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. diff --git a/docs_md/advanced-setup.md b/docs_md/advanced-setup.md index 5e047a7..ef95336 100644 --- a/docs_md/advanced-setup.md +++ b/docs_md/advanced-setup.md @@ -121,7 +121,7 @@ window.set_listener(on_window_callback) ``` -## EmmyLua Annotations +## Lua Annotations [EmmyLua](https://emmylua.github.io/annotation.html) is a Lua annotation library. It is a useful tool for enabling Lua code autocompletion in editors such as [VSCode](https://github.com/EmmyLua/VSCode-EmmyLua) and [IntelliJ IDEA](https://github.com/EmmyLua/IntelliJ-EmmyLua). diff --git a/druid/annotations.lua b/druid/annotations.lua deleted file mode 100644 index 9ccff3c..0000000 --- a/druid/annotations.lua +++ /dev/null @@ -1,1902 +0,0 @@ --- luacheck: ignore ----@meta - ----@class druid -local druid = {} - ---- Create a new Druid instance for creating GUI components. ----@param context table The Druid context. Usually, this is the self of the gui_script. It is passed into all Druid callbacks. ----@param style table|nil The Druid style table to override style parameters for this Druid instance. ----@return druid_instance The Druid instance @{DruidInstance}. -function druid.new(context, style) end - ---- Call this function when the game language changes. ---- This function will translate all current LangText components. -function druid.on_language_change() end - ---- Set the window callback to enable on_focus_gain and on_focus_lost functions. ---- This is used to trigger the on_focus_lost and on_focus_gain functions in Druid components. ----@param event string Event param from window listener -function druid.on_window_callback(event) end - ---- Register a new external Druid component. ---- You can register your own components to make new alias: the druid:new_{name} function. For example, if you want to register a component called "my_component", you can create it using druid:new_my_component(...). This can be useful if you have your own "basic" components that you don't want to re-create each time. ----@param name string module name ----@param module table lua table with component -function druid.register(name, module) end - ---- Set your own default style for all Druid instances. ---- To create your own style file, copy the default style file and make changes to it. Register the new style before creating your Druid instances. ----@param style table Druid style module -function druid.set_default_style(style) end - ---- Set the Druid sound function to play UI sounds if used. ---- Set a function to play a sound given a sound_id. This function is used for button clicks to play the "click" sound. It can also be used to play sounds in your custom components (see the default Druid style file for an example). ----@param callback function Sound play callback -function druid.set_sound_function(callback) end - ---- Set the text function for the LangText component. ---- The Druid locale component will call this function to get translated text. After setting the text function, all existing locale components will be updated. ----@param callback function Get localized text function -function druid.set_text_function(callback) end - - ----@class druid.back_handler : druid.base_component ----@field on_back druid.event The @{DruidEvent} Event on back handler action. ----@field params any|nil Custom args to pass in the callback -local druid__back_handler = {} - - ----@class druid.base_component -local druid__base_component = {} - ---- Return all children components, recursive ----@param self druid.base_component @{BaseComponent} ----@return table Array of childrens if the Druid component instance -function druid__base_component.get_childrens(self) end - ---- Context used as first arg in all Druid events ---- Context is usually self of gui_script. ----@param self druid.base_component @{BaseComponent} ----@return table BaseComponent context -function druid__base_component.get_context(self) end - ---- Get Druid instance for inner component creation. ----@param self druid.base_component @{BaseComponent} ----@param template string|nil The template name ----@param nodes table|nil The nodes table ----@return druid_instance Druid instance with component context -function druid__base_component.get_druid(self, template, nodes) end - ---- Return component input priority ----@param self druid.base_component @{BaseComponent} ----@return number The component input priority -function druid__base_component.get_input_priority(self) end - ---- Return component name ----@param self druid.base_component @{BaseComponent} ----@return string The component name -function druid__base_component.get_name(self) end - ---- Get component node by name. ---- If component has nodes, node_or_name should be string It autopick node by template name or from nodes by gui.clone_tree if they was setup via component:set_nodes, component:set_template. If node is not found, the exception will fired ----@param self druid.base_component @{BaseComponent} ----@param node_or_name string|node Node name or node itself ----@return node Gui node -function druid__base_component.get_node(self, node_or_name) end - ---- Return the parent component if exist ----@param self druid.base_component @{BaseComponent} ----@return druid.base_component|nil The druid component instance or nil -function druid__base_component.get_parent_component(self) end - ---- Return parent component name ----@param self druid.base_component @{BaseComponent} ----@return string|nil The parent component name if exist or bil -function druid__base_component.get_parent_name(self) end - ---- Get current component template name. ----@param self druid.base_component @{BaseComponent} ----@return string Component full template name -function druid__base_component.get_template(self) end - ---- Return component UID. ---- UID generated in component creation order. ----@param self druid.base_component @{BaseComponent} ----@return number The component uid -function druid__base_component.get_uid(self) end - ---- Reset component input priority to default value ----@param self druid.base_component @{BaseComponent} ----@return number The component input priority -function druid__base_component.reset_input_priority(self) end - ---- Set component input state. ---- By default it enabled If input is disabled, the component will not receive input events ----@param self druid.base_component @{BaseComponent} ----@param state boolean|nil The component input state ----@return druid.base_component BaseComponent itself -function druid__base_component.set_input_enabled(self, state) end - ---- Set component input priority ---- Default value: 10 ----@param self druid.base_component @{BaseComponent} ----@param value number The new input priority value ----@param is_temporary boolean|nil If true, the reset input priority will return to previous value ----@return number The component input priority -function druid__base_component.set_input_priority(self, value, is_temporary) end - - ----@class druid.blocker : druid.base_component ----@field node node Blocker node -local druid__blocker = {} - ---- The @{Blocker} constructor ----@param self druid.blocker @{Blocker} ----@param node node Gui node -function druid__blocker.init(self, node) end - ---- Return blocker enabled state ----@param self druid.blocker @{Blocker} ----@return boolean @True, if blocker is enabled -function druid__blocker.is_enabled(self) end - ---- Set enabled blocker component state. ---- Don't change node enabled state itself. ----@param self druid.blocker @{Blocker} ----@param state boolean|nil Enabled state -function druid__blocker.set_enabled(self, state) end - - ----@class druid.button : druid.base_component ----@field anim_node node|nil Button animation node. ----@field click_zone node|nil Additional button click area, defined by another GUI node ----@field hover druid.hover The @{Hover}: Button Hover component ----@field node node Button trigger node ----@field node_id hash The GUI node id from button node ----@field on_click druid.event The @{DruidEvent}: Event on successful release action over button. ----@field on_click_outside druid.event The @{DruidEvent}: Event calls if click event was outside of button. ----@field on_double_click druid.event The @{DruidEvent}: Event on double tap action over button. ----@field on_hold_callback druid.event The @{DruidEvent}: Event calls every frame before on_long_click event. ----@field on_long_click druid.event The @{DruidEvent}: Event on long tap action over button. ----@field on_pressed druid.event The @{DruidEvent}: Event triggered if button was pressed by user. ----@field on_repeated_click druid.event The @{DruidEvent}: Event on repeated action over button. ----@field params any Custom args for any Button event. ----@field style druid.button.style Component style params. -local druid__button = {} - ---- Get current key name to trigger this button. ----@param self druid.button ----@return hash The action_id of the input key -function druid__button.get_key_trigger(self) end - ---- The @{Button} constructor ----@param self druid.button @{Button} ----@param node string|node The node_id or gui.get_node(node_id) ----@param callback function On click button callback ----@param custom_args any|nil Button events custom arguments ----@param anim_node string|node|nil Node to animate instead of trigger node. -function druid__button.init(self, node, callback, custom_args, anim_node) end - ---- Get button enabled state. ---- By default all Buttons is enabled on creating. ----@param self druid.button @{Button} ----@return boolean @True, if button is enabled now, False overwise -function druid__button.is_enabled(self) end - ---- Set function for additional check for button click availability ----@param self druid.button ----@param check_function function|nil Should return true or false. If true - button can be pressed. ----@param failure_callback function|nil Function will be called on button click, if check function return false ----@return druid.button Current button instance -function druid__button.set_check_function(self, check_function, failure_callback) end - ---- Set additional button click area. ---- Useful to restrict click outside out stencil node or scrollable content. This functions calls automatically if you don't disable it in game.project: druid.no_stencil_check ----@param self druid.button @{Button} ----@param zone node|string|nil Gui node ----@return druid.button Current button instance -function druid__button.set_click_zone(self, zone) end - ---- Set button enabled state. ---- The style.on_set_enabled will be triggered. Disabled button is not clickable. ----@param self druid.button @{Button} ----@param state boolean|nil Enabled state ----@return druid.button Current button instance -function druid__button.set_enabled(self, state) end - ---- Set key name to trigger this button by keyboard. ----@param self druid.button @{Button} ----@param key hash|string The action_id of the input key ----@return druid.button Current button instance -function druid__button.set_key_trigger(self, key) end - ---- Set Button mode to work inside user HTML5 interaction event. ---- It's required to make protected things like copy & paste text, show mobile keyboard, etc The HTML5 button's doesn't call any events except on_click event. If the game is not HTML, html mode will be not enabled ----@param self druid.button ----@param is_web_mode boolean|nil If true - button will be called inside html5 callback ----@return druid.button Current button instance -function druid__button.set_web_user_interaction(self, is_web_mode) end - - ----@class druid.button.style ----@field AUTOHOLD_TRIGGER number|nil Maximum hold time to trigger button release while holding. Default: 0.8 ----@field DOUBLETAP_TIME number|nil Time between double taps. Default: 0.4 ----@field LONGTAP_TIME number|nil Minimum time to trigger on_hold_callback. Default: 0.4 ----@field on_click function function(self, node) ----@field on_click_disabled function function(self, node) ----@field on_hover function function(self, node, hover_state) ----@field on_mouse_hover function function(self, node, hover_state) ----@field on_set_enabled function function(self, node, enabled_state) -local druid__button__style = {} - - ----@class druid.data_list : druid.base_component ----@field grid druid.static_grid The Druid Grid component ----@field last_index number The current last index of visual elements ----@field on_element_add druid.event On DataList visual element created Event callback(self, index, node, instance) ----@field on_element_remove druid.event On DataList visual element created Event callback(self, index) ----@field on_scroll_progress_change druid.event Event triggered when scroll progress is changed; event(self, progress_value) ----@field scroll druid.scroll The Druid scroll component ----@field scroll_progress number The current progress of scroll posititon ----@field top_index number The current top index of visual elements -local druid__data_list = {} - ---- Add element to DataList. ---- Currenly untested ----@param self druid.data_list @{DataList} ----@param data table ----@param index number|nil ----@param shift_policy number|nil The constant from const.SHIFT.* -function druid__data_list.add(self, data, index, shift_policy) end - ---- Clear the DataList and refresh visuals ----@param self druid.data_list @{DataList} -function druid__data_list.clear(self) end - ---- Return all currenly created components in DataList ----@param self druid.data_list @{DataList} ----@return druid.base_component[] List of created nodes -function druid__data_list.get_created_components(self) end - ---- Return all currenly created nodes in DataList ----@param self druid.data_list @{DataList} ----@return node[] List of created nodes -function druid__data_list.get_created_nodes(self) end - ---- Return current data from DataList component ----@param self druid.data_list @{DataList} ----@return table The current data array -function druid__data_list.get_data(self) end - ---- Return index for data value ----@param self druid.data_list @{DataList} ----@param data table -function druid__data_list.get_index(self, data) end - ---- The @{DataList} constructor ----@param self druid.data_list @{DataList} ----@param scroll druid.scroll The @{Scroll} instance for Data List component ----@param grid druid.static_grid The @{StaticGrid} or @{DynamicGrid} instance for Data List component ----@param create_function function The create function callback(self, data, index, data_list). Function should return (node, [component]) -function druid__data_list.init(self, scroll, grid, create_function) end - ---- Druid System on_remove function ----@param self druid.data_list @{DataList} -function druid__data_list.on_remove(self) end - ---- Remove element from DataList. ---- Currenly untested ----@param self druid.data_list @{DataList} ----@param index number|nil ----@param shift_policy number|nil The constant from const.SHIFT.* -function druid__data_list.remove(self, index, shift_policy) end - ---- Remove element from DataList by data value. ---- Currenly untested ----@param self druid.data_list @{DataList} ----@param data table ----@param shift_policy number|nil The constant from const.SHIFT.* -function druid__data_list.remove_by_data(self, data, shift_policy) end - ---- Instant scroll to element with passed index ----@param self druid.data_list @{DataList} ----@param index number -function druid__data_list.scroll_to_index(self, index) end - ---- Set new data set for DataList component ----@param self druid.data_list @{DataList} ----@param data table The new data array ----@return druid.data_list Current DataList instance -function druid__data_list.set_data(self, data) end - ---- Set refresh function for DataList component ----@param self druid.data_list @{DataList} ----@param is_use_cache boolean Use cache version of DataList. Requires make setup of components in on_element_add callback and clean in on_element_remove ----@return druid.data_list Current DataList instance -function druid__data_list.set_use_cache(self, is_use_cache) end - - ----@class druid.drag : druid.base_component ----@field can_x boolean Is drag component process vertical dragging. ----@field can_y boolean Is drag component process horizontal. ----@field is_drag boolean Is component now dragging ----@field is_touch boolean Is component now touching ----@field node node Drag node ----@field on_drag druid.event on drag progress callback(self, dx, dy, total_x, total_y, touch) ----@field on_drag_end druid.event Event on drag end callback(self, total_x, total_y, touch) ----@field on_drag_start druid.event Event on drag start callback(self, touch) ----@field on_touch_end druid.event Event on touch end callback(self) ----@field on_touch_start druid.event Event on touch start callback(self) ----@field screen_x number Current touch x screen position ----@field screen_y number Current touch y screen position ----@field style druid.drag.style Component style params. ----@field touch_start_pos vector3 Touch start position ----@field x number Current touch x position ----@field y number Current touch y position -local druid__drag = {} - ---- The @{Drag} constructor ----@param self druid.drag @{Drag} ----@param node node GUI node to detect dragging ----@param on_drag_callback function Callback for on_drag_event(self, dx, dy) -function druid__drag.init(self, node, on_drag_callback) end - ---- Check if Drag component is enabled ----@param self druid.drag @{Drag} ----@return boolean -function druid__drag.is_enabled(self) end - ---- Strict drag click area. ---- Useful for restrict events outside stencil node ----@param self druid.drag @{Drag} ----@param node node|string|nil Gui node -function druid__drag.set_click_zone(self, node) end - ---- Set Drag input enabled or disabled ----@param self druid.drag @{Drag} ----@param is_enabled boolean|nil -function druid__drag.set_enabled(self, is_enabled) end - - ----@class druid.drag.style ----@field DRAG_DEADZONE number|nil Distance in pixels to start dragging. Default: 10 ----@field NO_USE_SCREEN_KOEF boolean|nil If screen aspect ratio affects on drag values. Default: false -local druid__drag__style = {} - - ----@class druid.dynamic_grid : druid.base_component ----@field border vector4 The size of item content ----@field first_index number The first index of node in grid ----@field last_index number The last index of node in grid ----@field node_size vector3 Item size ----@field nodes node[] List of all grid elements. ----@field on_add_item druid.event On item add callback(self, node, index) ----@field on_change_items druid.event On item add or remove callback(self, index) ----@field on_clear druid.event On grid clear callback(self) ----@field on_remove_item druid.event On item remove callback(self, index) ----@field on_update_positions druid.event On update item positions callback(self) ----@field parent node Parent gui node -local druid__dynamic_grid = {} - ---- Return side vector to correct node shifting ----@param self unknown ----@param side unknown ----@param is_forward unknown -function druid__dynamic_grid._get_side_vector(self, side, is_forward) end - ---- Add new node to the grid ----@param self druid.dynamic_grid @{DynamicGrid} ----@param node node Gui node ----@param index number|nil The node position. By default add as last node ----@param shift_policy number|nil How shift nodes, if required. Default: const.SHIFT.RIGHT ----@param is_instant boolean|nil If true, update node positions instantly -function druid__dynamic_grid.add(self, node, index, shift_policy, is_instant) end - ---- Clear grid nodes array. ---- GUI nodes will be not deleted! If you want to delete GUI nodes, use dynamic_grid.nodes array before grid:clear ----@param self druid.dynamic_grid @{DynamicGrid} ----@return druid.dynamic_grid Current grid instance -function druid__dynamic_grid.clear(self) end - ---- Return array of all node positions ----@param self druid.dynamic_grid @{DynamicGrid} ----@return vector3[] All grid node positions -function druid__dynamic_grid.get_all_pos(self) end - ---- Return grid content borders ----@param self druid.dynamic_grid @{DynamicGrid} ----@return vector3 The grid content borders -function druid__dynamic_grid.get_borders(self) end - ---- Return grid index by node ----@param self druid.dynamic_grid @{DynamicGrid} ----@param node node The gui node in the grid ----@return number The node index -function druid__dynamic_grid.get_index_by_node(self, node) end - ---- Return DynamicGrid offset, where DynamicGrid content starts. ----@param self druid.dynamic_grid @{DynamicGrid} The DynamicGrid instance ----@return vector3 The DynamicGrid offset -function druid__dynamic_grid.get_offset(self) end - ---- Return pos for grid node index ----@param self druid.dynamic_grid @{DynamicGrid} ----@param index number The grid element index ----@param node node The node to be placed ----@param origin_index number|nil Index of nearby node ----@return vector3 node position -function druid__dynamic_grid.get_pos(self, index, node, origin_index) end - ---- Return grid content size ----@param self druid.dynamic_grid @{DynamicGrid} ----@param border vector3 ----@return vector3 The grid content size -function druid__dynamic_grid.get_size(self, border) end - ---- The @{DynamicGrid} constructor ----@param self druid.dynamic_grid @{DynamicGrid} ----@param parent node The gui node parent, where items will be placed -function druid__dynamic_grid.init(self, parent) end - ---- Remove the item from the grid. ---- Note that gui node will be not deleted ----@param self druid.dynamic_grid @{DynamicGrid} ----@param index number The grid node index to remove ----@param shift_policy number|nil How shift nodes, if required. Default: const.SHIFT.RIGHT ----@param is_instant boolean|nil If true, update node positions instantly ----@return node The deleted gui node from grid -function druid__dynamic_grid.remove(self, index, shift_policy, is_instant) end - ---- Change set position function for grid nodes. ---- It will call on update poses on grid elements. Default: gui.set_position ----@param self druid.dynamic_grid @{DynamicGrid} ----@param callback function Function on node set position ----@return druid.dynamic_grid Current grid instance -function druid__dynamic_grid.set_position_function(self, callback) end - - ----@class druid.event -local druid__event = {} - ---- Clear the all event handlers ----@param self druid.event @{DruidEvent} -function druid__event.clear(self) end - ---- DruidEvent constructor ----@param callback function|nil Subscribe the callback on new event, if callback exist ----@param callback_context any|nil Additional context as first param to callback call -function druid__event.create(callback, callback_context) end - ---- Return true, if event not have handler ----@param self druid.event @{DruidEvent} ----@return boolean True if event not have handlers -function druid__event.is_empty(self) end - ---- Return true, if event have at lease one handler ----@param self druid.event @{DruidEvent} ----@return boolean True if event have handlers -function druid__event.is_exist(self) end - ---- Check is event subscribed. ----@param self druid.event @{DruidEvent} ----@param callback function Callback itself ----@param callback_context any|nil Additional context as first param to callback call ----@return boolean, number|nil @Is event subscribed, return index of callback in event as second param -function druid__event.is_subscribed(self, callback, callback_context) end - ---- Subscribe callback on event ----@param self druid.event @{DruidEvent} ----@param callback function Callback itself ----@param callback_context any|nil Additional context as first param to callback call, usually it's self ----@return boolean True if callback was subscribed -function druid__event.subscribe(self, callback, callback_context) end - ---- Trigger the event and call all subscribed callbacks ----@param self druid.event @{DruidEvent} ----@param ... any All event params -function druid__event.trigger(self, ...) end - ---- Unsubscribe callback on event ----@param self druid.event @{DruidEvent} ----@param callback function Callback itself ----@param callback_context any|nil Additional context as first param to callback call -function druid__event.unsubscribe(self, callback, callback_context) end - - ----@class druid.hotkey : druid.base_component ----@field button druid.button Button component from click_node ----@field click_node node|nil Button trigger node ----@field node node Visual node ----@field on_hotkey_pressed druid.event On hotkey released callback(self, argument) ----@field on_hotkey_released druid.event On hotkey released callback(self, argument) ----@field style druid.hotkey.style Component style params. -local druid__hotkey = {} - ---- Add hotkey for component callback ----@param self druid.hotkey @{Hotkey} ----@param keys string[]|hash[]|string|hash that have to be pressed before key pressed to activate ----@param callback_argument any|nil The argument to pass into the callback function ----@return druid.hotkey Current instance -function druid__hotkey.add_hotkey(self, keys, callback_argument) end - ---- The @{Hotkey} constructor ----@param self druid.hotkey @{Hotkey} ----@param keys string[]|string The keys to be pressed for trigger callback. Should contains one key and any modificator keys ----@param callback function The callback function ----@param callback_argument any|nil The argument to pass into the callback function -function druid__hotkey.init(self, keys, callback, callback_argument) end - ---- If true, the callback will be triggered on action.repeated ----@param self druid.hotkey @{Hotkey} ----@param is_enabled_repeated bool The flag value ----@return druid.hotkey -function druid__hotkey.set_repeat(self, is_enabled_repeated) end - - ----@class druid.hotkey.style ----@field MODIFICATORS string[] The list of action_id as hotkey modificators -local druid__hotkey__style = {} - - ----@class druid.hover : druid.base_component ----@field node node Hover node ----@field on_hover druid.event On hover callback(self, state, hover_instance) ----@field on_mouse_hover druid.event On mouse hover callback(self, state, hover_instance) ----@field style druid.hover.style Component style params. -local druid__hover = {} - ---- The @{Hover} constructor ----@param self druid.hover @{Hover} ----@param node node Gui node ----@param on_hover_callback function Hover callback ----@param on_mouse_hover function On mouse hover callback -function druid__hover.init(self, node, on_hover_callback, on_mouse_hover) end - ---- Return current hover enabled state ----@param self druid.hover @{Hover} ----@return boolean The hover enabled state -function druid__hover.is_enabled(self) end - ---- Return current hover state. ---- True if touch action was on the node at current time ----@param self druid.hover @{Hover} ----@return boolean The current hovered state -function druid__hover.is_hovered(self) end - ---- Return current hover state. ---- True if nil action_id (usually desktop mouse) was on the node at current time ----@param self druid.hover @{Hover} ----@return boolean The current hovered state -function druid__hover.is_mouse_hovered(self) end - ---- Strict hover click area. ---- Useful for no click events outside stencil node ----@param self druid.hover @{Hover} ----@param zone node|string|nil Gui node -function druid__hover.set_click_zone(self, zone) end - ---- Set enable state of hover component. ---- If hover is not enabled, it will not generate any hover events ----@param self druid.hover @{Hover} ----@param state boolean|nil The hover enabled state -function druid__hover.set_enabled(self, state) end - ---- Set hover state ----@param self druid.hover @{Hover} ----@param state boolean|nil The hover state -function druid__hover.set_hover(self, state) end - ---- Set mouse hover state ----@param self druid.hover @{Hover} ----@param state boolean|nil The mouse hover state -function druid__hover.set_mouse_hover(self, state) end - - ----@class druid.hover.style ----@field ON_HOVER_CURSOR string Mouse hover style on node hover ----@field ON_MOUSE_HOVER_CURSOR string Mouse hover style on node mouse hover -local druid__hover__style = {} - - ----@class druid.input : druid.base_component ----@field allowerd_characters string|nil Pattern matching for user input ----@field button druid.button Button component ----@field current_value string Current input value with marked text ----@field cursor_index number The cursor index. ----@field end_index number Theselection end index. ----@field is_empty boolean Is current input is empty now ----@field is_selected boolean Is current input selected now ----@field keyboard_type number Gui keyboard type for input field ----@field marked_text_width number Marked text width ----@field marked_value string Marked text for input field. ----@field max_length number|nil Max length for input text ----@field on_input_empty druid.event On input field text change to empty string callback(self, input_text) ----@field on_input_full druid.event On input field text change to max length string callback(self, input_text) ----@field on_input_select druid.event On input field select callback(self, input_instance) ----@field on_input_text druid.event On input field text change callback(self, input_text) ----@field on_input_unselect druid.event On input field unselect callback(self, input_text, input_instance) ----@field on_input_wrong druid.event On trying user input with not allowed character callback(self, params, input_text) ----@field on_select_cursor_change druid.event On cursor position change callback(self, cursor_index, start_index, end_index) ----@field previous_value string Previous input value ----@field start_index number The selection start index. ----@field style druid.input.style Component style params. ----@field text druid.text Text component ----@field text_width number Text width ----@field value string Current input value -local druid__input = {} - ---- Return current input field text ----@param self druid.input @{Input} ----@return string The current input field text -function druid__input.get_text(self) end - ---- Replace selected text with new text ----@param self druid.input @{Input} ----@param text string The text to replace selected text ----@return string New input text -function druid__input.get_text_selected_replaced(self, text) end - ---- The @{Input} constructor ----@param self druid.input @{Input} ----@param click_node node Node to enabled input component ----@param text_node node|druid.text Text node what will be changed on user input. You can pass text component instead of text node name @{Text} ----@param keyboard_type number|nil Gui keyboard type for input field -function druid__input.init(self, click_node, text_node, keyboard_type) end - ---- Change cursor position by delta ----@param self druid.input @{Input} ----@param delta number side for cursor position, -1 for left, 1 for right ----@param is_add_to_selection boolean (Shift key) ----@param is_move_to_end boolean (Ctrl key) -function druid__input.move_selection(self, delta, is_add_to_selection, is_move_to_end) end - ---- Reset current input selection and return previous value ----@param self druid.input @{Input} ----@return druid.input Current input instance -function druid__input.reset_changes(self) end - ---- Select input field. ---- It will show the keyboard and trigger on_select events ----@param self druid.input @{Input} -function druid__input.select(self) end - ---- Set cursor position in input field ----@param self druid.input @{Input} ----@param cursor_index number|nil Cursor index for cursor position, if nil - will be set to the end of the text ----@param start_index number|nil Start index for cursor position, if nil - will be set to the end of the text ----@param end_index number|nil End index for cursor position, if nil - will be set to the start_index ----@return druid.input Current input instance -function druid__input.select_cursor(self, cursor_index, start_index, end_index) end - ---- Set allowed charaters for input field. ---- See: https://defold.com/ref/stable/string/ ex: [%a%d] for alpha and numeric ----@param self druid.input @{Input} ----@param characters string Regulax exp. for validate user input ----@return druid.input Current input instance -function druid__input.set_allowed_characters(self, characters) end - ---- Set maximum length for input field. ---- Pass nil to make input field unliminted (by default) ----@param self druid.input @{Input} ----@param max_length number Maximum length for input text field ----@return druid.input Current input instance -function druid__input.set_max_length(self, max_length) end - ---- Set text for input field ----@param self druid.input @{Input} ----@param input_text string The string to apply for input field -function druid__input.set_text(self, input_text) end - ---- Remove selection from input. ---- It will hide the keyboard and trigger on_unselect events ----@param self druid.input @{Input} -function druid__input.unselect(self) end - - ----@class druid.input.style ----@field IS_LONGTAP_ERASE boolean Is long tap will erase current input data. Default: false ----@field IS_UNSELECT_ON_RESELECT boolean If true, call unselect on select selected input. Default: false ----@field MASK_DEFAULT_CHAR string Default character mask for password input. Default: *] ----@field on_input_wrong function (self, button_node) Callback on wrong user input ----@field on_select function (self, button_node) Callback on input field selecting ----@field on_unselect function (self, button_node) Callback on input field unselecting -local druid__input__style = {} - - ----@class druid.lang_text : druid.base_component ----@field node node Text node ----@field on_change druid.event On change text callback ----@field text druid.text The text component -local druid__lang_text = {} - ---- Format string with new text params on localized text ----@param self druid.lang_text @{LangText} ----@param a string|nil Optional param to string.format ----@param b string|nil Optional param to string.format ----@param c string|nil Optional param to string.format ----@param d string|nil Optional param to string.format ----@param e string|nil Optional param to string.format ----@param f string|nil Optional param to string.format ----@param g string|nil Optional param to string.format ----@return druid.lang_text Current instance -function druid__lang_text.format(self, a, b, c, d, e, f, g) end - ---- The @{LangText} constructor ----@param self druid.lang_text @{LangText} ----@param node string|node The node_id or gui.get_node(node_id) ----@param locale_id string|nil Default locale id or text from node as default ----@param adjust_type string|nil Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference -function druid__lang_text.init(self, node, locale_id, adjust_type) end - ---- Setup raw text to lang_text component ----@param self druid.lang_text @{LangText} ----@param text string Text for text node ----@return druid.lang_text Current instance -function druid__lang_text.set_to(self, text) end - ---- Translate the text by locale_id ----@param self druid.lang_text @{LangText} ----@param locale_id string Locale id ----@param a string|nil Optional param to string.format ----@param b string|nil Optional param to string.format ----@param c string|nil Optional param to string.format ----@param d string|nil Optional param to string.format ----@param e string|nil Optional param to string.format ----@param f string|nil Optional param to string.format ----@param g string|nil Optional param to string.format ----@return druid.lang_text Current instance -function druid__lang_text.translate(self, locale_id, a, b, c, d, e, f, g) end - - ----@class druid.layout : druid.base_component ----@field mode string Current layout mode ----@field node node Layout node -local druid__layout = {} - - ----@class druid.progress : druid.base_component ----@field key string The progress bar direction. ----@field max_size number Maximum size of progress bar ----@field node node Progress bar fill node ----@field on_change druid.event On progress bar change callback(self, new_value) ----@field scale vector3 Current progress bar scale ----@field size vector3 Current progress bar size ----@field slice vector4 Progress bar slice9 settings ----@field style druid.progress.style Component style params. -local druid__progress = {} - ---- Empty a progress bar ----@param self druid.progress @{Progress} -function druid__progress.empty(self) end - ---- Fill a progress bar and stop progress animation ----@param self druid.progress @{Progress} -function druid__progress.fill(self) end - ---- Return current progress bar value ----@param self druid.progress @{Progress} -function druid__progress.get(self) end - ---- The @{Progress} constructor ----@param self druid.progress @{Progress} ----@param node string|node Node name or GUI Node itself. ----@param key string Progress bar direction: const.SIDE.X or const.SIDE.Y ----@param init_value number|nil Initial value of progress bar. Default: 1 -function druid__progress.init(self, node, key, init_value) end - ---- Set progress bar max node size ----@param self druid.progress @{Progress} ----@param max_size vector3 The new node maximum (full) size ----@return druid.progress @{Progress} -function druid__progress.set_max_size(self, max_size) end - ---- Set points on progress bar to fire the callback ----@param self druid.progress @{Progress} ----@param steps number[] Array of progress bar values ----@param callback function Callback on intersect step value -function druid__progress.set_steps(self, steps, callback) end - ---- Instant fill progress bar to value ----@param self druid.progress @{Progress} ----@param to number Progress bar value, from 0 to 1 -function druid__progress.set_to(self, to) end - ---- Start animation of a progress bar ----@param self druid.progress @{Progress} ----@param to number value between 0..1 ----@param callback function|nil Callback on animation ends -function druid__progress.to(self, to, callback) end - - ----@class druid.progress.style ----@field MIN_DELTA number|nil Minimum step to fill progress bar. Default: 0.005 ----@field SPEED number|nil Progress bas fill rate. More -> faster. Default: 5 -local druid__progress__style = {} - - ----@class druid.rich_input ----@field cursor node On input field text change to empty string callback(self, input_text) ----@field cursor_position vector3 On input field text change to empty string callback(self, input_text) ----@field cursor_text node On input field text change to empty string callback(self, input_text) ----@field drag druid.drag On input field text change to empty string callback(self, input_text) ----@field druid druid_instance The component druid instance ----@field input druid.input On input field text change callback(self, input_text) ----@field input_text druid.text On input field text change to empty string callback(self, input_text) ----@field placeholder druid.text On input field text change to empty string callback(self, input_text) ----@field root node Root node ----@field text_position vector3 On input field text change to empty string callback(self, input_text) -local druid__rich_input = {} - ---- Set input field text ----@param self druid.rich_input @{RichInput} -function druid__rich_input.get_text(self) end - ---- The @{RichInput} constructor ----@param self druid.rich_input @{RichInput} ----@param template string The template string name ----@param nodes table Nodes table from gui.clone_tree -function druid__rich_input.init(self, template, nodes) end - ---- Select input field ----@param self druid.rich_input @{RichInput} -function druid__rich_input.select(self) end - ---- Set allowed charaters for input field. ---- See: https://defold.com/ref/stable/string/ ex: [%a%d] for alpha and numeric ----@param self druid.rich_input @{RichInput} ----@param characters string Regulax exp. for validate user input ----@return druid.rich_input Current instance -function druid__rich_input.set_allowed_characters(self, characters) end - ---- Set input field font ----@param self druid.rich_input @{RichInput} ----@param font hash The font hash ----@return druid.input Current input instance -function druid__rich_input.set_font(self, font) end - ---- Set placeholder text ----@param self druid.rich_input @{RichInput} ----@param placeholder_text string The placeholder text -function druid__rich_input.set_placeholder(self, placeholder_text) end - ---- Set input field text ----@param self druid.rich_input @{RichInput} ----@param text string The input text ----@return druid.input Current input instance -function druid__rich_input.set_text(self, text) end - - ----@class druid.rich_text : druid.base_component ----@field druid druid_instance The component druid instance ----@field root node The root node of the Rich Text ----@field style druid.rich_text.style Component style params. ----@field text_prefab node The text prefab node -local druid__rich_text = {} - ---- Split a word into it's characters ----@param self druid.rich_text @{RichText} ----@param word druid.rich_text.word ----@return druid.rich_text.word[] characters -function druid__rich_text.characters(self, word) end - ---- Clear all created words. -function druid__rich_text.clear() end - ---- Get current line metrics ----@return druid.rich_text.lines_metrics -function druid__rich_text.get_line_metric() end - ---- Get current text ----@param self druid.rich_text @{RichText} ----@return string text -function druid__rich_text.get_text(self) end - ---- Get all current words. ----@return table druid.rich_text.word[] -function druid__rich_text.get_words() end - ---- The @{RichText} constructor ----@param self druid.rich_text @{RichText} ----@param text_node node|string The text node to make Rich Text ----@param value string|nil The initial text value. Default will be gui.get_text(text_node) -function druid__rich_text.init(self, text_node, value) end - ---- Set text for Rich Text ----@param self druid.rich_text @{RichText} ----@param text string|nil The text to set ----@return druid.rich_text.word[] words ----@return druid.rich_text.lines_metrics line_metrics -function druid__rich_text.set_text(self, text) end - ---- Get all words, which has a passed tag. ----@param self druid.rich_text @{RichText} ----@param tag string ----@return druid.rich_text.word[] words -function druid__rich_text.tagged(self, tag) end - - ----@class druid.rich_text.style ----@field ADJUST_SCALE_DELTA number|nil Scale step on each height adjust step. Default: 0.02 ----@field ADJUST_STEPS number|nil Amount steps of attemps text adjust by height. Default: 20 ----@field COLORS table|nil Rich Text color aliases. Default: {} -local druid__rich_text__style = {} - - ----@class druid.scroll : druid.base_component ----@field _is_inert boolean Flag, if scroll now moving by inertion ----@field available_pos vector4 Available position for content node: (min_x, max_y, max_x, min_y) ----@field available_size vector3 Size of available positions: (width, height, 0) ----@field content_node node Scroll content node ----@field drag druid.drag Drag Druid component ----@field inertion vector3 Current inert speed ----@field is_animate boolean Flag, if scroll now animating by gui.animate ----@field on_point_scroll druid.event On scroll_to_index function callback(self, index, point) ----@field on_scroll druid.event On scroll move callback(self, position) ----@field on_scroll_to druid.event On scroll_to function callback(self, target, is_instant) ----@field position vector3 Current scroll posisition ----@field selected number|nil Current index of points of interests ----@field style druid.scroll.style Component style params. ----@field target_position vector3 Current scroll target position ----@field view_node node Scroll view node ----@field view_size vector3 Scroll view size -local druid__scroll = {} - ---- Bind the grid component (Static or Dynamic) to recalculate scroll size on grid changes ----@param self druid.scroll @{Scroll} ----@param grid druid.static_grid Druid grid component ----@return druid.scroll Current scroll instance -function druid__scroll.bind_grid(self, grid) end - ---- Return current scroll progress status. ---- Values will be in [0..1] interval ----@param self druid.scroll @{Scroll} ----@return vector3 New vector with scroll progress values -function druid__scroll.get_percent(self) end - ---- Return vector of scroll size with width and height. ----@param self druid.scroll @{Scroll} ----@return vector3 Available scroll size -function druid__scroll.get_scroll_size(self) end - ---- The @{Scroll} constructor ----@param self druid.scroll @{Scroll} ----@param view_node string|node GUI view scroll node ----@param content_node string|node GUI content scroll node -function druid__scroll.init(self, view_node, content_node) end - ---- Return if scroll have inertion. ----@param self druid.scroll @{Scroll} ----@return boolean @If scroll have inertion -function druid__scroll.is_inert(self) end - ---- Check node if it visible now on scroll. ---- Extra border is not affected. Return true for elements in extra scroll zone ----@param self druid.scroll @{Scroll} ----@param node node The node to check ----@return boolean True if node in visible scroll area -function druid__scroll.is_node_in_view(self, node) end - ---- Start scroll to target point. ----@param self druid.scroll @{Scroll} ----@param point vector3 Target point ----@param is_instant boolean|nil Instant scroll flag -function druid__scroll.scroll_to(self, point, is_instant) end - ---- Scroll to item in scroll by point index. ----@param self druid.scroll @{Scroll} ----@param index number Point index ----@param skip_cb boolean|nil If true, skip the point callback -function druid__scroll.scroll_to_index(self, index, skip_cb) end - ---- Start scroll to target scroll percent ----@param self druid.scroll @{Scroll} ----@param percent vector3 target percent ----@param is_instant boolean|nil instant scroll flag -function druid__scroll.scroll_to_percent(self, percent, is_instant) end - ---- Strict drag scroll area. ---- Useful for restrict events outside stencil node ----@param self druid.drag ----@param node node|string Gui node -function druid__scroll.set_click_zone(self, node) end - ---- Set extra size for scroll stretching. ---- Set 0 to disable stretching effect ----@param self druid.scroll @{Scroll} ----@param stretch_size number|nil Size in pixels of additional scroll area ----@return druid.scroll Current scroll instance -function druid__scroll.set_extra_stretch_size(self, stretch_size) end - ---- Lock or unlock horizontal scroll ----@param self druid.scroll @{Scroll} ----@param state boolean|nil True, if horizontal scroll is enabled ----@return druid.scroll Current scroll instance -function druid__scroll.set_horizontal_scroll(self, state) end - ---- Enable or disable scroll inert. ---- If disabled, scroll through points (if exist) If no points, just simple drag without inertion ----@param self druid.scroll @{Scroll} ----@param state boolean|nil Inert scroll state ----@return druid.scroll Current scroll instance -function druid__scroll.set_inert(self, state) end - ---- Set points of interest. ---- Scroll will always centered on closer points ----@param self druid.scroll @{Scroll} ----@param points table Array of vector3 points ----@return druid.scroll Current scroll instance -function druid__scroll.set_points(self, points) end - ---- Set scroll content size. ---- It will change content gui node size ----@param self druid.scroll @{Scroll} ----@param size vector3 The new size for content node ----@param offset vector3|nil Offset value to set, where content is starts ----@return druid.scroll Current scroll instance -function druid__scroll.set_size(self, size, offset) end - ---- Lock or unlock vertical scroll ----@param self druid.scroll @{Scroll} ----@param state boolean|nil True, if vertical scroll is enabled ----@return druid.scroll Current scroll instance -function druid__scroll.set_vertical_scroll(self, state) end - ---- Set new scroll view size in case the node size was changed. ----@param self druid.scroll @{Scroll} ----@param size vector3 The new size for view node ----@return druid.scroll Current scroll instance -function druid__scroll.set_view_size(self, size) end - ---- Refresh scroll view size ----@param self druid.scroll @{Scroll} -function druid__scroll.update_view_size(self) end - - ----@class druid.scroll.style ----@field ANIM_SPEED number|nil Scroll gui.animation speed for scroll_to function. Default: 2 ----@field BACK_SPEED number|nil Scroll back returning lerp speed. Default: 35 ----@field EXTRA_STRETCH_SIZE number|nil extra size in pixels outside of scroll (stretch effect). Default: 0 ----@field FRICT number|nil Multiplier for free inertion. Default: 0 ----@field FRICT_HOLD number|nil Multiplier for inertion, while touching. Default: 0 ----@field INERT_SPEED number|nil Multiplier for inertion speed. Default: 30 ----@field INERT_THRESHOLD number|nil Scroll speed to stop inertion. Default: 3 ----@field POINTS_DEADZONE number|nil Speed to check points of interests in no_inertion mode. Default: 20 ----@field SMALL_CONTENT_SCROLL boolean|nil If true, content node with size less than view node size can be scrolled. Default: false ----@field WHEEL_SCROLL_BY_INERTION boolean|nil If true, wheel will add inertion to scroll. Direct set position otherwise.. Default: false ----@field WHEEL_SCROLL_INVERTED boolean|nil If true, invert direction for touchpad and mouse wheel scroll. Default: false ----@field WHEEL_SCROLL_SPEED boolean|nil The scroll speed via mouse wheel scroll or touchpad. Set to 0 to disable wheel scrolling. Default: 0 -local druid__scroll__style = {} - - ----@class druid.slider : druid.base_component ----@field dist vector3 Length between start and end position ----@field end_pos vector3 End pin node position ----@field is_drag boolean Current drag state ----@field node node Slider pin node ----@field on_change_value druid.event On change value callback(self, value) ----@field pos vector3 Current pin node position ----@field start_pos vector3 Start pin node position ----@field target_pos vector3 Targer pin node position ----@field value number Current slider value -local druid__slider = {} - ---- The @{Slider} constructor ----@param self druid.slider @{Slider} ----@param node node Gui pin node ----@param end_pos vector3 The end position of slider ----@param callback function|nil On slider change callback -function druid__slider.init(self, node, end_pos, callback) end - ---- Check if Slider component is enabled ----@param self druid.slider @{Slider} ----@return boolean -function druid__slider.is_enabled(self) end - ---- Set value for slider ----@param self druid.slider @{Slider} ----@param value number Value from 0 to 1 ----@param is_silent boolean|nil Don't trigger event if true -function druid__slider.set(self, value, is_silent) end - ---- Set Slider input enabled or disabled ----@param self druid.slider @{Slider} ----@param is_enabled boolean -function druid__slider.set_enabled(self, is_enabled) end - ---- Set input zone for slider. ---- User can touch any place of node, pin instantly will move at this position and node drag will start. This function require the Defold version 1.3.0+ ----@param self druid.slider @{Slider} ----@param input_node node|string|nil ----@return druid.slider @{Slider} -function druid__slider.set_input_node(self, input_node) end - ---- Set slider steps. ---- Pin node will apply closest step position ----@param self druid.slider @{Slider} ----@param steps number[] Array of steps ----@return druid.slider @{Slider} -function druid__slider.set_steps(self, steps) end - - ----@class druid.static_grid : druid.base_component ----@field anchor vector3 Item anchor [0..1] ----@field border vector4 The size of item content ----@field first_index number The first index of node in grid ----@field last_index number The last index of node in grid ----@field node_size vector3 Item size ----@field nodes node[] List of all grid nodes ----@field on_add_item druid.event On item add callback(self, node, index) ----@field on_change_items druid.event On item add, remove or change in_row callback(self, index|nil) ----@field on_clear druid.event On grid clear callback(self) ----@field on_remove_item druid.event On item remove callback(self, index) ----@field on_update_positions druid.event On update item positions callback(self) ----@field parent node Parent gui node ----@field pivot vector3 Item pivot [-0.5..0.5] ----@field style druid.static_grid.style Component style params. -local druid__static_grid = {} - ---- Add new item to the grid ----@param self druid.static_grid @{StaticGrid} ----@param item node GUI node ----@param index number|nil The item position. By default add as last item ----@param shift_policy number|nil How shift nodes, if required. Default: const.SHIFT.RIGHT ----@param is_instant boolean|nil If true, update node positions instantly -function druid__static_grid.add(self, item, index, shift_policy, is_instant) end - ---- Clear grid nodes array. ---- GUI nodes will be not deleted! If you want to delete GUI nodes, use static_grid.nodes array before grid:clear ----@param self druid.static_grid @{StaticGrid} ----@return druid.static_grid Current grid instance -function druid__static_grid.clear(self) end - ---- Return array of all node positions ----@param self druid.static_grid @{StaticGrid} ----@return vector3[] All grid node positions -function druid__static_grid.get_all_pos(self) end - ---- Return grid content borders ----@param self druid.static_grid @{StaticGrid} ----@return vector3 The grid content borders -function druid__static_grid.get_borders(self) end - ---- Return index for grid pos ----@param self druid.static_grid @{StaticGrid} ----@param pos vector3 The node position in the grid ----@return number The node index -function druid__static_grid.get_index(self, pos) end - ---- Return grid index by node ----@param self druid.static_grid @{StaticGrid} ----@param node node The gui node in the grid ----@return number The node index -function druid__static_grid.get_index_by_node(self, node) end - ---- Return StaticGrid offset, where StaticGrid content starts. ----@param self druid.static_grid @{StaticGrid} The StaticGrid instance ----@return vector3 The StaticGrid offset -function druid__static_grid.get_offset(self) end - ---- Return pos for grid node index ----@param self druid.static_grid @{StaticGrid} ----@param index number The grid element index ----@return vector3 @Node position -function druid__static_grid.get_pos(self, index) end - ---- Return grid content size ----@param self druid.static_grid @{StaticGrid} ----@return vector3 The grid content size -function druid__static_grid.get_size(self) end - ---- The @{StaticGrid} constructor ----@param self druid.static_grid @{StaticGrid} ----@param parent string|node The GUI Node container, where grid's items will be placed ----@param element node Element prefab. Need to get it size ----@param in_row number|nil How many nodes in row can be placed. By default 1 -function druid__static_grid.init(self, parent, element, in_row) end - ---- Update grid content ----@param self druid.static_grid @{StaticGrid} -function druid__static_grid.refresh(self) end - ---- Remove the item from the grid. ---- Note that gui node will be not deleted ----@param self druid.static_grid @{StaticGrid} ----@param index number The grid node index to remove ----@param shift_policy number|nil How shift nodes, if required. Default: const.SHIFT.RIGHT ----@param is_instant boolean|nil If true, update node positions instantly ----@return node The deleted gui node from grid -function druid__static_grid.remove(self, index, shift_policy, is_instant) end - ---- Set grid anchor. ---- Default anchor is equal to anchor of grid parent node ----@param self druid.static_grid @{StaticGrid} ----@param anchor vector3 Anchor -function druid__static_grid.set_anchor(self, anchor) end - ---- Set new in_row elements for grid ----@param self druid.static_grid @{StaticGrid} ----@param in_row number The new in_row value ----@return druid.static_grid Current grid instance -function druid__static_grid.set_in_row(self, in_row) end - ---- Set new node size for grid ----@param self druid.static_grid @{StaticGrid} ----@param width number The new node width ----@param height number The new node height ----@return druid.static_grid Current grid instance -function druid__static_grid.set_item_size(self, width, height) end - ---- Set new items to the grid. ---- All previous items will be removed ----@param self druid.static_grid @{StaticGrid} ----@param nodes node[] The new grid nodes ----@param is_instant boolean If true, update node positions instantly -function druid__static_grid.set_items(self, nodes, is_instant) end - ---- Change set position function for grid nodes. ---- It will call on update poses on grid elements. Default: gui.set_position ----@param self druid.static_grid @{StaticGrid} ----@param callback function Function on node set position ----@return druid.static_grid Current grid instance -function druid__static_grid.set_position_function(self, callback) end - ---- Sort grid nodes by custom comparator function ----@param self druid.static_grid @{StaticGrid} ----@param comparator function The comparator function. (a, b) -> boolean ----@return druid.static_grid Current grid instance -function druid__static_grid.sort_nodes(self, comparator) end - - ----@class druid.static_grid.style ----@field IS_ALIGN_LAST_ROW boolean|nil If true, always align last row of the grid as grid pivot sets. Default: false ----@field IS_DYNAMIC_NODE_POSES boolean|nil If true, always center grid content as grid pivot sets. Default: false -local druid__static_grid__style = {} - - ----@class druid.swipe : druid.base_component ----@field click_zone node|nil Restriction zone ----@field node node Swipe node ----@field on_swipe druid.event Trigger on swipe event(self, swipe_side, dist, delta_time) ----@field style druid.swipe.style Component style params. -local druid__swipe = {} - ---- The @{Swipe} constructor ----@param self druid.swipe @{Swipe} ----@param node node Gui node ----@param on_swipe_callback function Swipe callback for on_swipe_end event -function druid__swipe.init(self, node, on_swipe_callback) end - ---- Strict swipe click area. ---- Useful for restrict events outside stencil node ----@param self druid.swipe @{Swipe} ----@param zone node|string|nil Gui node -function druid__swipe.set_click_zone(self, zone) end - - ----@class druid.swipe.style ----@field SWIPE_THRESHOLD number|nil Minimum distance for swipe trigger. Default: 50 ----@field SWIPE_TIME number|nil Maximum time for swipe trigger. Default: 0.4 ----@field SWIPE_TRIGGER_ON_MOVE boolean|nil If true, trigger on swipe moving, not only release action. Default: false -local druid__swipe__style = {} - - ----@class druid.text : druid.base_component ----@field adjust_type number Current text size adjust settings ----@field color vector3 Current text color ----@field last_value string The last text value ----@field node node Text node ----@field node_id hash The node id of text node ----@field on_set_pivot druid.event On change pivot callback(self, pivot) ----@field on_set_text druid.event On set text callback(self, text) ----@field on_update_text_scale druid.event On adjust text size callback(self, new_scale, text_metrics) ----@field pos vector3 Current text position ----@field scale vector3 Current text node scale ----@field start_scale vector3 Initial text node scale ----@field start_size vector3 Initial text node size ----@field style druid.text.style Component style params. ----@field text_area vector3 Current text node available are -local druid__text = {} - ---- Return current text adjust type ----@param self unknown ----@param adjust_type unknown ----@return number The current text adjust type -function druid__text.get_text_adjust(self, adjust_type) end - ---- Get chars count by width ----@param self druid.text @{Text} ----@param width number ----@return number Chars count -function druid__text.get_text_index_by_width(self, width) end - ---- Calculate text width with font with respect to trailing space ----@param self druid.text @{Text} ----@param text string |nil ----@return number Width ----@return number Height -function druid__text.get_text_size(self, text) end - ---- The @{Text} constructor ----@param self druid.text @{Text} ----@param node string|node Node name or GUI Text Node itself ----@param value string|nil Initial text. Default value is node text from GUI scene. Default: nil ----@param adjust_type string|nil Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference. Default: DOWNSCALE -function druid__text.init(self, node, value, adjust_type) end - ---- Return true, if text with line break ----@param self druid.text @{Text} ----@return boolean Is text node with line break -function druid__text.is_multiline(self) end - ---- Set alpha ----@param self druid.text @{Text} ----@param alpha number Alpha for node ----@return druid.text Current text instance -function druid__text.set_alpha(self, alpha) end - ---- Set color ----@param self druid.text @{Text} ----@param color vector4 Color for node ----@return druid.text Current text instance -function druid__text.set_color(self, color) end - ---- Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types ----@param self druid.text @{Text} ----@param minimal_scale number If pass nil - not use minimal scale ----@return druid.text Current text instance -function druid__text.set_minimal_scale(self, minimal_scale) end - ---- Set text pivot. ---- Text will re-anchor inside text area ----@param self druid.text @{Text} ----@param pivot number The gui.PIVOT_* constant ----@return druid.text Current text instance -function druid__text.set_pivot(self, pivot) end - ---- Set scale ----@param self druid.text @{Text} ----@param scale vector3 Scale for node ----@return druid.text Current text instance -function druid__text.set_scale(self, scale) end - ---- Set text area size ----@param self druid.text @{Text} ----@param size vector3 The new text area size ----@return druid.text Current text instance -function druid__text.set_size(self, size) end - ---- Set text adjust, refresh the current text visuals, if needed ----@param self druid.text @{Text} ----@param adjust_type string|nil See const.TEXT_ADJUST. If pass nil - use current adjust type ----@param minimal_scale number|nil If pass nil - not use minimal scale ----@return druid.text Current text instance -function druid__text.set_text_adjust(self, adjust_type, minimal_scale) end - ---- Set text to text field ----@param self druid.text @{Text} ----@param set_to string Text for node ----@return druid.text Current text instance -function druid__text.set_to(self, set_to) end - - ----@class druid.text.style ----@field ADJUST_SCALE_DELTA string|nil Scale step on each height adjust step. Default: 0.02 ----@field ADJUST_STEPS string|nil Amount of iterations for text adjust by height. Default: 20 ----@field DEFAULT_ADJUST string|nil The default adjust type for any text component. Default: DOWNSCALE ----@field TRIM_POSTFIX string|nil The postfix for TRIM adjust type. Default: ... -local druid__text__style = {} - - ----@class druid.timer : druid.base_component ----@field from number Initial timer value ----@field node node Trigger node ----@field on_set_enabled druid.event On timer change enabled state callback(self, is_enabled) ----@field on_tick druid.event On timer tick. ----@field on_timer_end druid.event On timer end callback ----@field target number Target timer value ----@field value number Current timer value -local druid__timer = {} - ---- The @{Timer} constructor ----@param self druid.timer @{Timer} ----@param node node Gui text node ----@param seconds_from number|nil Start timer value in seconds ----@param seconds_to number|nil End timer value in seconds ----@param callback function|nil Function on timer end -function druid__timer.init(self, node, seconds_from, seconds_to, callback) end - ---- Set time interval ----@param self druid.timer @{Timer} ----@param from number Start time in seconds ----@param to number Target time in seconds -function druid__timer.set_interval(self, from, to) end - ---- Called when update ----@param self druid.timer @{Timer} ----@param is_on boolean|nil Timer enable state -function druid__timer.set_state(self, is_on) end - ---- Set text to text field ----@param self druid.timer @{Timer} ----@param set_to number Value in seconds -function druid__timer.set_to(self, set_to) end - - ----@class druid_instance -local druid_instance = {} - ---- Call this in gui_script final function. ----@param self druid_instance -function druid_instance.final(self) end - ---- Create @{BackHandler} component ----@param self druid_instance ----@param callback function|nil @The callback(self, custom_args) to call on back event ----@param params any|nil Callback argument ----@return druid.back_handler @{BackHandler} component -function druid_instance.new_back_handler(self, callback, params) end - ---- Create @{Blocker} component ----@param self druid_instance ----@param node string|node The node_id or gui.get_node(node_id) ----@return druid.blocker @{Blocker} component -function druid_instance.new_blocker(self, node) end - ---- Create @{Button} component ----@param self druid_instance ----@param node string|node The node_id or gui.get_node(node_id) ----@param callback function|nil Button callback ----@param params any|nil Button callback params ----@param anim_node node|string|nil Button anim node (node, if not provided) ----@return druid.button @{Button} component -function druid_instance.new_button(self, node, callback, params, anim_node) end - ---- Create @{DataList} component ----@param self druid_instance ----@param druid_scroll druid.scroll The Scroll instance for Data List component ----@param druid_grid druid.static_grid The @{StaticGrid} or @{DynamicGrid} instance for Data List component ----@param create_function function The create function callback(self, data, index, data_list). Function should return (node, [component]) ----@return druid.data_list @{DataList} component -function druid_instance.new_data_list(self, druid_scroll, druid_grid, create_function) end - ---- Create @{Drag} component ----@param self druid_instance ----@param node string|node The node_id or gui.get_node(node_id). Will used as user input node. ----@param on_drag_callback function|nil Callback for on_drag_event(self, dx, dy) ----@return druid.drag @{Drag} component -function druid_instance.new_drag(self, node, on_drag_callback) end - ---- Create @{DynamicGrid} component Deprecated ----@param self druid_instance ----@param parent_node string|node The node_id or gui.get_node(node_id). Parent of all Grid items. ----@return druid.dynamic_grid @{DynamicGrid} component -function druid_instance.new_dynamic_grid(self, parent_node) end - ---- Create @{Hotkey} component ----@param self druid_instance ----@param keys_array string|string[] Keys for trigger action. Should contains one action key and any amount of modificator keys ----@param callback function The callback function ----@param callback_argument any|nil The argument to pass into the callback function ----@return druid.hotkey @{Hotkey} component -function druid_instance.new_hotkey(self, keys_array, callback, callback_argument) end - ---- Create @{Hover} component ----@param self druid_instance ----@param node string|node The node_id or gui.get_node(node_id) ----@param on_hover_callback function|nil Hover callback ----@param on_mouse_hover_callback function|nil Mouse hover callback ----@return druid.hover @{Hover} component -function druid_instance.new_hover(self, node, on_hover_callback, on_mouse_hover_callback) end - ---- Create @{Input} component ----@param self druid_instance ----@param click_node string|node Button node to enabled input component ----@param text_node string|node|druid.text Text node what will be changed on user input ----@param keyboard_type number|nil Gui keyboard type for input field ----@return druid.input @{Input} component -function druid_instance.new_input(self, click_node, text_node, keyboard_type) end - ---- Create @{LangText} component ----@param self druid_instance ----@param node string|node The_node id or gui.get_node(node_id) ----@param locale_id string|nil Default locale id or text from node as default ----@param adjust_type string|nil Adjust type for text node. Default: const.TEXT_ADJUST.DOWNSCALE ----@return druid.lang_text @{LangText} component -function druid_instance.new_lang_text(self, node, locale_id, adjust_type) end - ---- Create @{Layout} component ----@param self druid_instance ----@param node string|node The_node id or gui.get_node(node_id). ----@param mode string The layout mode ----@return druid.layout @{Layout} component -function druid_instance.new_layout(self, node, mode) end - ---- Create @{Progress} component ----@param self druid_instance ----@param node string|node Progress bar fill node or node name ----@param key string Progress bar direction: const.SIDE.X or const.SIDE.Y ----@param init_value number|nil Initial value of progress bar. Default: 1 ----@return druid.progress @{Progress} component -function druid_instance.new_progress(self, node, key, init_value) end - ---- Create @{RichInput} component. ---- As a template please check rich_input.gui layout. ----@param self druid_instance ----@param template string The template string name ----@param nodes table Nodes table from gui.clone_tree ----@return druid.rich_input @{RichInput} component -function druid_instance.new_rich_input(self, template, nodes) end - ---- Create @{RichText} component. ----@param self druid_instance ----@param text_node string|node The text node to make Rich Text ----@param value string|nil The initial text value. Default will be gui.get_text(text_node) ----@return druid.rich_text @{RichText} component -function druid_instance.new_rich_text(self, text_node, value) end - ---- Create @{Scroll} component ----@param self druid_instance ----@param view_node string|node The node_id or gui.get_node(node_id). Will used as user input node. ----@param content_node string|node The node_id or gui.get_node(node_id). Will used as scrollable node inside view_node. ----@return druid.scroll @{Scroll} component -function druid_instance.new_scroll(self, view_node, content_node) end - ---- Create @{Slider} component ----@param self druid_instance ----@param pin_node string|node The_node id or gui.get_node(node_id). ----@param end_pos vector3 The end position of slider ----@param callback function|nil On slider change callback ----@return druid.slider @{Slider} component -function druid_instance.new_slider(self, pin_node, end_pos, callback) end - ---- Create @{StaticGrid} component ----@param self druid_instance ----@param parent_node string|node The node_id or gui.get_node(node_id). Parent of all Grid items. ----@param item string|node Item prefab. Required to get grid's item size. Can be adjusted separately. ----@param in_row number|nil How many nodes in row can be placed ----@return druid.static_grid @{StaticGrid} component -function druid_instance.new_static_grid(self, parent_node, item, in_row) end - ---- Create @{Swipe} component ----@param self druid_instance ----@param node string|node The node_id or gui.get_node(node_id). Will used as user input node. ----@param on_swipe_callback function|nil Swipe callback for on_swipe_end event ----@return druid.swipe @{Swipe} component -function druid_instance.new_swipe(self, node, on_swipe_callback) end - ---- Create @{Text} component ----@param self druid_instance ----@param node string|node The node_id or gui.get_node(node_id) ----@param value string|nil Initial text. Default value is node text from GUI scene. ----@param no_adjust boolean|nil If true, text will be not auto-adjust size ----@return druid.text @{Text} component -function druid_instance.new_text(self, node, value, no_adjust) end - ---- Create @{Timer} component ----@param self druid_instance ----@param node string|node Gui text node ----@param seconds_from number Start timer value in seconds ----@param seconds_to number|nil End timer value in seconds ----@param callback function|nil Function on timer end ----@return druid.timer @{Timer} component -function druid_instance.new_timer(self, node, seconds_from, seconds_to, callback) end - ---- Call this in gui_script on_input function. ---- Used for almost all components ----@param self druid_instance ----@param action_id hash Action_id from on_input ----@param action table Action from on_input ----@return boolean The boolean value is input was consumed -function druid_instance.on_input(self, action_id, action) end - ---- Call this in gui_script on_message function. ---- Used for special actions. See SPECIFIC_UI_MESSAGES table ----@param self druid_instance ----@param message_id hash Message_id from on_message ----@param message table Message from on_message ----@param sender url Sender from on_message -function druid_instance.on_message(self, message_id, message, sender) end - ---- Remove created component from Druid instance. ---- Component `on_remove` function will be invoked, if exist. ----@param self druid_instance ----@param component druid.base_component Component instance ----@return boolean True if component was removed -function druid_instance.remove(self, component) end - ---- Set blacklist components for input processing. ---- If blacklist is not empty and component contains in this list, component will be not processed on input step ----@param self druid_instance @{DruidInstance} ----@param blacklist_components table|druid.base_component|nil The array of component to blacklist ----@return self @{DruidInstance} -function druid_instance.set_blacklist(self, blacklist_components) end - ---- Set whitelist components for input processing. ---- If whitelist is not empty and component not contains in this list, component will be not processed on input step ----@param self druid_instance ----@param whitelist_components table|druid.base_component|nil The array of component to whitelist ----@return self @{DruidInstance} -function druid_instance.set_whitelist(self, whitelist_components) end - ---- Call this in gui_script update function. ---- Used for: scroll, progress, timer components ----@param self druid_instance ----@param dt number Delta time -function druid_instance.update(self, dt) end - - ----@class helper -local helper = {} - ---- Add all elements from source array to the target array ----@param target any[] Array to put elements from source ----@param source any[]|nil The source array to get elements from ----@return any[] The target array -function helper.add_array(target, source) end - ---- Centerate nodes by x position with margin. ---- This functions calculate total width of nodes and set position for each node. The centrate will be around 0 x position. ----@param margin number|nil Offset between nodes ----@param ... unknown Gui nodes -function helper.centrate_nodes(margin, ...) end - ---- Clamp value between min and max ----@param a number Value ----@param min number Min value ----@param max number Max value ----@return number Clamped value -function helper.clamp(a, min, max) end - ---- Check if value is in array and return index of it ----@param t table Array ----@param value unknown Value ----@return number|nil Index of value or nil -function helper.contains(t, value) end - ---- Make a copy table with all nested tables ----@param orig_table table Original table ----@return table Copy of original table -function helper.deepcopy(orig_table) end - ---- Calculate distance between two points ----@param x1 number First point x ----@param y1 number First point y ----@param x2 number Second point x ----@param y2 number Second point y ----@return number Distance -function helper.distance(x1, y1, x2, y2) end - ---- Distance from node position to his borders ----@param node node GUI node ----@param offset vector3|nil Offset from node position. Pass current node position to get non relative border values ----@return vector4 Vector4 with border values (left, top, right, down) -function helper.get_border(node, offset) end - ---- Return closest non inverted clipping parent node for given node ----@param node node GUI node ----@return node|nil The closest stencil node or nil -function helper.get_closest_stencil_node(node) end - ---- Get current GUI scale for each side ----@return number scale_x ----@return number scale_y -function helper.get_gui_scale() end - ---- Get node offset for given GUI pivot. ---- Offset shown in [-0.5 .. 0.5] range, where -0.5 is left or bottom, 0.5 is right or top. ----@param pivot number The gui.PIVOT_* constant ----@return vector3 Vector offset with [-0.5..0.5] values -function helper.get_pivot_offset(pivot) end - ---- Get node size adjusted by scale ----@param node node GUI node ----@return vector3 Scaled size -function helper.get_scaled_size(node) end - ---- Get cumulative parent's node scale ----@param node node Gui node ----@param include_passed_node_scale boolean|nil True if add current node scale to result ----@return vector3 The scene node scale -function helper.get_scene_scale(node, include_passed_node_scale) end - ---- Get current screen stretch multiplier for each side ----@return number stretch_x ----@return number stretch_y -function helper.get_screen_aspect_koef() end - ---- Get text metric from GUI node. ----@param text_node node ----@return GUITextMetrics -function helper.get_text_metrics_from_node(text_node) end - ---- Add value to array with shift policy ---- Shift policy can be: left, right, no_shift ----@param array table Array ----@param any unknown Item to insert ----@param index number|nil Index to insert. If nil, item will be inserted at the end of array ----@param shift_policy number|nil The druid_const.SHIFT.* constant ----@return any Inserted item -function helper.insert_with_shift(array, any, index, shift_policy) end - ---- Check if device is native mobile (Android or iOS) ----@return boolean Is mobile -function helper.is_mobile() end - ---- Check if device is mobile and can support multitouch ----@return boolean Is multitouch supported -function helper.is_multitouch_supported() end - ---- Check if device is HTML5 ----@return boolean Is web -function helper.is_web() end - ---- Check if device is HTML5 mobile ----@return boolean Is web mobile -function helper.is_web_mobile() end - ---- Lerp between two values ----@param a number First value ----@param b number Second value ----@param t number Lerp amount ----@return number Lerped value -function helper.lerp(a, b, t) end - ---- Remove value from array with shift policy ---- Shift policy can be: left, right, no_shift ----@param array table Array ----@param index number|nil Index to remove. If nil, item will be removed from the end of array ----@param shift_policy number|nil The druid_const.SHIFT.* constant ----@return any Removed item -function helper.remove_with_shift(array, index, shift_policy) end - ---- Round number to specified decimal places ----@param num number Number ----@param num_decimal_places number|nil Decimal places ----@return number Rounded number -function helper.round(num, num_decimal_places) end - ---- Return sign of value (-1, 0, 1) ----@param val number Value ----@return number Sign -function helper.sign(val) end - ---- Move value from current to target value with step amount ----@param current number Current value ----@param target number Target value ----@param step number Step amount ----@return number New value -function helper.step(current, target, step) end - ---- Simple table to one-line string converter ----@param t table ----@return string -function helper.table_to_string(t) end - - --- Manual Annotations -- - ----@class druid.component: druid.base_component - ----@class druid.rich_text.metrics ----@field width number ----@field height number ----@field offset_x number|nil ----@field offset_y number|nil ----@field max_ascent number ----@field max_descent number ----@field node_size vector3|nil @For images only - ----@class druid.rich_text.lines_metrics ----@field text_width number ----@field text_height number ----@field lines table - ----@class druid.rich_text.word ----@field node node ----@field relative_scale number ----@field color vector4 ----@field position vector3 ----@field offset vector3 ----@field scale vector3 ----@field size vector3 ----@field metrics druid.rich_text.metrics ----@field pivot userdata @ The gui.PIVOT_* constant ----@field text string ----@field shadow vector4 ----@field outline vector4 ----@field font string ----@field image druid.rich_text.image ----@field default_animation string ----@field anchor number ----@field br boolean ----@field nobr boolean ----@field source_text string ----@field image_color vector4 ----@field text_color vector4 - ----@class druid.rich_text.image ----@field texture string ----@field anim string ----@field width number ----@field height number - ----@class druid.rich_text.settings ----@field parent node ----@field size number ----@field fonts table ----@field scale vector3 ----@field color vector4 ----@field shadow vector4 ----@field outline vector4 ----@field position vector3 ----@field image_pixel_grid_snap boolean ----@field combine_words boolean ----@field default_animation string ----@field text_prefab node ----@field adjust_scale number ----@field default_texture string ----@field is_multiline boolean ----@field text_leading number ----@field font hash ----@field width number ----@field height number - ----@class GUITextMetrics ----@field width number ----@field height number ----@field max_ascent number ----@field max_descent number - ----@class utf8 ----@field len fun(s: string):number ----@field sub fun(s: string, start_index: number, length: number) ----@field reverse fun() ----@field char fun() ----@field unicode fun() ----@field gensub fun() ----@field byte fun() ----@field find fun() ----@field match fun(s: string, m: string) ----@field gmatch fun(s: string, m: string) ----@field gsub fun() ----@field dump fun() ----@field format fun() ----@field lower fun() ----@field upper fun() ----@field rep fun() - - ----Add generics to some functions. - ----Create new component. ----@generic T: druid.base_component ----@param self druid_instance ----@param component T Component module ----@param ... any Other component params to pass it to component:init function ----@return T Component instance -function druid_instance.new(self, component, ...) end - ---- Set current component style table. ---- Invoke `on_style_change` on component, if exist. Component should handle their style changing and store all style params ----@generic T: druid.base_component ----@param self T @{BaseComponent} ----@param druid_style table|nil Druid style module ----@return T @{BaseComponent} -function druid__base_component.set_style(self, druid_style) end - ---- Set component template name. ---- 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() ----@generic T: druid.base_component ----@param self T @{BaseComponent} ----@param template string BaseComponent template name ----@return T @{BaseComponent} -function druid__base_component.set_template(self, template) end - ---- Set current component nodes. ---- Use if your component nodes was cloned with `gui.clone_tree` and you got the node tree. ----@generic T: druid.base_component ----@param self T @{BaseComponent} ----@param nodes table BaseComponent nodes table ----@return T @{BaseComponent} -function druid__base_component.set_nodes(self, nodes) end diff --git a/druid/base/back_handler.lua b/druid/base/back_handler.lua index 899e12e..56e0c0c 100644 --- a/druid/base/back_handler.lua +++ b/druid/base/back_handler.lua @@ -1,65 +1,24 @@ --- Copyright (c) 2023 Maksim Tuprikov . This code is licensed under MIT license - ---- Component with event on back and backspace button. --- # Overview # --- --- Back Handler is recommended to put in every game window to close it --- or in main screen to call settings window. --- --- # Notes # --- --- • Back Handler inheritance @{BaseComponent}, you can use all of its methods in addition to those described here. --- --- • Back Handler react on release action ACTION_BACK or ACTION_BACKSPACE --- @usage --- local callback = function(self, params) ... end --- --- local params = {} --- local back_handler = self.druid:new_back_handler(callback, [params]) --- @module BackHandler --- @within BaseComponent --- @alias druid.back_handler - ---- The @{DruidEvent} Event on back handler action. --- --- Trigger on input action ACTION_BACK or ACTION_BACKSPACE --- @usage --- -- Subscribe additional callbacks: --- back_handler.on_back:subscribe(callback) --- @tfield DruidEvent on_back @{DruidEvent} - ---- Custom args to pass in the callback --- @usage --- -- Replace params on runtime: --- back_handler.params = { ... } --- @tfield any|nil params - ---- - -local Event = require("druid.event") +local event = require("druid.event") local const = require("druid.const") local component = require("druid.component") -local BackHandler = component.create("back_handler") +---@class druid.back_handler: druid.base_component +---@field on_back druid.event Trigger on back handler action, fun(self, params) +---@field params any|nil Custom args to pass in the callback +local M = component.create("back_handler") ---- The @{BackHandler} constructor --- @tparam BackHandler self @{BackHandler} --- @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 - self.on_back = Event(callback) +---@param callback function|nil +---@param params any|nil +function M:init(callback, params) + self.params = params + self.on_back = event.create(callback) end ---- Component input handler --- @tparam BackHandler self @{BackHandler} --- @tparam string action_id on_input action id --- @tparam table action on_input action --- @local -function BackHandler.on_input(self, action_id, action) +---@param action_id string +---@param action table +function M:on_input(action_id, action) if not action.released then return false end @@ -73,4 +32,4 @@ function BackHandler.on_input(self, action_id, action) end -return BackHandler +return M diff --git a/druid/base/blocker.lua b/druid/base/blocker.lua index 92fc414..bbd1890 100644 --- a/druid/base/blocker.lua +++ b/druid/base/blocker.lua @@ -1,50 +1,22 @@ --- Copyright (c) 2023 Maksim Tuprikov . This code is licensed under MIT license - ---- Component to consume input in special zone defined by GUI node. --- # Overview # --- --- # Notes # --- --- Blocker consume input if `gui.pick_node` works on it. --- --- • Blocker inheritance @{BaseComponent}, you can use all of its methods in addition to those described here. --- --- • Blocker initial enabled state is `gui.is_enabled(node, true)` --- --- • The Blocker node should be enabled to capture the input --- @usage --- local node = gui.get_node("blocker_node") --- local blocker = self.druid:new_blocker(node) --- @module Blocker --- @within BaseComponent --- @alias druid.blocker - ----Blocker node --- @tfield node node - ---- - local const = require("druid.const") local component = require("druid.component") -local Blocker = component.create("blocker") +---@class druid.blocker: druid.base_component +---@field node node +---@field private _is_enabled boolean +local M = component.create("blocker") ---- The @{Blocker} constructor --- @tparam Blocker self @{Blocker} --- @tparam node node Gui node -function Blocker.init(self, node) +---@param node node +function M:init(node) self.node = self:get_node(node) self._is_enabled = gui.is_enabled(self.node, true) end ---- Component input handler --- @tparam Blocker self @{Blocker} --- @tparam string action_id on_input action id --- @tparam table action on_input action --- @local -function Blocker.on_input(self, action_id, action) +---@param action_id string +---@param action table +function M:on_input(action_id, action) if action_id ~= const.ACTION_TOUCH and action_id ~= const.ACTION_MULTITOUCH and action_id ~= nil then @@ -67,22 +39,21 @@ function Blocker.on_input(self, action_id, action) end ---- Set enabled blocker component state. --- --- Don't change node enabled state itself. --- @tparam Blocker self @{Blocker} --- @tparam boolean|nil state Enabled state -function Blocker.set_enabled(self, state) +---Set blocker enabled state +---@param state boolean +---@return druid.blocker self +function M:set_enabled(state) self._is_enabled = state + + return self end ---- Return blocker enabled state --- @tparam Blocker self @{Blocker} --- @treturn boolean @True, if blocker is enabled -function Blocker.is_enabled(self) +---Get blocker enabled state +---@return boolean +function M:is_enabled() return self._is_enabled end -return Blocker +return M diff --git a/druid/base/button.lua b/druid/base/button.lua index 9b09c48..7684380 100755 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -35,16 +35,16 @@ -- @alias druid.button ---- The @{DruidEvent}: Event on successful release action over button. +--- The DruidEvent: Event on successful release action over button. -- @usage -- -- Custom args passed in Button constructor -- button.on_click:subscribe(function(self, custom_args, button_instance) -- print("On button click!") -- end) --- @tfield DruidEvent on_click @{DruidEvent} +-- @tfield DruidEvent on_click DruidEvent ---- The @{DruidEvent}: Event on repeated action over button. +--- The DruidEvent: Event on repeated action over button. -- -- This callback will be triggered if user hold the button. The repeat rate pick from `input.repeat_interval` in game.project -- @usage @@ -52,10 +52,10 @@ -- button.on_repeated_click:subscribe(function(self, custom_args, button_instance, click_count) -- print("On repeated Button click!") -- end) --- @tfield DruidEvent on_repeated_click @{DruidEvent} +-- @tfield DruidEvent on_repeated_click DruidEvent ---- The @{DruidEvent}: Event on long tap action over button. +--- The DruidEvent: Event on long tap action over button. -- -- This callback will be triggered if user pressed the button and hold the some amount of time. -- The amount of time picked from button style param: LONGTAP_TIME @@ -64,10 +64,10 @@ -- button.on_long_click:subscribe(function(self, custom_args, button_instance, hold_time) -- print("On long Button click!") -- end) --- @tfield DruidEvent on_long_click @{DruidEvent} +-- @tfield DruidEvent on_long_click DruidEvent ---- The @{DruidEvent}: Event on double tap action over button. +--- The DruidEvent: Event on double tap action over button. -- -- If secondary click was too fast after previous one, the double -- click will be called instead usual click (if on_double_click subscriber exists) @@ -76,10 +76,10 @@ -- button.on_double_click:subscribe(function(self, custom_args, button_instance, click_amount) -- print("On double Button click!") -- end) --- @tfield DruidEvent on_double_click @{DruidEvent} +-- @tfield DruidEvent on_double_click DruidEvent ---- The @{DruidEvent}: Event calls every frame before on_long_click event. +--- The DruidEvent: Event calls every frame before on_long_click event. -- -- If long_click subscriber exists, the on_hold_callback will be called before long_click trigger. -- @@ -89,10 +89,10 @@ -- button.on_double_click:subscribe(function(self, custom_args, button_instance, time) -- print("On hold Button callback!") -- end) --- @tfield DruidEvent on_hold_callback @{DruidEvent} +-- @tfield DruidEvent on_hold_callback DruidEvent ---- The @{DruidEvent}: Event calls if click event was outside of button. +--- The DruidEvent: Event calls if click event was outside of button. -- -- This event will be triggered for each button what was not clicked on user click action -- @@ -102,16 +102,16 @@ -- button.on_click_outside:subscribe(function(self, custom_args, button_instance) -- print("On click Button outside!") -- end) --- @tfield DruidEvent on_click_outside @{DruidEvent} +-- @tfield DruidEvent on_click_outside DruidEvent ---- The @{DruidEvent}: Event triggered if button was pressed by user. +--- The DruidEvent: Event triggered if button was pressed by user. -- @usage -- -- Custom args passed in Button constructor -- button.on_pressed:subscribe(function(self, custom_args, button_instance) -- print("On Button pressed!") -- end) --- @tfield DruidEvent on_pressed @{DruidEvent} +-- @tfield DruidEvent on_pressed DruidEvent --- Button trigger node -- @tfield node node @@ -128,8 +128,8 @@ ---Custom args for any Button event. Setup in Button constructor -- @tfield any params ---- The @{Hover}: Button Hover component --- @tfield Hover hover @{Hover} +--- The Hover: Button Hover component +-- @tfield Hover hover Hover --- Additional button click area, defined by another GUI node -- @tfield node|nil click_zone @@ -141,7 +141,26 @@ local const = require("druid.const") local helper = require("druid.helper") local component = require("druid.component") -local Button = component.create("button") +---@class druid.button: druid.base_component +---@field on_click druid.event +---@field on_pressed druid.event +---@field on_repeated_click druid.event +---@field on_long_click druid.event +---@field on_double_click druid.event +---@field on_hold_callback druid.event +---@field on_click_outside druid.event +---@field node node +---@field node_id hash +---@field anim_node node +---@field params any +---@field hover druid.hover +---@field click_zone node +---@field start_scale vector3 +---@field start_pos vector3 +---@field disabled boolean +---@field key_trigger hash +---@field style table +local M = component.create("button") local function is_input_match(self, action_id) @@ -271,7 +290,7 @@ end -- @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) +function M:on_style_change(style) self.style = {} self.style.LONGTAP_TIME = style.LONGTAP_TIME or 0.4 self.style.AUTOHOLD_TRIGGER = style.AUTOHOLD_TRIGGER or 0.8 @@ -285,22 +304,21 @@ function Button.on_style_change(self, style) end ---- The @{Button} constructor --- @tparam Button self @{Button} --- @tparam string|node node The node_id or gui.get_node(node_id) --- @tparam function callback On click button callback --- @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) +---Button constructor +---@param node_or_node_id node|string Node name or GUI Node itself. +---@param callback fun()|nil Callback on button click +---@param custom_args any|nil Custom args for any Button event +---@param anim_node node|string|nil Node to animate instead of trigger node. +function M:init(node_or_node_id, callback, custom_args, anim_node) self.druid = self:get_druid() - self.node = self:get_node(node) + self.node = self:get_node(node_or_node_id) self.node_id = gui.get_id(self.node) self.anim_node = anim_node and self:get_node(anim_node) or self.node self.start_scale = gui.get_scale(self.anim_node) self.start_pos = gui.get_position(self.anim_node) self.params = custom_args - self.hover = self.druid:new_hover(node, on_button_hover) + self.hover = self.druid:new_hover(node_or_node_id, on_button_hover) self.hover.on_mouse_hover:subscribe(on_button_mouse_hover) self.click_zone = nil self.is_repeated_started = false @@ -325,7 +343,7 @@ function Button.init(self, node, callback, custom_args, anim_node) end -function Button.on_late_init(self) +function M:on_late_init() if not self.click_zone and const.IS_STENCIL_CHECK then local stencil_node = helper.get_closest_stencil_node(self.node) if stencil_node then @@ -335,7 +353,7 @@ function Button.on_late_init(self) end -function Button.on_input(self, action_id, action) +function M:on_input(action_id, action) if not is_input_match(self, action_id) then return false end @@ -416,14 +434,14 @@ function Button.on_input(self, action_id, action) end -function Button.on_input_interrupt(self) +function M:on_input_interrupt() self.can_action = false self.hover:set_hover(false) self.hover:set_mouse_hover(false) end -function Button.on_message_input(self, node_id, message) +function M:on_message_input(node_id, message) if node_id ~= self.node_id or self.disabled or not gui.is_enabled(self.node) then return false end @@ -451,13 +469,13 @@ end --- Set button enabled state. -- The style.on_set_enabled will be triggered. -- Disabled button is not clickable. --- @tparam Button self @{Button} +-- @tparam Button self Button -- @tparam boolean|nil state Enabled state -- @treturn Button Current button instance -- @usage -- button:set_enabled(false) -- button:set_enabled(true) -function Button.set_enabled(self, state) +function M:set_enabled(state) self.disabled = not state self.hover:set_enabled(state) self.style.on_set_enabled(self, self.node, state) @@ -469,11 +487,11 @@ end --- Get button enabled state. -- -- By default all Buttons is enabled on creating. --- @tparam Button self @{Button} +-- @tparam Button self Button -- @treturn boolean @True, if button is enabled now, False overwise -- @usage -- local is_enabled = button:is_enabled() -function Button.is_enabled(self) +function M:is_enabled() return not self.disabled end @@ -482,12 +500,12 @@ end -- Useful to restrict click outside out stencil node or scrollable content. -- -- This functions calls automatically if you don't disable it in game.project: druid.no_stencil_check --- @tparam Button self @{Button} +-- @tparam Button self Button -- @tparam node|string|nil zone Gui node -- @treturn Button Current button instance -- @usage -- button:set_click_zone("stencil_node") -function Button.set_click_zone(self, zone) +function M:set_click_zone(zone) self.click_zone = self:get_node(zone) self.hover:set_click_zone(zone) @@ -496,12 +514,12 @@ end --- Set key name to trigger this button by keyboard. --- @tparam Button self @{Button} +-- @tparam Button self Button -- @tparam hash|string key The action_id of the input key -- @treturn Button Current button instance -- @usage -- button:set_key_trigger("key_space") -function Button.set_key_trigger(self, key) +function M:set_key_trigger(key) self.key_trigger = hash(key) return self @@ -513,7 +531,7 @@ end -- @treturn hash The action_id of the input key -- @usage -- local key_hash = button:get_key_trigger() -function Button.get_key_trigger(self) +function M:get_key_trigger() return self.key_trigger end @@ -523,7 +541,7 @@ end -- @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) +function M:set_check_function(check_function, failure_callback) self._check_function = check_function self._failure_callback = failure_callback end @@ -540,10 +558,10 @@ end -- @treturn Button Current button instance -- @usage -- button:set_web_user_interaction(true) -function Button.set_web_user_interaction(self, is_web_mode) +function M:set_web_user_interaction(is_web_mode) self._is_html5_mode = not not (is_web_mode and html5) return self end -return Button +return M diff --git a/druid/base/drag.lua b/druid/base/drag.lua index fd79105..3218ae6 100644 --- a/druid/base/drag.lua +++ b/druid/base/drag.lua @@ -14,19 +14,19 @@ -- @tfield node node --- Event on touch start callback(self) --- @tfield DruidEvent on_touch_start @{DruidEvent} +-- @tfield DruidEvent on_touch_start DruidEvent --- Event on touch end callback(self) --- @tfield DruidEvent on_touch_end @{DruidEvent} +-- @tfield DruidEvent on_touch_end DruidEvent --- Event on drag start callback(self, touch) --- @tfield DruidEvent on_drag_start @{DruidEvent} +-- @tfield DruidEvent on_drag_start DruidEvent --- on drag progress callback(self, dx, dy, total_x, total_y, touch) --- @tfield DruidEvent on_drag Event @{DruidEvent} +-- @tfield DruidEvent on_drag Event DruidEvent --- Event on drag end callback(self, total_x, total_y, touch) --- @tfield DruidEvent on_drag_end @{DruidEvent} +-- @tfield DruidEvent on_drag_end DruidEvent --- Is component now touching -- @tfield boolean is_touch @@ -62,7 +62,31 @@ local const = require("druid.const") local helper = require("druid.helper") local component = require("druid.component") -local Drag = component.create("drag", const.PRIORITY_INPUT_HIGH) +---@class druid.drag: druid.base_component +---@field node node +---@field on_touch_start druid.event +---@field on_touch_end druid.event +---@field on_drag_start druid.event +---@field on_drag druid.event +---@field on_drag_end druid.event +---@field style table +---@field click_zone node +---@field is_touch boolean +---@field is_drag boolean +---@field can_x boolean +---@field can_y boolean +---@field dx number +---@field dy number +---@field touch_id number +---@field x number +---@field y number +---@field screen_x number +---@field screen_y number +---@field touch_start_pos vector3 +---@field private _is_enabled boolean +---@field private _x_koef number +---@field private _y_koef number +local M = component.create("drag", const.PRIORITY_INPUT_HIGH) local function start_touch(self, touch) @@ -177,19 +201,18 @@ end -- @table style -- @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) +function M:on_style_change(style) self.style = {} self.style.DRAG_DEADZONE = style.DRAG_DEADZONE or 10 self.style.NO_USE_SCREEN_KOEF = style.NO_USE_SCREEN_KOEF or false end ---- 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) -function Drag.init(self, node, on_drag_callback) - self.node = self:get_node(node) +---Drag constructor +---@param node_or_node_id node|string +---@param on_drag_callback function +function M:init(node_or_node_id, on_drag_callback) + self.node = self:get_node(node_or_node_id) self.dx = 0 self.dy = 0 @@ -219,7 +242,7 @@ function Drag.init(self, node, on_drag_callback) end -function Drag.on_late_init(self) +function M:on_late_init() if not self.click_zone and const.IS_STENCIL_CHECK then local stencil_node = helper.get_closest_stencil_node(self.node) if stencil_node then @@ -229,7 +252,7 @@ function Drag.on_late_init(self) end -function Drag.on_window_resized(self) +function M:on_window_resized() local x_koef, y_koef = helper.get_screen_aspect_koef() self._x_koef = x_koef self._y_koef = y_koef @@ -237,14 +260,17 @@ function Drag.on_window_resized(self) end -function Drag.on_input_interrupt(self) +function M:on_input_interrupt() if self.is_drag or self.is_touch then end_touch(self) end end -function Drag.on_input(self, action_id, action) +---@local +---@param action_id string +---@param action table +function M:on_input(action_id, action) if action_id ~= const.ACTION_TOUCH and action_id ~= const.ACTION_MULTITOUCH then return false end @@ -321,29 +347,31 @@ function Drag.on_input(self, action_id, action) end ---- Strict drag click area. Useful for --- restrict events outside stencil node --- @tparam Drag self @{Drag} --- @tparam node|string|nil node Gui node -function Drag.set_click_zone(self, node) +---Set Drag click zone +---@param node node|string|nil +---@return druid.drag self +function M:set_click_zone(node) self.click_zone = self:get_node(node) + + return self end ---- Set Drag input enabled or disabled --- @tparam Drag self @{Drag} --- @tparam boolean|nil is_enabled -function Drag.set_enabled(self, is_enabled) +---Set Drag component enabled state. +---@param is_enabled boolean +---@return druid.drag self +function M:set_enabled(is_enabled) self._is_enabled = is_enabled + + return self end ---- Check if Drag component is enabled --- @tparam Drag self @{Drag} --- @treturn boolean -function Drag.is_enabled(self) +---Check if Drag component is enabled +---@return boolean +function M:is_enabled() return self._is_enabled end -return Drag +return M diff --git a/druid/base/hover.lua b/druid/base/hover.lua index f178cf2..d5e1700 100644 --- a/druid/base/hover.lua +++ b/druid/base/hover.lua @@ -9,10 +9,10 @@ -- @tfield node node --- On hover callback(self, state, hover_instance) --- @tfield DruidEvent on_hover @{DruidEvent} +-- @tfield DruidEvent on_hover DruidEvent --- On mouse hover callback(self, state, hover_instance) --- @tfield DruidEvent on_mouse_hover @{DruidEvent} +-- @tfield DruidEvent on_mouse_hover DruidEvent --- @@ -21,15 +21,25 @@ local const = require("druid.const") local helper = require("druid.helper") local component = require("druid.component") -local Hover = component.create("hover") +---@class druid.hover: druid.base_component +---@field node node +---@field on_hover druid.event +---@field on_mouse_hover druid.event +---@field style table +---@field click_zone node +---@field private _is_hovered boolean +---@field private _is_mouse_hovered boolean +---@field private _is_enabled boolean +---@field private _is_mobile boolean +local M = component.create("hover") ---- The @{Hover} constructor --- @tparam Hover self @{Hover} +--- The Hover constructor +-- @tparam Hover self Hover -- @tparam node node Gui node -- @tparam function on_hover_callback Hover callback -- @tparam function on_mouse_hover On mouse hover callback -function Hover.init(self, node, on_hover_callback, on_mouse_hover) +function M:init(node, on_hover_callback, on_mouse_hover) self.node = self:get_node(node) self._is_hovered = false @@ -42,7 +52,7 @@ function Hover.init(self, node, on_hover_callback, on_mouse_hover) end -function Hover.on_late_init(self) +function M:on_late_init() if not self.click_zone and const.IS_STENCIL_CHECK then local stencil_node = helper.get_closest_stencil_node(self.node) if stencil_node then @@ -58,14 +68,14 @@ end -- @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) +function M:on_style_change(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) +function M:on_input(action_id, action) if action_id ~= const.ACTION_TOUCH and action_id ~= nil then return false end @@ -99,15 +109,15 @@ function Hover.on_input(self, action_id, action) end -function Hover.on_input_interrupt(self) +function M:on_input_interrupt() self:set_hover(false) end --- Set hover state --- @tparam Hover self @{Hover} +-- @tparam Hover self Hover -- @tparam boolean|nil state The hover state -function Hover.set_hover(self, state) +function M:set_hover(state) if self._is_hovered == state then return end @@ -122,17 +132,17 @@ end --- Return current hover state. True if touch action was on the node at current time --- @tparam Hover self @{Hover} +-- @tparam Hover self Hover -- @treturn boolean The current hovered state -function Hover.is_hovered(self) +function M:is_hovered() return self._is_hovered end --- Set mouse hover state --- @tparam Hover self @{Hover} +-- @tparam Hover self Hover -- @tparam boolean|nil state The mouse hover state -function Hover.set_mouse_hover(self, state) +function M:set_mouse_hover(state) if self._is_mouse_hovered == state then return end @@ -147,18 +157,18 @@ end --- Return current hover state. True if nil action_id (usually desktop mouse) was on the node at current time --- @tparam Hover self @{Hover} +-- @tparam Hover self Hover -- @treturn boolean The current hovered state -function Hover.is_mouse_hovered(self) +function M:is_mouse_hovered() return self._is_mouse_hovered end --- Strict hover click area. Useful for -- no click events outside stencil node --- @tparam Hover self @{Hover} +-- @tparam Hover self Hover -- @tparam node|string|nil zone Gui node -function Hover.set_click_zone(self, zone) +function M:set_click_zone(zone) self.click_zone = self:get_node(zone) end @@ -166,9 +176,9 @@ end --- Set enable state of hover component. -- If hover is not enabled, it will not generate -- any hover events --- @tparam Hover self @{Hover} +-- @tparam Hover self Hover -- @tparam boolean|nil state The hover enabled state -function Hover.set_enabled(self, state) +function M:set_enabled(state) self._is_enabled = state if not state then @@ -183,16 +193,17 @@ end --- Return current hover enabled state --- @tparam Hover self @{Hover} +-- @tparam Hover self Hover -- @treturn boolean The hover enabled state -function Hover.is_enabled(self) +function M:is_enabled() return self._is_enabled end -- Internal cursor stack local cursor_stack = {} -function Hover:_set_cursor(priority, cursor) +---@local +function M:_set_cursor(priority, cursor) if not defos then return end @@ -217,4 +228,4 @@ function Hover:_set_cursor(priority, cursor) end -return Hover +return M diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index 3aa9f77..f8bc2c6 100755 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -39,13 +39,13 @@ --- On scroll move callback(self, position) --- @tfield DruidEvent on_scroll @{DruidEvent} +-- @tfield DruidEvent on_scroll DruidEvent --- On scroll_to function callback(self, target, is_instant) --- @tfield DruidEvent on_scroll_to @{DruidEvent} +-- @tfield DruidEvent on_scroll_to DruidEvent --- On scroll_to_index function callback(self, index, point) --- @tfield DruidEvent on_point_scroll @{DruidEvent} +-- @tfield DruidEvent on_point_scroll DruidEvent --- Scroll view node -- @tfield node view_node @@ -75,7 +75,7 @@ -- @tfield vector3 available_size --- Drag Druid component --- @tfield Drag drag @{Drag} +-- @tfield Drag drag Drag --- Current index of points of interests -- @tfield number|nil selected @@ -90,7 +90,16 @@ local const = require("druid.const") local helper = require("druid.helper") local component = require("druid.component") -local Scroll = component.create("scroll") +---@class druid.scroll: druid.base_component +---@field on_scroll druid.event +---@field on_scroll_to druid.event +---@field on_point_scroll druid.event +---@field view_node node +---@field view_border vector4 +---@field content_node node +---@field view_size vector3 +---@field position vector3 +local M = component.create("scroll") local function inverse_lerp(min, max, current) @@ -138,7 +147,7 @@ end -- @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) +function M:on_style_change(style) self.style = {} self.style.EXTRA_STRETCH_SIZE = style.EXTRA_STRETCH_SIZE or 0 self.style.ANIM_SPEED = style.ANIM_SPEED or 0.2 @@ -161,11 +170,11 @@ function Scroll.on_style_change(self, style) end ---- The @{Scroll} constructor --- @tparam Scroll self @{Scroll} +--- 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 -function Scroll.init(self, view_node, content_node) +function M:init(view_node, content_node) self.druid = self:get_druid() self.view_node = self:get_node(view_node) @@ -203,7 +212,7 @@ function Scroll.init(self, view_node, content_node) end -function Scroll.on_late_init(self) +function M:on_late_init() if not self.click_zone and const.IS_STENCIL_CHECK then local stencil_node = helper.get_closest_stencil_node(self.node) if stencil_node then @@ -213,12 +222,12 @@ function Scroll.on_late_init(self) end -function Scroll.on_layout_change(self) +function M:on_layout_change() gui.set_position(self.content_node, self.position) end -function Scroll.update(self, dt) +function M:update(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") @@ -233,23 +242,23 @@ function Scroll.update(self, dt) end -function Scroll.on_input(self, action_id, action) +function M:on_input(action_id, action) return self:_process_scroll_wheel(action_id, action) end -function Scroll.on_remove(self) +function M:on_remove() self:bind_grid(nil) end --- Start scroll to target point. --- @tparam Scroll self @{Scroll} +-- @tparam Scroll self Scroll -- @tparam vector3 point Target point -- @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) +function M:scroll_to(point, is_instant) local b = self.available_pos local target = vmath.vector3( self._is_horizontal_scroll and -point.x or self.target_position.x, @@ -278,10 +287,10 @@ end --- Scroll to item in scroll by point index. --- @tparam Scroll self @{Scroll} +-- @tparam Scroll self Scroll -- @tparam number index Point index -- @tparam boolean|nil skip_cb If true, skip the point callback -function Scroll.scroll_to_index(self, index, skip_cb) +function M:scroll_to_index(index, skip_cb) if not self.points then return end @@ -301,11 +310,11 @@ end --- Start scroll to target scroll percent --- @tparam Scroll self @{Scroll} +-- @tparam Scroll self Scroll -- @tparam vector3 percent target percent -- @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) +function M:scroll_to_percent(percent, is_instant) local border = self.available_pos local pos = vmath.vector3( @@ -327,9 +336,9 @@ end --- Return current scroll progress status. -- Values will be in [0..1] interval --- @tparam Scroll self @{Scroll} +-- @tparam Scroll self Scroll -- @treturn vector3 New vector with scroll progress values -function Scroll.get_percent(self) +function M:get_percent() local x_perc = 1 - inverse_lerp(self.available_pos.x, self.available_pos.z, self.position.x) local y_perc = inverse_lerp(self.available_pos.w, self.available_pos.y, self.position.y) @@ -339,11 +348,11 @@ end --- Set scroll content size. -- It will change content gui node size --- @tparam Scroll self @{Scroll} +-- @tparam Scroll self Scroll -- @tparam vector3 size The new size for content node -- @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) +function M:set_size(size, offset) if offset then self._offset = offset end @@ -355,10 +364,10 @@ end --- Set new scroll view size in case the node size was changed. --- @tparam Scroll self @{Scroll} +-- @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) +function M:set_view_size(size) gui.set_size(self.view_node, size) self.view_size = size self.view_border = helper.get_border(self.view_node) @@ -369,8 +378,8 @@ end --- Refresh scroll view size --- @tparam Scroll self @{Scroll} -function Scroll.update_view_size(self) +-- @tparam Scroll self Scroll +function M:update_view_size() self.view_size = helper.get_scaled_size(self.view_node) self.view_border = helper.get_border(self.view_node) self:_update_size() @@ -382,10 +391,10 @@ 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 Scroll self Scroll -- @tparam boolean|nil state Inert scroll state -- @treturn druid.scroll Current scroll instance -function Scroll.set_inert(self, state) +function M:set_inert(state) self._is_inert = state return self @@ -393,19 +402,19 @@ end --- Return if scroll have inertion. --- @tparam Scroll self @{Scroll} +-- @tparam Scroll self Scroll -- @treturn boolean @If scroll have inertion -function Scroll.is_inert(self) +function M:is_inert() return self._is_inert end --- Set extra size for scroll stretching. -- Set 0 to disable stretching effect --- @tparam Scroll self @{Scroll} +-- @tparam Scroll self Scroll -- @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) +function M:set_extra_stretch_size(stretch_size) self.style.EXTRA_STRETCH_SIZE = stretch_size or 0 self:_update_size() @@ -414,19 +423,19 @@ end --- Return vector of scroll size with width and height. --- @tparam Scroll self @{Scroll} +-- @tparam Scroll self Scroll -- @treturn vector3 Available scroll size -function Scroll.get_scroll_size(self) +function M:get_scroll_size() return self.available_size end --- Set points of interest. -- Scroll will always centered on closer points --- @tparam Scroll self @{Scroll} +-- @tparam Scroll self Scroll -- @tparam table points Array of vector3 points -- @treturn druid.scroll Current scroll instance -function Scroll.set_points(self, points) +function M:set_points(points) self.points = points table.sort(self.points, function(a, b) @@ -440,10 +449,10 @@ end --- Lock or unlock horizontal scroll --- @tparam Scroll self @{Scroll} +-- @tparam Scroll self Scroll -- @tparam boolean|nil state True, if horizontal scroll is enabled -- @treturn druid.scroll Current scroll instance -function Scroll.set_horizontal_scroll(self, state) +function M:set_horizontal_scroll(state) self._is_horizontal_scroll = state self.drag.can_x = self.available_size.x > 0 and state return self @@ -451,10 +460,10 @@ end --- Lock or unlock vertical scroll --- @tparam Scroll self @{Scroll} +-- @tparam Scroll self Scroll -- @tparam boolean|nil state True, if vertical scroll is enabled -- @treturn druid.scroll Current scroll instance -function Scroll.set_vertical_scroll(self, state) +function M:set_vertical_scroll(state) self._is_vertical_scroll = state self.drag.can_y = self.available_size.y > 0 and state return self @@ -463,10 +472,10 @@ end --- Check node if it visible now on scroll. -- Extra border is not affected. Return true for elements in extra scroll zone --- @tparam Scroll self @{Scroll} +-- @tparam Scroll self Scroll -- @tparam node node The node to check -- @treturn boolean True if node in visible scroll area -function Scroll.is_node_in_view(self, node) +function M:is_node_in_view(node) local node_offset_for_view = gui.get_position(node) local parent = gui.get_parent(node) local is_parent_of_view = false @@ -504,10 +513,10 @@ end --- Bind the grid component (Static or Dynamic) to recalculate -- scroll size on grid changes --- @tparam Scroll self @{Scroll} +-- @tparam Scroll self Scroll -- @tparam StaticGrid grid Druid grid component -- @treturn druid.scroll Current scroll instance -function Scroll.bind_grid(self, grid) +function M:bind_grid(grid) if self._grid_on_change then self._grid_on_change:unsubscribe(self._grid_on_change_callback) @@ -535,12 +544,12 @@ end -- restrict events outside stencil node -- @tparam Drag self -- @tparam node|string node Gui node -function Scroll.set_click_zone(self, node) +function M:set_click_zone(node) self.drag:set_click_zone(node) end -function Scroll._on_scroll_drag(self, dx, dy) +function M:_on_scroll_drag(dx, dy) local t = self.target_position local b = self.available_pos local eb = self.available_pos_extra @@ -581,7 +590,7 @@ function Scroll._on_scroll_drag(self, dx, dy) end -function Scroll._check_soft_zone(self) +function M:_check_soft_zone() local target = self.target_position local border = self.available_pos local speed = self.style.BACK_SPEED @@ -610,7 +619,7 @@ end -- Cancel animation on other animation or input touch -function Scroll._cancel_animate(self) +function M:_cancel_animate() self.inertion.x = 0 self.inertion.y = 0 @@ -624,7 +633,7 @@ function Scroll._cancel_animate(self) end -function Scroll._set_scroll_position(self, position_x, position_y) +function M:_set_scroll_position(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) @@ -643,7 +652,7 @@ end -- if no inert, scroll to next point by scroll direction -- if inert, find next point by scroll director -- @local -function Scroll._check_points(self) +function M:_check_points() if not self.points then return end @@ -699,7 +708,7 @@ function Scroll._check_points(self) end -function Scroll._check_threshold(self) +function M:_check_threshold() local is_stopped = false if self.drag.can_x and math.abs(self.inertion.x) < self.style.INERT_THRESHOLD then @@ -717,7 +726,7 @@ function Scroll._check_threshold(self) end -function Scroll._update_free_scroll(self, dt) +function M:_update_free_scroll(dt) if self.is_animate then return end @@ -742,7 +751,7 @@ function Scroll._update_free_scroll(self, dt) end -function Scroll._update_hand_scroll(self, dt) +function M:_update_hand_scroll(dt) if self.is_animate then self:_cancel_animate() end @@ -757,7 +766,7 @@ function Scroll._update_hand_scroll(self, dt) end -function Scroll._on_touch_start(self) +function M:_on_touch_start() self.inertion.x = 0 self.inertion.y = 0 self.target_position.x = self.position.x @@ -765,12 +774,12 @@ function Scroll._on_touch_start(self) end -function Scroll._on_touch_end(self) +function M:_on_touch_end() self:_check_threshold() end -function Scroll._update_size(self) +function M:_update_size() local content_border = helper.get_border(self.content_node) local content_size = helper.get_scaled_size(self.content_node) @@ -808,7 +817,7 @@ function Scroll._update_size(self) end -function Scroll._process_scroll_wheel(self, action_id, action) +function M:_process_scroll_wheel(action_id, action) if not self._is_mouse_hover or self.style.WHEEL_SCROLL_SPEED == 0 then return false end @@ -845,9 +854,9 @@ function Scroll._process_scroll_wheel(self, action_id, action) end -function Scroll._on_mouse_hover(self, state) +function M:_on_mouse_hover(state) self._is_mouse_hover = state end -return Scroll +return M diff --git a/druid/base/static_grid.lua b/druid/base/static_grid.lua index c602ce0..c78d7ec 100644 --- a/druid/base/static_grid.lua +++ b/druid/base/static_grid.lua @@ -37,19 +37,19 @@ -- @alias druid.static_grid --- On item add callback(self, node, index) --- @tfield DruidEvent on_add_item @{DruidEvent} +-- @tfield DruidEvent on_add_item DruidEvent --- On item remove callback(self, index) --- @tfield DruidEvent on_remove_item @{DruidEvent} +-- @tfield DruidEvent on_remove_item DruidEvent --- On item add, remove or change in_row callback(self, index|nil) --- @tfield DruidEvent on_change_items @{DruidEvent} +-- @tfield DruidEvent on_change_items DruidEvent --- On grid clear callback(self) --- @tfield DruidEvent on_clear @{DruidEvent} +-- @tfield DruidEvent on_clear DruidEvent --- On update item positions callback(self) --- @tfield DruidEvent on_update_positions @{DruidEvent} +-- @tfield DruidEvent on_update_positions DruidEvent --- Parent gui node -- @tfield node parent @@ -82,7 +82,23 @@ local Event = require("druid.event") local helper = require("druid.helper") local component = require("druid.component") -local StaticGrid = component.create("static_grid") +---@class druid.grid: druid.base_component +---@field on_add_item druid.event +---@field on_remove_item druid.event +---@field on_change_items druid.event +---@field on_clear druid.event +---@field on_update_positions druid.event +---@field parent node +---@field nodes node[] +---@field first_index number +---@field last_index number +---@field anchor vector3 +---@field pivot vector3 +---@field node_size vector3 +---@field border vector4 +---@field in_row number +---@field style table +local M = component.create("static_grid") local function _extend_border(border, pos, size, pivot) @@ -104,23 +120,23 @@ end -- @table style -- @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) +function M:on_style_change(style) self.style = {} self.style.IS_DYNAMIC_NODE_POSES = style.IS_DYNAMIC_NODE_POSES or false self.style.IS_ALIGN_LAST_ROW = style.IS_ALIGN_LAST_ROW or false end ---- The @{StaticGrid} constructor --- @tparam StaticGrid self @{StaticGrid} +--- The StaticGrid constructor +-- @tparam StaticGrid self StaticGrid -- @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 number|nil in_row How many nodes in row can be placed. By default 1 -function StaticGrid.init(self, parent, element, in_row) +function M:init(parent, element, in_row) self.parent = self:get_node(parent) self.nodes = {} - self.pivot = helper.get_pivot_offset(gui.get_pivot(self.parent)) + self.pivot = helper.get_pivot_offset(self.parent) self.anchor = vmath.vector3(0.5 + self.pivot.x, 0.5 - self.pivot.y, 0) self.in_row = in_row or 1 @@ -149,10 +165,10 @@ end local _temp_pos = vmath.vector3(0) --- Return pos for grid node index --- @tparam StaticGrid self @{StaticGrid} +-- @tparam StaticGrid self StaticGrid -- @tparam number index The grid element index -- @treturn vector3 @Node position -function StaticGrid.get_pos(self, index) +function M:get_pos(index) local row = math.ceil(index / self.in_row) - 1 local col = (index - row * self.in_row) - 1 @@ -167,10 +183,10 @@ end --- Return index for grid pos --- @tparam StaticGrid self @{StaticGrid} +-- @tparam StaticGrid self StaticGrid -- @tparam vector3 pos The node position in the grid -- @treturn number The node index -function StaticGrid.get_index(self, pos) +function M:get_index(pos) -- 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) @@ -187,10 +203,10 @@ end --- Return grid index by node --- @tparam StaticGrid self @{StaticGrid} +-- @tparam StaticGrid self StaticGrid -- @tparam node node The gui node in the grid -- @treturn number The node index -function StaticGrid.get_index_by_node(self, node) +function M:get_index_by_node(node) for index, grid_node in pairs(self.nodes) do if node == grid_node then return index @@ -201,28 +217,28 @@ function StaticGrid.get_index_by_node(self, node) end -function StaticGrid.on_layout_change(self) +function M:on_layout_change() self:_update(true) end --- Set grid anchor. Default anchor is equal to anchor of grid parent node --- @tparam StaticGrid self @{StaticGrid} +-- @tparam StaticGrid self StaticGrid -- @tparam vector3 anchor Anchor -function StaticGrid.set_anchor(self, anchor) +function M:set_anchor(anchor) self.anchor = anchor self:_update() end --- Update grid content --- @tparam StaticGrid self @{StaticGrid} -function StaticGrid.refresh(self) +-- @tparam StaticGrid self StaticGrid +function M:refresh() self:_update(true) end -function StaticGrid.set_pivot(self, pivot) +function M:set_pivot(pivot) local prev_pivot = helper.get_pivot_offset(gui.get_pivot(self.parent)) self.pivot = helper.get_pivot_offset(pivot) @@ -254,12 +270,12 @@ end --- Add new item to the grid --- @tparam StaticGrid self @{StaticGrid} +-- @tparam StaticGrid self StaticGrid -- @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) +function M:add(item, index, shift_policy, is_instant) index = index or ((self.last_index or 0) + 1) helper.insert_with_shift(self.nodes, item, index, shift_policy) @@ -279,10 +295,10 @@ end --- Set new items to the grid. All previous items will be removed --- @tparam StaticGrid self @{StaticGrid} +-- @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) +function M:set_items(nodes, is_instant) self.nodes = nodes for index = 1, #nodes do local item = nodes[index] @@ -296,12 +312,12 @@ end --- Remove the item from the grid. Note that gui node will be not deleted --- @tparam StaticGrid self @{StaticGrid} +-- @tparam StaticGrid self StaticGrid -- @tparam number index The grid node index to remove -- @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) +function M:remove(index, shift_policy, is_instant) assert(self.nodes[index], "No grid item at given index " .. index) local remove_node = self.nodes[index] @@ -317,9 +333,9 @@ end --- Return grid content size --- @tparam StaticGrid self @{StaticGrid} +-- @tparam StaticGrid self StaticGrid -- @treturn vector3 The grid content size -function StaticGrid.get_size(self) +function M:get_size() return vmath.vector3( self.border.z - self.border.x, self.border.y - self.border.w, @@ -327,7 +343,7 @@ function StaticGrid.get_size(self) end -function StaticGrid.get_size_for(self, count) +function M:get_size_for(count) if not count or count == 0 then return vmath.vector3(0) end @@ -350,17 +366,17 @@ end --- Return grid content borders --- @tparam StaticGrid self @{StaticGrid} +-- @tparam StaticGrid self StaticGrid -- @treturn vector3 The grid content borders -function StaticGrid.get_borders(self) +function M:get_borders() return self.border end --- Return array of all node positions --- @tparam StaticGrid self @{StaticGrid} +-- @tparam StaticGrid self StaticGrid -- @treturn vector3[] All grid node positions -function StaticGrid.get_all_pos(self) +function M:get_all_pos() local result = {} for i, node in pairs(self.nodes) do table.insert(result, gui.get_position(node)) @@ -372,10 +388,10 @@ end --- Change set position function for grid nodes. It will call on -- update poses on grid elements. Default: gui.set_position --- @tparam StaticGrid self @{StaticGrid} +-- @tparam StaticGrid self StaticGrid -- @tparam function callback Function on node set position -- @treturn druid.static_grid Current grid instance -function StaticGrid.set_position_function(self, callback) +function M:set_position_function(callback) self._set_position_function = callback or gui.set_position return self @@ -384,9 +400,9 @@ end --- Clear grid nodes array. GUI nodes will be not deleted! -- If you want to delete GUI nodes, use static_grid.nodes array before grid:clear --- @tparam StaticGrid self @{StaticGrid} +-- @tparam StaticGrid self StaticGrid -- @treturn druid.static_grid Current grid instance -function StaticGrid.clear(self) +function M:clear() self.border.x = 0 self.border.y = 0 self.border.w = 0 @@ -403,9 +419,9 @@ end --- Return StaticGrid offset, where StaticGrid content starts. --- @tparam StaticGrid self @{StaticGrid} The StaticGrid instance +-- @tparam StaticGrid self StaticGrid The StaticGrid instance -- @treturn vector3 The StaticGrid offset -function StaticGrid:get_offset() +function M:get_offset() local borders = self:get_borders() local size = self:get_size() @@ -419,10 +435,10 @@ end --- Set new in_row elements for grid --- @tparam StaticGrid self @{StaticGrid} +-- @tparam StaticGrid self StaticGrid -- @tparam number in_row The new in_row value -- @treturn druid.static_grid Current grid instance -function StaticGrid.set_in_row(self, in_row) +function M:set_in_row(in_row) self.in_row = in_row self._grid_horizonal_offset = self.node_size.x * (self.in_row - 1) * self.anchor.x self._zero_offset = vmath.vector3( @@ -438,11 +454,11 @@ end --- Set new node size for grid --- @tparam StaticGrid self @{StaticGrid} +-- @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) +function M:set_item_size(width, height) if width then self.node_size.x = width end @@ -463,20 +479,20 @@ end --- Sort grid nodes by custom comparator function --- @tparam StaticGrid self @{StaticGrid} +-- @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) +function M:sort_nodes(comparator) table.sort(self.nodes, comparator) self:_update(true) end --- Update grid inner state --- @tparam StaticGrid self @{StaticGrid} +-- @tparam StaticGrid self StaticGrid -- @tparam boolean|nil is_instant If true, node position update instantly, otherwise with set_position_function callback -- @local -function StaticGrid._update(self, is_instant) +function M:_update(is_instant) self:_update_indexes() self:_update_borders() self:_update_pos(is_instant) @@ -484,9 +500,9 @@ end --- Update first and last indexes of grid nodes --- @tparam StaticGrid self @{StaticGrid} +-- @tparam StaticGrid self StaticGrid -- @local -function StaticGrid._update_indexes(self) +function M:_update_indexes() self.first_index = nil self.last_index = nil for index in pairs(self.nodes) do @@ -500,9 +516,9 @@ end --- Update grid content borders, recalculate min and max values --- @tparam StaticGrid self @{StaticGrid} +-- @tparam StaticGrid self StaticGrid -- @local -function StaticGrid._update_borders(self) +function M:_update_borders() if not self.first_index then self.border = vmath.vector4(0) return @@ -519,10 +535,10 @@ end --- Update grid nodes position --- @tparam StaticGrid self @{StaticGrid} +-- @tparam StaticGrid self StaticGrid -- @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) +function M:_update_pos(is_instant) local zero_offset = self:_get_zero_offset() for i, node in pairs(self.nodes) do @@ -545,7 +561,7 @@ end -- parent pivot node (0:0) with adjusting of node sizes and anchoring -- @treturn vector3 The offset vector -- @local -function StaticGrid:_get_zero_offset() +function M:_get_zero_offset() if not self.style.IS_DYNAMIC_NODE_POSES then return const.VECTOR_ZERO end @@ -562,7 +578,7 @@ end --- Return offset x for last row in grid. Used to align this row accorting to grid's anchor -- @treturn number The offset x value -- @local -function StaticGrid:_get_zero_offset_x(row_index) +function M:_get_zero_offset_x(row_index) if not self.style.IS_DYNAMIC_NODE_POSES or not self.style.IS_ALIGN_LAST_ROW then return self._zero_offset.x end @@ -580,4 +596,4 @@ function StaticGrid:_get_zero_offset_x(row_index) end -return StaticGrid +return M diff --git a/druid/base/text.lua b/druid/base/text.lua index 39188f4..66b11ac 100755 --- a/druid/base/text.lua +++ b/druid/base/text.lua @@ -36,13 +36,13 @@ -- @alias druid.text --- On set text callback(self, text) --- @tfield DruidEvent on_set_text @{DruidEvent} +-- @tfield DruidEvent on_set_text DruidEvent --- On adjust text size callback(self, new_scale, text_metrics) --- @tfield DruidEvent on_update_text_scale @{DruidEvent} +-- @tfield DruidEvent on_update_text_scale DruidEvent --- On change pivot callback(self, pivot) --- @tfield DruidEvent on_set_pivot @{DruidEvent} +-- @tfield DruidEvent on_set_pivot DruidEvent --- Text node -- @tfield node node @@ -83,7 +83,16 @@ local utf8_lua = require("druid.system.utf8") local component = require("druid.component") local utf8 = utf8 or utf8_lua --[[@as utf8]] -local Text = component.create("text") +---@class druid.text: druid.base_component +---@field node node +---@field on_set_text druid.event +---@field on_update_text_scale druid.event +---@field on_set_pivot druid.event +---@field style table +---@field private start_pivot number +---@field private start_scale vector3 +---@field private scale vector3 +local M = component.create("text") local function update_text_size(self) if self.scale.x == 0 or self.scale.y == 0 then @@ -269,7 +278,7 @@ end -- @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) +function M:on_style_change(style) self.style = {} self.style.TRIM_POSTFIX = style.TRIM_POSTFIX or "..." self.style.DEFAULT_ADJUST = style.DEFAULT_ADJUST or const.TEXT_ADJUST.DOWNSCALE @@ -278,12 +287,12 @@ function Text.on_style_change(self, style) end ---- The @{Text} constructor --- @tparam Text self @{Text} +--- The Text constructor +-- @tparam Text self Text -- @tparam string|node node Node name or GUI Text Node itself -- @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) +function M:init(node, value, adjust_type) self.node = self:get_node(node) self.pos = gui.get_position(self.node) self.node_id = gui.get_id(self.node) @@ -309,12 +318,12 @@ function Text.init(self, node, value, adjust_type) end -function Text.on_layout_change(self) +function M:on_layout_change() self:set_to(self.last_value) end -function Text.on_message_input(self, node_id, message) +function M:on_message_input(node_id, message) if node_id ~= self.node_id then return false end @@ -326,11 +335,11 @@ end --- Calculate text width with font with respect to trailing space --- @tparam Text self @{Text} +-- @tparam Text self Text -- @tparam string text|nil -- @treturn number Width -- @treturn number Height -function Text.get_text_size(self, text) +function M:get_text_size(text) text = text or self.last_value local font_name = gui.get_font(self.node) local font = gui.get_font_resource(font_name) @@ -351,10 +360,10 @@ end --- Get chars count by width --- @tparam Text self @{Text} +-- @tparam Text self Text -- @tparam number width -- @treturn number Chars count -function Text.get_text_index_by_width(self, width) +function M:get_text_index_by_width(width) local text = self.last_value local font_name = gui.get_font(self.node) local font = gui.get_font_resource(font_name) @@ -385,10 +394,10 @@ end --- Set text to text field --- @tparam Text self @{Text} +-- @tparam Text self Text -- @tparam string set_to Text for node -- @treturn Text Current text instance -function Text.set_to(self, set_to) +function M:set_to(set_to) set_to = set_to or "" self.last_value = set_to @@ -403,10 +412,10 @@ end --- Set text area size --- @tparam Text self @{Text} +-- @tparam Text self Text -- @tparam vector3 size The new text area size -- @treturn Text Current text instance -function Text.set_size(self, size) +function M:set_size(size) self.start_size = size self.text_area = vmath.vector3(size) self.text_area.x = self.text_area.x * self.start_scale.x @@ -416,10 +425,10 @@ end --- Set color --- @tparam Text self @{Text} +-- @tparam Text self Text -- @tparam vector4 color Color for node -- @treturn Text Current text instance -function Text.set_color(self, color) +function M:set_color(color) self.color = color gui.set_color(self.node, color) @@ -428,10 +437,10 @@ end --- Set alpha --- @tparam Text self @{Text} +-- @tparam Text self Text -- @tparam number alpha Alpha for node -- @treturn Text Current text instance -function Text.set_alpha(self, alpha) +function M:set_alpha(alpha) self.color.w = alpha gui.set_color(self.node, self.color) @@ -440,10 +449,10 @@ end --- Set scale --- @tparam Text self @{Text} +-- @tparam Text self Text -- @tparam vector3 scale Scale for node -- @treturn Text Current text instance -function Text.set_scale(self, scale) +function M:set_scale(scale) self.last_scale = scale gui.set_scale(self.node, scale) @@ -452,10 +461,10 @@ end --- Set text pivot. Text will re-anchor inside text area --- @tparam Text self @{Text} +-- @tparam Text self Text -- @tparam number pivot The gui.PIVOT_* constant -- @treturn Text Current text instance -function Text.set_pivot(self, pivot) +function M:set_pivot(pivot) local prev_pivot = gui.get_pivot(self.node) local prev_offset = const.PIVOTS[prev_pivot] @@ -478,19 +487,19 @@ end --- Return true, if text with line break --- @tparam Text self @{Text} +-- @tparam Text self Text -- @treturn boolean Is text node with line break -function Text.is_multiline(self) +function M:is_multiline() return gui.get_line_break(self.node) end --- Set text adjust, refresh the current text visuals, if needed --- @tparam Text self @{Text} +-- @tparam Text self Text -- @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) +function M:set_text_adjust(adjust_type, minimal_scale) self.adjust_type = adjust_type self._minimal_scale = minimal_scale self:set_to(self.last_value) @@ -500,10 +509,10 @@ end --- Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types --- @tparam Text self @{Text} +-- @tparam Text self Text -- @tparam number minimal_scale If pass nil - not use minimal scale -- @treturn Text Current text instance -function Text.set_minimal_scale(self, minimal_scale) +function M:set_minimal_scale(minimal_scale) self._minimal_scale = minimal_scale return self @@ -512,9 +521,9 @@ end --- Return current text adjust type -- @treturn number The current text adjust type -function Text.get_text_adjust(self, adjust_type) +function M:get_text_adjust(adjust_type) return self.adjust_type end -return Text +return M diff --git a/druid/component.lua b/druid/component.lua index 0672303..9ce4138 100644 --- a/druid/component.lua +++ b/druid/component.lua @@ -1,83 +1,99 @@ --- Copyright (c) 2021 Maksim Tuprikov . This code is licensed under MIT license - ---- Basic class for all Druid components. --- To create you custom component, use static function `component.create` --- @usage --- -- Create your component: --- local component = require("druid.component") --- --- local AwesomeComponent = component.create("awesome_component") --- --- function AwesomeComponent:init(template, nodes) --- self:set_template(template) --- self:set_nodes(nodes) --- self.druid = self:get_druid() --- end --- --- return AwesomeComponent --- @module BaseComponent --- @alias druid.base_component +---Base component class for all Druid components. local const = require("druid.const") local helper = require("druid.helper") -local BaseComponent = {} +---@class druid.base_component.meta +---@field template string +---@field context table +---@field nodes table +---@field style table +---@field druid druid_instance +---@field input_enabled boolean +---@field children table +---@field parent druid.base_component +---@field instance_class table + +---@class druid.base_component.component +---@field name string +---@field input_priority number +---@field default_input_priority number +---@field _is_input_priority_changed boolean +---@field _uid number + +---@class druid.base_component +---@field druid druid_instance Druid instance to create inner components +---@field protected init fun(self:druid.base_component, ...)|nil +---@field protected update fun(self:druid.base_component, dt:number)|nil +---@field protected on_remove fun(self:druid.base_component)|nil +---@field protected on_input fun(self:druid.base_component, action_id:number, action:table)|nil +---@field protected on_message fun(self:druid.base_component, message_id:hash, message:table, sender:userdata)|nil +---@field protected on_late_init fun(self:druid.base_component)|nil +---@field protected on_focus_lost fun(self:druid.base_component)|nil +---@field protected on_focus_gained fun(self:druid.base_component)|nil +---@field protected on_style_change fun(self:druid.base_component, style: table)|nil +---@field protected on_layout_change fun(self:druid.base_component)|nil +---@field protected on_window_resized fun(self:druid.base_component, width:number, height:number)|nil +---@field protected on_language_change fun(self:druid.base_component, language:string)|nil +---@field private _component druid.base_component.component +---@field private _meta druid.base_component.meta +local M = {} local INTERESTS = {} -- Cache interests per component class in runtime local IS_AUTO_TEMPLATE = not (sys.get_config_int("druid.no_auto_template", 0) == 1) -- Component Interests -BaseComponent.ON_INPUT = const.ON_INPUT -BaseComponent.ON_UPDATE = const.ON_UPDATE -BaseComponent.ON_MESSAGE = const.ON_MESSAGE -BaseComponent.ON_LATE_INIT = const.ON_LATE_INIT -BaseComponent.ON_FOCUS_LOST = const.ON_FOCUS_LOST -BaseComponent.ON_FOCUS_GAINED = const.ON_FOCUS_GAINED -BaseComponent.ON_LAYOUT_CHANGE = const.ON_LAYOUT_CHANGE -BaseComponent.ON_MESSAGE_INPUT = const.ON_MESSAGE_INPUT -BaseComponent.ON_WINDOW_RESIZED = const.ON_WINDOW_RESIZED -BaseComponent.ON_LANGUAGE_CHANGE = const.ON_LANGUAGE_CHANGE +M.ON_INPUT = const.ON_INPUT +M.ON_UPDATE = const.ON_UPDATE +M.ON_MESSAGE = const.ON_MESSAGE +M.ON_LATE_INIT = const.ON_LATE_INIT +M.ON_FOCUS_LOST = const.ON_FOCUS_LOST +M.ON_FOCUS_GAINED = const.ON_FOCUS_GAINED +M.ON_LAYOUT_CHANGE = const.ON_LAYOUT_CHANGE +M.ON_MESSAGE_INPUT = const.ON_MESSAGE_INPUT +M.ON_WINDOW_RESIZED = const.ON_WINDOW_RESIZED +M.ON_LANGUAGE_CHANGE = const.ON_LANGUAGE_CHANGE -BaseComponent.ALL_INTERESTS = { - BaseComponent.ON_INPUT, - BaseComponent.ON_UPDATE, - BaseComponent.ON_MESSAGE, - BaseComponent.ON_LATE_INIT, - BaseComponent.ON_FOCUS_LOST, - BaseComponent.ON_FOCUS_GAINED, - BaseComponent.ON_LAYOUT_CHANGE, - BaseComponent.ON_MESSAGE_INPUT, - BaseComponent.ON_WINDOW_RESIZED, - BaseComponent.ON_LANGUAGE_CHANGE, +M.ALL_INTERESTS = { + M.ON_INPUT, + M.ON_UPDATE, + M.ON_MESSAGE, + M.ON_LATE_INIT, + M.ON_FOCUS_LOST, + M.ON_FOCUS_GAINED, + M.ON_LAYOUT_CHANGE, + M.ON_MESSAGE_INPUT, + M.ON_WINDOW_RESIZED, + M.ON_LANGUAGE_CHANGE, } -- Mapping from on_message method to specific method name -BaseComponent.SPECIFIC_UI_MESSAGES = { - [hash("layout_changed")] = BaseComponent.ON_LAYOUT_CHANGE, -- The message_id from Defold - [hash(BaseComponent.ON_FOCUS_LOST)] = BaseComponent.ON_FOCUS_LOST, - [hash(BaseComponent.ON_FOCUS_GAINED)] = BaseComponent.ON_FOCUS_GAINED, - [hash(BaseComponent.ON_WINDOW_RESIZED)] = BaseComponent.ON_WINDOW_RESIZED, - [hash(BaseComponent.ON_MESSAGE_INPUT)] = BaseComponent.ON_MESSAGE_INPUT, - [hash(BaseComponent.ON_LANGUAGE_CHANGE)] = BaseComponent.ON_LANGUAGE_CHANGE, +M.SPECIFIC_UI_MESSAGES = { + [hash("layout_changed")] = M.ON_LAYOUT_CHANGE, -- The message_id from Defold + [hash(M.ON_FOCUS_LOST)] = M.ON_FOCUS_LOST, + [hash(M.ON_FOCUS_GAINED)] = M.ON_FOCUS_GAINED, + [hash(M.ON_WINDOW_RESIZED)] = M.ON_WINDOW_RESIZED, + [hash(M.ON_MESSAGE_INPUT)] = M.ON_MESSAGE_INPUT, + [hash(M.ON_LANGUAGE_CHANGE)] = M.ON_LANGUAGE_CHANGE, } local uid = 0 -function BaseComponent.create_uid() +---@private +function M.create_uid() uid = uid + 1 return uid end ---- Set current component style table. --- --- Invoke `on_style_change` on component, if exist. Component should handle --- their style changing and store all style params --- @tparam BaseComponent self @{BaseComponent} --- @tparam table|nil druid_style Druid style module --- @treturn BaseComponent @{BaseComponent} --- @local -function BaseComponent.set_style(self, druid_style) +---Set component style. Pass nil to clear style +---@generic T +---@param self T +---@param druid_style table|nil +---@return T self The component itself for chaining +function M.set_style(self, druid_style) + ---@cast self druid.base_component + self._meta.style = druid_style or {} local component_style = self._meta.style[self._component.name] or {} @@ -89,15 +105,16 @@ function BaseComponent.set_style(self, druid_style) end ---- Set component template name. --- --- 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() --- @tparam BaseComponent self @{BaseComponent} --- @tparam string template BaseComponent template name --- @treturn BaseComponent @{BaseComponent} --- @local -function BaseComponent.set_template(self, template) +---Set component template name. Pass nil to clear template. +---This template id used to access nodes inside the template on GUI scene. +---Parent template will be added automatically if exist. +---@generic T +---@param self T +---@param template string|nil +---@return T self The component itself for chaining +function M.set_template(self, template) + ---@cast self druid.base_component + template = template or "" local parent = self:get_parent_component() @@ -116,101 +133,49 @@ function BaseComponent.set_template(self, template) end ---- Get current component template name. --- @tparam BaseComponent self @{BaseComponent} --- @treturn string Component full template name -function BaseComponent.get_template(self) +---Get full template name. +---@return string +function M:get_template() return self._meta.template end ---- Set current component nodes. --- Use if your component nodes was cloned with `gui.clone_tree` and you got the node tree. --- @tparam BaseComponent self @{BaseComponent} --- @tparam table nodes BaseComponent nodes table --- @treturn BaseComponent @{BaseComponent} --- @usage --- local nodes = gui.clone_tree(self.prefab) --- ... In your component: --- self:set_nodes(nodes) --- @local -function BaseComponent.set_nodes(self, nodes) +---Set current component nodes, returned from `gui.clone_tree` function. +---@param nodes table +---@return druid.base_component +function M.set_nodes(self, nodes) self._meta.nodes = nodes - - -- When we use gui.clone_tree in inner template (template inside other template) - -- this nodes have no id. We have table: hash(correct_id) : hash("") - -- It's wrong and we use this hack to fix this - if nodes then - for id, node in pairs(nodes) do - gui.set_id(node, id) - end - end - return self end ---- Context used as first arg in all Druid events --- --- Context is usually self of gui_script. --- @tparam BaseComponent self @{BaseComponent} --- @treturn table BaseComponent context -function BaseComponent.get_context(self) +---Return current component context +---@return any context Usually it's self of script but can be any other Druid component +function M.get_context(self) return self._meta.context end ---- Increase input priority in input stack --- @tparam BaseComponent self @{BaseComponent} --- @local -function BaseComponent.increase_input_priority(self) - helper.deprecated("The component:increase_input_priority is deprecated. Please use component:set_input_priority(druid_const.PRIORITY_INPUT_MAX) instead") -end - - ---- Get component node by name. --- --- If component has nodes, node_or_name should be string --- It autopick node by template name or from nodes by gui.clone_tree --- if they was setup via component:set_nodes, component:set_template. --- If node is not found, the exception will fired --- @tparam BaseComponent self @{BaseComponent} --- @tparam string|node node_or_name Node name or node itself --- @treturn node Gui node -function BaseComponent.get_node(self, node_or_name) - if type(node_or_name) ~= "string" then +---Get component node by node_id. Respect to current template and nodes. +---@param node_id string|node +---@return node +function M.get_node(self, node_id) + if type(node_id) ~= "string" then -- Assume it's already node from gui.get_node - return node_or_name + return node_id end local template_name = self:get_template() - local nodes = self:__get_nodes() - - if #template_name > 0 then - template_name = template_name .. "/" - end - - local node - if nodes then - node = nodes[template_name .. node_or_name] - else - node = gui.get_node(template_name .. node_or_name) - end - - if not node then - assert(node, "No component with name: " .. (template_name or "") .. (node_or_name or "")) - end - - return node + local nodes = self:get_nodes() + return helper.get_node(node_id, template_name, nodes) end ---- Get Druid instance for inner component creation. --- @tparam BaseComponent self @{BaseComponent} --- @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) +---Get Druid instance for inner component creation. +---@param template string|nil +---@param nodes table|nil +---@return druid_instance +function M:get_druid(template, nodes) local context = { _context = self } local druid_instance = setmetatable(context, { __index = self._meta.druid }) @@ -226,39 +191,33 @@ function BaseComponent.get_druid(self, template, nodes) end ---- Return component name --- @tparam BaseComponent self @{BaseComponent} --- @treturn string The component name -function BaseComponent.get_name(self) - return self._component.name .. BaseComponent.create_uid() +---Get component name +---@return string name The component name + uid +function M.get_name(self) + return self._component.name .. M.create_uid() end ---- Return parent component name --- @tparam BaseComponent self @{BaseComponent} --- @treturn string|nil The parent component name if exist or bil -function BaseComponent.get_parent_name(self) +---Get parent component name +---@return string|nil parent_name The parent component name if exist or nil +function M.get_parent_name(self) local parent = self:get_parent_component() return parent and parent:get_name() end ---- Return component input priority --- @tparam BaseComponent self @{BaseComponent} --- @treturn number The component input priority -function BaseComponent.get_input_priority(self) +---Get component input priority, the bigger number processed first. Default value: 10 +---@return number +function M.get_input_priority(self) return self._component.input_priority end ---- Set component input priority --- --- Default value: 10 --- @tparam BaseComponent self @{BaseComponent} --- @tparam number value The new input priority 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) +---Set component input priority, the bigger number processed first. Default value: 10 +---@param value number +---@param is_temporary boolean|nil If true, the reset input priority will return to previous value +---@return druid.base_component self The component itself for chaining +function M.set_input_priority(self, value, is_temporary) assert(value) if self._component.input_priority == value then @@ -281,32 +240,27 @@ function BaseComponent.set_input_priority(self, value, is_temporary) end ---- Reset component input priority to default value --- @tparam BaseComponent self @{BaseComponent} --- @treturn number The component input priority -function BaseComponent.reset_input_priority(self) +---Reset component input priority to it's default value, that was set in `create` function or `set_input_priority` +---@return druid.base_component self The component itself for chaining +function M.reset_input_priority(self) self:set_input_priority(self._component.default_input_priority) return self end ---- Return component UID. --- --- UID generated in component creation order. --- @tparam BaseComponent self @{BaseComponent} --- @treturn number The component uid -function BaseComponent.get_uid(self) +---Get component UID, unique identifier created in component creation order. +---@return number uid The component uid +function M.get_uid(self) return self._component._uid end ---- Set component input state. By default it enabled --- --- If input is disabled, the component will not receive input events --- @tparam BaseComponent self @{BaseComponent} --- @tparam boolean|nil state The component input state --- @treturn BaseComponent BaseComponent itself -function BaseComponent.set_input_enabled(self, state) +---Set component input state. By default it's enabled. +---If input is disabled, the component will not receive input events. +---Recursive for all children components. +---@param state boolean +---@return druid.base_component self The component itself for chaining +function M.set_input_enabled(self, state) self._meta.input_enabled = state for index = 1, #self._meta.children do @@ -317,23 +271,22 @@ function BaseComponent.set_input_enabled(self, state) end ---- Return the parent component if exist --- @tparam BaseComponent self @{BaseComponent} --- @treturn BaseComponent|nil The druid component instance or nil -function BaseComponent.get_parent_component(self) +---Get parent component +---@return druid.base_component|nil parent The parent component if exist or nil +function M.get_parent_component(self) return self._meta.parent end --- Setup component context and his style table --- @tparam BaseComponent self @{BaseComponent} +-- @tparam BaseComponent self BaseComponent -- @tparam table druid_instance The parent druid instance -- @tparam table context Druid context. Usually it is self of script -- @tparam table style Druid style module -- @tparam table instance_class The component instance class -- @treturn component BaseComponent itself --- @local -function BaseComponent.setup_component(self, druid_instance, context, style, instance_class) +---@private +function M:setup_component(druid_instance, context, style, instance_class) self._meta = { template = "", context = context, @@ -357,62 +310,35 @@ function BaseComponent.setup_component(self, druid_instance, context, style, ins end ---- Print log information if debug mode is enabled --- @tparam BaseComponent self @{BaseComponent} --- @tparam string message --- @tparam table context --- @local -function BaseComponent.log_message(self, message, context) - if not self._component.is_debug then - return - end - print("[" .. self:get_name() .. "]:", message, helper.table_to_string(context)) -end - - ---- Set debug logs for component enabled or disabled --- @tparam BaseComponent self @{BaseComponent} --- @tparam boolean|nil is_debug --- @local -function BaseComponent.set_debug(self, is_debug) - self._component.is_debug = is_debug -end - - --- Return true, if input priority was changed --- @tparam BaseComponent self @{BaseComponent} --- @local -function BaseComponent._is_input_priority_changed(self) +-- @tparam BaseComponent self BaseComponent +---@private +function M._is_input_priority_changed(self) return self._component._is_input_priority_changed end --- Reset is_input_priority_changed field --- @tparam BaseComponent self @{BaseComponent} --- @local -function BaseComponent._reset_input_priority_changed(self) +-- @tparam BaseComponent self BaseComponent +---@private +function M._reset_input_priority_changed(self) self._component._is_input_priority_changed = false end -function BaseComponent.__tostring(self) - return self._component.name -end - - --- Get current component interests --- @tparam BaseComponent self @{BaseComponent} +-- @tparam BaseComponent self BaseComponent -- @treturn table List of component interests --- @local -function BaseComponent.__get_interests(self) +---@private +function M.__get_interests(self) local instance_class = self._meta.instance_class if INTERESTS[instance_class] then return INTERESTS[instance_class] end local interests = {} - for index = 1, #BaseComponent.ALL_INTERESTS do - local interest = BaseComponent.ALL_INTERESTS[index] + for index = 1, #M.ALL_INTERESTS do + local interest = M.ALL_INTERESTS[index] if self[interest] and type(self[interest]) == "function" then table.insert(interests, interest) end @@ -423,34 +349,31 @@ function BaseComponent.__get_interests(self) end ---- Get current component nodes --- @tparam BaseComponent self @{BaseComponent} --- @treturn table BaseComponent nodes table --- @local -function BaseComponent.__get_nodes(self) +---Get current component nodes +---@return table +function M.get_nodes(self) local nodes = self._meta.nodes local parent = self:get_parent_component() if parent then - nodes = nodes or parent:__get_nodes() + nodes = nodes or parent:get_nodes() end return nodes end ---- Add child to component children list --- @tparam BaseComponent self @{BaseComponent} --- @tparam component child The druid component instance --- @local -function BaseComponent.__add_child(self, child) +---Add child to component children list +---@param child druid.base_component The druid component instance +---@private +function M:__add_child(child) table.insert(self._meta.children, child) end --- Remove child from component children list --- @tparam BaseComponent self @{BaseComponent} +-- @tparam BaseComponent self BaseComponent -- @tparam component child The druid component instance --- @local -function BaseComponent.__remove_child(self, child) +---@private +function M.__remove_child(self, child) for i = #self._meta.children, 1, -1 do if self._meta.children[i] == child then table.remove(self._meta.children, i) @@ -461,9 +384,9 @@ end --- Return all children components, recursive --- @tparam BaseComponent self @{BaseComponent} +-- @tparam BaseComponent self BaseComponent -- @treturn table Array of childrens if the Druid component instance -function BaseComponent.get_childrens(self) +function M.get_childrens(self) local childrens = {} for i = 1, #self._meta.children do @@ -477,23 +400,21 @@ function BaseComponent.get_childrens(self) end ---- Create new component. It will inheritance from basic Druid component. --- @function BaseComponent.create --- @tparam string name BaseComponent name --- @tparam number|nil input_priority The input priority. The bigger number processed first --- @local -function BaseComponent.create(name, input_priority) +---Сreate a new component class, which will inherit from the base Druid component. +---@param name string|nil The name of the component +---@param input_priority number|nil The input priority. The bigger number processed first. Default value: 10 +---@return druid.base_component +function M.create(name, input_priority) local new_class = setmetatable({}, { - __index = BaseComponent, + __index = M, __call = function(cls, ...) local self = setmetatable({ _component = { - name = name, + name = name or "Druid Component", 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() + _uid = M.create_uid() } }, { __index = cls @@ -506,4 +427,4 @@ function BaseComponent.create(name, input_priority) end -return BaseComponent +return M diff --git a/druid/const.lua b/druid/const.lua index 70667de..639585f 100755 --- a/druid/const.lua +++ b/druid/const.lua @@ -1,10 +1,4 @@ --- Copyright (c) 2021 Maksim Tuprikov . This code is licensed under MIT license - ---- Druid constants --- @local --- @module DruidConst --- @alias druid_const - +---@class druid.system.const local M = {} M.ACTION_TEXT = hash(sys.get_config_string("druid.input_text", "text")) @@ -25,7 +19,6 @@ 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.ON_INPUT = "on_input" M.ON_UPDATE = "update" M.ON_MESSAGE = "on_message" @@ -123,10 +116,6 @@ M.SWIPE = { RIGHT = "right", } -M.ERRORS = { - GRID_DYNAMIC_ANCHOR = "The pivot of dynamic grid node should be West, East, South or North" -} - M.EMPTY_FUNCTION = function() end return M diff --git a/druid/custom/rich_input/rich_input.gui b/druid/custom/rich_input/rich_input.gui index b511cec..5467ee9 100644 --- a/druid/custom/rich_input/rich_input.gui +++ b/druid/custom/rich_input/rich_input.gui @@ -1,11 +1,11 @@ script: "" fonts { - name: "game" - font: "/example/assets/fonts/game.font" + name: "text_bold" + font: "/example/assets/fonts/text_bold.font" } textures { - name: "kenney" - texture: "/example/assets/images/kenney.atlas" + name: "druid" + texture: "/example/assets/druid.atlas" } background_color { x: 0.0 @@ -33,8 +33,8 @@ nodes { w: 1.0 } size { - x: 1.0 - y: 1.0 + x: 500.0 + y: 80.0 z: 0.0 w: 1.0 } @@ -46,7 +46,7 @@ nodes { } type: TYPE_BOX blend_mode: BLEND_MODE_ALPHA - texture: "kenney/empty" + texture: "" id: "root" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE @@ -65,7 +65,11 @@ nodes { clipping_inverted: false alpha: 1.0 template_node_child: false - size_mode: SIZE_MODE_AUTO + size_mode: SIZE_MODE_MANUAL + custom_type: 0 + enabled: true + visible: false + material: "" } nodes { position { @@ -87,8 +91,8 @@ nodes { w: 1.0 } size { - x: 190.0 - y: 45.0 + x: 500.0 + y: 80.0 z: 0.0 w: 1.0 } @@ -100,7 +104,7 @@ nodes { } type: TYPE_BOX blend_mode: BLEND_MODE_ALPHA - texture: "kenney/progress_back" + texture: "druid/rect_round2_width1" id: "button" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE @@ -110,17 +114,21 @@ nodes { layer: "" inherit_alpha: true slice9 { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + x: 4.0 + y: 4.0 + z: 4.0 + w: 4.0 } clipping_mode: CLIPPING_MODE_NONE clipping_visible: true clipping_inverted: false alpha: 1.0 template_node_child: false - size_mode: SIZE_MODE_AUTO + size_mode: SIZE_MODE_MANUAL + custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { @@ -136,27 +144,27 @@ nodes { w: 1.0 } scale { - x: 0.5 - y: 0.5 + x: 1.0 + y: 1.0 z: 1.0 w: 1.0 } size { - x: 300.0 + x: 480.0 y: 60.0 z: 0.0 w: 1.0 } color { - x: 0.9490196 - y: 0.9490196 - z: 0.9490196 + x: 0.31 + y: 0.318 + z: 0.322 w: 1.0 } type: TYPE_TEXT blend_mode: BLEND_MODE_ALPHA text: "Placeholder" - font: "game" + font: "text_bold" id: "placeholder_text" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE @@ -179,11 +187,15 @@ nodes { layer: "" inherit_alpha: true alpha: 1.0 - outline_alpha: 1.0 + outline_alpha: 0.0 shadow_alpha: 0.0 template_node_child: false text_leading: 1.0 text_tracking: 0.0 + custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { @@ -199,27 +211,27 @@ nodes { w: 1.0 } scale { - x: 0.6 - y: 0.6 - z: 1.0 - w: 1.0 - } - size { - x: 300.0 - y: 60.0 - z: 0.0 - w: 1.0 - } - color { x: 1.0 y: 1.0 z: 1.0 w: 1.0 } + size { + x: 480.0 + y: 60.0 + z: 0.0 + w: 1.0 + } + color { + x: 0.722 + y: 0.741 + z: 0.761 + w: 1.0 + } type: TYPE_TEXT blend_mode: BLEND_MODE_ALPHA text: "User input" - font: "game" + font: "text_bold" id: "input_text" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE @@ -242,15 +254,19 @@ nodes { layer: "" inherit_alpha: true alpha: 1.0 - outline_alpha: 1.0 + outline_alpha: 0.0 shadow_alpha: 0.0 template_node_child: false text_leading: 1.0 text_tracking: 0.0 + custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { - x: 67.0 + x: 118.0 y: 0.0 z: 0.0 w: 1.0 @@ -262,26 +278,26 @@ nodes { w: 1.0 } scale { - x: 0.6 - y: 0.6 + x: 1.0 + y: 1.0 z: 1.0 w: 1.0 } size { - x: 1.0 - y: 1.0 + x: 16.0 + y: 50.0 z: 0.0 w: 1.0 } color { - x: 1.0 - y: 1.0 - z: 1.0 + x: 0.631 + y: 0.843 + z: 0.961 w: 1.0 } type: TYPE_BOX blend_mode: BLEND_MODE_ALPHA - texture: "kenney/empty" + texture: "druid/ui_circle_16" id: "cursor_node" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE @@ -291,22 +307,26 @@ nodes { layer: "" inherit_alpha: true slice9 { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + x: 8.0 + y: 8.0 + z: 8.0 + w: 8.0 } clipping_mode: CLIPPING_MODE_NONE clipping_visible: true clipping_inverted: false - alpha: 1.0 + alpha: 0.5 template_node_child: false - size_mode: SIZE_MODE_AUTO + size_mode: SIZE_MODE_MANUAL + custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { x: 0.0 - y: 2.0 + y: 4.0 z: 0.0 w: 1.0 } @@ -317,8 +337,8 @@ nodes { w: 1.0 } scale { - x: 1.0 - y: 1.0 + x: 1.2 + y: 1.2 z: 1.0 w: 1.0 } @@ -329,15 +349,15 @@ nodes { w: 1.0 } color { - x: 0.2 - y: 0.2 - z: 0.2 + x: 0.722 + y: 0.741 + z: 0.761 w: 1.0 } type: TYPE_TEXT blend_mode: BLEND_MODE_ALPHA text: "|" - font: "game" + font: "text_bold" id: "cursor_text" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE @@ -358,13 +378,17 @@ nodes { line_break: false parent: "cursor_node" layer: "" - inherit_alpha: true + inherit_alpha: false alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 template_node_child: false text_leading: 1.0 text_tracking: 0.0 + custom_type: 0 + enabled: true + visible: true + material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/custom/rich_input/rich_input.lua b/druid/custom/rich_input/rich_input.lua index c42b637..a1f18ab 100644 --- a/druid/custom/rich_input/rich_input.lua +++ b/druid/custom/rich_input/rich_input.lua @@ -6,13 +6,13 @@ -- @alias druid.rich_input --- The component druid instance --- @tfield DruidInstance druid @{DruidInstance} +-- @tfield DruidInstance druid DruidInstance --- Root node -- @tfield node root --- On input field text change callback(self, input_text) --- @tfield Input input @{Input} +-- @tfield Input input Input --- On input field text change to empty string callback(self, input_text) -- @tfield node cursor @@ -44,16 +44,23 @@ 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 = { - ROOT = "root", - BUTTON = "button", - PLACEHOLDER = "placeholder_text", - INPUT = "input_text", - CURSOR = "cursor_node", - CURSOR_TEXT = "cursor_text", -} +---@class druid.rich_input: druid.base_component +---@field root node +---@field input druid.input +---@field cursor node +---@field cursor_text node +---@field cursor_position vector3 +local M = component.create("druid.rich_input") + +--local SCHEME = { +-- ROOT = "root", +-- BUTTON = "button", +-- PLACEHOLDER = "placeholder_text", +-- INPUT = "input_text", +-- CURSOR = "cursor_node", +-- CURSOR_TEXT = "cursor_text", +--} local DOUBLE_CLICK_TIME = 0.35 @@ -189,13 +196,11 @@ local function on_drag_callback(self, dx, dy, x, y, touch) 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) +---@param template string The template string name +---@param nodes table Nodes table from gui.clone_tree +function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.root = self:get_node(SCHEME.ROOT) + self.root = self:get_node("root") self._last_touch_info = { cursor_index = nil, @@ -204,20 +209,20 @@ function RichInput.init(self, template, nodes) 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.input = self.druid:new(input, "button", "input_text") self.is_button_input_enabled = gui.is_enabled(self.input.button.node) - self.cursor = self:get_node(SCHEME.CURSOR) + self.cursor = self:get_node("cursor_node") self.cursor_position = gui.get_position(self.cursor) - self.cursor_text = self:get_node(SCHEME.CURSOR_TEXT) + self.cursor_text = self:get_node("cursor_text") - self.drag = self.druid:new_drag(self:get_node(SCHEME.BUTTON), on_drag_callback) + self.drag = self.druid:new_drag("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.placeholder = self.druid:new_text("placeholder_text") self.text_position = gui.get_position(self.input.text.node) self.input.on_input_text:subscribe(update_text) @@ -230,7 +235,7 @@ function RichInput.init(self, template, nodes) end -function RichInput.on_input(self, action_id, action) +function M:on_input(action_id, action) if action_id == const.ACTION_LSHIFT then if action.pressed then self.is_lshift = true @@ -258,26 +263,26 @@ end --- Set placeholder text --- @tparam RichInput self @{RichInput} +-- @tparam RichInput self RichInput -- @tparam string placeholder_text The placeholder text -function RichInput.set_placeholder(self, placeholder_text) +function M:set_placeholder(placeholder_text) self.placeholder:set_to(placeholder_text) return self end --- Select input field --- @tparam RichInput self @{RichInput} -function RichInput.select(self) +-- @tparam RichInput self RichInput +function M:select() self.input:select() end --- Set input field text --- @tparam RichInput self @{RichInput} +-- @tparam RichInput self RichInput -- @treturn druid.input Current input instance -- @tparam string text The input text -function RichInput.set_text(self, text) +function M:set_text(text) self.input:set_text(text) gui.set_enabled(self.placeholder.node, true and #self.input:get_text() == 0) @@ -286,10 +291,10 @@ end --- Set input field font --- @tparam RichInput self @{RichInput} +-- @tparam RichInput self RichInput -- @tparam hash font The font hash -- @treturn druid.input Current input instance -function RichInput.set_font(self, font) +function M:set_font(font) gui.set_font(self.input.text.node, font) gui.set_font(self.placeholder.node, font) @@ -298,8 +303,8 @@ end --- Set input field text --- @tparam RichInput self @{RichInput} -function RichInput.get_text(self) +-- @tparam RichInput self RichInput +function M:get_text() return self.input:get_text() end @@ -307,14 +312,14 @@ 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 RichInput self RichInput -- @tparam string characters Regulax exp. for validate user input -- @treturn RichInput Current instance -function RichInput.set_allowed_characters(self, characters) +function M:set_allowed_characters(characters) self.input:set_allowed_characters(characters) return self end -return RichInput +return M diff --git a/druid/custom/rich_text/rich_text.lua b/druid/custom/rich_text/rich_text.lua index 4ed7198..e2a2d5c 100644 --- a/druid/custom/rich_text/rich_text.lua +++ b/druid/custom/rich_text/rich_text.lua @@ -63,7 +63,7 @@ -- @alias druid.rich_text --- The component druid instance --- @tfield DruidInstance druid @{DruidInstance} +-- @tfield DruidInstance druid DruidInstance --- The root node of the Rich Text -- @tfield node root @@ -76,14 +76,19 @@ local component = require("druid.component") local rich_text = require("druid.custom.rich_text.module.rt") -local RichText = component.create("rich_text") +---@class druid.rich_text: druid.base_component +---@field root node +---@field text_prefab node +---@field private _last_value string +---@field private _settings table +local M = component.create("rich_text") ---- The @{RichText} constructor --- @tparam RichText self @{RichText} +--- The RichText constructor +-- @tparam RichText self RichText -- @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) +function M:init(text_node, value) self.root = self:get_node(text_node) self.text_prefab = self.root @@ -98,7 +103,7 @@ function RichText.init(self, text_node, value) end -function RichText.on_layout_change(self) +function M:on_layout_change() if self._last_value then self:set_text(self._last_value) end @@ -112,7 +117,7 @@ end -- @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) +function M:on_style_change(style) self.style = {} self.style.COLORS = style.COLORS or {} self.style.ADJUST_STEPS = style.ADJUST_STEPS or 20 @@ -121,7 +126,7 @@ end --- Set text for Rich Text --- @tparam RichText self @{RichText} +-- @tparam RichText self RichText -- @tparam string|nil text The text to set -- @treturn druid.rich_text.word[] words -- @treturn druid.rich_text.lines_metrics line_metrics @@ -168,7 +173,7 @@ end -- -- -- -function RichText.set_text(self, text) +function M:set_text(text) text = text or "" self:clear() self._last_value = text @@ -184,14 +189,14 @@ end --- Get current text --- @tparam RichText self @{RichText} +-- @tparam RichText self RichText -- @treturn string text -function RichText.get_text(self) +function M:get_text() return self._last_value end -function RichText:on_remove() +function M:on_remove() gui.set_scale(self.root, self._default_scale) gui.set_size(self.root, self._default_size) self:clear() @@ -199,7 +204,7 @@ end --- Clear all created words. -function RichText:clear() +function M:clear() if self._words then rich_text.remove(self._words) self._words = nil @@ -209,10 +214,10 @@ end --- Get all words, which has a passed tag. --- @tparam RichText self @{RichText} +-- @tparam RichText self RichText -- @tparam string tag -- @treturn druid.rich_text.word[] words -function RichText.tagged(self, tag) +function M:tagged(tag) if not self._words then return end @@ -222,29 +227,29 @@ end ---Split a word into it's characters --- @tparam RichText self @{RichText} +-- @tparam RichText self RichText -- @tparam druid.rich_text.word word -- @treturn druid.rich_text.word[] characters -function RichText.characters(self, word) +function M:characters(word) return rich_text.characters(word) end --- Get all current words. -- @treturn table druid.rich_text.word[] -function RichText:get_words() +function M:get_words() return self._words end --- Get current line metrics --- @treturn druid.rich_text.lines_metrics -function RichText:get_line_metric() +function M:get_line_metric() return self._line_metrics end -function RichText:_create_settings() +function M:_create_settings() local root_size = gui.get_size(self.root) local scale = gui.get_scale(self.root) @@ -280,4 +285,4 @@ function RichText:_create_settings() end -return RichText +return M diff --git a/druid/druid.lua b/druid/druid.lua index 37997d4..b198728 100644 --- a/druid/druid.lua +++ b/druid/druid.lua @@ -13,7 +13,7 @@ -- -- • Each Druid instance maintains the self context from the constructor and passes it to each Druid callback. -- --- See next: @{DruidInstance} +-- See next: DruidInstance -- -- @usage -- local druid = require("druid.druid") @@ -52,15 +52,15 @@ local druid_instance = require("druid.system.druid_instance") local default_style = require("druid.styles.default.style") +---@class druid local M = {} - -local _instances = {} +local druid_instances = {} local function clean_deleted_druid_instances() - for i = #_instances, 1, -1 do - if _instances[i]._deleted then - table.remove(_instances, i) + for i = #druid_instances, 1, -1 do + if druid_instances[i]._deleted then + table.remove(druid_instances, i) end end end @@ -68,45 +68,27 @@ end local function get_druid_instances() clean_deleted_druid_instances() - return _instances + return druid_instances end ---- Register a new external Druid component. --- --- You can register your own components to make new alias: the druid:new_{name} function. --- For example, if you want to register a component called "my_component", you can create it using druid:new_my_component(...). --- This can be useful if you have your own "basic" components that you don't want to re-create each time. --- @function druid.register --- @tparam string name module name --- @tparam table module lua table with component --- @usage --- local my_component = require("path.to.my.component") --- druid.register("my_component", my_component) --- ... --- local druid = druid.new(self) --- local component_instance = self.druid:new_my_component(...) +---Register a new external Druid component. +---You can register your own components to make new alias: the druid:new_{name} function. +---For example, if you want to register a component called "my_component", you can create it using druid:new_my_component(...). +---This can be useful if you have your own "basic" components that you don't want to re-create each time. +---@param name string Module name +---@param module table Lua table with component function M.register(name, module) druid_instance["new_" .. name] = function(self, ...) return druid_instance.new(self, module, ...) end - - return druid_instance["new_" .. name] end ---- Create a new Druid instance for creating GUI components. --- --- @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 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") --- --- function init(self) --- self.druid = druid.new(self) --- end +---Create a new Druid instance for creating GUI components. +---@param context table The Druid context. Usually, this is the self of the gui_script. It is passed into all Druid callbacks. +---@param style table|nil The Druid style table to override style parameters for this Druid instance. +---@return druid_instance druid_instance The new Druid instance function M.new(context, style) clean_deleted_druid_instances() @@ -117,65 +99,35 @@ function M.new(context, style) local new_instance = setmetatable({}, { __index = druid_instance }) new_instance:initialize(context, style) - table.insert(_instances, new_instance) + table.insert(druid_instances, new_instance) return new_instance end ---- Set your own default style for all Druid instances. --- --- To create your own style file, copy the default style file and make changes to it. --- Register the new style before creating your Druid instances. --- @function druid.set_default_style --- @tparam table style Druid style module --- @usage --- local my_style = require("path.to.my.style") --- druid.set_default_style(my_style) +---Set the default style for all Druid instances. +---@param style table Default style function M.set_default_style(style) settings.default_style = style or {} end ---- Set the text function for the LangText component. --- --- The Druid locale component will call this function to get translated text. --- After setting the text function, all existing locale components will be updated. --- @function druid.set_text_function --- @tparam function callback Get localized text function --- @usage --- druid.set_text_function(function(text_id) --- return lang_data[text_id] -- Replace with your real function --- end) +---Set the text function for the LangText component. +---@param callback fun(text_id: string): string Get localized text function function M.set_text_function(callback) settings.get_text = callback or const.EMPTY_FUNCTION M.on_language_change() end ---- Set the Druid sound function to play UI sounds if used. --- --- Set a function to play a sound given a sound_id. This function is used for button clicks to play the "click" sound. --- It can also be used to play sounds in your custom components (see the default Druid style file for an example). --- @function druid.set_sound_function --- @tparam function callback Sound play callback --- @usage --- druid.set_sound_function(function(sound_id) --- sound.play(sound_id) -- Replace with your real function --- end) +---Set the sound function to able components to play sounds. +---@param callback fun(sound_id: string) Sound play callback function M.set_sound_function(callback) settings.play_sound = callback or const.EMPTY_FUNCTION end ---- Set the window callback to enable on_focus_gain and on_focus_lost functions. --- --- This is used to trigger the on_focus_lost and on_focus_gain functions in Druid components. --- @function druid.on_window_callback --- @tparam string event Event param from window listener --- @usage --- window.set_listener(function(_, event) --- druid.on_window_callback(event) --- end) +---Set the window callback to enable Druid window events. +---@param event constant Event param from window listener function M.on_window_callback(event) local instances = get_druid_instances() @@ -195,12 +147,7 @@ function M.on_window_callback(event) end ---- Call this function when the game language changes. --- --- This function will translate all current LangText components. --- @function druid.on_language_change --- @usage --- druid.on_language_change() +---Call this function when the game language changes. function M.on_language_change() local instances = get_druid_instances() diff --git a/druid/editor_scripts/create_druid_component.py b/druid/editor_scripts/create_druid_component.py index 24d1203..195429a 100644 --- a/druid/editor_scripts/create_druid_component.py +++ b/druid/editor_scripts/create_druid_component.py @@ -48,10 +48,6 @@ def process_component(node_name, component_name): component_define += "\n--TODO: Replace prefab_name with grid element prefab" 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(\"{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") diff --git a/druid/event.lua b/druid/event.lua index ef79c86..395172b 100644 --- a/druid/event.lua +++ b/druid/event.lua @@ -8,6 +8,7 @@ -- @module DruidEvent -- @alias druid.event +---@class druid.event local M = {} M.COUNTER = 0 @@ -39,11 +40,11 @@ end --- Check is event subscribed. --- @tparam DruidEvent self @{DruidEvent} +-- @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) +function M:is_subscribed(callback, callback_context) if #self == 0 then return false, nil end @@ -60,7 +61,7 @@ end --- Subscribe callback on event --- @tparam DruidEvent self @{DruidEvent} +-- @tparam DruidEvent self DruidEvent -- @tparam function callback Callback itself -- @tparam any|nil callback_context Additional context as first param to callback call, usually it's self -- @treturn boolean True if callback was subscribed @@ -71,7 +72,7 @@ end -- ... -- local button = self.druid:new_button("button", callback) -- button.on_long_click:subscribe(on_long_callback, self) -function M.subscribe(self, callback, callback_context) +function M:subscribe(callback, callback_context) assert(type(self) == "table", "You should subscribe to event with : syntax") assert(callback, "A function must be passed to subscribe to an event") @@ -85,7 +86,7 @@ end --- Unsubscribe callback on event --- @tparam DruidEvent self @{DruidEvent} +-- @tparam DruidEvent self DruidEvent -- @tparam function callback Callback itself -- @tparam any|nil callback_context Additional context as first param to callback call -- @usage @@ -94,7 +95,7 @@ end -- end -- ... -- button.on_long_click:unsubscribe(on_long_callback, self) -function M.unsubscribe(self, callback, callback_context) +function M:unsubscribe(callback, callback_context) assert(callback, "A function must be passed to subscribe to an event") local _, event_index = self:is_subscribed(callback, callback_context) @@ -108,17 +109,17 @@ end --- Return true, if event have at lease one handler --- @tparam DruidEvent self @{DruidEvent} +-- @tparam DruidEvent self DruidEvent -- @treturn boolean True if event have handlers -- @usage -- local is_long_click_handler_exists = button.on_long_click:is_exist() -function M.is_exist(self) +function M:is_exist() return #self > 0 end --- Return true, if event not have handler ---- @tparam DruidEvent self @{DruidEvent} +--- @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() @@ -128,10 +129,10 @@ end --- Clear the all event handlers --- @tparam DruidEvent self @{DruidEvent} +-- @tparam DruidEvent self DruidEvent -- @usage -- button.on_long_click:clear() -function M.clear(self) +function M:clear() for index = #self, 1, -1 do self[index] = nil end @@ -139,14 +140,14 @@ end --- Trigger the event and call all subscribed callbacks --- @tparam DruidEvent self @{DruidEvent} +-- @tparam DruidEvent self DruidEvent -- @tparam any ... All event params -- @usage -- local Event = require("druid.event") -- ... -- local event = Event() -- event:trigger("Param1", "Param2") -function M.trigger(self, ...) +function M:trigger(...) if #self == 0 then return end diff --git a/druid/extended/data_list.lua b/druid/extended/data_list.lua index 81bf959..9fadb6a 100644 --- a/druid/extended/data_list.lua +++ b/druid/extended/data_list.lua @@ -10,10 +10,10 @@ --- The Druid scroll component --- @tfield Scroll scroll @{Scroll} +-- @tfield Scroll scroll Scroll --- The Druid Grid component --- @tfield StaticGrid grid @{StaticGrid}, @{DynamicGrid} +-- @tfield StaticGrid grid StaticGrid}, @{DynamicGrid --- The current progress of scroll posititon -- @tfield number scroll_progress @@ -25,13 +25,13 @@ -- @tfield number last_index --- Event triggered when scroll progress is changed; event(self, progress_value) --- @tfield DruidEvent on_scroll_progress_change @{DruidEvent} +-- @tfield DruidEvent on_scroll_progress_change DruidEvent ---On DataList visual element created Event callback(self, index, node, instance) --- @tfield DruidEvent on_element_add @{DruidEvent} +-- @tfield DruidEvent on_element_add DruidEvent ---On DataList visual element created Event callback(self, index) --- @tfield DruidEvent on_element_remove @{DruidEvent} +-- @tfield DruidEvent on_element_remove DruidEvent --- @@ -40,15 +40,27 @@ local helper = require("druid.helper") local component = require("druid.component") local Event = require("druid.event") -local DataList = component.create("data_list") +---@class druid.data_list: druid.base_component +---@field scroll druid.scroll +---@field grid druid.grid +---@field on_scroll_progress_change druid.event +---@field on_element_add druid.event +---@field on_element_remove druid.event +---@field private _create_function function +---@field private _is_use_cache boolean +---@field private _cache table +---@field private _data table +---@field private _data_visual table +---@field private top_index number +local M = component.create("data_list") ---- The @{DataList} constructor --- @tparam DataList self @{DataList} --- @tparam Scroll scroll The @{Scroll} instance for Data List component --- @tparam StaticGrid grid The @{StaticGrid} or @{DynamicGrid} instance for Data List component +--- The DataList constructor +-- @tparam DataList self DataList +-- @tparam Scroll scroll The Scroll 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) +function M:init(scroll, grid, create_function) self.scroll = scroll self.grid = grid if self.grid.style then @@ -75,28 +87,28 @@ end --- Druid System on_remove function --- @tparam DataList self @{DataList} -function DataList.on_remove(self) +-- @tparam DataList self DataList +function M:on_remove() self:clear() self.scroll.on_scroll:unsubscribe(self._refresh, self) end --- Set refresh function for DataList component --- @tparam DataList self @{DataList} +-- @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) +function M:set_use_cache(is_use_cache) self._is_use_cache = is_use_cache return self end --- Set new data set for DataList component --- @tparam DataList self @{DataList} +-- @tparam DataList self DataList -- @tparam table data The new data array -- @treturn druid.data_list Current DataList instance -function DataList.set_data(self, data) +function M:set_data(data) self._data = data or {} self:_refresh() @@ -105,19 +117,19 @@ end --- Return current data from DataList component --- @tparam DataList self @{DataList} +-- @tparam DataList self DataList -- @treturn table The current data array -function DataList.get_data(self) +function M:get_data() return self._data end --- Add element to DataList. Currenly untested --- @tparam DataList self @{DataList} +-- @tparam DataList self DataList -- @tparam table data -- @tparam number|nil index -- @tparam number|nil shift_policy The constant from const.SHIFT.* -function DataList.add(self, data, index, shift_policy) +function M:add(data, index, shift_policy) index = index or #self._data + 1 shift_policy = shift_policy or const.SHIFT.RIGHT @@ -127,20 +139,20 @@ end --- Remove element from DataList. Currenly untested --- @tparam DataList self @{DataList} +-- @tparam DataList self DataList -- @tparam number|nil index -- @tparam number|nil shift_policy The constant from const.SHIFT.* -function DataList.remove(self, index, shift_policy) +function M:remove(index, shift_policy) helper.remove_with_shift(self._data, index, shift_policy) self:_refresh() end --- Remove element from DataList by data value. Currenly untested --- @tparam DataList self @{DataList} +-- @tparam DataList self DataList -- @tparam table data -- @tparam number|nil shift_policy The constant from const.SHIFT.* -function DataList.remove_by_data(self, data, shift_policy) +function M:remove_by_data(data, shift_policy) local index = helper.contains(self._data, data) if index then helper.remove_with_shift(self._data, index, shift_policy) @@ -150,17 +162,17 @@ end --- Clear the DataList and refresh visuals --- @tparam DataList self @{DataList} -function DataList.clear(self) +-- @tparam DataList self DataList +function M:clear() self._data = {} self:_refresh() end --- Return index for data value --- @tparam DataList self @{DataList} +-- @tparam DataList self DataList -- @tparam table data -function DataList.get_index(self, data) +function M:get_index(data) for index, value in pairs(self._data) do if value == data then return index @@ -172,9 +184,9 @@ end --- Return all currenly created nodes in DataList --- @tparam DataList self @{DataList} +-- @tparam DataList self DataList -- @treturn node[] List of created nodes -function DataList.get_created_nodes(self) +function M:get_created_nodes() local nodes = {} for index, data in pairs(self._data_visual) do @@ -186,9 +198,9 @@ end --- Return all currenly created components in DataList --- @tparam DataList self @{DataList} +-- @tparam DataList self DataList -- @treturn druid.base_component[] List of created nodes -function DataList.get_created_components(self) +function M:get_created_components() local components = {} for index, data in pairs(self._data_visual) do @@ -200,19 +212,19 @@ end --- Instant scroll to element with passed index --- @tparam DataList self @{DataList} +-- @tparam DataList self DataList -- @tparam number index -function DataList.scroll_to_index(self, index) +function M:scroll_to_index(index) local pos = self.grid:get_pos(index) self.scroll:scroll_to(pos) end --- Add element at passed index using cache or create new --- @tparam DataList self @{DataList} +-- @tparam DataList self DataList -- @tparam number index -- @local -function DataList._add_at(self, index) +function M:_add_at(index) if self._data_visual[index] then self:_remove_at(index) end @@ -243,10 +255,10 @@ end --- Remove element from passed index and add it to cache if applicable --- @tparam DataList self @{DataList} +-- @tparam DataList self DataList -- @tparam number index -- @local -function DataList._remove_at(self, index) +function M:_remove_at(index) self.grid:remove(index, const.SHIFT.NO_SHIFT) local visual_data = self._data_visual[index] @@ -274,9 +286,9 @@ end --- Refresh all elements in DataList --- @tparam DataList self @{DataList} +-- @tparam DataList self DataList -- @local -function DataList._refresh(self) +function M:_refresh() self.scroll:set_size(self.grid:get_size_for(#self._data)) local start_pos = -self.scroll.position --[[@as vector3]] @@ -313,4 +325,4 @@ function DataList._refresh(self) end -return DataList +return M diff --git a/druid/extended/dynamic_grid.lua b/druid/extended/dynamic_grid.lua deleted file mode 100644 index c4f0c76..0000000 --- a/druid/extended/dynamic_grid.lua +++ /dev/null @@ -1,427 +0,0 @@ --- Copyright (c) 2021 Maksim Tuprikov . This code is licensed under MIT license - ---- Component to handle placing components in row --- --- Example Link --- @module DynamicGrid --- @within BaseComponent --- @alias druid.dynamic_grid - ---- On item add callback(self, node, index) --- @tfield DruidEvent on_add_item @{DruidEvent} - ---- On item remove callback(self, index) --- @tfield DruidEvent on_remove_item @{DruidEvent} - ---- On item add or remove callback(self, index) --- @tfield DruidEvent on_change_items @{DruidEvent} - ---- On grid clear callback(self) --- @tfield DruidEvent on_clear @{DruidEvent} - ---- On update item positions callback(self) --- @tfield DruidEvent on_update_positions @{DruidEvent} - ---- Parent gui node --- @tfield node parent - ---- List of all grid elements. Contains from node, pos, size, pivot --- @tfield node[] nodes - ---- The first index of node in grid --- @tfield number first_index - ---- The last index of node in grid --- @tfield number last_index - ---- Item size --- @tfield vector3 node_size - ---- The size of item content --- @tfield vector4 border - ---- - -local const = require("druid.const") -local Event = require("druid.event") -local helper = require("druid.helper") -local component = require("druid.component") - -local DynamicGrid = component.create("dynamic_grid") - - -local SIDE_VECTORS = { - LEFT = vmath.vector3(-1, 0, 0), - RIGHT = vmath.vector3(1, 0, 0), - TOP = vmath.vector3(0, -1, 0), - BOT = vmath.vector3(0, 1, 0), -} - -local AVAILABLE_PIVOTS = { - gui.PIVOT_N, - gui.PIVOT_S, - gui.PIVOT_W, - gui.PIVOT_E, -} - - ---- The @{DynamicGrid} constructor --- @tparam DynamicGrid self @{DynamicGrid} --- @tparam node parent The gui node parent, where items will be placed -function DynamicGrid.init(self, parent) - self.parent = self:get_node(parent) - - local parent_pivot = gui.get_pivot(self.parent) - self.pivot = helper.get_pivot_offset(parent_pivot) - - assert(helper.contains(AVAILABLE_PIVOTS, parent_pivot), const.ERRORS.GRID_DYNAMIC_ANCHOR) - self.side = ((parent_pivot == gui.PIVOT_W or parent_pivot == gui.PIVOT_E) - and const.SIDE.X or const.SIDE.Y) - - self.nodes = {} - self.border = vmath.vector4(0) -- Current grid content size - - self.on_add_item = Event() - self.on_remove_item = Event() - self.on_change_items = Event() - self.on_clear = Event() - self.on_update_positions = Event() - - self._set_position_function = gui.set_position -end - - -function DynamicGrid.on_layout_change(self) - self:_update(true) -end - - ---- Return pos for grid node index --- @tparam DynamicGrid self @{DynamicGrid} --- @tparam number index The grid element index --- @tparam node node The node to be placed --- @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] - - -- If anchor node is not exist, check around nodes - if not origin_node then - if self.nodes[index + 1] then - origin_index = index + 1 - end - if self.nodes[index - 1] then - origin_index = index - 1 - end - origin_node = self.nodes[origin_index] - end - - if not origin_node then - assert(not self.first_index, "Dynamic Grid can't have gaps between nodes. Error on grid:add") - - -- If not origin node, so it should be first element in the grid - local size = helper.get_scaled_size(node) - local pivot = const.PIVOTS[gui.get_pivot(node)] - return vmath.vector3( - size.x * pivot.x - size.x * self.pivot.x, - size.y * pivot.y - size.y * self.pivot.y, - 0) - end - - if origin_node then - -- Other nodes spawn from other side of the origin node - local is_forward = origin_index < index - local delta = is_forward and 1 or -1 - return self:_get_next_node_pos(index - delta, node, self:_get_side_vector(self.side, is_forward)) - end -end - - ---- Add new node to the grid --- @tparam DynamicGrid self @{DynamicGrid} --- @tparam node node Gui node --- @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 - - -- By default add node at end - index = index or ((self.last_index or 0) + 1) - - -- If node exist at index place, shifting them - local is_shift = self.nodes[index] and shift_policy ~= const.SHIFT.NO_SHIFT - if is_shift then - -- We need to iterate from index to start or end grid, depends of shift side - local start_index = shift_policy == const.SHIFT.LEFT and self.first_index or self.last_index - for i = start_index, index, -delta do - self.nodes[i + delta] = self.nodes[i] - end - end - - self:_add_node(node, index, index - delta) - - -- After shifting we should recalc node poses - if is_shift then - -- We need to iterate from placed node to start or end grid, depends of shift side - local target_index = shift_policy == const.SHIFT.LEFT and self.first_index or self.last_index - for i = index + delta, target_index + delta, delta do - local move_node = self.nodes[i] - move_node.pos = self:get_pos(i, move_node.node, i - delta) - end - end - - -- Sync grid data - self:_update(is_instant) - - self.on_add_item:trigger(self:get_context(), node, index) - self.on_change_items:trigger(self:get_context(), index) -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 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 - local delta = shift_policy -- -1 or 1 or 0 - - assert(self.nodes[index], "No grid item at given index " .. index) - - -- Just set nil for delete node data - local removed_node = self.nodes[index].node - self.nodes[index] = nil - - -- After delete node, we should shift nodes and recalc their poses, depends from is_shift_left - if shift_policy ~= const.SHIFT.NO_SHIFT then - local target_index = shift_policy == const.SHIFT.LEFT and self.first_index or self.last_index - for i = index, target_index, delta do - self.nodes[i] = self.nodes[i + delta] - if self.nodes[i] then - self.nodes[i].pos = self:get_pos(i, self.nodes[i].node, i - delta) - end - end - end - - -- Sync grid data - self:_update(is_instant) - - self.on_remove_item:trigger(self:get_context(), index) - self.on_change_items:trigger(self:get_context(), index) - - return removed_node -end - - ---- Return grid content size --- @tparam DynamicGrid self @{DynamicGrid} --- @tparam vector3 border --- @treturn vector3 The grid content size -function DynamicGrid.get_size(self, border) - border = border or self.border - return vmath.vector3( - border.z - border.x, - border.y - border.w, - 0) -end - - ---- Return DynamicGrid offset, where DynamicGrid content starts. --- @tparam DynamicGrid self @{DynamicGrid} The DynamicGrid instance --- @treturn vector3 The DynamicGrid offset -function DynamicGrid.get_offset(self) - local size = self:get_size() - local borders = self:get_borders() - local offset = vmath.vector3( - (borders.z + borders.x)/2 + size.x * self.pivot.x, - (borders.y + borders.w)/2 + size.y * self.pivot.y, - 0) - - return offset -end - - ---- Return grid content borders --- @tparam DynamicGrid self @{DynamicGrid} --- @treturn vector3 The grid content borders -function DynamicGrid.get_borders(self) - return self.border -end - - ---- Return grid index by node --- @tparam DynamicGrid self @{DynamicGrid} --- @tparam node node The gui node in the grid --- @treturn number The node index -function DynamicGrid.get_index_by_node(self, node) - for index, node_info in pairs(self.nodes) do - if node == node_info.node then - return index - end - end - - return nil -end - - ---- Return array of all node positions --- @tparam DynamicGrid self @{DynamicGrid} --- @treturn vector3[] All grid node positions -function DynamicGrid.get_all_pos(self) - local result = {} - for i, node in pairs(self.nodes) do - table.insert(result, gui.get_position(node.node)) - end - - return result -end - - ---- Change set position function for grid nodes. It will call on --- update poses on grid elements. Default: gui.set_position --- @tparam DynamicGrid self @{DynamicGrid} --- @tparam function callback Function on node set position --- @treturn druid.dynamic_grid Current grid instance -function DynamicGrid.set_position_function(self, callback) - self._set_position_function = callback or gui.set_position - return self -end - - ---- Clear grid nodes array. GUI nodes will be not deleted! --- If you want to delete GUI nodes, use dynamic_grid.nodes array before grid:clear --- @tparam DynamicGrid self @{DynamicGrid} --- @treturn druid.dynamic_grid Current grid instance -function DynamicGrid.clear(self) - self.nodes = {} - self:_update() - - self.on_clear:trigger(self:get_context()) - - return self -end - - -function DynamicGrid._add_node(self, node, index, origin_index) - self.nodes[index] = { - node = node, - pos = self:get_pos(index, node, origin_index), - size = helper.get_scaled_size(node), - pivot = const.PIVOTS[gui.get_pivot(node)] - } - - -- Add new item instantly in new pos - gui.set_parent(node, self.parent) - gui.set_position(node, self.nodes[index].pos) -end - - ---- Update grid inner state --- @tparam DynamicGrid self @{DynamicGrid} --- @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() - self:_update_borders() - self:_update_pos(is_instant) -end - - ---- Update first and last indexes of grid nodes --- @tparam DynamicGrid self @{DynamicGrid} --- @local -function DynamicGrid._update_indexes(self) - self.first_index = nil - self.last_index = nil - for index in pairs(self.nodes) do - self.first_index = self.first_index or index - self.last_index = self.last_index or index - - self.first_index = math.min(self.first_index, index) - self.last_index = math.max(self.last_index, index) - end -end - - ---- Update grid content borders, recalculate min and max values --- @tparam DynamicGrid self @{DynamicGrid} --- @local -function DynamicGrid._update_borders(self) - if not self.first_index then - self.border = vmath.vector4(0) - return - end - - self.border = vmath.vector4(math.huge, -math.huge, -math.huge, math.huge) - - for index, node in pairs(self.nodes) do - local pos = node.pos - local size = node.size - local pivot = node.pivot - - local left = pos.x - size.x/2 - (size.x * pivot.x) - local right = pos.x + size.x/2 - (size.x * pivot.x) - local top = pos.y + size.y/2 - (size.y * pivot.y) - local bottom = pos.y - size.y/2 - (size.y * pivot.y) - - self.border.x = math.min(self.border.x, left) - self.border.y = math.max(self.border.y, top) - self.border.z = math.max(self.border.z, right) - self.border.w = math.min(self.border.w, bottom) - end -end - - ---- Update grid nodes position --- @tparam DynamicGrid self @{DynamicGrid} --- @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 - if is_instant then - gui.set_position(node.node, node.pos) - else - self._set_position_function(node.node, node.pos) - end - end - - self.on_update_positions:trigger(self:get_context()) -end - - -function DynamicGrid._get_next_node_pos(self, origin_node_index, new_node, place_side) - local node = self.nodes[origin_node_index] - - local new_node_size = helper.get_scaled_size(new_node) - local new_pivot = const.PIVOTS[gui.get_pivot(new_node)] - - local dist_x = (node.size.x/2 + new_node_size.x/2) * place_side.x - local dist_y = (node.size.y/2 + new_node_size.y/2) * place_side.y - local node_center_x = node.pos.x - node.size.x * node.pivot.x - local node_center_y = node.pos.y - node.size.y * node.pivot.y - - return vmath.vector3( - node_center_x + dist_x + new_node_size.x * new_pivot.x, - node_center_y - dist_y + new_node_size.y * new_pivot.y, - 0 - ) -end - - ---- Return side vector to correct node shifting -function DynamicGrid._get_side_vector(self, side, is_forward) - if side == const.SIDE.X then - return is_forward and SIDE_VECTORS.RIGHT or SIDE_VECTORS.LEFT - end - - if side == const.SIDE.Y then - return is_forward and SIDE_VECTORS.BOT or SIDE_VECTORS.TOP - end -end - - -return DynamicGrid diff --git a/druid/extended/hotkey.lua b/druid/extended/hotkey.lua index 41507bd..b5db756 100644 --- a/druid/extended/hotkey.lua +++ b/druid/extended/hotkey.lua @@ -8,10 +8,10 @@ -- @alias druid.hotkey --- On hotkey released callback(self, argument) --- @tfield DruidEvent on_hotkey_pressed @{DruidEvent} +-- @tfield DruidEvent on_hotkey_pressed DruidEvent --- On hotkey released callback(self, argument) --- @tfield DruidEvent on_hotkey_released @{DruidEvent} +-- @tfield DruidEvent on_hotkey_released DruidEvent --- Visual node -- @tfield node node @@ -20,7 +20,7 @@ -- @tfield node|nil click_node --- Button component from click_node --- @tfield Button button @{Button} +-- @tfield Button button Button --- @@ -28,15 +28,21 @@ local helper = require("druid.helper") local component = require("druid.component") local Event = require("druid.event") -local Hotkey = component.create("hotkey") +---@class druid.hotkey: druid.base_component +---@field on_hotkey_pressed druid.event +---@field on_hotkey_released druid.event +---@field style table +---@field private _hotkeys table +---@field private _modificators table +local M = component.create("hotkey") ---- The @{Hotkey} constructor --- @tparam Hotkey self @{Hotkey} +--- 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 any|nil callback_argument The argument to pass into the callback function -function Hotkey.init(self, keys, callback, callback_argument) +function M:init(keys, callback, callback_argument) self.druid = self:get_druid() self._hotkeys = {} @@ -56,7 +62,7 @@ end -- or create your own style -- @table style -- @tfield string[] MODIFICATORS The list of action_id as hotkey modificators -function Hotkey.on_style_change(self, style) +function M:on_style_change(style) self.style = {} self.style.MODIFICATORS = style.MODIFICATORS or {} @@ -67,11 +73,11 @@ end --- Add hotkey for component callback --- @tparam Hotkey self @{Hotkey} +-- @tparam Hotkey self Hotkey -- @tparam string[]|hash[]|string|hash keys that have to be pressed before key pressed to activate -- @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) +function M:add_hotkey(keys, callback_argument) keys = keys or {} if type(keys) == "string" then keys = { keys } @@ -110,14 +116,14 @@ function Hotkey.add_hotkey(self, keys, callback_argument) end -function Hotkey.on_focus_gained(self) +function M:on_focus_gained() for k, v in pairs(self._modificators) do self._modificators[k] = false end end -function Hotkey.on_input(self, action_id, action) +function M:on_input(action_id, action) if not action_id or #self._hotkeys == 0 then return false end @@ -168,13 +174,13 @@ end --- If true, the callback will be triggered on action.repeated --- @tparam Hotkey self @{Hotkey} +-- @tparam Hotkey self Hotkey -- @tparam bool is_enabled_repeated The flag value -- @treturn Hotkey -function Hotkey.set_repeat(self, is_enabled_repeated) +function M:set_repeat(is_enabled_repeated) self._is_process_repeated = is_enabled_repeated return self end -return Hotkey +return M diff --git a/druid/extended/input.lua b/druid/extended/input.lua index db608e1..b4f29dd 100755 --- a/druid/extended/input.lua +++ b/druid/extended/input.lua @@ -10,25 +10,25 @@ -- @alias druid.input --- On input field select callback(self, input_instance) --- @tfield DruidEvent on_input_select @{DruidEvent} +-- @tfield DruidEvent on_input_select DruidEvent --- On input field unselect callback(self, input_text, input_instance) --- @tfield DruidEvent on_input_unselect @{DruidEvent} +-- @tfield DruidEvent on_input_unselect DruidEvent --- On input field text change callback(self, input_text) --- @tfield DruidEvent on_input_text @{DruidEvent} +-- @tfield DruidEvent on_input_text DruidEvent --- On input field text change to empty string callback(self, input_text) --- @tfield DruidEvent on_input_empty @{DruidEvent} +-- @tfield DruidEvent on_input_empty DruidEvent --- On input field text change to max length string callback(self, input_text) --- @tfield DruidEvent on_input_full @{DruidEvent} +-- @tfield DruidEvent on_input_full DruidEvent --- On trying user input with not allowed character callback(self, params, input_text) --- @tfield DruidEvent on_input_wrong @{DruidEvent} +-- @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} +-- @tfield DruidEvent on_select_cursor_change DruidEvent --- The cursor index. The index of letter cursor after. Leftmost cursor - 0 -- @tfield number cursor_index @@ -40,7 +40,7 @@ -- @tfield number end_index --- Text component --- @tfield Text text @{Text} +-- @tfield Text text Text --- Current input value -- @tfield string value @@ -61,7 +61,7 @@ -- @tfield number marked_text_width --- Button component --- @tfield Button button @{Button} +-- @tfield Button button Button --- Is current input selected now -- @tfield boolean is_selected @@ -87,9 +87,19 @@ local component = require("druid.component") local utf8_lua = require("druid.system.utf8") local utf8 = utf8 or utf8_lua -local Input = component.create("input") +---@class druid.input: druid.base_component +---@field on_input_select druid.event +---@field on_input_unselect druid.event +---@field on_input_text druid.event +---@field on_input_empty druid.event +---@field on_input_full druid.event +---@field on_input_wrong druid.event +---@field on_select_cursor_change druid.event +---@field style table +---@field text druid.text +local M = component.create("input") -Input.ALLOWED_ACTIONS = { +M.ALLOWED_ACTIONS = { [const.ACTION_TOUCH] = true, [const.ACTION_TEXT] = true, [const.ACTION_MARKED_TEXT] = true, @@ -132,7 +142,7 @@ end -- @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 -function Input.on_style_change(self, style) +function M:on_style_change(style) self.style = {} self.style.IS_LONGTAP_ERASE = style.IS_LONGTAP_ERASE or false @@ -145,12 +155,12 @@ function Input.on_style_change(self, style) end ---- The @{Input} constructor --- @tparam Input self @{Input} +--- 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 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 number|nil keyboard_type Gui keyboard type for input field -function Input.init(self, click_node, text_node, keyboard_type) +function M:init(click_node, text_node, keyboard_type) self.druid = self:get_druid() if type(text_node) == "table" then @@ -201,8 +211,8 @@ function Input.init(self, click_node, text_node, keyboard_type) end -function Input.on_input(self, action_id, action) - if not (action_id == nil or Input.ALLOWED_ACTIONS[action_id]) then +function M:on_input(action_id, action) + if not (action_id == nil or M.ALLOWED_ACTIONS[action_id]) then return false end @@ -299,17 +309,17 @@ function Input.on_input(self, action_id, action) end -function Input.on_focus_lost(self) +function M:on_focus_lost() self:unselect() end -function Input.on_input_interrupt(self) +function M:on_input_interrupt() --self:unselect() end -function Input.get_text_selected(self) +function M:get_text_selected() if self.start_index == self.end_index then return self.value end @@ -318,10 +328,10 @@ function Input.get_text_selected(self) end --- Replace selected text with new text --- @tparam Input self @{Input} +-- @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) +function M:get_text_selected_replaced(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 @@ -336,9 +346,9 @@ end --- Set text for input field --- @tparam Input self @{Input} +-- @tparam Input self Input -- @tparam string input_text The string to apply for input field -function Input.set_text(self, input_text) +function M:set_text(input_text) input_text = tostring(input_text or "") -- Case when update with marked text @@ -385,8 +395,8 @@ end --- Select input field. It will show the keyboard and trigger on_select events --- @tparam Input self @{Input} -function Input.select(self) +-- @tparam Input self Input +function M:select() gui.reset_keyboard() self.marked_value = "" if not self.is_selected then @@ -410,8 +420,8 @@ end --- Remove selection from input. It will hide the keyboard and trigger on_unselect events --- @tparam Input self @{Input} -function Input.unselect(self) +-- @tparam Input self Input +function M:unselect() gui.reset_keyboard() self.marked_value = "" self.value = self.current_value @@ -429,9 +439,9 @@ end --- Return current input field text --- @tparam Input self @{Input} +-- @tparam Input self Input -- @treturn string The current input field text -function Input.get_text(self) +function M:get_text() if self.marked_value ~= "" then return self.value .. self.marked_value end @@ -442,10 +452,10 @@ end --- Set maximum length for input field. -- Pass nil to make input field unliminted (by default) --- @tparam Input self @{Input} +-- @tparam Input self Input -- @tparam number max_length Maximum length for input text field -- @treturn druid.input Current input instance -function Input.set_max_length(self, max_length) +function M:set_max_length(max_length) self.max_length = max_length return self end @@ -454,19 +464,19 @@ end --- Set allowed charaters for input field. -- See: https://defold.com/ref/stable/string/ -- ex: [%a%d] for alpha and numeric --- @tparam Input self @{Input} +-- @tparam Input self Input -- @tparam string characters Regulax exp. for validate user input -- @treturn druid.input Current input instance -function Input.set_allowed_characters(self, characters) +function M:set_allowed_characters(characters) self.allowed_characters = characters return self end --- Reset current input selection and return previous value --- @tparam Input self @{Input} +-- @tparam Input self Input -- @treturn druid.input Current input instance -function Input.reset_changes(self) +function M:reset_changes() self:set_text(self.previous_value) self:unselect() return self @@ -474,12 +484,12 @@ end --- Set cursor position in input field --- @tparam Input self @{Input} +-- @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) +function M:select_cursor(cursor_index, start_index, end_index) local len = utf8.len(self.value) self.cursor_index = cursor_index or len @@ -497,11 +507,11 @@ end --- Change cursor position by delta --- @tparam Input self @{Input} +-- @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) +function M:move_selection(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 @@ -559,4 +569,4 @@ function Input.move_selection(self, delta, is_add_to_selection, is_move_to_end) end -return Input +return M diff --git a/druid/extended/lang_text.lua b/druid/extended/lang_text.lua index 6d38f83..03a6970 100755 --- a/druid/extended/lang_text.lua +++ b/druid/extended/lang_text.lua @@ -18,10 +18,10 @@ -- @alias druid.lang_text --- On change text callback --- @tfield DruidEvent on_change @{DruidEvent} +-- @tfield DruidEvent on_change DruidEvent --- The text component --- @tfield Text text @{Text} +-- @tfield Text text Text --- Text node -- @tfield node node @@ -32,15 +32,21 @@ local Event = require("druid.event") local settings = require("druid.system.settings") local component = require("druid.component") -local LangText = component.create("lang_text") +---@class druid.lang_text: druid.base_component +---@field text druid.text +---@field node node +---@field on_change druid.event +---@field private last_locale_args table +---@field private last_locale string +local M = component.create("lang_text") ---- The @{LangText} constructor --- @tparam LangText self @{LangText} +--- The LangText constructor +-- @tparam LangText self LangText -- @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) +function M:init(node, locale_id, adjust_type) self.druid = self:get_druid() self.text = self.druid:new_text(node, locale_id, adjust_type) self.node = self.text.node @@ -55,7 +61,7 @@ function LangText.init(self, node, locale_id, adjust_type) end -function LangText.on_language_change(self) +function M:on_language_change() if self.last_locale then self:translate(self.last_locale, unpack(self.last_locale_args)) end @@ -63,10 +69,10 @@ end --- Setup raw text to lang_text component --- @tparam LangText self @{LangText} +-- @tparam LangText self LangText -- @tparam string text Text for text node -- @treturn LangText Current instance -function LangText.set_to(self, text) +function M:set_to(text) self.last_locale = false self.text:set_to(text) self.on_change:trigger() @@ -76,7 +82,7 @@ end --- Translate the text by locale_id --- @tparam LangText self @{LangText} +-- @tparam LangText self LangText -- @tparam string locale_id Locale id -- @tparam string|nil a Optional param to string.format -- @tparam string|nil b Optional param to string.format @@ -86,7 +92,7 @@ end -- @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) +function M:translate(locale_id, a, b, c, d, e, f, g) self.last_locale_args = { a, b, c, d, e, f, g } self.last_locale = locale_id or self.last_locale self.text:set_to(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "") @@ -96,7 +102,7 @@ end --- Format string with new text params on localized text --- @tparam LangText self @{LangText} +-- @tparam LangText self LangText -- @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 @@ -105,11 +111,11 @@ end -- @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) +function M:format(a, b, c, d, e, f, g) self.last_locale_args = { a, b, c, d, e, f, g } self.text:set_to(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "") return self end -return LangText +return M diff --git a/druid/extended/layout.lua b/druid/extended/layout.lua index dea876b..e29eca3 100644 --- a/druid/extended/layout.lua +++ b/druid/extended/layout.lua @@ -1,45 +1,41 @@ --- Copyright (c) 2024 Maksim Tuprikov . This code is licensed under MIT license - ---- Layout management on node --- --- Example Link --- @module Layout --- @within BaseComponent --- @alias druid.layout - ---- Layout node --- @tfield node node - ---- Current layout mode --- @tfield string mode - ---- - local helper = require("druid.helper") local component = require("druid.component") --- @class druid.layout.row_data --- @tfield width number --- @tfield height number --- @tfield count number +---@alias druid.layout.mode +---| "horizontal" Elements are placed horizontally +---| "vertical" Elements are placed vertically +---| "horizontal_wrap" Elements are placed horizontally, but if the row width is greater than the parent width, the next row is created --- @class druid.layout.rows_data --- @tfield total_width number --- @tfield total_height number --- @tfield nodes_width table --- @tfield nodes_height table --- @tfield rows druid.layout.row_data[]> +---@class druid.layout.row_data +---@field width number +---@field height number +---@field count number --- @class druid.layout: druid.base_component +---@class druid.layout.rows_data +---@field total_width number +---@field total_height number +---@field nodes_width table +---@field nodes_height table +---@field rows druid.layout.row_data[]> + +---@class druid.layout: druid.base_component +---@field node node +---@field is_dirty boolean +---@field entities node[] +---@field margin {x: number, y: number} +---@field padding vector4 +---@field type string +---@field is_resize_width boolean +---@field is_resize_height boolean +---@field is_justify boolean local M = component.create("layout") --- The @{Layout} constructor --- @tparam Layout self @{Layout} --- @tparam node node Gui node --- @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) +---Layout component constructor +---@local +---@param node_or_node_id node|string +---@param layout_type druid.layout.mode +function M:init(node_or_node_id, layout_type) + self.node = self:get_node(node_or_node_id) self.is_dirty = true self.entities = {} @@ -51,6 +47,8 @@ function M.init(self, node, layout_type) self.is_justify = false end + +---@local function M:update() if not self.is_dirty then return @@ -60,11 +58,10 @@ function M:update() end --- @tparam Layout self @{Layout} --- @tparam number|nil margin_x --- @tparam number|nil margin_y --- @treturn druid.layout @{Layout} -function M.set_margin(self, margin_x, margin_y) +---@param margin_x number|nil +---@param margin_y number|nil +---@return druid.layout +function M:set_margin(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 @@ -73,10 +70,9 @@ function M.set_margin(self, margin_x, margin_y) end --- @tparam Layout self @{Layout} --- @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) +---@param padding vector4 The vector4 with padding values, where x - left, y - top, z - right, w - bottom +---@return druid.layout +function M:set_padding(padding) self.padding = padding self.is_dirty = true @@ -84,19 +80,17 @@ function M.set_padding(self, padding) end --- @tparam Layout self @{Layout} --- @treturn druid.layout @{Layout} -function M.set_dirty(self) +---@return druid.layout +function M:set_dirty() self.is_dirty = true return self end --- @tparam Layout self @{Layout} --- @tparam boolean is_justify --- @treturn druid.layout @{Layout} -function M.set_justify(self, is_justify) +---@param is_justify boolean +---@return druid.layout +function M:set_justify(is_justify) self.is_justify = is_justify self.is_dirty = true @@ -104,10 +98,9 @@ function M.set_justify(self, is_justify) end --- @tparam Layout self @{Layout} --- @tparam string type The layout type: "horizontal", "vertical", "horizontal_wrap" --- @treturn druid.layout @{Layout} -function M.set_type(self, type) +---@param type string The layout type: "horizontal", "vertical", "horizontal_wrap" +---@return druid.layout +function M:set_type(type) self.type = type self.is_dirty = true @@ -115,11 +108,10 @@ function M.set_type(self, type) end --- @tparam Layout self @{Layout} --- @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) +---@param is_hug_width boolean +---@param is_hug_height boolean +---@return druid.layout +function M:set_hug_content(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 @@ -128,21 +120,20 @@ function M.set_hug_content(self, is_hug_width, is_hug_height) end --- @tparam Layout self @{Layout} --- @tparam string|node node_or_node_id --- @treturn druid.layout @{Layout} -function M.add(self, node_or_node_id) +---@param node_or_node_id node|string node_or_node_id +---@return druid.layout +function M:add(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 + ---@cast node_or_node_id string|node node = self:get_node(node_or_node_id) end - -- @cast node node + ---@cast node node table.insert(self.entities, node) gui.set_parent(node, self.node) @@ -152,9 +143,8 @@ function M.add(self, node_or_node_id) end --- @tparam Layout self @{Layout} --- @treturn druid.layout @{Layout} -function M.refresh_layout(self) +---@return druid.layout +function M:refresh_layout() local layout_node = self.node local entities = self.entities @@ -289,9 +279,8 @@ function M.refresh_layout(self) end --- @tparam Layout self @{Layout} --- @treturn druid.layout @{Layout} -function M.clear_layout(self) +---@return druid.layout +function M:clear_layout() for index = #self.entities, 1, -1 do self.entities[index] = nil end @@ -302,10 +291,9 @@ function M.clear_layout(self) end --- @tparam node node --- @treturn number, number --- @local -function M.get_node_size(node) +---@param node node +---@return number, number +function M:get_node_size(node) if not gui.is_enabled(node, false) then return 0, 0 end @@ -323,11 +311,10 @@ function M.get_node_size(node) 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) +---Calculate rows data for layout. Contains total width, height and rows info (width, height, count of elements in row) +---@local +---@return druid.layout.rows_data +function M:calculate_rows_data() local entities = self.entities local margin = self.margin local type = self.type @@ -353,7 +340,7 @@ function M.calculate_rows_data(self) -- 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) + node_width, node_height = self:get_node_size(node) rows_data.nodes_width[node] = node_width rows_data.nodes_height[node] = node_height end @@ -407,11 +394,10 @@ function M.calculate_rows_data(self) end --- @tparam node node --- @tparam number x --- @tparam number y --- @treturn node --- @local +---@param node node +---@param x number +---@param y number +---@return node function M:set_node_position(node, x, y) local position = gui.get_position(node) position.x = x diff --git a/druid/extended/progress.lua b/druid/extended/progress.lua index 163b017..ad31cce 100644 --- a/druid/extended/progress.lua +++ b/druid/extended/progress.lua @@ -20,7 +20,7 @@ -- @alias druid.progress --- On progress bar change callback(self, new_value) --- @tfield DruidEvent on_change @{DruidEvent} +-- @tfield DruidEvent on_change DruidEvent --- Progress bar fill node -- @tfield node node @@ -49,7 +49,13 @@ local const = require("druid.const") local helper = require("druid.helper") local component = require("druid.component") -local Progress = component.create("progress") +---@class druid.progress: druid.base_component +---@field node node +---@field on_change druid.event +---@field style table +---@field key string +---@field prop hash +local M = component.create("progress") local function check_steps(self, from, to, exactly) @@ -117,19 +123,19 @@ end -- @table style -- @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) +function M:on_style_change(style) self.style = {} self.style.SPEED = style.SPEED or 5 self.style.MIN_DELTA = style.MIN_DELTA or 0.005 end ---- The @{Progress} constructor --- @tparam Progress self @{Progress} +--- 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 number|nil init_value Initial value of progress bar. Default: 1 -function Progress.init(self, node, key, init_value) +function M:init(node, key, init_value) assert(key == const.SIDE.X or const.SIDE.Y, "Progress bar key should be 'x' or 'y'") self.key = key @@ -155,18 +161,18 @@ function Progress.init(self, node, key, init_value) end -function Progress.on_layout_change(self) +function M:on_layout_change() self:set_to(self.last_value) end -function Progress.on_remove(self) +function M:on_remove() -- Return default size gui.set_size(self.node, self.max_size) end -function Progress.update(self, dt) +function M:update(dt) if self.target then local prev_value = self.last_value local step = math.abs(self.last_value - self.target) * (self.style.SPEED*dt) @@ -187,51 +193,51 @@ end --- Fill a progress bar and stop progress animation --- @tparam Progress self @{Progress} -function Progress.fill(self) +-- @tparam Progress self Progress +function M:fill() set_bar_to(self, 1, true) end --- Empty a progress bar --- @tparam Progress self @{Progress} -function Progress.empty(self) +-- @tparam Progress self Progress +function M:empty() set_bar_to(self, 0, true) end --- Instant fill progress bar to value --- @tparam Progress self @{Progress} +-- @tparam Progress self Progress -- @tparam number to Progress bar value, from 0 to 1 -function Progress.set_to(self, to) +function M:set_to(to) to = helper.clamp(to, 0, 1) set_bar_to(self, to) end --- Return current progress bar value --- @tparam Progress self @{Progress} -function Progress.get(self) +-- @tparam Progress self Progress +function M:get() return self.last_value end --- Set points on progress bar to fire the callback --- @tparam Progress self @{Progress} +-- @tparam Progress self Progress -- @tparam number[] steps Array of progress bar values -- @tparam function callback Callback on intersect step value -- @usage progress:set_steps({0, 0.3, 0.6, 1}, function(self, step) end) -function Progress.set_steps(self, steps, callback) +function M:set_steps(steps, callback) self.steps = steps self.step_callback = callback end --- Start animation of a progress bar --- @tparam Progress self @{Progress} +-- @tparam Progress self Progress -- @tparam number to value between 0..1 -- @tparam function|nil callback Callback on animation ends -function Progress.to(self, to, callback) +function M:to(to, callback) to = helper.clamp(to, 0, 1) -- cause of float error local value = helper.round(to, 5) @@ -247,14 +253,14 @@ end --- Set progress bar max node size --- @tparam Progress self @{Progress} +-- @tparam Progress self Progress -- @tparam vector3 max_size The new node maximum (full) size --- @treturn Progress @{Progress} -function Progress.set_max_size(self, max_size) +-- @treturn Progress Progress +function M:set_max_size(max_size) self.max_size[self.key] = max_size[self.key] self:set_to(self.last_value) return self end -return Progress +return M diff --git a/druid/extended/slider.lua b/druid/extended/slider.lua index 7af97d3..6be43e4 100644 --- a/druid/extended/slider.lua +++ b/druid/extended/slider.lua @@ -8,7 +8,7 @@ -- @alias druid.slider --- On change value callback(self, value) --- @tfield DruidEvent on_change_value @{DruidEvent} +-- @tfield DruidEvent on_change_value DruidEvent --- Slider pin node -- @tfield node node @@ -42,7 +42,19 @@ local helper = require("druid.helper") local const = require("druid.const") local component = require("druid.component") -local Slider = component.create("slider", const.PRIORITY_INPUT_HIGH) +---@class druid.slider: druid.base_component +---@field node node +---@field on_change_value druid.event +---@field style table +---@field private start_pos vector3 +---@field private pos vector3 +---@field private target_pos vector3 +---@field private end_pos vector3 +---@field private dist vector3 +---@field private is_drag boolean +---@field private value number +---@field private steps number[] +local M = component.create("slider", const.PRIORITY_INPUT_HIGH) local function on_change_value(self) @@ -56,12 +68,12 @@ local function set_position(self, value) end ---- The @{Slider} constructor --- @tparam Slider self @{Slider} +--- The Slider constructor +-- @tparam Slider self Slider -- @tparam node node Gui pin node -- @tparam vector3 end_pos The end position of slider -- @tparam function|nil callback On slider change callback -function Slider.init(self, node, end_pos, callback) +function M:init(node, end_pos, callback) self.node = self:get_node(node) self.start_pos = gui.get_position(self.node) @@ -81,18 +93,18 @@ function Slider.init(self, node, end_pos, callback) end -function Slider.on_layout_change(self) +function M:on_layout_change() self:set(self.value) end -function Slider.on_remove(self) +function M:on_remove() -- Return pin to start position gui.set_position(self.node, self.start_pos) end -function Slider.on_window_resized(self) +function M:on_window_resized() local x_koef, y_koef = helper.get_screen_aspect_koef() self._x_koef = x_koef self._y_koef = y_koef @@ -100,7 +112,7 @@ function Slider.on_window_resized(self) end -function Slider.on_input(self, action_id, action) +function M:on_input(action_id, action) if action_id ~= const.ACTION_TOUCH then return false end @@ -185,10 +197,10 @@ end --- Set value for slider --- @tparam Slider self @{Slider} +-- @tparam Slider self Slider -- @tparam number value Value from 0 to 1 -- @tparam boolean|nil is_silent Don't trigger event if true -function Slider.set(self, value, is_silent) +function M:set(value, is_silent) value = helper.clamp(value, 0, 1) set_position(self, value) self.value = value @@ -200,11 +212,11 @@ end --- Set slider steps. Pin node will -- apply closest step position --- @tparam Slider self @{Slider} +-- @tparam Slider self Slider -- @tparam number[] steps Array of steps -- @usage slider:set_steps({0, 0.2, 0.6, 1}) --- @treturn Slider @{Slider} -function Slider.set_steps(self, steps) +-- @treturn Slider Slider +function M:set_steps(steps) self.steps = steps return self end @@ -214,29 +226,29 @@ end -- User can touch any place of node, pin instantly will -- move at this position and node drag will start. -- This function require the Defold version 1.3.0+ --- @tparam Slider self @{Slider} +-- @tparam Slider self Slider -- @tparam node|string|nil input_node --- @treturn Slider @{Slider} -function Slider.set_input_node(self, input_node) +-- @treturn Slider Slider +function M:set_input_node(input_node) self._input_node = self:get_node(input_node) return self end --- Set Slider input enabled or disabled --- @tparam Slider self @{Slider} +-- @tparam Slider self Slider -- @tparam boolean is_enabled -function Slider.set_enabled(self, is_enabled) +function M:set_enabled(is_enabled) self._is_enabled = is_enabled end --- Check if Slider component is enabled --- @tparam Slider self @{Slider} +-- @tparam Slider self Slider -- @treturn boolean -function Slider.is_enabled(self) +function M:is_enabled() return self._is_enabled end -return Slider +return M diff --git a/druid/extended/swipe.lua b/druid/extended/swipe.lua index 110d9f4..c153ce7 100644 --- a/druid/extended/swipe.lua +++ b/druid/extended/swipe.lua @@ -16,7 +16,7 @@ -- @tparam node|nil click_zone --- Trigger on swipe event(self, swipe_side, dist, delta_time) --- @tfield DruidEvent on_swipe) @{DruidEvent} +-- @tfield DruidEvent on_swipe) DruidEvent --- @@ -25,7 +25,17 @@ local const = require("druid.const") local helper = require("druid.helper") local component = require("druid.component") -local Swipe = component.create("swipe") +---@class druid.swipe: druid.base_component +---@field node node +---@field on_swipe druid.event +---@field style table +---@field click_zone node +---@field private _trigger_on_move boolean +---@field private _swipe_start_time number +---@field private _start_pos vector3 +---@field private _is_enabled boolean +---@field private _is_mobile boolean +local M = component.create("swipe") local function start_swipe(self, action) @@ -36,7 +46,7 @@ end local function reset_swipe(self, action) - self._swipe_start_time = false + self._swipe_start_time = 0 end @@ -77,7 +87,7 @@ end -- @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) +function M:on_style_change(style) self.style = {} self.style.SWIPE_TIME = style.SWIPE_TIME or 0.4 self.style.SWIPE_THRESHOLD = style.SWIPE_THRESHOLD or 50 @@ -85,15 +95,19 @@ function Swipe.on_style_change(self, style) end ---- The @{Swipe} constructor --- @tparam Swipe self @{Swipe} +--- The Swipe constructor +-- @tparam Swipe self Swipe -- @tparam node node Gui node -- @tparam function on_swipe_callback Swipe callback for on_swipe_end event -function Swipe.init(self, node, on_swipe_callback) - self._trigger_on_move = self.style.SWIPE_TRIGGER_ON_MOVE - self.node = self:get_node(node) - self._swipe_start_time = false +---Swipe constructor +---@param node_or_node_id node|string +---@param on_swipe_callback function +function M:init(node_or_node_id, on_swipe_callback) + self._trigger_on_move = self.style.SWIPE_TRIGGER_ON_MOVE + self.node = self:get_node(node_or_node_id) + + self._swipe_start_time = 0 self._start_pos = vmath.vector3(0) self.click_zone = nil @@ -101,7 +115,7 @@ function Swipe.init(self, node, on_swipe_callback) end -function Swipe.on_late_init(self) +function M:on_late_init() if not self.click_zone and const.IS_STENCIL_CHECK then local stencil_node = helper.get_closest_stencil_node(self.node) if stencil_node then @@ -111,7 +125,7 @@ function Swipe.on_late_init(self) end -function Swipe.on_input(self, action_id, action) +function M:on_input(action_id, action) if action_id ~= const.ACTION_TOUCH then return false end @@ -126,7 +140,7 @@ function Swipe.on_input(self, action_id, action) return false end - if self._swipe_start_time and (self._trigger_on_move or action.released) then + if self._swipe_start_time ~= 0 and (self._trigger_on_move or action.released) then check_swipe(self, action) end @@ -142,18 +156,18 @@ function Swipe.on_input(self, action_id, action) end -function Swipe.on_input_interrupt(self) +function M:on_input_interrupt() reset_swipe(self) end --- Strict swipe click area. Useful for -- restrict events outside stencil node --- @tparam Swipe self @{Swipe} +-- @tparam Swipe self Swipe -- @tparam node|string|nil zone Gui node -function Swipe.set_click_zone(self, zone) +function M:set_click_zone(zone) self.click_zone = self:get_node(zone) end -return Swipe +return M diff --git a/druid/extended/timer.lua b/druid/extended/timer.lua index 235f4be..8bd9ae3 100644 --- a/druid/extended/timer.lua +++ b/druid/extended/timer.lua @@ -1,40 +1,18 @@ --- Copyright (c) 2021 Maksim Tuprikov . This code is licensed under MIT license - ---- Component to handle GUI timers. --- Timer updating by game delta time. If game is not focused - --- timer will be not updated. --- @module Timer --- @within BaseComponent --- @alias druid.timer - ---- On timer tick. Fire every second callback(self, value) --- @tfield DruidEvent on_tick @{DruidEvent} - ---- On timer change enabled state callback(self, is_enabled) --- @tfield DruidEvent on_set_enabled @{DruidEvent} - ---- On timer end callback --- @tfield DruidEvent on_timer_end(self, Timer) @{DruidEvent} - ---- Trigger node --- @tfield node node - ---- Initial timer value --- @tfield number from - ---- Target timer value --- @tfield number target - ---- Current timer value --- @tfield number value - ---- - local Event = require("druid.event") local helper = require("druid.helper") local component = require("druid.component") -local Timer = component.create("timer") +---@class druid.timer: druid.base_component +---@field on_tick druid.event +---@field on_set_enabled druid.event +---@field on_timer_end druid.event +---@field style table +---@field node node +---@field from number +---@field target number +---@field value number +---@field is_on boolean|nil +local M = component.create("timer") local function second_string_min(sec) @@ -44,13 +22,12 @@ local function second_string_min(sec) end ---- The @{Timer} constructor --- @tparam Timer self @{Timer} --- @tparam node node Gui text node --- @tparam number|nil seconds_from Start timer value in seconds --- @tparam number|nil seconds_to End timer value in seconds --- @tparam function|nil callback Function on timer end -function Timer.init(self, node, seconds_from, seconds_to, callback) +---The Timer constructor +---@param node node Gui text node +---@param seconds_from number|nil Start timer value in seconds +---@param seconds_to number|nil End timer value in seconds +---@param callback function|nil Function on timer end +function M:init(node, seconds_from, seconds_to, callback) self.node = self:get_node(node) seconds_to = math.max(seconds_to or 0, 0) @@ -73,7 +50,7 @@ function Timer.init(self, node, seconds_from, seconds_to, callback) end -function Timer.update(self, dt) +function M:update(dt) if not self.is_on then return end @@ -96,42 +73,47 @@ function Timer.update(self, dt) end -function Timer.on_layout_change(self) +function M:on_layout_change() self:set_to(self.last_value) end ---- Set text to text field --- @tparam Timer self @{Timer} --- @tparam number set_to Value in seconds -function Timer.set_to(self, set_to) +---@param self druid.timer +---@param set_to number Value in seconds +---@return druid.timer self +function M:set_to(set_to) self.last_value = set_to gui.set_text(self.node, second_string_min(set_to)) + + return self end ---- Called when update --- @tparam Timer self @{Timer} --- @tparam boolean|nil is_on Timer enable state -function Timer.set_state(self, is_on) +---@param self druid.timer +---@param is_on boolean|nil Timer enable state +---@return druid.timer self +function M:set_state(is_on) self.is_on = is_on - self.on_set_enabled:trigger(self:get_context(), is_on) + + return self end ---- Set time interval --- @tparam Timer self @{Timer} --- @tparam number from Start time in seconds --- @tparam number to Target time in seconds -function Timer.set_interval(self, from, to) +---@param self druid.timer +---@param from number Start time in seconds +---@param to number Target time in seconds +---@return druid.timer self +function M:set_interval(from, to) self.from = from self.value = from self.temp = 0 self.target = to self:set_state(true) self:set_to(from) + + return self end -return Timer +return M diff --git a/druid/helper.lua b/druid/helper.lua index 827e9cf..1cf3c38 100644 --- a/druid/helper.lua +++ b/druid/helper.lua @@ -1,15 +1,13 @@ --- Copyright (c) 2021 Maksim Tuprikov . This code is licensed under MIT license - ---- Helper module with various usefull GUI functions. --- @usage --- local helper = require("druid.helper") --- helper.centrate_nodes(0, node_1, node_2) --- @module Helper --- @alias druid.helper +--- Druid Helper module local const = require("druid.const") +local gui_get_node = gui.get_node + + +---@class druid.system.helper local M = {} + local POSITION_X = hash("position.x") local SCALE_X = hash("scale.x") local SIZE_X = hash("size.x") @@ -46,39 +44,35 @@ local function get_width(node) end ---- Center two nodes. --- Nodes will be center around 0 x position --- text_node will be first (at left side) --- @function helper.centrate_text_with_icon --- @tparam text|nil text_node Gui text node --- @tparam box|nil icon_node Gui box node --- @tparam number margin Offset between nodes --- @local +---Center two nodes. +--Nodes will be center around 0 x position +--text_node will be first (at left side) +---@param text_node node|nil Gui text node +---@param icon_node node|nil Gui box node +---@param margin number Offset between nodes +---@local function M.centrate_text_with_icon(text_node, icon_node, margin) return M.centrate_nodes(margin, text_node, icon_node) end - ---- Center two nodes. --- Nodes will be center around 0 x position --- icon_node will be first (at left side) --- @function helper.centrate_icon_with_text --- @tparam box|nil icon_node Gui box node --- @tparam text|nil text_node Gui text node --- @tparam number|nil margin Offset between nodes --- @local +---Center two nodes. +--Nodes will be center around 0 x position +--icon_node will be first (at left side) +---@param icon_node node|nil Gui box node +---@param text_node node|nil Gui text node +---@param margin number|nil Offset between nodes +---@local function M.centrate_icon_with_text(icon_node, text_node, margin) return M.centrate_nodes(margin, icon_node, text_node) end ---- Centerate nodes by x position with margin. --- --- This functions calculate total width of nodes and set position for each node. --- The centrate will be around 0 x position. --- @function helper.centrate_nodes --- @tparam number|nil margin Offset between nodes --- @param ... Gui nodes +---Centerate nodes by x position with margin. +--- +---This functions calculate total width of nodes and set position for each node. +---The centrate will be around 0 x position. +---@param margin number|nil Offset between nodes +---@param ... node Nodes to centrate function M.centrate_nodes(margin, ...) margin = margin or 0 @@ -113,10 +107,33 @@ function M.centrate_nodes(margin, ...) end ---- Get current screen stretch multiplier for each side --- @function helper.get_screen_aspect_koef --- @treturn number stretch_x --- @treturn number stretch_y +---@param node_id string|node +---@param template string|nil @Full Path to the template +---@param nodes table|nil @Nodes what created with gui.clone_tree +---@return node +function M.get_node(node_id, template, nodes) + if type(node_id) ~= "string" then + -- Assume it's already node from gui.get_node + return node_id + end + + -- If template is set, then add it to the node_id + if template and #template > 0 then + node_id = template .. "/" .. node_id + end + + -- If nodes is set, then try to find node in it + if nodes then + return nodes[node_id] + end + + return gui_get_node(node_id) +end + + +---Get current screen stretch multiplier for each side +---@return number stretch_x +---@return number stretch_y function M.get_screen_aspect_koef() local window_x, window_y = window.get_size() local stretch_x = window_x / gui.get_width() @@ -126,10 +143,8 @@ function M.get_screen_aspect_koef() end ---- Get current GUI scale for each side --- @function helper.get_gui_scale --- @treturn number scale_x --- @treturn number scale_y +---Get current GUI scale for each side +---@return number scale_x function M.get_gui_scale() local window_x, window_y = window.get_size() return math.min(window_x / gui.get_width(), @@ -137,12 +152,11 @@ function M.get_gui_scale() end ---- Move value from current to target value with step amount --- @function helper.step --- @tparam number current Current value --- @tparam number target Target value --- @tparam number step Step amount --- @treturn number New value +---Move value from current to target value with step amount +---@param current number Current value +---@param target number Target value +---@param step number Step amount +---@return number New value function M.step(current, target, step) if current < target then return math.min(current + step, target) @@ -152,12 +166,11 @@ function M.step(current, target, step) end ---- Clamp value between min and max --- @function helper.clamp --- @tparam number a Value --- @tparam number min Min value --- @tparam number max Max value --- @treturn number Clamped value +---Clamp value between min and max +---@param a number Value +---@param min number Min value +---@param max number Max value +---@return number value Clamped value function M.clamp(a, min, max) if min > max then min, max = max, min @@ -173,22 +186,20 @@ function M.clamp(a, min, max) end ---- Calculate distance between two points --- @function helper.distance --- @tparam number x1 First point x --- @tparam number y1 First point y --- @tparam number x2 Second point x --- @tparam number y2 Second point y --- @treturn number Distance +---Calculate distance between two points +---@param x1 number First point x +---@param y1 number First point y +---@param x2 number Second point x +---@param y2 number Second point y +---@return number Distance function M.distance(x1, y1, x2, y2) return math.sqrt((x2 - x1) ^ 2 + (y2 - y1) ^ 2) end ---- Return sign of value (-1, 0, 1) --- @function helper.sign --- @tparam number val Value --- @treturn number Sign +---Return sign of value +---@param val number Value +---@return number sign Sign of value, -1, 0 or 1 function M.sign(val) if val == 0 then return 0 @@ -198,47 +209,42 @@ function M.sign(val) end ---- Round number to specified decimal places --- @function helper.round --- @tparam number num Number --- @tparam number|nil num_decimal_places Decimal places --- @treturn number Rounded number +---Round number to specified decimal places +---@param num number Number +---@param num_decimal_places number|nil Decimal places +---@return number value Rounded number function M.round(num, num_decimal_places) local mult = 10^(num_decimal_places or 0) return math.floor(num * mult + 0.5) / mult end ---- Lerp between two values --- @function helper.lerp --- @tparam number a First value --- @tparam number b Second value --- @tparam number t Lerp amount --- @treturn number Lerped value +---Lerp between two values +---@param a number First value +---@param b number Second value +---@param t number Lerp amount +---@return number value Lerped value function M.lerp(a, b, t) return a + (b - a) * t end ---- Check if value is in array and return index of it --- @function helper.contains --- @tparam table t Array --- @param value Value --- @treturn number|nil Index of value or nil -function M.contains(t, value) - for i = 1, #t do - if t[i] == value then - return i +---Check if value contains in array +---@param array any[] Array to check +---@param value any Value +function M.contains(array, value) + for index = 1, #array do + if array[index] == value then + return index end end return nil end ---- Make a copy table with all nested tables --- @function helper.deepcopy --- @tparam table orig_table Original table --- @treturn table Copy of original table +---Make a copy table with all nested tables +---@param orig_table table Original table +---@return table Copy of original table function M.deepcopy(orig_table) local orig_type = type(orig_table) local copy @@ -254,11 +260,10 @@ function M.deepcopy(orig_table) end ---- Add all elements from source array to the target array --- @function helper.add_array --- @tparam any[] target Array to put elements from source --- @tparam any[]|nil source The source array to get elements from --- @treturn any[] The target array +---Add all elements from source array to the target array +---@param target any[] Array to put elements from source +---@param source any[]|nil The source array to get elements from +---@return any[] The target array function M.add_array(target, source) assert(target) @@ -274,13 +279,12 @@ function M.add_array(target, source) end ---- Make a check with gui.pick_node, but with additional node_click_area check. --- @function helper.pick_node --- @tparam node node --- @tparam number x --- @tparam number y --- @tparam node|nil node_click_area --- @local +---Make a check with gui.pick_node, but with additional node_click_area check. +---@param node node +---@param x number +---@param y number +---@param node_click_area node|nil +---@local function M.pick_node(node, x, y, node_click_area) local is_pick = gui.pick_node(node, x, y) @@ -291,20 +295,19 @@ function M.pick_node(node, x, y, node_click_area) return is_pick end ---- Get node size adjusted by scale --- @function helper.get_scaled_size --- @tparam node node GUI node --- @treturn vector3 Scaled size + +---Get size of node with scale multiplier +---@param node node GUI node +---@treturn vector3 Scaled size function M.get_scaled_size(node) return vmath.mul_per_elem(gui.get_size(node), gui.get_scale(node)) end ---- Get cumulative parent's node scale --- @function helper.get_scene_scale --- @tparam node node Gui node --- @tparam boolean|nil include_passed_node_scale True if add current node scale to result --- @treturn vector3 The scene node scale +---Get cumulative parent's node scale +---@param node node Gui node +---@param include_passed_node_scale boolean|nil True if add current node scale to result +---@return vector3 The scene node scale function M.get_scene_scale(node, include_passed_node_scale) local scale = include_passed_node_scale and gui.get_scale(node) or vmath.vector3(1) local parent = gui.get_parent(node) @@ -317,10 +320,9 @@ function M.get_scene_scale(node, include_passed_node_scale) end ---- Return closest non inverted clipping parent node for given node --- @function helper.get_closest_stencil_node --- @tparam node node GUI node --- @treturn node|nil The closest stencil node or nil +---Return closest non inverted clipping parent node for given node +---@param node node GUI node +---@return node|nil stencil_node The closest stencil node or nil function M.get_closest_stencil_node(node) if not node then return nil @@ -348,8 +350,15 @@ end -- @function helper.get_pivot_offset -- @tparam number pivot The gui.PIVOT_* constant -- @treturn vector3 Vector offset with [-0.5..0.5] values -function M.get_pivot_offset(pivot) - return const.PIVOTS[pivot] + +---Get pivot offset for given pivot or node +---@param pivot_or_node number|node GUI pivot or node +---@return vector3 offset The pivot offset +function M.get_pivot_offset(pivot_or_node) + if type(pivot_or_node) == "number" then + return const.PIVOTS[pivot_or_node] + end + return const.PIVOTS[gui.get_pivot(pivot_or_node)] end diff --git a/druid/styles/default/style.lua b/druid/styles/default/style.lua index 03c722d..0f74a66 100644 --- a/druid/styles/default/style.lua +++ b/druid/styles/default/style.lua @@ -1,5 +1,3 @@ --- Copyright (c) 2021 Maksim Tuprikov . This code is licensed under MIT license - local const = require("druid.const") local settings = require("druid.system.settings") diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index 56de63f..3c4837a 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -10,11 +10,11 @@ -- -- Please review the following API pages: -- --- @{Helper} - A useful set of functions for working with GUI nodes, such as centering nodes, get GUI scale ratio, etc +-- Helper - A useful set of functions for working with GUI nodes, such as centering nodes, get GUI scale ratio, etc -- --- @{DruidEvent} - The core event system in Druid. Learn how to subscribe to any event in every Druid component. +-- DruidEvent - The core event system in Druid. Learn how to subscribe to any event in every Druid component. -- --- @{BaseComponent} - The parent class of all Druid components. You can find all default component methods there. +-- BaseComponent - The parent class of all Druid components. You can find all default component methods there. -- -- # Tech Info # -- @@ -89,7 +89,21 @@ local back_handler = require("druid.base.back_handler") -- local lang_text = require("druid.extended.lang_text") -- local timer_component = require("druid.extended.timer") -local DruidInstance = {} +---@class druid_instance +---@field components_all druid.base_component[] All created components +---@field components_interest table All components sorted by interest +---@field url url +---@field private _context table Druid context +---@field private _style table Druid style table +---@field private _deleted boolean +---@field private _is_late_remove_enabled boolean +---@field private _late_remove druid.base_component[] +---@field private _input_blacklist druid.base_component[]|nil +---@field private _input_whitelist druid.base_component[]|nil +---@field private _input_inited boolean +---@field private _late_init_timer_id number +---@field private _input_components druid.base_component[] +local M = {} local MSG_ADD_FOCUS = hash("acquire_input_focus") local MSG_REMOVE_FOCUS = hash("release_input_focus") @@ -219,17 +233,15 @@ end --- Druid class constructor --- @tparam DruidInstance self -- @tparam table context Druid context. Usually it is self of gui script -- @tparam table style Druid style table -- @local -function DruidInstance.initialize(self, context, style) +function M:initialize(context, style) self._context = context self._style = style or settings.default_style self._deleted = false self._is_late_remove_enabled = false self._late_remove = {} - self._is_debug = false self.url = msg.url() self._input_blacklist = nil @@ -244,11 +256,10 @@ end -- Create new component. --- @tparam DruidInstance self -- @tparam BaseComponent component Component module -- @tparam any ... Other component params to pass it to component:init function -- @treturn BaseComponent Component instance -function DruidInstance.new(self, component, ...) +function M:new(component, ...) local instance = create(self, component) if instance.init then @@ -263,8 +274,7 @@ end --- Call this in gui_script final function. --- @tparam DruidInstance self -function DruidInstance.final(self) +function M:final() local components = self.components_all for i = #components, 1, -1 do @@ -282,10 +292,9 @@ end --- Remove created component from Druid instance. -- -- Component `on_remove` function will be invoked, if exist. --- @tparam DruidInstance self -- @tparam BaseComponent component Component instance -- @treturn boolean True if component was removed -function DruidInstance.remove(self, component) +function M:remove(component) if self._is_late_remove_enabled then table.insert(self._late_remove, component) return false @@ -334,9 +343,8 @@ end --- Druid late update function called after initialization and before the regular update step -- This function is used to check the GUI state and perform actions after all components and nodes have been created. -- An example use case is performing an auto stencil check in the GUI hierarchy for input components. --- @tparam DruidInstance self -- @local -function DruidInstance.late_init(self) +function M:late_init() local late_init_components = self.components_interest[base_component.ON_LATE_INIT] while late_init_components[1] do late_init_components[1]:on_late_init() @@ -353,9 +361,8 @@ end --- Call this in gui_script update function. -- -- Used for: scroll, progress, timer components --- @tparam DruidInstance self -- @tparam number dt Delta time -function DruidInstance.update(self, dt) +function M:update(dt) self._is_late_remove_enabled = true local components = self.components_interest[base_component.ON_UPDATE] @@ -371,11 +378,10 @@ end --- Call this in gui_script on_input function. -- -- Used for almost all components --- @tparam DruidInstance self -- @tparam hash action_id Action_id from on_input -- @tparam table action Action from on_input -- @treturn boolean The boolean value is input was consumed -function DruidInstance.on_input(self, action_id, action) +function M:on_input(action_id, action) self._is_late_remove_enabled = true local components = self.components_interest[base_component.ON_INPUT] @@ -392,11 +398,10 @@ end --- Call this in gui_script on_message function. -- -- Used for special actions. See SPECIFIC_UI_MESSAGES table --- @tparam DruidInstance self -- @tparam hash message_id Message_id from on_message -- @tparam table message Message from on_message -- @tparam url sender Sender from on_message -function DruidInstance.on_message(self, message_id, message, sender) +function M:on_message(message_id, message, sender) local specific_ui_message = base_component.SPECIFIC_UI_MESSAGES[message_id] if specific_ui_message == base_component.ON_MESSAGE_INPUT then @@ -431,9 +436,8 @@ end --- Calls the on_focus_lost function in all related components -- This one called by on_window_callback by global window listener --- @tparam DruidInstance self -- @local -function DruidInstance.on_focus_lost(self) +function M:on_focus_lost() local components = self.components_interest[base_component.ON_FOCUS_LOST] for i = 1, #components do components[i]:on_focus_lost() @@ -443,9 +447,8 @@ end --- Calls the on_focus_gained function in all related components -- This one called by on_window_callback by global window listener --- @tparam DruidInstance self -- @local -function DruidInstance.on_focus_gained(self) +function M:on_focus_gained() local components = self.components_interest[base_component.ON_FOCUS_GAINED] for i = 1, #components do components[i]:on_focus_gained() @@ -456,9 +459,8 @@ end --- Calls the on_language_change function in all related components -- This one called by global druid.on_language_change, but can be -- call manualy to update all translations --- @tparam DruidInstance self -- @local -function DruidInstance.on_language_change(self) +function M:on_language_change() local components = self.components_interest[base_component.ON_LANGUAGE_CHANGE] for i = 1, #components do components[i]:on_language_change() @@ -470,10 +472,9 @@ end -- -- If whitelist is not empty and component not contains in this list, -- component will be not processed on input step --- @tparam DruidInstance self -- @tparam table|BaseComponent|nil whitelist_components The array of component to whitelist --- @treturn self @{DruidInstance} -function DruidInstance.set_whitelist(self, whitelist_components) +-- @treturn self DruidInstance +function M:set_whitelist(whitelist_components) if whitelist_components and whitelist_components._component then whitelist_components = { whitelist_components } end @@ -491,11 +492,10 @@ end --- Set blacklist components for input processing. -- -- If blacklist is not empty and component contains in this list, --- component will be not processed on input step --- @tparam DruidInstance self @{DruidInstance} +-- component will be not processed on input step DruidInstance -- @tparam table|BaseComponent|nil blacklist_components The array of component to blacklist --- @treturn self @{DruidInstance} -function DruidInstance.set_blacklist(self, blacklist_components) +-- @treturn self DruidInstance +function M:set_blacklist(blacklist_components) if blacklist_components and blacklist_components._component then blacklist_components = { blacklist_components } end @@ -510,35 +510,9 @@ function DruidInstance.set_blacklist(self, blacklist_components) end ---- Set debug mode for current Druid instance. It's enable debug log messages --- @tparam DruidInstance self @{DruidInstance} --- @tparam boolean|nil is_debug --- @treturn self @{DruidInstance} +--- Remove all components on late remove step DruidInstance -- @local -function DruidInstance.set_debug(self, is_debug) - self._is_debug = is_debug - return self -end - - ---- Log message, if is_debug mode is enabled --- @tparam DruidInstance self @{DruidInstance} --- @tparam string message --- @tparam table|nil context --- @local -function DruidInstance.log_message(self, message, context) - if not self._is_debug then - return - end - - print("[Druid]:", message, helper.table_to_string(context)) -end - - ---- Remove all components on late remove step --- @tparam DruidInstance self @{DruidInstance} --- @local -function DruidInstance._clear_late_remove(self) +function M:_clear_late_remove() if #self._late_remove == 0 then return end @@ -550,229 +524,188 @@ function DruidInstance._clear_late_remove(self) end ---- Create @{Button} component --- @tparam DruidInstance self --- @tparam string|node node The node_id or gui.get_node(node_id) --- @tparam function|nil callback Button callback --- @tparam any|nil params Button callback params --- @tparam node|string|nil anim_node Button anim node (node, if not provided) --- @treturn Button @{Button} component -function DruidInstance.new_button(self, node, callback, params, anim_node) - return DruidInstance.new(self, button, node, callback, params, anim_node) +--- Create Button component +---@param node string|node The node_id or gui.get_node(node_id) +---@param callback function|nil Button callback +---@param params any|nil Button callback params +---@param anim_node node|string|nil Button anim node (node, if not provided) +---@return druid.button Button component +function M:new_button(node, callback, params, anim_node) + return self:new(button, node, callback, params, anim_node) end ---- Create @{Blocker} component --- @tparam DruidInstance self --- @tparam string|node node The node_id or gui.get_node(node_id) --- @treturn Blocker @{Blocker} component -function DruidInstance.new_blocker(self, node) - return DruidInstance.new(self, blocker, node) +--- Create Blocker component +---@param node string|node The node_id or gui.get_node(node_id) +---@return druid.blocker Blocker component +function M:new_blocker(node) + return self:new(blocker, node) end ---- Create @{BackHandler} component --- @tparam DruidInstance self --- @tparam function|nil callback @The callback(self, custom_args) to call on back event --- @tparam any|nil params Callback argument --- @treturn BackHandler @{BackHandler} component -function DruidInstance.new_back_handler(self, callback, params) - return DruidInstance.new(self, back_handler, callback, params) +--- Create BackHandler component +---@param callback function|nil The callback(self, custom_args) to call on back event +---@param params any|nil Callback argument +---@return druid.back_handler BackHandler component +function M:new_back_handler(callback, params) + return self:new(back_handler, callback, params) end ---- Create @{Hover} component --- @tparam DruidInstance self --- @tparam string|node node The node_id or gui.get_node(node_id) --- @tparam function|nil on_hover_callback Hover callback --- @tparam function|nil on_mouse_hover_callback Mouse hover callback --- @treturn Hover @{Hover} component -function DruidInstance.new_hover(self, node, on_hover_callback, on_mouse_hover_callback) - return DruidInstance.new(self, hover, node, on_hover_callback, on_mouse_hover_callback) +--- Create Hover component +---@param node string|node The node_id or gui.get_node(node_id) +---@param on_hover_callback function|nil Hover callback +---@param on_mouse_hover_callback function|nil Mouse hover callback +---@return druid.hover Hover component +function M:new_hover(node, on_hover_callback, on_mouse_hover_callback) + return self:new(hover, node, on_hover_callback, on_mouse_hover_callback) end ---- Create @{Text} component --- @tparam DruidInstance self --- @tparam string|node node The node_id or gui.get_node(node_id) --- @tparam string|nil value Initial text. Default value is node text from GUI scene. --- @tparam boolean|nil no_adjust If true, text will be not auto-adjust size --- @treturn Text @{Text} component -function DruidInstance.new_text(self, node, value, no_adjust) - return DruidInstance.new(self, text, node, value, no_adjust) +--- Create Text component +---@param node string|node The node_id or gui.get_node(node_id) +---@param value string|nil Initial text. Default value is node text from GUI scene. +---@param no_adjust boolean|nil If true, text will be not auto-adjust size +---@return druid.text Text component +function M:new_text(node, value, no_adjust) + return self:new(text, node, value, no_adjust) end ---- Create @{StaticGrid} component --- @tparam DruidInstance self --- @tparam string|node parent_node The node_id or gui.get_node(node_id). Parent of all Grid items. --- @tparam node item Element prefab. Required to get grid's item size. Can be adjusted separately. --- @tparam number|nil in_row How many nodes in row can be placed --- @treturn StaticGrid @{StaticGrid} component --- @local -function DruidInstance.new_grid(self, parent_node, item, in_row) - return DruidInstance.new(self, static_grid, parent_node, item, in_row) +--- Create StaticGrid component +---@param parent_node string|node The node_id or gui.get_node(node_id). Parent of all Grid items. +---@param item node Element prefab. Required to get grid's item size. Can be adjusted separately. +---@param in_row number|nil How many nodes in row can be placed +---@return druid.grid StaticGrid component +function M:new_grid(parent_node, item, in_row) + return self:new(static_grid, parent_node, item, in_row) end ---- Create @{StaticGrid} component --- @tparam DruidInstance self --- @tparam string|node parent_node The node_id or gui.get_node(node_id). Parent of all Grid items. --- @tparam string|node item Item prefab. Required to get grid's item size. Can be adjusted separately. --- @tparam number|nil in_row How many nodes in row can be placed --- @treturn StaticGrid @{StaticGrid} component -function DruidInstance.new_static_grid(self, parent_node, item, in_row) - return DruidInstance.new(self, static_grid, parent_node, item, in_row) +--- Create StaticGrid component +---@param parent_node string|node The node_id or gui.get_node(node_id). Parent of all Grid items. +---@param item string|node Item prefab. Required to get grid's item size. Can be adjusted separately. +---@param in_row number|nil How many nodes in row can be placed +---@return druid.grid StaticGrid component +function M:new_static_grid(parent_node, item, in_row) + return self:new(static_grid, parent_node, item, in_row) end ---- Create @{Scroll} component --- @tparam DruidInstance self --- @tparam string|node view_node The node_id or gui.get_node(node_id). Will used as user input node. --- @tparam string|node content_node The node_id or gui.get_node(node_id). Will used as scrollable node inside view_node. --- @treturn Scroll @{Scroll} component -function DruidInstance.new_scroll(self, view_node, content_node) - return DruidInstance.new(self, scroll, view_node, content_node) +--- Create Scroll component +---@param view_node string|node The node_id or gui.get_node(node_id). Will used as user input node. +---@param content_node string|node The node_id or gui.get_node(node_id). Will used as scrollable node inside view_node. +---@return druid.scroll Scroll component +function M:new_scroll(view_node, content_node) + return self:new(scroll, view_node, content_node) end ---- Create @{Drag} component --- @tparam DruidInstance self --- @tparam string|node node The node_id or gui.get_node(node_id). Will used as user input node. --- @tparam function|nil on_drag_callback Callback for on_drag_event(self, dx, dy) --- @treturn Drag @{Drag} component -function DruidInstance.new_drag(self, node, on_drag_callback) - return DruidInstance.new(self, drag, node, on_drag_callback) +--- Create Drag component +---@param node string|node The node_id or gui.get_node(node_id). Will used as user input node. +---@param on_drag_callback function|nil Callback for on_drag_event(self, dx, dy) +---@return druid.drag Drag component +function M:new_drag(node, on_drag_callback) + return self:new(drag, node, on_drag_callback) end ---- Create @{Swipe} component --- @tparam DruidInstance self --- @tparam string|node node The node_id or gui.get_node(node_id). Will used as user input node. --- @tparam function|nil on_swipe_callback Swipe callback for on_swipe_end event --- @treturn Swipe @{Swipe} component -function DruidInstance.new_swipe(self, node, on_swipe_callback) - return helper.require_component_message("swipe") +--- Create Swipe component +---@param node string|node The node_id or gui.get_node(node_id). Will used as user input node. +---@param on_swipe_callback function|nil Swipe callback for on_swipe_end event +---@return druid.swipe Swipe component +function M:new_swipe(node, on_swipe_callback) + return helper.require_component_message("swipe") --[[@as druid.swipe]] end ---- Create @{DynamicGrid} component --- Deprecated --- @tparam DruidInstance self --- @tparam string|node parent_node The node_id or gui.get_node(node_id). Parent of all Grid items. --- @treturn DynamicGrid @{DynamicGrid} component -function DruidInstance.new_dynamic_grid(self, parent_node) - return helper.require_component_message("dynamic_grid") +--- Create LangText component +---@param node string|node The_node id or gui.get_node(node_id) +---@param locale_id string|nil Default locale id or text from node as default +---@param adjust_type string|nil Adjust type for text node. Default: const.TEXT_ADJUST.DOWNSCALE +---@return druid.lang_text LangText component +function M:new_lang_text(node, locale_id, adjust_type) + return helper.require_component_message("lang_text") --[[@as druid.lang_text]] end - ---- Create @{LangText} component --- @tparam DruidInstance self --- @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 node. Default: const.TEXT_ADJUST.DOWNSCALE --- @treturn LangText @{LangText} component -function DruidInstance.new_lang_text(self, node, locale_id, adjust_type) - return helper.require_component_message("lang_text") +--- Create Slider component +---@param pin_node string|node The_node id or gui.get_node(node_id). +---@param end_pos vector3 The end position of slider +---@param callback function|nil On slider change callback +---@return druid.slider Slider component +function M:new_slider(pin_node, end_pos, callback) + return helper.require_component_message("slider") --[[@as druid.slider]] end - ---- Create @{Slider} component --- @tparam DruidInstance self --- @tparam string|node pin_node The_node id or gui.get_node(node_id). --- @tparam vector3 end_pos The end position of slider --- @tparam function|nil callback On slider change callback --- @treturn Slider @{Slider} component -function DruidInstance.new_slider(self, pin_node, end_pos, callback) - return helper.require_component_message("slider") +--- Create Input component +---@param click_node string|node Button node to enabled input component +---@param text_node string|node|druid.text Text node what will be changed on user input +---@param keyboard_type number|nil Gui keyboard type for input field +---@return druid.input Input component +function M:new_input(click_node, text_node, keyboard_type) + return helper.require_component_message("input") --[[@as druid.input]] end - ---- Create @{Input} component --- @tparam DruidInstance self --- @tparam string|node click_node Button node to enabled input component --- @tparam string|node|druid.text text_node Text node what will be changed on user input --- @tparam number|nil keyboard_type Gui keyboard type for input field --- @treturn Input @{Input} component -function DruidInstance.new_input(self, click_node, text_node, keyboard_type) - return helper.require_component_message("input") +--- Create DataList component +---@param druid_scroll druid.scroll The Scroll instance for Data List component +---@param druid_grid druid.grid The StaticGrid} or @{DynamicGrid instance for Data List component +---@param create_function function The create function callback(self, data, index, data_list). Function should return (node, [component]) +---@return druid.data_list DataList component +function M:new_data_list(druid_scroll, druid_grid, create_function) + return helper.require_component_message("data_list") --[[@as druid.data_list]] end - ---- Create @{DataList} component --- @tparam DruidInstance self --- @tparam Scroll druid_scroll The Scroll instance for Data List component --- @tparam StaticGrid druid_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]) --- @treturn DataList @{DataList} component -function DruidInstance.new_data_list(self, druid_scroll, druid_grid, create_function) - return helper.require_component_message("data_list") +--- Create Timer component +---@param node string|node Gui text node +---@param seconds_from number Start timer value in seconds +---@param seconds_to number|nil End timer value in seconds +---@param callback function|nil Function on timer end +---@return druid.timer Timer component +function M:new_timer(node, seconds_from, seconds_to, callback) + return helper.require_component_message("timer") --[[@as druid.timer]] end - ---- Create @{Timer} component --- @tparam DruidInstance self --- @tparam string|node node Gui text node --- @tparam number seconds_from Start timer value in seconds --- @tparam number|nil seconds_to End timer value in seconds --- @tparam function|nil callback Function on timer end --- @treturn Timer @{Timer} component -function DruidInstance.new_timer(self, node, seconds_from, seconds_to, callback) - return helper.require_component_message("timer") +--- Create Progress component +---@param node string|node Progress bar fill node or node name +---@param key string Progress bar direction: const.SIDE.X or const.SIDE.Y +---@param init_value number|nil Initial value of progress bar. Default: 1 +---@return druid.progress Progress component +function M:new_progress(node, key, init_value) + return helper.require_component_message("progress") --[[@as druid.progress]] end - ---- Create @{Progress} component --- @tparam DruidInstance self --- @tparam string|node node Progress bar fill node or node name --- @tparam string key Progress bar direction: const.SIDE.X or const.SIDE.Y --- @tparam number|nil init_value Initial value of progress bar. Default: 1 --- @treturn Progress @{Progress} component -function DruidInstance.new_progress(self, node, key, init_value) - return helper.require_component_message("progress") +--- Create Layout component +---@param node string|node The_node id or gui.get_node(node_id). +---@param mode string The layout mode +---@return druid.layout Layout component +function M:new_layout(node, mode) + return helper.require_component_message("layout") --[[@as druid.layout]] end - ---- Create @{Layout} component --- @tparam DruidInstance self --- @tparam string|node node The_node id or gui.get_node(node_id). --- @tparam string mode The layout mode --- @treturn Layout @{Layout} component -function DruidInstance.new_layout(self, node, mode) - return helper.require_component_message("layout") +--- Create Hotkey component +---@param keys_array string|string[] Keys for trigger action. Should contains one action key and any amount of modificator keys +---@param callback function The callback function +---@param callback_argument any|nil The argument to pass into the callback function +---@return druid.hotkey Hotkey component +function M:new_hotkey(keys_array, callback, callback_argument) + return helper.require_component_message("hotkey") --[[@as druid.hotkey]] end - ---- Create @{Hotkey} component --- @tparam DruidInstance self --- @tparam string|string[] keys_array Keys for trigger action. Should contains one action key and any amount of modificator keys --- @tparam function callback The callback function --- @tparam any|nil callback_argument The argument to pass into the callback function --- @treturn Hotkey @{Hotkey} component -function DruidInstance.new_hotkey(self, keys_array, callback, callback_argument) - return helper.require_component_message("hotkey") +--- Create RichText component. +---@param text_node string|node The text node to make Rich Text +---@param value string|nil The initial text value. Default will be gui.get_text(text_node) +---@return druid.rich_text RichText component +function M:new_rich_text(text_node, value) + return helper.require_component_message("rich_text", "custom") --[[@as druid.rich_text]] end - ---- Create @{RichText} component. --- @tparam DruidInstance self --- @tparam string|node 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) --- @treturn RichText @{RichText} component -function DruidInstance.new_rich_text(self, text_node, value) - return helper.require_component_message("rich_text", "custom") -end - - ---- Create @{RichInput} component. +--- Create RichInput component. -- As a template please check rich_input.gui layout. --- @tparam DruidInstance self --- @tparam string template The template string name --- @tparam table nodes Nodes table from gui.clone_tree --- @treturn RichInput @{RichInput} component -function DruidInstance.new_rich_input(self, template, nodes) - return helper.require_component_message("rich_input", "custom") +---@param template string The template string name +---@param nodes table Nodes table from gui.clone_tree +---@return druid.rich_input RichInput component +function M:new_rich_input(template, nodes) + return helper.require_component_message("rich_input", "custom") --[[@as druid.rich_input]] end - -return DruidInstance +return M diff --git a/druid/system/settings.lua b/druid/system/settings.lua index 384a706..ea8f8b6 100755 --- a/druid/system/settings.lua +++ b/druid/system/settings.lua @@ -1,21 +1,15 @@ --- Copyright (c) 2021 Maksim Tuprikov . This code is licensed under MIT license - ---- Druid settings file --- @module settings --- @local - +---@class druid.system.settings local M = {} M.default_style = nil - -function M.get_text(name, a, b, c, d, e, f, g) +---@param text_id string +---@vararg any +function M.get_text(text_id, ...) return "[Druid]: locales not inited" end - -function M.play_sound(name) +function M.play_sound(sound_id) end - return M diff --git a/druid/templates/component.template.lua b/druid/templates/component.template.lua index d67bf32..059ef31 100644 --- a/druid/templates/component.template.lua +++ b/druid/templates/component.template.lua @@ -1,21 +1,16 @@ local component = require("druid.component") ---@class component_name : druid.base_component -local Component = component.create("component_name") +local M = component.create("component_name") -- Component constructor. Template name and nodes are optional. Pass it if you use it in your component -function Component:init(template, nodes) - self.druid = self:get_druid(template, nodes) - self.root = self:get_node("root") +function M:init(template, nodes) + self.druid = self:get_druid(template, nodes) + self.root = self:get_node("root") - self.button = self.druid:new_button("button", function() end) + self.button = self.druid:new_button("button", function() end) end --- [OPTIONAL] Call on component remove or on druid:final -function Component:on_remove() -end - - -return Component +return M diff --git a/druid/templates/component_full.template.lua b/druid/templates/component_full.template.lua index 1978cf2..81fd322 100644 --- a/druid/templates/component_full.template.lua +++ b/druid/templates/component_full.template.lua @@ -1,10 +1,10 @@ local component = require("druid.component") ----@class component_name : druid.base_component -local Component = component.create("component_name") +---@class new_component: druid.base_component +local M = component.create("new_component") -- Component constructor. Template name and nodes are optional. Pass it if you use it in your component -function Component:init(template, nodes) +function M:init(template, nodes) -- If your component is gui template, pass the template name and set it -- If your component is cloned my gui.clone_tree, pass nodes to component and set it -- Use inner druid instance to create components inside this component @@ -17,55 +17,55 @@ end -- [OPTIONAL] Call every update step -function Component:update(dt) +function M:update(dt) end -- [OPTIONAL] Call default on_input from gui script -function Component:on_input(action_id, action) +function M:on_input(action_id, action) return false end -- [OPTIONAL] Call on component creation and on component:set_style() function -function Component:on_style_change(style) +function M:on_style_change(style) end -- [OPTIONAL] Call default on_message from gui script -function Component:on_message(message_id, message, sender) +function M:on_message(message_id, message, sender) end -- [OPTIONAL] Call if druid has triggered on_language_change -function Component:on_language_change() +function M:on_language_change() end -- [OPTIONAL] Call if game layout has changed and need to restore values in component -function Component:on_layout_change() +function M:on_layout_change() end -- [OPTIONAL] Call, if input was capturing before this component -- Example: scroll is start scrolling, so you need unhover button -function Component:on_input_interrupt() +function M:on_input_interrupt() end -- [OPTIONAL] Call, if game lost focus -function Component:on_focus_lost() +function M:on_focus_lost() end -- [OPTIONAL] Call, if game gained focus -function Component:on_focus_gained() +function M:on_focus_gained() end -- [OPTIONAL] Call on component remove or on druid:final -function Component:on_remove() +function M:on_remove() end -return Component +return M diff --git a/example/components/container/container.lua b/example/components/container/container.lua index 8e0c977..ffacc27 100644 --- a/example/components/container/container.lua +++ b/example/components/container/container.lua @@ -134,7 +134,7 @@ end --- Set new size of layout node ---@param width number|nil ---@param height number|nil ----@return druid.container @{Container} +---@return druid.container Container function M:set_size(width, height) width = width or self.size.x height = height or self.size.y @@ -191,7 +191,7 @@ end --- Set size for layout node to fit inside it ---@param target_size vector3 ----@return druid.container @{Container} +---@return druid.container Container function M:fit_into_size(target_size) self.fit_size = target_size self:refresh() @@ -200,7 +200,7 @@ end --- Set current size for layout node to fit inside it ----@return druid.container @{Container} +---@return druid.container Container function M:fit_into_window() return self:fit_into_size(vmath.vector3(gui.get_width(), gui.get_height(), 0)) end @@ -221,7 +221,7 @@ end ---@param node_or_container node|string|druid.container|table ---@param mode string|nil stretch, fit, stretch_x, stretch_y. Default: Pick from node, "fit" or "stretch" ---@param on_resize_callback fun(self: userdata, size: vector3)|nil ----@return druid.container @{Container} New created layout instance +---@return druid.container Container New created layout instance function M:add_container(node_or_container, mode, on_resize_callback) local container = nil local node = node_or_container @@ -422,7 +422,7 @@ function M:update_child_containers() end ----@return druid.container @{Container} +---@return druid.container Container function M:create_draggable_corners() self:clear_draggable_corners() @@ -452,7 +452,7 @@ function M:create_draggable_corners() end ----@return druid.container @{Container} +---@return druid.container Container function M:clear_draggable_corners() for index = 1, #self._draggable_corners do local drag_component = self._draggable_corners[index] @@ -505,7 +505,7 @@ end --- Set node for layout node to fit inside it. Pass nil to reset ---@param node string|node The node_id or gui.get_node(node_id) ----@return druid.container @{Layout} +---@return druid.container Layout function M:fit_into_node(node) self._fit_node = self:get_node(node) self:refresh_scale() diff --git a/example/examples/basic/blocker/basic_blocker.lua b/example/examples/basic/blocker/basic_blocker.lua index 1885d91..57bcfc0 100644 --- a/example/examples/basic/blocker/basic_blocker.lua +++ b/example/examples/basic/blocker/basic_blocker.lua @@ -1,6 +1,6 @@ local component = require("druid.component") ----@class basic_blocker: druid.component +---@class basic_blocker: druid.base_component ---@field druid druid_instance ---@field root node ---@field blocker druid.blocker diff --git a/utils/annotations_manual.lua b/utils/annotations_manual.lua index 46b8284..ee86713 100644 --- a/utils/annotations_manual.lua +++ b/utils/annotations_manual.lua @@ -104,23 +104,23 @@ function druid_instance.new(self, component, ...) end --- Set current component style table. --- Invoke `on_style_change` on component, if exist. Component should handle their style changing and store all style params ---@generic T: druid.base_component ----@param self T @{BaseComponent} +---@param self T BaseComponent ---@param druid_style table|nil Druid style module ----@return T @{BaseComponent} +---@return T BaseComponent function druid__base_component.set_style(self, druid_style) end --- Set component template name. --- 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() ---@generic T: druid.base_component ----@param self T @{BaseComponent} +---@param self T BaseComponent ---@param template string BaseComponent template name ----@return T @{BaseComponent} +---@return T BaseComponent function druid__base_component.set_template(self, template) end --- Set current component nodes. --- Use if your component nodes was cloned with `gui.clone_tree` and you got the node tree. ---@generic T: druid.base_component ----@param self T @{BaseComponent} +---@param self T BaseComponent ---@param nodes table BaseComponent nodes table ----@return T @{BaseComponent} +---@return T BaseComponent function druid__base_component.set_nodes(self, nodes) end From 91bdcb66783dd9573bd93b07b91492ac3c554bdd Mon Sep 17 00:00:00 2001 From: Insality Date: Wed, 30 Oct 2024 00:34:43 +0200 Subject: [PATCH 02/50] Update --- README.md | 28 +++++++++++++++++++++++++++- druid/extended/layout.lua | 7 ++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c0ba53a..b1eb47a 100644 --- a/README.md +++ b/README.md @@ -89,12 +89,38 @@ end function on_input(self, action_id, action) return self.druid:on_input(action_id, action) end - ``` For all **Druid** instance functions, [see here](https://insality.github.io/druid/modules/DruidInstance.html). +### Default GUI Script + +```lua +local druid = require("druid.druid") + +function init(self) + self.druid = druid.new(self) +end + +function final(self) + self.druid:final() +end + +function update(self, dt) + self.druid:update(dt) +end + +function on_message(self, message_id, message, sender) + self.druid:on_message(message_id, message, sender) +end + +function on_input(self, action_id, action) + self.druid:on_input(action_id, action) +end +``` + + ### API Documentation **Druid** offers a wide range of components and functions. To facilitate usage, **Druid** provides comprehensive API documentation with examples and annotations. diff --git a/druid/extended/layout.lua b/druid/extended/layout.lua index e29eca3..4285746 100644 --- a/druid/extended/layout.lua +++ b/druid/extended/layout.lua @@ -39,8 +39,12 @@ function M:init(node_or_node_id, layout_type) self.is_dirty = true self.entities = {} - self.margin = { x = 0, y = 0 } + self.padding = gui.get_slice9(self.node) + self.margin = { x = self.padding.z, y = self.padding.w } + self.padding.z = self.padding.x + self.padding.w = self.padding.y + self.type = layout_type or "horizontal" self.is_resize_width = false self.is_resize_height = false @@ -120,6 +124,7 @@ function M:set_hug_content(is_hug_width, is_hug_height) end +---Add node to layout ---@param node_or_node_id node|string node_or_node_id ---@return druid.layout function M:add(node_or_node_id) From 00b8b192a7e46ce0b138ac18101370791e17371d Mon Sep 17 00:00:00 2001 From: Insality Date: Wed, 30 Oct 2024 01:29:46 +0200 Subject: [PATCH 03/50] Add test "new_widget" --- druid/component.lua | 1 - druid/editor_scripts/component.lua_template | 2 +- druid/system/druid_instance.lua | 77 +++++++++++++++++++-- 3 files changed, 74 insertions(+), 6 deletions(-) diff --git a/druid/component.lua b/druid/component.lua index 9ce4138..05c7e0d 100644 --- a/druid/component.lua +++ b/druid/component.lua @@ -79,7 +79,6 @@ M.SPECIFIC_UI_MESSAGES = { local uid = 0 ----@private function M.create_uid() uid = uid + 1 return uid diff --git a/druid/editor_scripts/component.lua_template b/druid/editor_scripts/component.lua_template index f33bae3..560dc2a 100644 --- a/druid/editor_scripts/component.lua_template +++ b/druid/editor_scripts/component.lua_template @@ -7,7 +7,7 @@ local component = require("druid.component") ----@class {COMPONENT_TYPE}: druid.component +---@class {COMPONENT_TYPE}: druid.base_component ---@field druid druid_instance{COMPONENT_ANNOTATIONS} local M = component.create("{COMPONENT_TYPE}") diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index 3c4837a..80712ca 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -67,6 +67,7 @@ -- @see Text -- @see Timer +local const = require("druid.const") local helper = require("druid.helper") local settings = require("druid.system.settings") local base_component = require("druid.component") @@ -160,6 +161,51 @@ local function create(self, instance_class) end +local WIDGET_METATABLE = { __index = base_component } + +-- Create the Druid component instance +local function create_widget(self, widget_class) + local instance = setmetatable({}, { + __index = setmetatable(widget_class, WIDGET_METATABLE) + }) + + local uid = base_component.create_uid() + instance._components = { + _uid = uid, + name = "Druid Widget #" .. uid, + input_priority = const.PRIORITY_INPUT, + default_input_priority = const.PRIORITY_INPUT, + _is_input_priority_changed = true, -- Default true for sort once time after GUI init + } + instance._meta = { + template = "", + context = self._context, + nodes = nil, + style = nil, + druid = self, + input_enabled = true, + children = {}, + parent = type(self._context) ~= "userdata" and self._context, + instance_class = widget_class + } + + -- Register + if instance._meta.parent then + instance._meta.parent:__add_child(instance) + end + + table.insert(self.components_all, instance) + + local register_to = instance:__get_interests() + for i = 1, #register_to do + local interest = register_to[i] + table.insert(self.components_interest[interest], instance) + end + + return instance +end + + -- Before processing any input check if we need to update input stack local function check_sort_input_stack(self, components) if not components or #components == 0 then @@ -255,10 +301,11 @@ function M:initialize(context, style) end --- Create new component. --- @tparam BaseComponent component Component module --- @tparam any ... Other component params to pass it to component:init function --- @treturn BaseComponent Component instance +---Create new Druid component instance +---@generic T: druid.base_component +---@param component T +---@vararg any +---@return T function M:new(component, ...) local instance = create(self, component) @@ -524,6 +571,28 @@ function M:_clear_late_remove() end +---Create new Druid widget instance +---@generic T: druid.base_component +---@param widget T +---@param template string|nil The template name used by widget +---@param nodes table|nil The nodes table from gui.clone_tree +---@vararg any +---@return T +function M:new_widget(widget, template, nodes, ...) + local instance = create_widget(self, widget) + instance.druid = instance:get_druid(template, nodes) + + if instance.init then + instance:init(...) + end + if instance.on_late_init or (not self.input_inited and instance.on_input) then + schedule_late_init(self) + end + + return instance +end + + --- Create Button component ---@param node string|node The node_id or gui.get_node(node_id) ---@param callback function|nil Button callback From 72cf310d6c3c71dab8ba80546761be4a2a36a83f Mon Sep 17 00:00:00 2001 From: Insality Date: Wed, 30 Oct 2024 23:37:43 +0200 Subject: [PATCH 04/50] Update --- druid/druid.lua | 55 ++---------------- druid/event.lua | 93 +++++++++---------------------- druid/helper.lua | 99 +++++++++++++-------------------- druid/system/druid_instance.lua | 8 ++- 4 files changed, 74 insertions(+), 181 deletions(-) diff --git a/druid/druid.lua b/druid/druid.lua index b198728..f933afa 100644 --- a/druid/druid.lua +++ b/druid/druid.lua @@ -1,53 +1,6 @@ --- Copyright (c) 2021 Maksim Tuprikov . This code is licensed under MIT license - ---- Druid UI Component Framework. --- # Overview # --- --- Druid - powerful Defold component UI library. Use basic and extended --- Druid components or make your own game-specific components to make --- amazing GUI in your games. --- --- To start using Druid, please refer to the Usage section below. --- --- # Notes # --- --- • Each Druid instance maintains the self context from the constructor and passes it to each Druid callback. --- --- See next: DruidInstance --- --- @usage --- local druid = require("druid.druid") --- --- local function on_play(self) --- print("Gonna play!") --- end --- --- function init(self) --- self.druid = druid.new(self) --- self.druid:new_button("button_play", on_play) --- end --- --- function final(self) --- self.druid:final() --- end --- --- function update(self, dt) --- self.druid:update(dt) --- end --- --- function on_message(self, message_id, message, sender) --- self.druid:on_message(message_id, message, sender) --- end --- --- function on_input(self, action_id, action) --- return self.druid:on_input(action_id, action) --- end --- --- @module Druid - local const = require("druid.const") -local base_component = require("druid.component") local settings = require("druid.system.settings") +local base_component = require("druid.component") local druid_instance = require("druid.system.druid_instance") local default_style = require("druid.styles.default.style") @@ -73,9 +26,9 @@ end ---Register a new external Druid component. ----You can register your own components to make new alias: the druid:new_{name} function. ----For example, if you want to register a component called "my_component", you can create it using druid:new_my_component(...). ----This can be useful if you have your own "basic" components that you don't want to re-create each time. +---Register component just makes the druid:new_{name} function. +---For example, if you register a component called "my_component", you can create it using druid:new_my_component(...). +---This can be useful if you have your own "basic" components that you don't want to require in every file. ---@param name string Module name ---@param module table Lua table with component function M.register(name, module) diff --git a/druid/event.lua b/druid/event.lua index 395172b..fab7026 100644 --- a/druid/event.lua +++ b/druid/event.lua @@ -1,15 +1,6 @@ --- Copyright (c) 2021 Maksim Tuprikov . This code is licensed under MIT license - ---- Druid Event Module --- --- The Event module provides a simple class for handling callbacks. It is used in many Druid components. --- --- You can subscribe to an event using the `:subscribe` method and unsubscribe using the `:unsubscribe` method. --- @module DruidEvent --- @alias druid.event - ---@class druid.event local M = {} + M.COUNTER = 0 -- Forward declaration @@ -20,13 +11,11 @@ local pcall = pcall local tinsert = table.insert local tremove = table.remove ---- DruidEvent constructor --- @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(callback) +--- Return new event instance +---@param callback fun()|nil Subscribe the callback on new event, if callback exist +---@param callback_context any|nil Additional context as first param to callback call +---@return druid.event +---@nodiscard function M.create(callback, callback_context) local instance = setmetatable({}, EVENT_METATABLE) @@ -40,9 +29,8 @@ 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 +---@param callback fun() Callback itself +---@param callback_context any|nil 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(callback, callback_context) if #self == 0 then @@ -60,18 +48,10 @@ function M:is_subscribed(callback, callback_context) end ---- Subscribe callback on event --- @tparam DruidEvent self DruidEvent --- @tparam function callback Callback itself --- @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!") --- end --- ... --- local button = self.druid:new_button("button", callback) --- button.on_long_click:subscribe(on_long_callback, self) +---Subscribe callback on event +---@param callback fun() Callback itself +---@param callback_context any|nil Additional context as first param to callback call, usually it's self +---@return boolean function M:subscribe(callback, callback_context) assert(type(self) == "table", "You should subscribe to event with : syntax") assert(callback, "A function must be passed to subscribe to an event") @@ -85,16 +65,10 @@ function M:subscribe(callback, callback_context) end ---- Unsubscribe callback on event --- @tparam DruidEvent self DruidEvent --- @tparam function callback Callback itself --- @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) +---Unsubscribe callback on event +---@param callback fun() Callback itself +---@param callback_context any|nil Additional context as first param to callback call +---@return boolean function M:unsubscribe(callback, callback_context) assert(callback, "A function must be passed to subscribe to an event") @@ -108,30 +82,21 @@ function M:unsubscribe(callback, callback_context) end ---- Return true, if event have at lease one handler --- @tparam DruidEvent self DruidEvent --- @treturn boolean True if event have handlers --- @usage --- local is_long_click_handler_exists = button.on_long_click:is_exist() +---Return true, if event have at lease one handler +---@return boolean function M:is_exist() 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() +---Return true, if event not have handler +---@return boolean True if event not have handlers function M:is_empty() return #self == 0 end ---- Clear the all event handlers --- @tparam DruidEvent self DruidEvent --- @usage --- button.on_long_click:clear() +---Clear the all event handlers function M:clear() for index = #self, 1, -1 do self[index] = nil @@ -140,13 +105,8 @@ end --- Trigger the event and call all subscribed callbacks --- @tparam DruidEvent self DruidEvent --- @tparam any ... All event params --- @usage --- local Event = require("druid.event") --- ... --- local event = Event() --- event:trigger("Param1", "Param2") +---@param ... any All event params +---@return any result Last returned value from subscribers function M:trigger(...) if #self == 0 then return @@ -163,10 +123,9 @@ function M:trigger(...) end --- @tparam table callback Callback data {function, context} --- @tparam any ... All event params --- @treturn any Result of the callback --- @local +---@param callback table Callback data {function, context} +---@param ... any All event params +---@return any result Result of the callback function M:call_callback(callback, ...) local event_callback = callback[1] local event_callback_context = callback[2] diff --git a/druid/helper.lua b/druid/helper.lua index 1cf3c38..8d54cee 100644 --- a/druid/helper.lua +++ b/druid/helper.lua @@ -344,14 +344,8 @@ function M.get_closest_stencil_node(node) end ---- Get node offset for given GUI pivot. --- --- Offset shown in [-0.5 .. 0.5] range, where -0.5 is left or bottom, 0.5 is right or top. --- @function helper.get_pivot_offset --- @tparam number pivot The gui.PIVOT_* constant --- @treturn vector3 Vector offset with [-0.5..0.5] values - ---Get pivot offset for given pivot or node +---Offset shown in [-0.5 .. 0.5] range, where -0.5 is left or bottom, 0.5 is right or top. ---@param pivot_or_node number|node GUI pivot or node ---@return vector3 offset The pivot offset function M.get_pivot_offset(pivot_or_node) @@ -362,26 +356,23 @@ function M.get_pivot_offset(pivot_or_node) end ---- Check if device is native mobile (Android or iOS) --- @function helper.is_mobile --- @treturn boolean Is mobile +---Check if device is native mobile (Android or iOS) +---@return boolean Is mobile function M.is_mobile() - return const.CURRENT_SYSTEM_NAME == const.OS.IOS or - const.CURRENT_SYSTEM_NAME == const.OS.ANDROID + local sys_name = const.CURRENT_SYSTEM_NAME + return sys_name == const.OS.IOS or sys_name == const.OS.ANDROID end ---- Check if device is HTML5 --- @function helper.is_web --- @treturn boolean Is web +---Check if device is HTML5 +---@return boolean function M.is_web() return const.CURRENT_SYSTEM_NAME == const.OS.BROWSER end ---- Check if device is HTML5 mobile --- @function helper.is_web_mobile --- @treturn boolean Is web mobile +---Check if device is HTML5 mobile +---@return boolean function M.is_web_mobile() if html5 then return html5.run("(typeof window.orientation !== 'undefined') || (navigator.userAgent.indexOf('IEMobile') !== -1);") == "true" @@ -390,18 +381,16 @@ function M.is_web_mobile() end ---- Check if device is mobile and can support multitouch --- @function helper.is_multitouch_supported --- @treturn boolean Is multitouch supported +---Check if device is mobile and can support multitouch +---@return boolean is_multitouch Is multitouch supported function M.is_multitouch_supported() return M.is_mobile() or M.is_web_mobile() end ---- Simple table to one-line string converter --- @function helper.table_to_string --- @tparam table t --- @treturn string +---Simple table to one-line string converter +---@param t table +---@return string function M.table_to_string(t) if not t then return "" @@ -420,11 +409,10 @@ function M.table_to_string(t) end ---- Distance from node position to his borders --- @function helper.get_border --- @tparam node node GUI node --- @tparam vector3|nil offset Offset from node position. Pass current node position to get non relative border values --- @treturn vector4 Vector4 with border values (left, top, right, down) +---Distance from node position to his borders +---@param node node GUI node +---@param offset vector3|nil Offset from node position. Pass current node position to get non relative border values +---@return vector4 border Vector4 with border values (left, top, right, down) function M.get_border(node, offset) local pivot = gui.get_pivot(node) local pivot_offset = M.get_pivot_offset(pivot) @@ -447,17 +435,9 @@ function M.get_border(node, offset) end ---- Get text metric from GUI node. --- @function helper.get_text_metrics_from_node --- @tparam node text_node --- @treturn GUITextMetrics --- @usage --- type GUITextMetrics = { --- width: number, --- height: number, --- max_ascent: number, --- max_descent: number --- } +---Get text metric from GUI node. +---@param text_node node +---@return GUITextMetrics function M.get_text_metrics_from_node(text_node) local font_resource = gui.get_font_resource(gui.get_font(text_node)) local options = { @@ -475,15 +455,13 @@ function M.get_text_metrics_from_node(text_node) end ---- Add value to array with shift policy --- +---Add value to array with shift policy -- Shift policy can be: left, right, no_shift --- @function helper.insert_with_shift --- @tparam table array Array --- @param any Item to insert --- @tparam number|nil index Index to insert. If nil, item will be inserted at the end of array --- @tparam number|nil shift_policy The druid_const.SHIFT.* constant --- @treturn any Inserted item +---@param array table Array +---@param item any Item to insert +---@param index number|nil Index to insert. If nil, item will be inserted at the end of array +---@param shift_policy number|nil The druid_const.SHIFT.* constant +---@return any Inserted item function M.insert_with_shift(array, item, index, shift_policy) shift_policy = shift_policy or const.SHIFT.RIGHT @@ -507,14 +485,13 @@ function M.insert_with_shift(array, item, index, shift_policy) end ---- Remove value from array with shift policy +---Remove value from array with shift policy -- -- Shift policy can be: left, right, no_shift --- @function helper.remove_with_shift --- @tparam table array Array --- @tparam number|nil index Index to remove. If nil, item will be removed from the end of array --- @tparam number|nil shift_policy The druid_const.SHIFT.* constant --- @treturn any Removed item +---@param array any[] Array +---@param index number|nil Index to remove. If nil, item will be removed from the end of array +---@param shift_policy number|nil The druid_const.SHIFT.* constant +---@return any Removed item function M.remove_with_shift(array, index, shift_policy) shift_policy = shift_policy or const.SHIFT.RIGHT @@ -539,11 +516,10 @@ function M.remove_with_shift(array, index, shift_policy) end ---- Show deprecated message. Once time per message --- @function helper.deprecated --- @tparam string message The deprecated message --- @local local _deprecated_messages = {} + +---Show deprecated message. Once time per message +---@param message string The deprecated message function M.deprecated(message) if _deprecated_messages[message] then return @@ -554,8 +530,9 @@ function M.deprecated(message) end ---- Show message to require component --- @local +---Show message to require component +---@param component_name string +---@param component_type string function M.require_component_message(component_name, component_type) component_type = component_type or "extended" diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index 80712ca..176caff 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -163,7 +163,9 @@ end local WIDGET_METATABLE = { __index = base_component } --- Create the Druid component instance +---Create the Druid component instance +---@param self druid_instance +---@param widget_class druid.base_component local function create_widget(self, widget_class) local instance = setmetatable({}, { __index = setmetatable(widget_class, WIDGET_METATABLE) @@ -206,7 +208,9 @@ local function create_widget(self, widget_class) end --- Before processing any input check if we need to update input stack +---Before processing any input check if we need to update input stack +---@param self druid_instance +---@param components table[] local function check_sort_input_stack(self, components) if not components or #components == 0 then return From 6ccf58d527d6161bb58ea16d10857bb9eb417ecc Mon Sep 17 00:00:00 2001 From: Insality Date: Wed, 30 Oct 2024 23:46:39 +0200 Subject: [PATCH 05/50] Update docs --- druid/extended/swipe.lua | 7 +- druid/helper.lua | 12 ++-- druid/system/druid_instance.lua | 84 ++++------------------ example/components/container/container.lua | 1 + 4 files changed, 25 insertions(+), 79 deletions(-) diff --git a/druid/extended/swipe.lua b/druid/extended/swipe.lua index c153ce7..6d900a1 100644 --- a/druid/extended/swipe.lua +++ b/druid/extended/swipe.lua @@ -95,11 +95,6 @@ function M:on_style_change(style) end ---- The Swipe constructor --- @tparam Swipe self Swipe --- @tparam node node Gui node --- @tparam function on_swipe_callback Swipe callback for on_swipe_end event - ---Swipe constructor ---@param node_or_node_id node|string ---@param on_swipe_callback function @@ -125,6 +120,8 @@ function M:on_late_init() end +---@param action_id hash +---@param action action function M:on_input(action_id, action) if action_id ~= const.ACTION_TOUCH then return false diff --git a/druid/helper.lua b/druid/helper.lua index 8d54cee..7560fe7 100644 --- a/druid/helper.lua +++ b/druid/helper.lua @@ -3,7 +3,8 @@ local const = require("druid.const") local gui_get_node = gui.get_node - +local gui_get = gui.get +local gui_pick_node = gui.pick_node ---@class druid.system.helper local M = {} @@ -16,7 +17,7 @@ local SIZE_X = hash("size.x") local function get_text_width(text_node) if text_node then local text_metrics = M.get_text_metrics_from_node(text_node) - local text_scale = gui.get(text_node, SCALE_X) + local text_scale = gui_get(text_node, SCALE_X) return text_metrics.width * text_scale end @@ -26,7 +27,7 @@ end local function get_icon_width(icon_node) if icon_node then - return gui.get(icon_node, SIZE_X) * gui.get(icon_node, SCALE_X) -- icon width + return gui_get(icon_node, SIZE_X) * gui_get(icon_node, SCALE_X) -- icon width end return 0 @@ -55,6 +56,7 @@ function M.centrate_text_with_icon(text_node, icon_node, margin) return M.centrate_nodes(margin, text_node, icon_node) end + ---Center two nodes. --Nodes will be center around 0 x position --icon_node will be first (at left side) @@ -286,10 +288,10 @@ end ---@param node_click_area node|nil ---@local function M.pick_node(node, x, y, node_click_area) - local is_pick = gui.pick_node(node, x, y) + local is_pick = gui_pick_node(node, x, y) if node_click_area then - is_pick = is_pick and gui.pick_node(node_click_area, x, y) + is_pick = is_pick and gui_pick_node(node_click_area, x, y) end return is_pick diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index 176caff..62f2323 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -1,13 +1,4 @@ --- Copyright (c) 2021 Maksim Tuprikov . This code is licensed under MIT license ---- Druid Instance which you use for component creation. --- --- # Component List # --- --- For a list of all available components, please refer to the "See Also" section. --- --- # Notes # --- -- Please review the following API pages: -- -- Helper - A useful set of functions for working with GUI nodes, such as centering nodes, get GUI scale ratio, etc @@ -23,49 +14,6 @@ -- • When using Druid components, provide the node name as a string argument directly. Avoid calling gui.get_node() before passing it to the component. Because Druid can get nodes from template and cloned gui nodes. -- -- • All Druid and component methods are called using the colon operator (e.g., self.druid:new_button()). --- @usage --- local druid = require("druid.druid") --- --- local function close_window(self) --- print("Yeah! You closed the game!") --- end --- --- function init(self) --- self.druid = druid.new(self) --- --- -- Call all druid instance function with ":" syntax: --- local text = self.druid:new_text("text_header", "Hello Druid!") --- local button = self.druid:new_button("button_close", close_window) --- --- -- You not need to save component reference if not need it --- self.druid:new_back_handler(close_window) --- end --- --- @module DruidInstance --- @alias druid_instance --- @see BackHandler --- @see Blocker --- @see Button --- @see Checkbox --- @see CheckboxGroup --- @see DataList --- @see Drag --- @see DynamicGrid --- @see Hotkey --- @see Hover --- @see Input --- @see LangText --- @see Layout --- @see Progress --- @see RadioGroup --- @see RichInput --- @see RichText --- @see Scroll --- @see Slider --- @see StaticGrid --- @see Swipe --- @see Text --- @see Timer local const = require("druid.const") local helper = require("druid.helper") @@ -283,8 +231,8 @@ end --- Druid class constructor --- @tparam table context Druid context. Usually it is self of gui script --- @tparam table style Druid style table +---@param table context Druid context. Usually it is self of gui script +---@param table style Druid style table -- @local function M:initialize(context, style) self._context = context @@ -343,8 +291,8 @@ end --- Remove created component from Druid instance. -- -- Component `on_remove` function will be invoked, if exist. --- @tparam BaseComponent component Component instance --- @treturn boolean True if component was removed +---@param BaseComponent component Component instance +---@return boolean True if component was removed function M:remove(component) if self._is_late_remove_enabled then table.insert(self._late_remove, component) @@ -412,7 +360,7 @@ end --- Call this in gui_script update function. -- -- Used for: scroll, progress, timer components --- @tparam number dt Delta time +---@param dt number Delta time function M:update(dt) self._is_late_remove_enabled = true @@ -429,9 +377,9 @@ end --- Call this in gui_script on_input function. -- -- Used for almost all components --- @tparam hash action_id Action_id from on_input --- @tparam table action Action from on_input --- @treturn boolean The boolean value is input was consumed +---@param action_id hash Action_id from on_input +---@param action table Action from on_input +---@return boolean The boolean value is input was consumed function M:on_input(action_id, action) self._is_late_remove_enabled = true @@ -449,9 +397,9 @@ end --- Call this in gui_script on_message function. -- -- Used for special actions. See SPECIFIC_UI_MESSAGES table --- @tparam hash message_id Message_id from on_message --- @tparam table message Message from on_message --- @tparam url sender Sender from on_message +---@param message_id hash Message_id from on_message +---@param message table Message from on_message +---@param sender url Sender from on_message function M:on_message(message_id, message, sender) local specific_ui_message = base_component.SPECIFIC_UI_MESSAGES[message_id] @@ -520,11 +468,10 @@ end --- Set whitelist components for input processing. --- -- If whitelist is not empty and component not contains in this list, -- component will be not processed on input step --- @tparam table|BaseComponent|nil whitelist_components The array of component to whitelist --- @treturn self DruidInstance +---@param whitelist_components table|druid.base_component[]|nil The array of component to whitelist +---@return druid_instance function M:set_whitelist(whitelist_components) if whitelist_components and whitelist_components._component then whitelist_components = { whitelist_components } @@ -541,11 +488,10 @@ end --- Set blacklist components for input processing. --- -- If blacklist is not empty and component contains in this list, -- component will be not processed on input step DruidInstance --- @tparam table|BaseComponent|nil blacklist_components The array of component to blacklist --- @treturn self DruidInstance +---@param blacklist_components table|druid.base_component[]|nil The array of component to blacklist +---@return druid_instance function M:set_blacklist(blacklist_components) if blacklist_components and blacklist_components._component then blacklist_components = { blacklist_components } diff --git a/example/components/container/container.lua b/example/components/container/container.lua index ffacc27..d425c45 100644 --- a/example/components/container/container.lua +++ b/example/components/container/container.lua @@ -195,6 +195,7 @@ end function M:fit_into_size(target_size) self.fit_size = target_size self:refresh() + return self end From 0972c53c700caf32354463a0734798891aa20635 Mon Sep 17 00:00:00 2001 From: Insality Date: Wed, 30 Oct 2024 23:46:55 +0200 Subject: [PATCH 06/50] Remove HTML API from this branch --- docs/index.html | 186 ---- docs/ldoc_fixed.css | 311 ------ docs/modules/BackHandler.html | 172 ---- docs/modules/BaseComponent.html | 549 ---------- docs/modules/Blocker.html | 233 ----- docs/modules/Button.html | 880 ---------------- docs/modules/Checkbox.html | 350 ------- docs/modules/CheckboxGroup.html | 259 ----- docs/modules/DataList.html | 712 ------------- docs/modules/Drag.html | 633 ------------ docs/modules/Druid.html | 374 ------- docs/modules/DruidEvent.html | 399 -------- docs/modules/DruidInstance.html | 1223 ----------------------- docs/modules/DynamicGrid.html | 788 --------------- docs/modules/Helper.html | 927 ----------------- docs/modules/Hotkey.html | 373 ------- docs/modules/Hover.html | 469 --------- docs/modules/Input.html | 1086 -------------------- docs/modules/LangText.html | 380 ------- docs/modules/Layout.html | 147 --- docs/modules/PinKnob.html | 299 ------ docs/modules/Progress.html | 569 ----------- docs/modules/RadioGroup.html | 259 ----- docs/modules/RichInput.html | 567 ----------- docs/modules/RichText.html | 560 ----------- docs/modules/Scroll.html | 1183 ---------------------- docs/modules/Slider.html | 531 ---------- docs/modules/StaticGrid.html | 1094 -------------------- docs/modules/Swipe.html | 288 ------ docs/modules/Text.html | 942 ----------------- docs/modules/Timer.html | 409 -------- docs/modules/druid.extended.layout.html | 95 -- docs/modules/druid.system.utf8.html | 93 -- 33 files changed, 17340 deletions(-) delete mode 100644 docs/index.html delete mode 100644 docs/ldoc_fixed.css delete mode 100644 docs/modules/BackHandler.html delete mode 100644 docs/modules/BaseComponent.html delete mode 100644 docs/modules/Blocker.html delete mode 100644 docs/modules/Button.html delete mode 100644 docs/modules/Checkbox.html delete mode 100644 docs/modules/CheckboxGroup.html delete mode 100644 docs/modules/DataList.html delete mode 100644 docs/modules/Drag.html delete mode 100644 docs/modules/Druid.html delete mode 100644 docs/modules/DruidEvent.html delete mode 100644 docs/modules/DruidInstance.html delete mode 100644 docs/modules/DynamicGrid.html delete mode 100644 docs/modules/Helper.html delete mode 100644 docs/modules/Hotkey.html delete mode 100644 docs/modules/Hover.html delete mode 100644 docs/modules/Input.html delete mode 100644 docs/modules/LangText.html delete mode 100644 docs/modules/Layout.html delete mode 100644 docs/modules/PinKnob.html delete mode 100644 docs/modules/Progress.html delete mode 100644 docs/modules/RadioGroup.html delete mode 100644 docs/modules/RichInput.html delete mode 100644 docs/modules/RichText.html delete mode 100644 docs/modules/Scroll.html delete mode 100644 docs/modules/Slider.html delete mode 100644 docs/modules/StaticGrid.html delete mode 100644 docs/modules/Swipe.html delete mode 100644 docs/modules/Text.html delete mode 100644 docs/modules/Timer.html delete mode 100644 docs/modules/druid.extended.layout.html delete mode 100644 docs/modules/druid.system.utf8.html diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index 192ca28..0000000 --- a/docs/index.html +++ /dev/null @@ -1,186 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- - -

Documentation for Druid Framework

- -

Modules

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

## Overview ## -

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

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

The Event module provides a simple class for handling callbacks.

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

# Overview # -

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

LayoutLayout management on node
ProgressDruid component to handle the progress bars.
SliderDruid slider component
SwipeComponent to handle swipe gestures on node.
TimerComponent to handle GUI timers.
HelperHelper module with various usefull GUI functions.
DruidInstanceDruid Instance which you use for component creation.
- -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - diff --git a/docs/ldoc_fixed.css b/docs/ldoc_fixed.css deleted file mode 100644 index e63d191..0000000 --- a/docs/ldoc_fixed.css +++ /dev/null @@ -1,311 +0,0 @@ -/* BEGIN RESET - -Copyright (c) 2010, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.com/yui/license.html -version: 2.8.2r1 -*/ -html { - color: #000; - background: #FFF; -} -body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td { - margin: 0; - padding: 0; -} -table { - border-collapse: collapse; - border-spacing: 0; -} -fieldset,img { - border: 0; -} -address,caption,cite,code,dfn,em,strong,th,var,optgroup { - font-style: inherit; - font-weight: inherit; -} -del,ins { - text-decoration: none; -} -li { - margin-left: 20px; -} -caption,th { - text-align: left; -} -h1,h2,h3,h4,h5,h6 { - font-size: 100%; - font-weight: bold; -} -q:before,q:after { - content: ''; -} -abbr,acronym { - border: 0; - font-variant: normal; -} -sup { - vertical-align: baseline; -} -sub { - vertical-align: baseline; -} -legend { - color: #000; -} -input,button,textarea,select,optgroup,option { - font-family: inherit; - font-size: inherit; - font-style: inherit; - font-weight: inherit; -} -input,button,textarea,select {*font-size:100%; -} -/* END RESET */ - -body { - margin-left: 1em; - margin-right: 1em; - font-family: arial, helvetica, geneva, sans-serif; - background-color: #ffffff; margin: 0px; -} - -code, tt { font-family: monospace; font-size: 1.1em; } -span.parameter { font-family:monospace; } -span.parameter:after { content:":"; } -span.types:before { content:"("; } -span.types:after { content:")"; } -.type { font-weight: bold; font-style:italic } - -body, p, td, th { font-size: .95em; line-height: 1.2em;} - -p, ul { margin: 10px 0 0 0px;} - -strong { font-weight: bold;} - -em { font-style: italic;} - -h1 { - font-size: 1.5em; - margin: 0 0 20px 0; -} -h2, h3, h4 { margin: 15px 0 10px 0; } -h2 { font-size: 1.25em; } -h3 { font-size: 1.15em; } -h4 { font-size: 1.06em; } - -a:link { font-weight: bold; color: #004080; text-decoration: none; } -a:visited { font-weight: bold; color: #006699; text-decoration: none; } -a:link:hover { text-decoration: underline; } - -hr { - color:#cccccc; - background: #00007f; - height: 1px; -} - -blockquote { margin-left: 3em; } - -ul { list-style-type: disc; } - -p.name { - font-family: "Andale Mono", monospace; - padding-top: 1em; -} - -pre { - background-color: rgb(245, 245, 245); - border: 1px solid #C0C0C0; /* silver */ - padding: 10px; - margin: 10px 0 10px 0; - overflow: auto; - font-family: "Andale Mono", monospace; -} - -pre.example { - font-size: .85em; -} - -table.index { border: 1px #00007f; } -table.index td { text-align: left; vertical-align: top; } - -#container { - margin-left: 1em; - margin-right: 1em; - background-color: #ffffff; -} - -#product { - text-align: center; - border-bottom: 1px solid #cccccc; - background-color: #ffffff; -} - -#product big { - font-size: 2em; -} - -#main { - background-color:#FFFFFF; // #f0f0f0; - border-left: 1px solid #cccccc; -} - -#navigation { - position: fixed; - top: 0; - left: 0; - float: left; - width: 14em; - vertical-align: top; - background-color:#FFFFFF; // #f0f0f0; - border-right: 2px solid #cccccc; - overflow: visible; - overflow-y: scroll; - height: 100%; - padding-left: 1em; -} - -#navigation h2 { - background-color:#FFFFFF;//:#e7e7e7; - font-size:1.1em; - color:#000000; - text-align: left; - padding:0.2em; - border-bottom:1px solid #dddddd; -} - -#navigation ul -{ - font-size:1em; - list-style-type: none; - margin: 1px 1px 10px 1px; -} - -#navigation li { - text-indent: -1em; - display: block; - margin: 3px 0px 0px 22px; -} - -#navigation li li a { - margin: 0px 3px 0px -1em; -} - -#content { - margin-left: 14em; - padding: 1em; - padding-left: 2em; - width: 900px; - border-left: 2px solid #cccccc; - // border-right: 2px solid #cccccc; - background-color: #ffffff; -} - -#about { - clear: both; - padding-left: 1em; - margin-left: 14em; // avoid the damn sidebar! - border-top: 2px solid #cccccc; - border-left: 2px solid #cccccc; - background-color: #ffffff; -} - -@media print { - body { - font: 12pt "Times New Roman", "TimeNR", Times, serif; - } - a { font-weight: bold; color: #004080; text-decoration: underline; } - - #main { - background-color: #ffffff; - border-left: 0px; - } - - #container { - margin-left: 2%; - margin-right: 2%; - background-color: #ffffff; - } - - #content { - padding: 1em; - background-color: #ffffff; - } - - #navigation { - display: none; - } - pre.example { - font-family: "Andale Mono", monospace; - font-size: 10pt; - page-break-inside: avoid; - } -} - -table.module_list { - border-width: 1px; - border-style: solid; - border-color: #cccccc; - border-collapse: collapse; -} -table.module_list td { - border-width: 1px; - padding: 3px; - border-style: solid; - border-color: #cccccc; -} -table.module_list td.name { background-color: #f0f0f0; ; min-width: 200px; } -table.module_list td.summary { width: 100%; } - -table.function_list { - border-width: 1px; - border-style: solid; - border-color: #cccccc; - border-collapse: collapse; -} -table.function_list td { - border-width: 1px; - padding: 3px; - border-style: solid; - border-color: #cccccc; -} -table.function_list td.name { background-color: #f6f6ff; ; min-width: 200px; } -table.function_list td.summary { width: 100%; } - -dl.table dt, dl.function dt {border-top: 1px solid #ccc; padding-top: 1em;} -dl.table dd, dl.function dd {padding-bottom: 1em; margin: 10px 0 0 20px;} -dl.table h3, dl.function h3 {font-size: .95em;} - -ul.nowrap { - overflow:auto; - whitespace:nowrap; -} - -/* stop sublists from having initial vertical space */ -ul ul { margin-top: 0px; } -ol ul { margin-top: 0px; } -ol ol { margin-top: 0px; } -ul ol { margin-top: 0px; } - -/* make the target distinct; helps when we're navigating to a function */ -a:target + * { - background-color: #FF9; -} - - -/* styles for prettification of source */ -pre .comment { color: #558817; } -pre .constant { color: #a8660d; } -pre .escape { color: #844631; } -pre .keyword { color: #aa5050; font-weight: bold; } -pre .library { color: #0e7c6b; } -pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; } -pre .string { color: #8080ff; } -pre .number { color: #f8660d; } -pre .operator { color: #2239a8; font-weight: bold; } -pre .preprocessor, pre .prepro { color: #a33243; } -pre .global { color: #800080; } -pre .user-keyword { color: #800080; } -pre .prompt { color: #558817; } -pre .url { color: #272fc2; text-decoration: underline; } - diff --git a/docs/modules/BackHandler.html b/docs/modules/BackHandler.html deleted file mode 100644 index e8f7dc7..0000000 --- a/docs/modules/BackHandler.html +++ /dev/null @@ -1,172 +0,0 @@ - - - - - Defold Druid UI Framework - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module BackHandler

-

Component with event on back and backspace button.

-

- # Overview # -

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

# Notes # -

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

• Back Handler react on release action ACTION_BACK or ACTION_BACKSPACE

-

Usage:

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

Fields

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

Fields

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

Trigger on input action ACTION_BACK or ACTION_BACKSPACE - - -

- - - - -

Usage:

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

Usage:

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

Module BaseComponent

-

Basic class for all Druid components.

-

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

-

Usage:

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

Functions

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

Functions

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

Parameters:

- - -

Returns:

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

Parameters:

- - -

Returns:

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

Parameters:

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

Returns:

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

Parameters:

- - -

Returns:

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

Parameters:

- - -

Returns:

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

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

Parameters:

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

Returns:

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

Parameters:

- - -

Returns:

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

Parameters:

- - -

Returns:

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

Parameters:

- - -

Returns:

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

UID generated in component creation order. - - -

Parameters:

- - -

Returns:

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

Parameters:

- - -

Returns:

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

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Module Blocker

-

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

-

- # Overview # -

# Notes # -

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

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

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

• The Blocker node should be enabled to capture the input

-

Usage:

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

Functions

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

Fields

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

Functions

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

Parameters:

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

Parameters:

- - -

Returns:

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

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

Parameters:

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

Fields

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

Module Button

-

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

-

-

# Overview # -

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

# Notes # -

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

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

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

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

Example Link

-

Usage:

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

Functions

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

Tables

- - - - - -
styleComponent style params.
-

Fields

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

Functions

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

Parameters:

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

Returns:

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

Usage:

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

Parameters:

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

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

Parameters:

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

Returns:

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

Usage:

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

Parameters:

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

Returns:

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

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

Parameters:

- - -

Returns:

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

Usage:

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

Parameters:

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

Returns:

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

Usage:

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

Parameters:

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

Returns:

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

Usage:

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

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

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

Parameters:

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

Returns:

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

Usage:

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

Tables

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

Fields:

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

Fields

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

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

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

Usage:

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

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

Usecase: Hide the popup when click outside - - -

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

Usage:

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

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

- - - - -

Usage:

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

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

Usecase: Animate button progress of long tap - - -

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

Usage:

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

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

- - - - -

Usage:

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

Usage:

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

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

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

Usage:

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

Module Checkbox

-

Druid checkbox component

-

Example Link

- - -

Functions

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

Tables

- - - - - -
styleComponent style params.
-

Fields

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

Functions

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

Parameters:

- - -

Returns:

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

Parameters:

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

Parameters:

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

Tables

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

Fields:

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

Fields

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

Module CheckboxGroup

-

Checkbox group module

-

Example Link

- - -

Functions

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

Fields

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

Functions

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

Parameters:

- - -

Returns:

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

Parameters:

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

Parameters:

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

Fields

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

Module DataList

-

Component to manage data for huge dataset in scroll.

-

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

Example Link

- - -

Functions

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

Fields

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

Functions

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

Parameters:

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

Parameters:

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

Parameters:

- - -

Returns:

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

Parameters:

- - -

Returns:

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

Parameters:

- - -

Returns:

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

Parameters:

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

Parameters:

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

Parameters:

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

Parameters:

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

Parameters:

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

Parameters:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Fields

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

Module Drag

-

Component to handle drag action on node.

-

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

Example Link

- - -

Functions

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

Tables

- - - - - -
styleComponent style params.
-

Fields

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

Functions

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

Parameters:

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

Parameters:

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

Returns:

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

Parameters:

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

Parameters:

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

Tables

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

Fields:

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

Fields

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

Module Druid

-

Druid UI Component Framework.

-

- # Overview # -

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

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

# Notes # -

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

See next: DruidInstance -

-

Usage:

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

Functions

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

Functions

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

Parameters:

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

Returns:

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

Usage:

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

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

Usage:

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

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

Parameters:

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

Usage:

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

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

Parameters:

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

Usage:

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

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

Parameters:

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

Usage:

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

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

Parameters:

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

Usage:

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

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

Parameters:

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

Usage:

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

Module DruidEvent

-

Druid Event Module -

The Event module provides a simple class for handling callbacks.

-

It is used in many Druid components. -

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

- - -

Functions

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

Functions

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

Parameters:

- - - - - -

Usage:

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

Parameters:

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

Usage:

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

Parameters:

- - -

Returns:

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

Usage:

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

Parameters:

- - -

Returns:

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

Usage:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Usage:

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

Parameters:

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

Usage:

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

Parameters:

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

Usage:

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

Module DruidInstance

-

Druid Instance which you use for component creation.

-

-

# Component List # -

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

# Notes # -

Please review the following API pages: -

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

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

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

# Tech Info # -

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

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

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

-

See also:

- -

Usage:

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

Functions

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

Functions

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

Parameters:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Used for almost all components - - -

Parameters:

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

Returns:

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

Used for special actions. See SPECIFIC_UI_MESSAGES table - - -

Parameters:

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

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

Parameters:

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

Returns:

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

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

Parameters:

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

Returns:

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

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

Parameters:

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

Returns:

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

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

Parameters:

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

Module DynamicGrid

-

Component to handle placing components in row

-

Example Link

- - -

Functions

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

Fields

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

Functions

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

Parameters:

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

Parameters:

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

Parameters:

- - -

Returns:

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

Parameters:

- - -

Returns:

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

Parameters:

- - -

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Fields

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

Module Helper

-

Helper module with various usefull GUI functions.

-

-

Usage:

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

Functions

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

Functions

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

Parameters:

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

Returns:

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

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

Parameters:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Returns:

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

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Returns:

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

Parameters:

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

Returns:

-
    - - GUITextMetrics - -
- - - -

Usage:

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

Parameters:

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

Returns:

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

Returns:

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

Returns:

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

Returns:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

- - -

Returns:

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

Module Hotkey

-

Druid hotkey component

-

Example Link

- - -

Functions

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

Tables

- - - - - -
styleComponent style params.
-

Fields

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

Functions

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

Parameters:

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

Returns:

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

Parameters:

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

Parameters:

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

Returns:

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

Tables

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

Fields:

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

Fields

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

Module Hover

-

Component to handle hover node interaction

-

- - -

Functions

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

Tables

- - - - - -
styleComponent style params.
-

Fields

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

Functions

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

Parameters:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Parameters:

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

Parameters:

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

Parameters:

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

Tables

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

Fields:

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

Fields

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

Module Input

-

Druid input text component.

-

- Carry on user text input -

Example Link

-

Info:

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

Functions

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

Tables

- - - - - -
styleComponent style params.
-

Fields

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

Functions

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Parameters:

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

Parameters:

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

Returns:

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

Parameters:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Parameters:

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

Tables

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

Fields:

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

Fields

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

Module LangText

-

Component to wrap over GUI Text nodes with localization helpers -

# Overview # -

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

-

-

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

# Notes # -

Example Link

- - -

Functions

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

Fields

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

Functions

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

Parameters:

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

Returns:

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

Parameters:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Fields

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

Module Layout

-

Layout management on node

-

Example Link

- - -

Fields

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

Fields

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

Module PinKnob

-

Druid pin knob custom component.

-

- It's simple rotating input element

- - -

Functions

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

Fields

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

Functions

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

Parameters:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Fields

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

Module Progress

-

Druid component to handle the progress bars.

-

- # Overview # -

# Notes # -

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

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

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

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

- Example Link

- - -

Functions

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

Tables

- - - - - -
styleComponent style params.
-

Fields

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

Functions

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

Parameters:

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

Parameters:

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

Parameters:

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

Parameters:

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

Parameters:

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

Returns:

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

Parameters:

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

Usage:

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

Parameters:

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

Parameters:

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

Tables

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

Fields:

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

Fields

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

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

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

Module RadioGroup

-

Radio group module

-

Example Link

- - -

Functions

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

Fields

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

Functions

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

Parameters:

- - -

Returns:

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

Parameters:

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

Parameters:

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

Fields

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

Module RichInput

-

Druid Rich Input custom component.

-

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

- - -

Functions

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

Fields

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

Functions

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

Parameters:

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

Parameters:

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

Parameters:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Parameters:

- - -

Returns:

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

Fields

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

Module RichText

-

Druid Rich Text Custom Component.

-

- # Overview # -

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

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

# Notes # -

• Nested tags are supported -

Example Link

-

Usage:

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

Functions

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

Tables

- - - - - -
styleComponent style params.
-

Fields

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

Functions

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

Parameters:

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

Returns:

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

Returns:

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

Parameters:

- - -

Returns:

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

Returns:

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

Parameters:

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

Parameters:

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

Returns:

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

Usage:

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

Parameters:

- - -

Returns:

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

Tables

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

Fields:

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

Fields

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

Module Scroll

-

Component to handle scroll content.

-

- # Overview # -

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

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

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

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

# Notes # -

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

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

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

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

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

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

Example Link

- - -

Functions

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

Tables

- - - - - -
styleComponent style params.
-

Fields

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

Functions

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Usage:

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

Parameters:

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

Parameters:

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

Usage:

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

Parameters:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Tables

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

Fields:

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

Fields

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

Module Slider

-

Druid slider component

-

Example Link

- - -

Functions

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

Fields

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

Functions

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

Parameters:

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

Parameters:

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

Returns:

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

Parameters:

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

Parameters:

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

Parameters:

- - -

Returns:

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

Parameters:

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

Returns:

-
    - - Slider - Slider -
- - - -

Usage:

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

Fields

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

Module StaticGrid

-

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

-

- # Overview # -

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

# Notes # -

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

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

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

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

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

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

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

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

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

Example Link

- - -

Functions

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

Tables

- - - - - -
styleComponent style params.
-

Fields

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

Functions

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

Parameters:

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

Parameters:

- - -

Returns:

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

Parameters:

- - -

Returns:

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

Parameters:

- - -

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

- - -

Returns:

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

Parameters:

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

Parameters:

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

Parameters:

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

Returns:

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

Parameters:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Tables

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

Fields:

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

Fields

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

Module Swipe

-

Component to handle swipe gestures on node.

-

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

Example Link

- - -

Functions

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

Tables

- - - - - -
styleComponent style params.
-

Fields

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

Functions

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

Parameters:

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

Parameters:

- - - - - - -
-
-

Tables

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

Fields:

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

Fields

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

Module Text

-

Component for Wrapping GUI Text Nodes: Druid Text -

## Overview ## -

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

-

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

## Notes ## -

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

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

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

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

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

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

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

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

Example Link

- - -

Functions

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

Tables

- - - - - -
styleComponent style params.
-

Fields

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

Functions

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Tables

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

Fields:

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

Fields

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

Module Timer

-

Component to handle GUI timers.

-

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

- - -

Functions

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

Fields

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

Functions

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

Parameters:

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

Parameters:

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

Parameters:

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

Parameters:

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

Fields

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

Module druid.extended.layout

-

Druid layout module -

# Overview # -

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

-

Works like a Figma layout. -

# Notes

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

Module druid.system.utf8

-

-

- - - -
-
- - - - -
-
-
-generated by LDoc TESTING -Last updated 2015-01-01 12:00:00 -
-
- - From 60ef641276ae71403b87222876dc5705f42d09b0 Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 2 Nov 2024 17:16:09 +0100 Subject: [PATCH 07/50] Update --- druid/editor_scripts/druid.editor_script | 23 ++++------------------- druid/extended/layout.lua | 5 +---- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/druid/editor_scripts/druid.editor_script b/druid/editor_scripts/druid.editor_script index 2f63c92..27d4adc 100644 --- a/druid/editor_scripts/druid.editor_script +++ b/druid/editor_scripts/druid.editor_script @@ -1,6 +1,3 @@ ---- @license MIT, Insality 2021 ---- @source https://github.com/Insality/druid - local M = {} @@ -27,18 +24,12 @@ function M.get_commands() return { { label = "Assign Layers", - - locations = {"Edit"}, - - query = { - selection = {type = "resource", cardinality = "one"} - }, - + locations = { "Edit" }, + query = { selection = {type = "resource", cardinality = "one"} }, active = function(opts) local path = editor.get(opts.selection, "path") return ends_with(path, ".gui") end, - run = function(opts) local file = opts.selection print("Run script for", editor.get(file, "path")) @@ -60,18 +51,12 @@ function M.get_commands() { label = "Create Druid Component", - - locations = {"Edit"}, - - query = { - selection = {type = "resource", cardinality = "one"} - }, - + locations = { "Edit", "Assets" }, + query = { selection = {type = "resource", cardinality = "one"} }, active = function(opts) local path = editor.get(opts.selection, "path") return ends_with(path, ".gui") end, - run = function(opts) local file = opts.selection print("Run script for", editor.get(file, "path")) diff --git a/druid/extended/layout.lua b/druid/extended/layout.lua index 4285746..457c17c 100644 --- a/druid/extended/layout.lua +++ b/druid/extended/layout.lua @@ -1,10 +1,7 @@ local helper = require("druid.helper") local component = require("druid.component") ----@alias druid.layout.mode ----| "horizontal" Elements are placed horizontally ----| "vertical" Elements are placed vertically ----| "horizontal_wrap" Elements are placed horizontally, but if the row width is greater than the parent width, the next row is created +---@alias druid.layout.mode "horizontal"|"vertical"|"horizontal_wrap" ---@class druid.layout.row_data ---@field width number From 999c6222a0029529a1a58f100e9438e14c71bda5 Mon Sep 17 00:00:00 2001 From: Insality Date: Thu, 7 Nov 2024 18:32:46 +0100 Subject: [PATCH 08/50] Update annotations --- README.md | 2 +- druid/base/button.lua | 90 ++++++++------------ druid/base/drag.lua | 10 +-- druid/base/hover.lua | 4 +- druid/base/scroll.lua | 8 +- druid/base/static_grid.lua | 22 ++--- druid/base/text.lua | 6 +- druid/custom/rich_text/module/rt.lua | 4 - druid/druid.lua | 2 + druid/event.lua | 3 +- druid/extended/data_list.lua | 12 +-- druid/extended/hotkey.lua | 4 +- druid/extended/input.lua | 14 +-- druid/extended/lang_text.lua | 2 +- druid/extended/progress.lua | 2 +- druid/extended/slider.lua | 2 +- druid/extended/swipe.lua | 2 +- druid/fonts/text_bold.font | 2 +- druid/fonts/text_regular.font | 2 +- druid/helper.lua | 12 ++- druid/system/druid_instance.lua | 75 +++++++++------- example/examples/basic/drag/drag_to_node.lua | 4 +- 22 files changed, 140 insertions(+), 144 deletions(-) diff --git a/README.md b/README.md index b1eb47a..b72efc3 100644 --- a/README.md +++ b/README.md @@ -185,7 +185,7 @@ For a complete overview, see: **_[components.md](docs_md/01-components.md)_**. ## Druid Events -Any **Druid** components as callbacks use [Druid Events](https://insality.github.io/druid/modules/DruidEvent.html). In component API ([button example](https://insality.github.io/druid/modules/Button.html#on_click)) pointed list of component events. You can manually subscribe to these events with the following API: +Any **Druid** components as callbacks use [Druid Events](https://insality.github.io/druid/modules/druid.event.html). In component API ([button example](https://insality.github.io/druid/modules/Button.html#on_click)) pointed list of component events. You can manually subscribe to these events with the following API: - **event:subscribe**(callback) diff --git a/druid/base/button.lua b/druid/base/button.lua index 7684380..d2d5e94 100755 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -35,16 +35,16 @@ -- @alias druid.button ---- The DruidEvent: Event on successful release action over button. +--- The druid.event: Event on successful release action over button. -- @usage -- -- Custom args passed in Button constructor -- button.on_click:subscribe(function(self, custom_args, button_instance) -- print("On button click!") -- end) --- @tfield DruidEvent on_click DruidEvent +-- @tfield druid.event on_click druid.event ---- The DruidEvent: Event on repeated action over button. +--- The druid.event: Event on repeated action over button. -- -- This callback will be triggered if user hold the button. The repeat rate pick from `input.repeat_interval` in game.project -- @usage @@ -52,10 +52,10 @@ -- button.on_repeated_click:subscribe(function(self, custom_args, button_instance, click_count) -- print("On repeated Button click!") -- end) --- @tfield DruidEvent on_repeated_click DruidEvent +-- @tfield druid.event on_repeated_click druid.event ---- The DruidEvent: Event on long tap action over button. +--- The druid.event: Event on long tap action over button. -- -- This callback will be triggered if user pressed the button and hold the some amount of time. -- The amount of time picked from button style param: LONGTAP_TIME @@ -64,10 +64,10 @@ -- button.on_long_click:subscribe(function(self, custom_args, button_instance, hold_time) -- print("On long Button click!") -- end) --- @tfield DruidEvent on_long_click DruidEvent +-- @tfield druid.event on_long_click druid.event ---- The DruidEvent: Event on double tap action over button. +--- The druid.event: Event on double tap action over button. -- -- If secondary click was too fast after previous one, the double -- click will be called instead usual click (if on_double_click subscriber exists) @@ -76,10 +76,10 @@ -- button.on_double_click:subscribe(function(self, custom_args, button_instance, click_amount) -- print("On double Button click!") -- end) --- @tfield DruidEvent on_double_click DruidEvent +-- @tfield druid.event on_double_click druid.event ---- The DruidEvent: Event calls every frame before on_long_click event. +--- The druid.event: Event calls every frame before on_long_click event. -- -- If long_click subscriber exists, the on_hold_callback will be called before long_click trigger. -- @@ -89,10 +89,10 @@ -- button.on_double_click:subscribe(function(self, custom_args, button_instance, time) -- print("On hold Button callback!") -- end) --- @tfield DruidEvent on_hold_callback DruidEvent +-- @tfield druid.event on_hold_callback druid.event ---- The DruidEvent: Event calls if click event was outside of button. +--- The druid.event: Event calls if click event was outside of button. -- -- This event will be triggered for each button what was not clicked on user click action -- @@ -102,16 +102,16 @@ -- button.on_click_outside:subscribe(function(self, custom_args, button_instance) -- print("On click Button outside!") -- end) --- @tfield DruidEvent on_click_outside DruidEvent +-- @tfield druid.event on_click_outside druid.event ---- The DruidEvent: Event triggered if button was pressed by user. +--- The druid.event: Event triggered if button was pressed by user. -- @usage -- -- Custom args passed in Button constructor -- button.on_pressed:subscribe(function(self, custom_args, button_instance) -- print("On Button pressed!") -- end) --- @tfield DruidEvent on_pressed DruidEvent +-- @tfield druid.event on_pressed druid.event --- Button trigger node -- @tfield node node @@ -279,17 +279,19 @@ end --- Component style params. --- You can override this component styles params in Druid styles table --- or create your own style --- @table style --- @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) +---You can override this component styles params in Druid styles table +---or create your own style +---@class druid.button.style +---@field LONGTAP_TIME number|nil Minimum time to trigger on_hold_callback. Default: 0.4 +---@field AUTOHOLD_TRIGGER number|nil Maximum hold time to trigger button release while holding. Default: 0.8 +---@field DOUBLETAP_TIME number|nil Time between double taps. Default: 0.4 +---@field on_click fun(self, node)|nil +---@field on_click_disabled fun(self, node)|nil +---@field on_hover fun(self, node, hover_state)|nil +---@field on_mouse_hover fun(self, node, hover_state)|nil +---@field on_set_enabled fun(self, node, enabled_state)|nil + +---@param style druid.button.style function M:on_style_change(style) self.style = {} self.style.LONGTAP_TIME = style.LONGTAP_TIME or 0.4 @@ -469,12 +471,8 @@ end --- Set button enabled state. -- The style.on_set_enabled will be triggered. -- Disabled button is not clickable. --- @tparam Button self Button -- @tparam boolean|nil state Enabled state --- @treturn Button Current button instance --- @usage --- button:set_enabled(false) --- button:set_enabled(true) +---@return druid.button self function M:set_enabled(state) self.disabled = not state self.hover:set_enabled(state) @@ -487,10 +485,7 @@ end --- Get button enabled state. -- -- By default all Buttons is enabled on creating. --- @tparam Button self Button --- @treturn boolean @True, if button is enabled now, False overwise --- @usage --- local is_enabled = button:is_enabled() +---@return boolean @True, if button is enabled now, False overwise function M:is_enabled() return not self.disabled end @@ -500,11 +495,8 @@ end -- Useful to restrict click outside out stencil node or scrollable content. -- -- This functions calls automatically if you don't disable it in game.project: druid.no_stencil_check --- @tparam Button self Button -- @tparam node|string|nil zone Gui node --- @treturn Button Current button instance --- @usage --- button:set_click_zone("stencil_node") +---@return druid.button self function M:set_click_zone(zone) self.click_zone = self:get_node(zone) self.hover:set_click_zone(zone) @@ -513,12 +505,9 @@ function M:set_click_zone(zone) end ---- Set key name to trigger this button by keyboard. --- @tparam Button self Button --- @tparam hash|string key The action_id of the input key --- @treturn Button Current button instance --- @usage --- button:set_key_trigger("key_space") +---Set key name to trigger this button by keyboard. +---@param key hash|string The action_id of the input key. Example: "key_space" +---@return druid.button self function M:set_key_trigger(key) self.key_trigger = hash(key) @@ -527,20 +516,16 @@ end --- Get current key name to trigger this button. --- @tparam Button self --- @treturn hash The action_id of the input key --- @usage --- local key_hash = button:get_key_trigger() +---@return hash key_trigger The action_id of the input key function M:get_key_trigger() return self.key_trigger end --- Set function for additional check for button click availability --- @tparam Button self -- @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 +---@return druid.button self function M:set_check_function(check_function, failure_callback) self._check_function = check_function self._failure_callback = failure_callback @@ -553,11 +538,8 @@ end -- The HTML5 button's doesn't call any events except on_click event. -- -- If the game is not HTML, html mode will be not enabled --- @tparam Button self -- @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) +---@return druid.button self function M:set_web_user_interaction(is_web_mode) self._is_html5_mode = not not (is_web_mode and html5) return self diff --git a/druid/base/drag.lua b/druid/base/drag.lua index 3218ae6..5458900 100644 --- a/druid/base/drag.lua +++ b/druid/base/drag.lua @@ -14,19 +14,19 @@ -- @tfield node node --- Event on touch start callback(self) --- @tfield DruidEvent on_touch_start DruidEvent +-- @tfield druid.event on_touch_start druid.event --- Event on touch end callback(self) --- @tfield DruidEvent on_touch_end DruidEvent +-- @tfield druid.event on_touch_end druid.event --- Event on drag start callback(self, touch) --- @tfield DruidEvent on_drag_start DruidEvent +-- @tfield druid.event on_drag_start druid.event --- on drag progress callback(self, dx, dy, total_x, total_y, touch) --- @tfield DruidEvent on_drag Event DruidEvent +-- @tfield druid.event on_drag Event druid.event --- Event on drag end callback(self, total_x, total_y, touch) --- @tfield DruidEvent on_drag_end DruidEvent +-- @tfield druid.event on_drag_end druid.event --- Is component now touching -- @tfield boolean is_touch diff --git a/druid/base/hover.lua b/druid/base/hover.lua index d5e1700..cd6730b 100644 --- a/druid/base/hover.lua +++ b/druid/base/hover.lua @@ -9,10 +9,10 @@ -- @tfield node node --- On hover callback(self, state, hover_instance) --- @tfield DruidEvent on_hover DruidEvent +-- @tfield druid.event on_hover druid.event --- On mouse hover callback(self, state, hover_instance) --- @tfield DruidEvent on_mouse_hover DruidEvent +-- @tfield druid.event on_mouse_hover druid.event --- diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index f8bc2c6..3bc6b79 100755 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -39,13 +39,13 @@ --- On scroll move callback(self, position) --- @tfield DruidEvent on_scroll DruidEvent +-- @tfield druid.event on_scroll druid.event --- On scroll_to function callback(self, target, is_instant) --- @tfield DruidEvent on_scroll_to DruidEvent +-- @tfield druid.event on_scroll_to druid.event --- On scroll_to_index function callback(self, index, point) --- @tfield DruidEvent on_point_scroll DruidEvent +-- @tfield druid.event on_point_scroll druid.event --- Scroll view node -- @tfield node view_node @@ -651,7 +651,7 @@ end --- Find closer point of interest -- if no inert, scroll to next point by scroll direction -- if inert, find next point by scroll director --- @local +---@private function M:_check_points() if not self.points then return diff --git a/druid/base/static_grid.lua b/druid/base/static_grid.lua index c78d7ec..245b6dc 100644 --- a/druid/base/static_grid.lua +++ b/druid/base/static_grid.lua @@ -37,19 +37,19 @@ -- @alias druid.static_grid --- On item add callback(self, node, index) --- @tfield DruidEvent on_add_item DruidEvent +-- @tfield druid.event on_add_item druid.event --- On item remove callback(self, index) --- @tfield DruidEvent on_remove_item DruidEvent +-- @tfield druid.event on_remove_item druid.event --- On item add, remove or change in_row callback(self, index|nil) --- @tfield DruidEvent on_change_items DruidEvent +-- @tfield druid.event on_change_items druid.event --- On grid clear callback(self) --- @tfield DruidEvent on_clear DruidEvent +-- @tfield druid.event on_clear druid.event --- On update item positions callback(self) --- @tfield DruidEvent on_update_positions DruidEvent +-- @tfield druid.event on_update_positions druid.event --- Parent gui node -- @tfield node parent @@ -491,7 +491,7 @@ end --- Update grid inner state -- @tparam StaticGrid self StaticGrid -- @tparam boolean|nil is_instant If true, node position update instantly, otherwise with set_position_function callback --- @local +---@private function M:_update(is_instant) self:_update_indexes() self:_update_borders() @@ -501,7 +501,7 @@ end --- Update first and last indexes of grid nodes -- @tparam StaticGrid self StaticGrid --- @local +---@private function M:_update_indexes() self.first_index = nil self.last_index = nil @@ -517,7 +517,7 @@ end --- Update grid content borders, recalculate min and max values -- @tparam StaticGrid self StaticGrid --- @local +---@private function M:_update_borders() if not self.first_index then self.border = vmath.vector4(0) @@ -537,7 +537,7 @@ end --- Update grid nodes position -- @tparam StaticGrid self StaticGrid -- @tparam boolean|nil is_instant If true, node position update instantly, otherwise with set_position_function callback --- @local +---@private function M:_update_pos(is_instant) local zero_offset = self:_get_zero_offset() @@ -560,7 +560,7 @@ end --- Return elements offset for correct posing nodes. Correct posing at -- parent pivot node (0:0) with adjusting of node sizes and anchoring -- @treturn vector3 The offset vector --- @local +---@private function M:_get_zero_offset() if not self.style.IS_DYNAMIC_NODE_POSES then return const.VECTOR_ZERO @@ -577,7 +577,7 @@ end --- Return offset x for last row in grid. Used to align this row accorting to grid's anchor -- @treturn number The offset x value --- @local +---@private function M:_get_zero_offset_x(row_index) if not self.style.IS_DYNAMIC_NODE_POSES or not self.style.IS_ALIGN_LAST_ROW then return self._zero_offset.x diff --git a/druid/base/text.lua b/druid/base/text.lua index 66b11ac..e63ab86 100755 --- a/druid/base/text.lua +++ b/druid/base/text.lua @@ -36,13 +36,13 @@ -- @alias druid.text --- On set text callback(self, text) --- @tfield DruidEvent on_set_text DruidEvent +-- @tfield druid.event on_set_text druid.event --- On adjust text size callback(self, new_scale, text_metrics) --- @tfield DruidEvent on_update_text_scale DruidEvent +-- @tfield druid.event on_update_text_scale druid.event --- On change pivot callback(self, pivot) --- @tfield DruidEvent on_set_pivot DruidEvent +-- @tfield druid.event on_set_pivot druid.event --- Text node -- @tfield node node diff --git a/druid/custom/rich_text/module/rt.lua b/druid/custom/rich_text/module/rt.lua index 8baa48c..4ae501f 100755 --- a/druid/custom/rich_text/module/rt.lua +++ b/druid/custom/rich_text/module/rt.lua @@ -2,10 +2,6 @@ -- Author: Britzl -- Modified by: Insality ---- RT --- @module rich_text.rt --- @local - local helper = require("druid.helper") local parser = require("druid.custom.rich_text.module.rt_parse") local utf8_lua = require("druid.system.utf8") diff --git a/druid/druid.lua b/druid/druid.lua index f933afa..1172f34 100644 --- a/druid/druid.lua +++ b/druid/druid.lua @@ -29,6 +29,7 @@ end ---Register component just makes the druid:new_{name} function. ---For example, if you register a component called "my_component", you can create it using druid:new_my_component(...). ---This can be useful if you have your own "basic" components that you don't want to require in every file. +---The default way to create component is `druid_instance:new(component_class, ...)`. ---@param name string Module name ---@param module table Lua table with component function M.register(name, module) @@ -101,6 +102,7 @@ end ---Call this function when the game language changes. +---It will notify all Druid instances to update the lang text components. function M.on_language_change() local instances = get_druid_instances() diff --git a/druid/event.lua b/druid/event.lua index fab7026..9da6a6c 100644 --- a/druid/event.lua +++ b/druid/event.lua @@ -1,3 +1,4 @@ +---Event system for Druid ---@class druid.event local M = {} @@ -31,7 +32,7 @@ end --- Check is event subscribed. ---@param callback fun() Callback itself ---@param callback_context any|nil Additional context as first param to callback call --- @treturn boolean, number|nil @Is event subscribed, return index of callback in event as second param +---@return boolean, number|nil Is event subscribed, return index of callback in event as second param function M:is_subscribed(callback, callback_context) if #self == 0 then return false, nil diff --git a/druid/extended/data_list.lua b/druid/extended/data_list.lua index 9fadb6a..c81109a 100644 --- a/druid/extended/data_list.lua +++ b/druid/extended/data_list.lua @@ -25,13 +25,13 @@ -- @tfield number last_index --- Event triggered when scroll progress is changed; event(self, progress_value) --- @tfield DruidEvent on_scroll_progress_change DruidEvent +-- @tfield druid.event on_scroll_progress_change druid.event ---On DataList visual element created Event callback(self, index, node, instance) --- @tfield DruidEvent on_element_add DruidEvent +-- @tfield druid.event on_element_add druid.event ---On DataList visual element created Event callback(self, index) --- @tfield DruidEvent on_element_remove DruidEvent +-- @tfield druid.event on_element_remove druid.event --- @@ -223,7 +223,7 @@ end --- Add element at passed index using cache or create new -- @tparam DataList self DataList -- @tparam number index --- @local +---@private function M:_add_at(index) if self._data_visual[index] then self:_remove_at(index) @@ -257,7 +257,7 @@ end --- Remove element from passed index and add it to cache if applicable -- @tparam DataList self DataList -- @tparam number index --- @local +---@private function M:_remove_at(index) self.grid:remove(index, const.SHIFT.NO_SHIFT) @@ -287,7 +287,7 @@ end --- Refresh all elements in DataList -- @tparam DataList self DataList --- @local +---@private function M:_refresh() self.scroll:set_size(self.grid:get_size_for(#self._data)) diff --git a/druid/extended/hotkey.lua b/druid/extended/hotkey.lua index b5db756..5177c5a 100644 --- a/druid/extended/hotkey.lua +++ b/druid/extended/hotkey.lua @@ -8,10 +8,10 @@ -- @alias druid.hotkey --- On hotkey released callback(self, argument) --- @tfield DruidEvent on_hotkey_pressed DruidEvent +-- @tfield druid.event on_hotkey_pressed druid.event --- On hotkey released callback(self, argument) --- @tfield DruidEvent on_hotkey_released DruidEvent +-- @tfield druid.event on_hotkey_released druid.event --- Visual node -- @tfield node node diff --git a/druid/extended/input.lua b/druid/extended/input.lua index b4f29dd..be0c1a5 100755 --- a/druid/extended/input.lua +++ b/druid/extended/input.lua @@ -10,25 +10,25 @@ -- @alias druid.input --- On input field select callback(self, input_instance) --- @tfield DruidEvent on_input_select DruidEvent +-- @tfield druid.event on_input_select druid.event --- On input field unselect callback(self, input_text, input_instance) --- @tfield DruidEvent on_input_unselect DruidEvent +-- @tfield druid.event on_input_unselect druid.event --- On input field text change callback(self, input_text) --- @tfield DruidEvent on_input_text DruidEvent +-- @tfield druid.event on_input_text druid.event --- On input field text change to empty string callback(self, input_text) --- @tfield DruidEvent on_input_empty DruidEvent +-- @tfield druid.event on_input_empty druid.event --- On input field text change to max length string callback(self, input_text) --- @tfield DruidEvent on_input_full DruidEvent +-- @tfield druid.event on_input_full druid.event --- On trying user input with not allowed character callback(self, params, input_text) --- @tfield DruidEvent on_input_wrong DruidEvent +-- @tfield druid.event on_input_wrong druid.event --- On cursor position change callback(self, cursor_index, start_index, end_index) --- @tfield DruidEvent on_select_cursor_change DruidEvent +-- @tfield druid.event on_select_cursor_change druid.event --- The cursor index. The index of letter cursor after. Leftmost cursor - 0 -- @tfield number cursor_index diff --git a/druid/extended/lang_text.lua b/druid/extended/lang_text.lua index 03a6970..2e4c968 100755 --- a/druid/extended/lang_text.lua +++ b/druid/extended/lang_text.lua @@ -18,7 +18,7 @@ -- @alias druid.lang_text --- On change text callback --- @tfield DruidEvent on_change DruidEvent +-- @tfield druid.event on_change druid.event --- The text component -- @tfield Text text Text diff --git a/druid/extended/progress.lua b/druid/extended/progress.lua index ad31cce..a5061b2 100644 --- a/druid/extended/progress.lua +++ b/druid/extended/progress.lua @@ -20,7 +20,7 @@ -- @alias druid.progress --- On progress bar change callback(self, new_value) --- @tfield DruidEvent on_change DruidEvent +-- @tfield druid.event on_change druid.event --- Progress bar fill node -- @tfield node node diff --git a/druid/extended/slider.lua b/druid/extended/slider.lua index 6be43e4..352a630 100644 --- a/druid/extended/slider.lua +++ b/druid/extended/slider.lua @@ -8,7 +8,7 @@ -- @alias druid.slider --- On change value callback(self, value) --- @tfield DruidEvent on_change_value DruidEvent +-- @tfield druid.event on_change_value druid.event --- Slider pin node -- @tfield node node diff --git a/druid/extended/swipe.lua b/druid/extended/swipe.lua index 6d900a1..4c9fc53 100644 --- a/druid/extended/swipe.lua +++ b/druid/extended/swipe.lua @@ -16,7 +16,7 @@ -- @tparam node|nil click_zone --- Trigger on swipe event(self, swipe_side, dist, delta_time) --- @tfield DruidEvent on_swipe) DruidEvent +-- @tfield druid.event on_swipe) druid.event --- diff --git a/druid/fonts/text_bold.font b/druid/fonts/text_bold.font index 3bae9c5..a8546d6 100644 --- a/druid/fonts/text_bold.font +++ b/druid/fonts/text_bold.font @@ -7,4 +7,4 @@ shadow_alpha: 1.0 shadow_blur: 2 output_format: TYPE_DISTANCE_FIELD render_mode: MODE_MULTI_LAYER -characters: " !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\302\241\302\277\303\200\303\202\303\206\303\207\303\210\303\211\303\212\303\213\303\216\303\217\303\224\303\231\303\233\303\234\303\240\303\241\303\242\303\243\303\244\303\246\303\247\303\250\303\251\303\252\303\253\303\255\303\256\303\257\303\261\303\263\303\264\303\271\303\273\303\274\303\277\305\222\305\223\305\270\320\201\320\220\320\221\320\222\320\223\320\224\320\225\320\226\320\227\320\230\320\231\320\232\320\233\320\234\320\235\320\236\320\237\320\240\320\241\320\242\320\243\320\244\320\245\320\246\320\247\320\250\320\251\320\252\320\253\320\254\320\255\320\256\320\257\320\260\320\261\320\262\320\263\320\264\320\265\320\266\320\267\320\270\320\271\320\272\320\273\320\274\320\275\320\276\320\277\321\200\321\201\321\202\321\203\321\204\321\205\321\206\321\207\321\210\321\211\321\212\321\213\321\214\321\215\321\216\321\217\321\221\343\200\202\357\274\201\357\274\237" +characters: "\302\241\302\253\302\273\302\277\303\200\303\202\303\206\303\207\303\210\303\211\303\212\303\213\303\216\303\217\303\224\303\231\303\233\303\234\303\237\303\240\303\241\303\242\303\243\303\244\303\246\303\247\303\250\303\251\303\252\303\253\303\255\303\256\303\257\303\261\303\262\303\263\303\264\303\265\303\266\303\271\303\273\303\274\303\277\305\222\305\223\305\270\320\201\320\220\320\221\320\222\320\223\320\224\320\225\320\226\320\227\320\230\320\231\320\232\320\233\320\234\320\235\320\236\320\237\320\240\320\241\320\242\320\243\320\244\320\245\320\246\320\247\320\250\320\251\320\252\320\253\320\254\320\255\320\256\320\257\320\260\320\261\320\262\320\263\320\264\320\265\320\266\320\267\320\270\320\271\320\272\320\273\320\274\320\275\320\276\320\277\321\200\321\201\321\202\321\203\321\204\321\205\321\206\321\207\321\210\321\211\321\212\321\213\321\214\321\215\321\216\321\217\321\221\342\200\224\343\200\201\343\200\202\343\200\214\343\200\215\343\201\202\343\201\204\343\201\206\343\201\210\343\201\212\343\201\213\343\201\214\343\201\215\343\201\217\343\201\223\343\201\225\343\201\227\343\201\230\343\201\231\343\201\233\343\201\237\343\201\240\343\201\244\343\201\246\343\201\247\343\201\250\343\201\251\343\201\252\343\201\253\343\201\256\343\201\257\343\201\263\343\201\276\343\202\200\343\202\201\343\202\202\343\202\210\343\202\211\343\202\212\343\202\213\343\202\214\343\202\222\343\202\223\343\202\241\343\202\242\343\202\243\343\202\244\343\202\246\343\202\250\343\202\251\343\202\254\343\202\255\343\202\257\343\202\260\343\202\261\343\202\262\343\202\263\343\202\265\343\202\267\343\202\270\343\202\271\343\202\272\343\202\273\343\202\277\343\203\200\343\203\201\343\203\203\343\203\206\343\203\207\343\203\210\343\203\211\343\203\213\343\203\215\343\203\216\343\203\220\343\203\221\343\203\224\343\203\225\343\203\226\343\203\227\343\203\231\343\203\233\343\203\234\343\203\235\343\203\236\343\203\240\343\203\241\343\203\242\343\203\243\343\203\245\343\203\247\343\203\251\343\203\252\343\203\253\343\203\254\343\203\255\343\203\257\343\203\263\343\203\274\344\270\200\344\270\207\344\270\212\344\270\213\344\270\215\344\270\216\344\270\241\344\270\244\344\270\252\344\270\255\344\270\272\344\271\211\344\271\260\344\272\213\344\272\216\344\273\213\344\273\216\344\273\230\344\273\243\344\273\245\344\273\254\344\273\266\344\275\206\344\275\223\344\275\225\344\275\234\344\275\240\344\275\277\344\276\213\344\277\241\345\200\244\345\200\274\345\201\234\345\205\203\345\205\205\345\205\245\345\205\266\345\206\205\345\207\246\345\207\272\345\207\273\345\210\206\345\210\227\345\210\233\345\210\235\345\210\240\345\210\245\345\210\260\345\210\266\345\211\212\345\211\215\345\211\252\345\212\233\345\212\237\345\212\240\345\212\250\345\212\271\345\214\272\345\215\225\345\215\230\345\217\214\345\217\221\345\217\226\345\217\243\345\217\246\345\217\257\345\220\210\345\220\214\345\220\221\345\220\227\345\220\253\345\220\257\345\222\214\345\231\250\345\233\236\345\234\250\345\235\227\345\236\202\345\236\213\345\237\237\345\237\272\345\240\261\345\241\253\345\244\204\345\244\232\345\244\247\345\245\275\345\246\202\345\247\213\345\255\227\345\255\230\345\256\203\345\256\232\345\257\206\345\257\214\345\257\271\345\260\206\345\260\217\345\260\261\345\261\200\345\261\217\345\261\236\345\267\245\345\270\203\345\270\246\345\271\225\345\271\263\345\271\266\345\272\246\345\273\272\345\274\200\345\274\271\345\276\227\345\277\205\345\277\253\346\200\201\346\200\247\346\201\257\346\202\254\346\203\205\346\210\217\346\210\220\346\211\200\346\211\213\346\212\236\346\212\274\346\213\226\346\213\251\346\214\201\346\214\211\346\215\256\346\215\267\346\216\247\346\217\203\346\220\255\346\221\270\346\223\215\346\224\257\346\224\276\346\225\210\346\225\260\346\225\264\346\226\207\346\226\271\346\227\245\346\227\266\346\230\216\346\230\257\346\230\276\346\233\264\346\234\200\346\234\211\346\234\254\346\235\206\346\235\241\346\236\220\346\237\204\346\237\245\346\240\207\346\240\274\346\243\200\346\251\237\346\254\241\346\255\244\346\255\245\346\260\264\346\261\275\346\262\241\346\263\225\346\264\262\346\265\213\346\266\210\346\267\267\346\267\273\346\270\205\346\270\270\346\273\221\346\273\232\347\202\271\347\211\210\347\216\207\347\220\206\347\224\250\347\224\273\347\225\260\347\231\276\347\232\204\347\233\264\347\233\270\347\234\213\347\240\201\347\241\200\347\241\256\347\242\272\347\244\272\347\247\222\347\247\273\347\252\227\347\253\257\347\255\276\347\256\200\347\260\241\347\261\273\347\264\224\347\264\240\347\264\271\347\272\265\347\273\204\347\273\215\347\273\221\347\274\223\347\274\251\347\275\221\347\275\256\347\276\216\347\276\251\350\203\275\350\211\257\350\211\262\350\212\202\350\216\267\350\241\214\350\241\250\350\243\201\350\244\207\350\246\201\350\246\213\350\247\246\350\250\200\350\250\255\350\252\215\350\252\236\350\252\254\350\252\277\350\256\241\350\256\244\350\256\276\350\257\225\350\257\255\350\257\264\350\257\267\350\260\203\350\261\271\350\263\274\350\264\255\350\267\235\350\273\212\350\273\270\350\275\246\350\275\264\350\276\223\350\276\271\350\277\207\350\277\231\350\277\233\350\277\275\351\200\211\351\200\232\351\201\270\351\205\215\351\207\214\351\222\256\351\224\256\351\225\267\351\225\277\351\231\244\351\234\200\351\235\231\351\235\242\351\240\230\351\242\204\351\242\234\351\252\244\351\253\230\351\274\240\351\275\220\352\260\200\352\260\204\352\260\222\352\260\231\352\260\234\352\261\260\352\262\203\352\262\214\352\262\240\352\263\204\352\263\240\352\263\274\352\265\254\352\265\255\352\267\270\352\270\200\352\270\260\352\271\214\352\273\230\352\274\264\353\202\230\353\202\264\353\204\214\353\205\270\353\206\223\353\210\204\353\212\224\353\212\245\353\213\210\353\213\244\353\213\250\353\213\254\353\213\271\353\214\200\353\215\224\353\215\260\353\217\204\353\217\231\353\220\230\353\220\234\353\220\251\353\221\220\353\223\234\353\223\244\353\224\251\353\225\214\353\226\273\353\235\274\353\236\230\353\236\265\353\237\254\353\240\210\353\240\244\353\240\245\353\240\254\353\241\234\353\241\235\353\241\244\353\245\264\353\245\270\353\245\274\353\246\254\353\246\255\353\247\210\353\247\214\353\247\216\353\247\244\353\250\270\353\251\224\353\251\264\353\252\205\353\252\250\353\252\251\353\260\200\353\260\217\353\260\224\353\260\233\353\260\251\353\260\260\353\260\261\353\262\204\353\262\210\353\262\225\353\262\227\353\262\244\353\263\264\353\263\270\353\270\224\353\271\204\354\202\254\354\203\201\354\203\211\354\204\234\354\204\240\354\204\244\354\204\261\354\204\270\354\205\230\354\206\214\354\206\215\354\210\230\354\212\244\354\212\254\354\212\265\354\213\234\354\213\240\354\213\255\354\225\204\354\225\240\354\226\221\354\226\264\354\226\270\354\227\206\354\227\220\354\227\254\354\227\255\354\230\201\354\230\210\354\230\244\354\230\254\354\231\200\354\232\224\354\232\251\354\232\260\354\233\203\354\234\204\354\234\210\354\234\240\354\234\250\354\234\274\354\235\200\354\235\204\354\235\214\354\235\230\354\235\264\354\235\270\354\235\274\354\236\204\354\236\205\354\236\210\354\236\220\354\236\221\354\236\230\354\236\245\354\240\201\354\240\204\354\240\225\354\240\234\354\241\260\354\242\213\354\244\221\354\247\200\354\247\201\354\247\204\354\247\210\354\260\250\354\260\275\354\262\230\354\264\210\354\265\234\354\266\224\354\266\225\354\266\234\354\267\250\354\271\230\354\272\220\354\273\250\354\273\264\354\274\200\354\275\224\354\275\234\355\201\254\355\201\264\355\202\244\355\203\200\355\203\204\355\203\234\355\203\235\355\204\260\355\205\214\355\205\215\355\212\270\355\212\274\355\213\261\355\214\214\355\214\250\355\214\254\355\217\211\355\217\254\355\221\234\355\224\204\355\224\274\355\225\204\355\225\221\355\225\230\355\225\234\355\225\240\355\225\250\355\225\251\355\225\264\355\226\211\355\230\225\355\230\270\355\230\274\355\231\224\355\231\225\355\231\234\355\232\250\357\274\201\357\274\214\357\274\237 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}" diff --git a/druid/fonts/text_regular.font b/druid/fonts/text_regular.font index 3decaf2..ec01934 100644 --- a/druid/fonts/text_regular.font +++ b/druid/fonts/text_regular.font @@ -5,4 +5,4 @@ outline_alpha: 1.0 outline_width: 2.0 output_format: TYPE_DISTANCE_FIELD render_mode: MODE_MULTI_LAYER -characters: " !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\302\241\302\277\303\200\303\202\303\206\303\207\303\210\303\211\303\212\303\213\303\216\303\217\303\224\303\231\303\233\303\234\303\240\303\241\303\242\303\243\303\244\303\246\303\247\303\250\303\251\303\252\303\253\303\255\303\256\303\257\303\261\303\263\303\264\303\271\303\273\303\274\303\277\305\222\305\223\305\270\320\201\320\220\320\221\320\222\320\223\320\224\320\225\320\226\320\227\320\230\320\231\320\232\320\233\320\234\320\235\320\236\320\237\320\240\320\241\320\242\320\243\320\244\320\245\320\246\320\247\320\250\320\251\320\252\320\253\320\254\320\255\320\256\320\257\320\260\320\261\320\262\320\263\320\264\320\265\320\266\320\267\320\270\320\271\320\272\320\273\320\274\320\275\320\276\320\277\321\200\321\201\321\202\321\203\321\204\321\205\321\206\321\207\321\210\321\211\321\212\321\213\321\214\321\215\321\216\321\217\321\221\343\200\202\357\274\201\357\274\237" +characters: "\302\241\302\253\302\273\302\277\303\200\303\202\303\206\303\207\303\210\303\211\303\212\303\213\303\216\303\217\303\224\303\231\303\233\303\234\303\237\303\240\303\241\303\242\303\243\303\244\303\246\303\247\303\250\303\251\303\252\303\253\303\255\303\256\303\257\303\261\303\262\303\263\303\264\303\265\303\266\303\271\303\273\303\274\303\277\305\222\305\223\305\270\320\201\320\220\320\221\320\222\320\223\320\224\320\225\320\226\320\227\320\230\320\231\320\232\320\233\320\234\320\235\320\236\320\237\320\240\320\241\320\242\320\243\320\244\320\245\320\246\320\247\320\250\320\251\320\252\320\253\320\254\320\255\320\256\320\257\320\260\320\261\320\262\320\263\320\264\320\265\320\266\320\267\320\270\320\271\320\272\320\273\320\274\320\275\320\276\320\277\321\200\321\201\321\202\321\203\321\204\321\205\321\206\321\207\321\210\321\211\321\212\321\213\321\214\321\215\321\216\321\217\321\221\342\200\224\343\200\201\343\200\202\343\200\214\343\200\215\343\201\202\343\201\204\343\201\206\343\201\210\343\201\212\343\201\213\343\201\214\343\201\215\343\201\217\343\201\223\343\201\225\343\201\227\343\201\230\343\201\231\343\201\233\343\201\237\343\201\240\343\201\244\343\201\246\343\201\247\343\201\250\343\201\251\343\201\252\343\201\253\343\201\256\343\201\257\343\201\263\343\201\276\343\202\200\343\202\201\343\202\202\343\202\210\343\202\211\343\202\212\343\202\213\343\202\214\343\202\222\343\202\223\343\202\241\343\202\242\343\202\243\343\202\244\343\202\246\343\202\250\343\202\251\343\202\254\343\202\255\343\202\257\343\202\260\343\202\261\343\202\262\343\202\263\343\202\265\343\202\267\343\202\270\343\202\271\343\202\272\343\202\273\343\202\277\343\203\200\343\203\201\343\203\203\343\203\206\343\203\207\343\203\210\343\203\211\343\203\213\343\203\215\343\203\216\343\203\220\343\203\221\343\203\224\343\203\225\343\203\226\343\203\227\343\203\231\343\203\233\343\203\234\343\203\235\343\203\236\343\203\240\343\203\241\343\203\242\343\203\243\343\203\245\343\203\247\343\203\251\343\203\252\343\203\253\343\203\254\343\203\255\343\203\257\343\203\263\343\203\274\344\270\200\344\270\207\344\270\212\344\270\213\344\270\215\344\270\216\344\270\241\344\270\244\344\270\252\344\270\255\344\270\272\344\271\211\344\271\260\344\272\213\344\272\216\344\273\213\344\273\216\344\273\230\344\273\243\344\273\245\344\273\254\344\273\266\344\275\206\344\275\223\344\275\225\344\275\234\344\275\240\344\275\277\344\276\213\344\277\241\345\200\244\345\200\274\345\201\234\345\205\203\345\205\205\345\205\245\345\205\266\345\206\205\345\207\246\345\207\272\345\207\273\345\210\206\345\210\227\345\210\233\345\210\235\345\210\240\345\210\245\345\210\260\345\210\266\345\211\212\345\211\215\345\211\252\345\212\233\345\212\237\345\212\240\345\212\250\345\212\271\345\214\272\345\215\225\345\215\230\345\217\214\345\217\221\345\217\226\345\217\243\345\217\246\345\217\257\345\220\210\345\220\214\345\220\221\345\220\227\345\220\253\345\220\257\345\222\214\345\231\250\345\233\236\345\234\250\345\235\227\345\236\202\345\236\213\345\237\237\345\237\272\345\240\261\345\241\253\345\244\204\345\244\232\345\244\247\345\245\275\345\246\202\345\247\213\345\255\227\345\255\230\345\256\203\345\256\232\345\257\206\345\257\214\345\257\271\345\260\206\345\260\217\345\260\261\345\261\200\345\261\217\345\261\236\345\267\245\345\270\203\345\270\246\345\271\225\345\271\263\345\271\266\345\272\246\345\273\272\345\274\200\345\274\271\345\276\227\345\277\205\345\277\253\346\200\201\346\200\247\346\201\257\346\202\254\346\203\205\346\210\217\346\210\220\346\211\200\346\211\213\346\212\236\346\212\274\346\213\226\346\213\251\346\214\201\346\214\211\346\215\256\346\215\267\346\216\247\346\217\203\346\220\255\346\221\270\346\223\215\346\224\257\346\224\276\346\225\210\346\225\260\346\225\264\346\226\207\346\226\271\346\227\245\346\227\266\346\230\216\346\230\257\346\230\276\346\233\264\346\234\200\346\234\211\346\234\254\346\235\206\346\235\241\346\236\220\346\237\204\346\237\245\346\240\207\346\240\274\346\243\200\346\251\237\346\254\241\346\255\244\346\255\245\346\260\264\346\261\275\346\262\241\346\263\225\346\264\262\346\265\213\346\266\210\346\267\267\346\267\273\346\270\205\346\270\270\346\273\221\346\273\232\347\202\271\347\211\210\347\216\207\347\220\206\347\224\250\347\224\273\347\225\260\347\231\276\347\232\204\347\233\264\347\233\270\347\234\213\347\240\201\347\241\200\347\241\256\347\242\272\347\244\272\347\247\222\347\247\273\347\252\227\347\253\257\347\255\276\347\256\200\347\260\241\347\261\273\347\264\224\347\264\240\347\264\271\347\272\265\347\273\204\347\273\215\347\273\221\347\274\223\347\274\251\347\275\221\347\275\256\347\276\216\347\276\251\350\203\275\350\211\257\350\211\262\350\212\202\350\216\267\350\241\214\350\241\250\350\243\201\350\244\207\350\246\201\350\246\213\350\247\246\350\250\200\350\250\255\350\252\215\350\252\236\350\252\254\350\252\277\350\256\241\350\256\244\350\256\276\350\257\225\350\257\255\350\257\264\350\257\267\350\260\203\350\261\271\350\263\274\350\264\255\350\267\235\350\273\212\350\273\270\350\275\246\350\275\264\350\276\223\350\276\271\350\277\207\350\277\231\350\277\233\350\277\275\351\200\211\351\200\232\351\201\270\351\205\215\351\207\214\351\222\256\351\224\256\351\225\267\351\225\277\351\231\244\351\234\200\351\235\231\351\235\242\351\240\230\351\242\204\351\242\234\351\252\244\351\253\230\351\274\240\351\275\220\352\260\200\352\260\204\352\260\222\352\260\231\352\260\234\352\261\260\352\262\203\352\262\214\352\262\240\352\263\204\352\263\240\352\263\274\352\265\254\352\265\255\352\267\270\352\270\200\352\270\260\352\271\214\352\273\230\352\274\264\353\202\230\353\202\264\353\204\214\353\205\270\353\206\223\353\210\204\353\212\224\353\212\245\353\213\210\353\213\244\353\213\250\353\213\254\353\213\271\353\214\200\353\215\224\353\215\260\353\217\204\353\217\231\353\220\230\353\220\234\353\220\251\353\221\220\353\223\234\353\223\244\353\224\251\353\225\214\353\226\273\353\235\274\353\236\230\353\236\265\353\237\254\353\240\210\353\240\244\353\240\245\353\240\254\353\241\234\353\241\235\353\241\244\353\245\264\353\245\270\353\245\274\353\246\254\353\246\255\353\247\210\353\247\214\353\247\216\353\247\244\353\250\270\353\251\224\353\251\264\353\252\205\353\252\250\353\252\251\353\260\200\353\260\217\353\260\224\353\260\233\353\260\251\353\260\260\353\260\261\353\262\204\353\262\210\353\262\225\353\262\227\353\262\244\353\263\264\353\263\270\353\270\224\353\271\204\354\202\254\354\203\201\354\203\211\354\204\234\354\204\240\354\204\244\354\204\261\354\204\270\354\205\230\354\206\214\354\206\215\354\210\230\354\212\244\354\212\254\354\212\265\354\213\234\354\213\240\354\213\255\354\225\204\354\225\240\354\226\221\354\226\264\354\226\270\354\227\206\354\227\220\354\227\254\354\227\255\354\230\201\354\230\210\354\230\244\354\230\254\354\231\200\354\232\224\354\232\251\354\232\260\354\233\203\354\234\204\354\234\210\354\234\240\354\234\250\354\234\274\354\235\200\354\235\204\354\235\214\354\235\230\354\235\264\354\235\270\354\235\274\354\236\204\354\236\205\354\236\210\354\236\220\354\236\221\354\236\230\354\236\245\354\240\201\354\240\204\354\240\225\354\240\234\354\241\260\354\242\213\354\244\221\354\247\200\354\247\201\354\247\204\354\247\210\354\260\250\354\260\275\354\262\230\354\264\210\354\265\234\354\266\224\354\266\225\354\266\234\354\267\250\354\271\230\354\272\220\354\273\250\354\273\264\354\274\200\354\275\224\354\275\234\355\201\254\355\201\264\355\202\244\355\203\200\355\203\204\355\203\234\355\203\235\355\204\260\355\205\214\355\205\215\355\212\270\355\212\274\355\213\261\355\214\214\355\214\250\355\214\254\355\217\211\355\217\254\355\221\234\355\224\204\355\224\274\355\225\204\355\225\221\355\225\230\355\225\234\355\225\240\355\225\250\355\225\251\355\225\264\355\226\211\355\230\225\355\230\270\355\230\274\355\231\224\355\231\225\355\231\234\355\232\250\357\274\201\357\274\214\357\274\237 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}" diff --git a/druid/helper.lua b/druid/helper.lua index 7560fe7..3819219 100644 --- a/druid/helper.lua +++ b/druid/helper.lua @@ -13,7 +13,6 @@ local POSITION_X = hash("position.x") local SCALE_X = hash("scale.x") local SIZE_X = hash("size.x") - local function get_text_width(text_node) if text_node then local text_metrics = M.get_text_metrics_from_node(text_node) @@ -138,10 +137,15 @@ end ---@return number stretch_y function M.get_screen_aspect_koef() local window_x, window_y = window.get_size() + local stretch_x = window_x / gui.get_width() local stretch_y = window_y / gui.get_height() - return stretch_x / math.min(stretch_x, stretch_y), - stretch_y / math.min(stretch_x, stretch_y) + local stretch_koef = math.min(stretch_x, stretch_y) + + local koef_x = window_x / (stretch_koef * sys.get_config_int("display.width")) + local koef_y = window_y / (stretch_koef * sys.get_config_int("display.height")) + + return koef_x, koef_y end @@ -534,7 +538,7 @@ end ---Show message to require component ---@param component_name string ----@param component_type string +---@param component_type string|nil function M.require_component_message(component_name, component_type) component_type = component_type or "extended" diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index 62f2323..f71835e 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -3,7 +3,7 @@ -- -- Helper - A useful set of functions for working with GUI nodes, such as centering nodes, get GUI scale ratio, etc -- --- DruidEvent - The core event system in Druid. Learn how to subscribe to any event in every Druid component. +-- druid.event - The core event system in Druid. Learn how to subscribe to any event in every Druid component. -- -- BaseComponent - The parent class of all Druid components. You can find all default component methods there. -- @@ -49,7 +49,7 @@ local back_handler = require("druid.base.back_handler") ---@field private _late_remove druid.base_component[] ---@field private _input_blacklist druid.base_component[]|nil ---@field private _input_whitelist druid.base_component[]|nil ----@field private _input_inited boolean +---@field private input_inited boolean ---@field private _late_init_timer_id number ---@field private _input_components druid.base_component[] local M = {} @@ -69,7 +69,7 @@ end -- The a and b - two Druid components --- @local +---@private local function sort_input_comparator(a, b) local a_priority = a:get_input_priority() local b_priority = b:get_input_priority() @@ -231,9 +231,9 @@ end --- Druid class constructor ----@param table context Druid context. Usually it is self of gui script ----@param table style Druid style table --- @local +---@param context table Druid context. Usually it is self of gui script +---@param style table Druid style table +---@private function M:initialize(context, style) self._context = context self._style = style or settings.default_style @@ -291,7 +291,8 @@ end --- Remove created component from Druid instance. -- -- Component `on_remove` function will be invoked, if exist. ----@param BaseComponent component Component instance +---@generic T: druid.base_component +---@param component T Component instance ---@return boolean True if component was removed function M:remove(component) if self._is_late_remove_enabled then @@ -342,7 +343,7 @@ end --- Druid late update function called after initialization and before the regular update step -- This function is used to check the GUI state and perform actions after all components and nodes have been created. -- An example use case is performing an auto stencil check in the GUI hierarchy for input components. --- @local +---@private function M:late_init() local late_init_components = self.components_interest[base_component.ON_LATE_INIT] while late_init_components[1] do @@ -435,7 +436,7 @@ end --- Calls the on_focus_lost function in all related components -- This one called by on_window_callback by global window listener --- @local +---@private function M:on_focus_lost() local components = self.components_interest[base_component.ON_FOCUS_LOST] for i = 1, #components do @@ -446,7 +447,7 @@ end --- Calls the on_focus_gained function in all related components -- This one called by on_window_callback by global window listener --- @local +---@private function M:on_focus_gained() local components = self.components_interest[base_component.ON_FOCUS_GAINED] for i = 1, #components do @@ -458,7 +459,7 @@ end --- Calls the on_language_change function in all related components -- This one called by global druid.on_language_change, but can be -- call manualy to update all translations --- @local +---@private function M:on_language_change() local components = self.components_interest[base_component.ON_LANGUAGE_CHANGE] for i = 1, #components do @@ -508,7 +509,7 @@ end --- Remove all components on late remove step DruidInstance --- @local +---@private function M:_clear_late_remove() if #self._late_remove == 0 then return @@ -543,7 +544,7 @@ function M:new_widget(widget, template, nodes, ...) end ---- Create Button component +---Create Button component ---@param node string|node The node_id or gui.get_node(node_id) ---@param callback function|nil Button callback ---@param params any|nil Button callback params @@ -554,7 +555,7 @@ function M:new_button(node, callback, params, anim_node) end ---- Create Blocker component +---Create Blocker component ---@param node string|node The node_id or gui.get_node(node_id) ---@return druid.blocker Blocker component function M:new_blocker(node) @@ -562,7 +563,7 @@ function M:new_blocker(node) end ---- Create BackHandler component +---Create BackHandler component ---@param callback function|nil The callback(self, custom_args) to call on back event ---@param params any|nil Callback argument ---@return druid.back_handler BackHandler component @@ -571,7 +572,7 @@ function M:new_back_handler(callback, params) end ---- Create Hover component +---Create Hover component ---@param node string|node The node_id or gui.get_node(node_id) ---@param on_hover_callback function|nil Hover callback ---@param on_mouse_hover_callback function|nil Mouse hover callback @@ -581,7 +582,7 @@ function M:new_hover(node, on_hover_callback, on_mouse_hover_callback) end ---- Create Text component +---Create Text component ---@param node string|node The node_id or gui.get_node(node_id) ---@param value string|nil Initial text. Default value is node text from GUI scene. ---@param no_adjust boolean|nil If true, text will be not auto-adjust size @@ -591,7 +592,7 @@ function M:new_text(node, value, no_adjust) end ---- Create StaticGrid component +---Create StaticGrid component ---@param parent_node string|node The node_id or gui.get_node(node_id). Parent of all Grid items. ---@param item node Element prefab. Required to get grid's item size. Can be adjusted separately. ---@param in_row number|nil How many nodes in row can be placed @@ -601,7 +602,7 @@ function M:new_grid(parent_node, item, in_row) end ---- Create StaticGrid component +---Create StaticGrid component ---@param parent_node string|node The node_id or gui.get_node(node_id). Parent of all Grid items. ---@param item string|node Item prefab. Required to get grid's item size. Can be adjusted separately. ---@param in_row number|nil How many nodes in row can be placed @@ -611,7 +612,7 @@ function M:new_static_grid(parent_node, item, in_row) end ---- Create Scroll component +---Create Scroll component ---@param view_node string|node The node_id or gui.get_node(node_id). Will used as user input node. ---@param content_node string|node The node_id or gui.get_node(node_id). Will used as scrollable node inside view_node. ---@return druid.scroll Scroll component @@ -620,7 +621,7 @@ function M:new_scroll(view_node, content_node) end ---- Create Drag component +---Create Drag component ---@param node string|node The node_id or gui.get_node(node_id). Will used as user input node. ---@param on_drag_callback function|nil Callback for on_drag_event(self, dx, dy) ---@return druid.drag Drag component @@ -629,7 +630,7 @@ function M:new_drag(node, on_drag_callback) end ---- Create Swipe component +---Create Swipe component ---@param node string|node The node_id or gui.get_node(node_id). Will used as user input node. ---@param on_swipe_callback function|nil Swipe callback for on_swipe_end event ---@return druid.swipe Swipe component @@ -638,7 +639,7 @@ function M:new_swipe(node, on_swipe_callback) end ---- Create LangText component +---Create LangText component ---@param node string|node The_node id or gui.get_node(node_id) ---@param locale_id string|nil Default locale id or text from node as default ---@param adjust_type string|nil Adjust type for text node. Default: const.TEXT_ADJUST.DOWNSCALE @@ -647,7 +648,8 @@ function M:new_lang_text(node, locale_id, adjust_type) return helper.require_component_message("lang_text") --[[@as druid.lang_text]] end ---- Create Slider component + +---Create Slider component ---@param pin_node string|node The_node id or gui.get_node(node_id). ---@param end_pos vector3 The end position of slider ---@param callback function|nil On slider change callback @@ -656,7 +658,7 @@ function M:new_slider(pin_node, end_pos, callback) return helper.require_component_message("slider") --[[@as druid.slider]] end ---- Create Input component +---Create Input component ---@param click_node string|node Button node to enabled input component ---@param text_node string|node|druid.text Text node what will be changed on user input ---@param keyboard_type number|nil Gui keyboard type for input field @@ -665,7 +667,8 @@ function M:new_input(click_node, text_node, keyboard_type) return helper.require_component_message("input") --[[@as druid.input]] end ---- Create DataList component + +---Create DataList component ---@param druid_scroll druid.scroll The Scroll instance for Data List component ---@param druid_grid druid.grid The StaticGrid} or @{DynamicGrid instance for Data List component ---@param create_function function The create function callback(self, data, index, data_list). Function should return (node, [component]) @@ -674,7 +677,8 @@ function M:new_data_list(druid_scroll, druid_grid, create_function) return helper.require_component_message("data_list") --[[@as druid.data_list]] end ---- Create Timer component + +---Create Timer component ---@param node string|node Gui text node ---@param seconds_from number Start timer value in seconds ---@param seconds_to number|nil End timer value in seconds @@ -684,7 +688,9 @@ function M:new_timer(node, seconds_from, seconds_to, callback) return helper.require_component_message("timer") --[[@as druid.timer]] end ---- Create Progress component + + +---Create Progress component ---@param node string|node Progress bar fill node or node name ---@param key string Progress bar direction: const.SIDE.X or const.SIDE.Y ---@param init_value number|nil Initial value of progress bar. Default: 1 @@ -693,7 +699,8 @@ function M:new_progress(node, key, init_value) return helper.require_component_message("progress") --[[@as druid.progress]] end ---- Create Layout component + +---Create Layout component ---@param node string|node The_node id or gui.get_node(node_id). ---@param mode string The layout mode ---@return druid.layout Layout component @@ -701,7 +708,8 @@ function M:new_layout(node, mode) return helper.require_component_message("layout") --[[@as druid.layout]] end ---- Create Hotkey component + +---Create Hotkey component ---@param keys_array string|string[] Keys for trigger action. Should contains one action key and any amount of modificator keys ---@param callback function The callback function ---@param callback_argument any|nil The argument to pass into the callback function @@ -710,7 +718,8 @@ function M:new_hotkey(keys_array, callback, callback_argument) return helper.require_component_message("hotkey") --[[@as druid.hotkey]] end ---- Create RichText component. + +---Create RichText component. ---@param text_node string|node The text node to make Rich Text ---@param value string|nil The initial text value. Default will be gui.get_text(text_node) ---@return druid.rich_text RichText component @@ -718,7 +727,8 @@ function M:new_rich_text(text_node, value) return helper.require_component_message("rich_text", "custom") --[[@as druid.rich_text]] end ---- Create RichInput component. + +---Create RichInput component. -- As a template please check rich_input.gui layout. ---@param template string The template string name ---@param nodes table Nodes table from gui.clone_tree @@ -727,4 +737,5 @@ function M:new_rich_input(template, nodes) return helper.require_component_message("rich_input", "custom") --[[@as druid.rich_input]] end + return M diff --git a/example/examples/basic/drag/drag_to_node.lua b/example/examples/basic/drag/drag_to_node.lua index 34fec17..eb927f9 100644 --- a/example/examples/basic/drag/drag_to_node.lua +++ b/example/examples/basic/drag/drag_to_node.lua @@ -15,7 +15,7 @@ function M:init(template, nodes) gui.set_text(self.text_counter, self.counter) -- Init drag and move the drag node on drag callback - self.drag = self.druid:new_drag("drag/root", self.on_drag_start) + self.drag = self.druid:new_drag("drag/root", self.on_drag) self.drag.on_drag_end:subscribe(self.on_drag_end) -- Save start position for animation @@ -23,7 +23,7 @@ function M:init(template, nodes) end -function M:on_drag_start(dx, dy, x, y, touch) +function M:on_drag(dx, dy, x, y, touch) local position_x = gui.get(self.drag.node, "position.x") local position_y = gui.get(self.drag.node, "position.y") gui.set(self.drag.node, "position.x", position_x + dx) From 620facbe1fa140dfc48cf8c016624ed1c88c8106 Mon Sep 17 00:00:00 2001 From: Insality Date: Thu, 7 Nov 2024 18:34:27 +0100 Subject: [PATCH 09/50] replace all tparam --- druid/base/button.lua | 10 +-- druid/base/hover.lua | 30 ++++----- druid/base/scroll.lua | 74 +++++++++++------------ druid/base/static_grid.lua | 84 +++++++++++++------------- druid/base/text.lua | 52 ++++++++-------- druid/component.lua | 22 +++---- druid/custom/rich_input/rich_input.lua | 20 +++--- druid/custom/rich_text/rich_text.lua | 20 +++--- druid/extended/data_list.lua | 64 ++++++++++---------- druid/extended/hotkey.lua | 18 +++--- druid/extended/input.lua | 52 ++++++++-------- druid/extended/lang_text.lua | 46 +++++++------- druid/extended/progress.lua | 34 +++++------ druid/extended/slider.lua | 28 ++++----- druid/extended/swipe.lua | 8 +-- 15 files changed, 281 insertions(+), 281 deletions(-) diff --git a/druid/base/button.lua b/druid/base/button.lua index d2d5e94..e7a5011 100755 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -471,7 +471,7 @@ end --- Set button enabled state. -- The style.on_set_enabled will be triggered. -- Disabled button is not clickable. --- @tparam boolean|nil state Enabled state +---@param state boolean|nil Enabled state ---@return druid.button self function M:set_enabled(state) self.disabled = not state @@ -495,7 +495,7 @@ end -- Useful to restrict click outside out stencil node or scrollable content. -- -- This functions calls automatically if you don't disable it in game.project: druid.no_stencil_check --- @tparam node|string|nil zone Gui node +---@param zone node|string|nil Gui node ---@return druid.button self function M:set_click_zone(zone) self.click_zone = self:get_node(zone) @@ -523,8 +523,8 @@ end --- Set function for additional check for button click availability --- @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 +---@param check_function function|nil Should return true or false. If true - button can be pressed. +---@param failure_callback function|nil Function will be called on button click, if check function return false ---@return druid.button self function M:set_check_function(check_function, failure_callback) self._check_function = check_function @@ -538,7 +538,7 @@ end -- The HTML5 button's doesn't call any events except on_click event. -- -- If the game is not HTML, html mode will be not enabled --- @tparam boolean|nil is_web_mode If true - button will be called inside html5 callback +---@param is_web_mode boolean|nil If true - button will be called inside html5 callback ---@return druid.button self function M:set_web_user_interaction(is_web_mode) self._is_html5_mode = not not (is_web_mode and html5) diff --git a/druid/base/hover.lua b/druid/base/hover.lua index cd6730b..0433432 100644 --- a/druid/base/hover.lua +++ b/druid/base/hover.lua @@ -35,10 +35,10 @@ local M = component.create("hover") --- The Hover constructor --- @tparam Hover self Hover --- @tparam node node Gui node --- @tparam function on_hover_callback Hover callback --- @tparam function on_mouse_hover On mouse hover callback +---@param self Hover Hover +---@param node node Gui node +---@param on_hover_callback function Hover callback +---@param on_mouse_hover function On mouse hover callback function M:init(node, on_hover_callback, on_mouse_hover) self.node = self:get_node(node) @@ -115,8 +115,8 @@ end --- Set hover state --- @tparam Hover self Hover --- @tparam boolean|nil state The hover state +---@param self Hover Hover +---@param state boolean|nil The hover state function M:set_hover(state) if self._is_hovered == state then return @@ -132,7 +132,7 @@ end --- Return current hover state. True if touch action was on the node at current time --- @tparam Hover self Hover +---@param self Hover Hover -- @treturn boolean The current hovered state function M:is_hovered() return self._is_hovered @@ -140,8 +140,8 @@ end --- Set mouse hover state --- @tparam Hover self Hover --- @tparam boolean|nil state The mouse hover state +---@param self Hover Hover +---@param state boolean|nil The mouse hover state function M:set_mouse_hover(state) if self._is_mouse_hovered == state then return @@ -157,7 +157,7 @@ end --- Return current hover state. True if nil action_id (usually desktop mouse) was on the node at current time --- @tparam Hover self Hover +---@param self Hover Hover -- @treturn boolean The current hovered state function M:is_mouse_hovered() return self._is_mouse_hovered @@ -166,8 +166,8 @@ end --- Strict hover click area. Useful for -- no click events outside stencil node --- @tparam Hover self Hover --- @tparam node|string|nil zone Gui node +---@param self Hover Hover +---@param zone node|string|nil Gui node function M:set_click_zone(zone) self.click_zone = self:get_node(zone) end @@ -176,8 +176,8 @@ end --- Set enable state of hover component. -- If hover is not enabled, it will not generate -- any hover events --- @tparam Hover self Hover --- @tparam boolean|nil state The hover enabled state +---@param self Hover Hover +---@param state boolean|nil The hover enabled state function M:set_enabled(state) self._is_enabled = state @@ -193,7 +193,7 @@ end --- Return current hover enabled state --- @tparam Hover self Hover +---@param self Hover Hover -- @treturn boolean The hover enabled state function M:is_enabled() return self._is_enabled diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index 3bc6b79..d53be7d 100755 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -171,9 +171,9 @@ end --- 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 +---@param self Scroll Scroll +---@param view_node string|node GUI view scroll node +---@param content_node string|node GUI content scroll node function M:init(view_node, content_node) self.druid = self:get_druid() @@ -253,9 +253,9 @@ end --- Start scroll to target point. --- @tparam Scroll self Scroll --- @tparam vector3 point Target point --- @tparam boolean|nil is_instant Instant scroll flag +---@param self Scroll Scroll +---@param point vector3 Target point +---@param is_instant boolean|nil Instant scroll flag -- @usage scroll:scroll_to(vmath.vector3(0, 50, 0)) -- @usage scroll:scroll_to(vmath.vector3(0), true) function M:scroll_to(point, is_instant) @@ -287,9 +287,9 @@ end --- Scroll to item in scroll by point index. --- @tparam Scroll self Scroll --- @tparam number index Point index --- @tparam boolean|nil skip_cb If true, skip the point callback +---@param self Scroll Scroll +---@param index number Point index +---@param skip_cb boolean|nil If true, skip the point callback function M:scroll_to_index(index, skip_cb) if not self.points then return @@ -310,9 +310,9 @@ end --- Start scroll to target scroll percent --- @tparam Scroll self Scroll --- @tparam vector3 percent target percent --- @tparam boolean|nil is_instant instant scroll flag +---@param self Scroll Scroll +---@param percent vector3 target percent +---@param is_instant boolean|nil instant scroll flag -- @usage scroll:scroll_to_percent(vmath.vector3(0.5, 0, 0)) function M:scroll_to_percent(percent, is_instant) local border = self.available_pos @@ -336,7 +336,7 @@ end --- Return current scroll progress status. -- Values will be in [0..1] interval --- @tparam Scroll self Scroll +---@param self Scroll Scroll -- @treturn vector3 New vector with scroll progress values function M:get_percent() local x_perc = 1 - inverse_lerp(self.available_pos.x, self.available_pos.z, self.position.x) @@ -348,9 +348,9 @@ end --- Set scroll content size. -- It will change content gui node size --- @tparam Scroll self Scroll --- @tparam vector3 size The new size for content node --- @tparam vector3|nil offset Offset value to set, where content is starts +---@param self Scroll Scroll +---@param size vector3 The new size for content node +---@param offset vector3|nil Offset value to set, where content is starts -- @treturn druid.scroll Current scroll instance function M:set_size(size, offset) if offset then @@ -364,8 +364,8 @@ 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 +---@param self Scroll Scroll +---@param size vector3 The new size for view node -- @treturn druid.scroll Current scroll instance function M:set_view_size(size) gui.set_size(self.view_node, size) @@ -378,7 +378,7 @@ end --- Refresh scroll view size --- @tparam Scroll self Scroll +---@param self Scroll Scroll function M:update_view_size() self.view_size = helper.get_scaled_size(self.view_node) self.view_border = helper.get_border(self.view_node) @@ -391,8 +391,8 @@ 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 boolean|nil state Inert scroll state +---@param self Scroll Scroll +---@param state boolean|nil Inert scroll state -- @treturn druid.scroll Current scroll instance function M:set_inert(state) self._is_inert = state @@ -402,7 +402,7 @@ end --- Return if scroll have inertion. --- @tparam Scroll self Scroll +---@param self Scroll Scroll -- @treturn boolean @If scroll have inertion function M:is_inert() return self._is_inert @@ -411,8 +411,8 @@ end --- Set extra size for scroll stretching. -- Set 0 to disable stretching effect --- @tparam Scroll self Scroll --- @tparam number|nil stretch_size Size in pixels of additional scroll area +---@param self Scroll Scroll +---@param stretch_size number|nil Size in pixels of additional scroll area -- @treturn druid.scroll Current scroll instance function M:set_extra_stretch_size(stretch_size) self.style.EXTRA_STRETCH_SIZE = stretch_size or 0 @@ -423,7 +423,7 @@ end --- Return vector of scroll size with width and height. --- @tparam Scroll self Scroll +---@param self Scroll Scroll -- @treturn vector3 Available scroll size function M:get_scroll_size() return self.available_size @@ -432,8 +432,8 @@ end --- Set points of interest. -- Scroll will always centered on closer points --- @tparam Scroll self Scroll --- @tparam table points Array of vector3 points +---@param self Scroll Scroll +---@param points table Array of vector3 points -- @treturn druid.scroll Current scroll instance function M:set_points(points) self.points = points @@ -449,8 +449,8 @@ end --- Lock or unlock horizontal scroll --- @tparam Scroll self Scroll --- @tparam boolean|nil state True, if horizontal scroll is enabled +---@param self Scroll Scroll +---@param state boolean|nil True, if horizontal scroll is enabled -- @treturn druid.scroll Current scroll instance function M:set_horizontal_scroll(state) self._is_horizontal_scroll = state @@ -460,8 +460,8 @@ end --- Lock or unlock vertical scroll --- @tparam Scroll self Scroll --- @tparam boolean|nil state True, if vertical scroll is enabled +---@param self Scroll Scroll +---@param state boolean|nil True, if vertical scroll is enabled -- @treturn druid.scroll Current scroll instance function M:set_vertical_scroll(state) self._is_vertical_scroll = state @@ -472,8 +472,8 @@ end --- Check node if it visible now on scroll. -- Extra border is not affected. Return true for elements in extra scroll zone --- @tparam Scroll self Scroll --- @tparam node node The node to check +---@param self Scroll Scroll +---@param node node The node to check -- @treturn boolean True if node in visible scroll area function M:is_node_in_view(node) local node_offset_for_view = gui.get_position(node) @@ -513,8 +513,8 @@ end --- Bind the grid component (Static or Dynamic) to recalculate -- scroll size on grid changes --- @tparam Scroll self Scroll --- @tparam StaticGrid grid Druid grid component +---@param self Scroll Scroll +---@param grid StaticGrid Druid grid component -- @treturn druid.scroll Current scroll instance function M:bind_grid(grid) if self._grid_on_change then @@ -542,8 +542,8 @@ end --- Strict drag scroll area. Useful for -- restrict events outside stencil node --- @tparam Drag self --- @tparam node|string node Gui node +---@param self Drag +---@param node node|string Gui node function M:set_click_zone(node) self.drag:set_click_zone(node) end diff --git a/druid/base/static_grid.lua b/druid/base/static_grid.lua index 245b6dc..8e7caf3 100644 --- a/druid/base/static_grid.lua +++ b/druid/base/static_grid.lua @@ -128,10 +128,10 @@ end --- The StaticGrid constructor --- @tparam StaticGrid self StaticGrid --- @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 number|nil in_row How many nodes in row can be placed. By default 1 +---@param self StaticGrid StaticGrid +---@param parent string|node The GUI Node container, where grid's items will be placed +---@param element node Element prefab. Need to get it size +---@param in_row number|nil How many nodes in row can be placed. By default 1 function M:init(parent, element, in_row) self.parent = self:get_node(parent) self.nodes = {} @@ -165,8 +165,8 @@ end local _temp_pos = vmath.vector3(0) --- Return pos for grid node index --- @tparam StaticGrid self StaticGrid --- @tparam number index The grid element index +---@param self StaticGrid StaticGrid +---@param index number The grid element index -- @treturn vector3 @Node position function M:get_pos(index) local row = math.ceil(index / self.in_row) - 1 @@ -183,8 +183,8 @@ end --- Return index for grid pos --- @tparam StaticGrid self StaticGrid --- @tparam vector3 pos The node position in the grid +---@param self StaticGrid StaticGrid +---@param pos vector3 The node position in the grid -- @treturn number The node index function M:get_index(pos) -- Offset to left-top corner from node pivot @@ -203,8 +203,8 @@ end --- Return grid index by node --- @tparam StaticGrid self StaticGrid --- @tparam node node The gui node in the grid +---@param self StaticGrid StaticGrid +---@param node node The gui node in the grid -- @treturn number The node index function M:get_index_by_node(node) for index, grid_node in pairs(self.nodes) do @@ -223,8 +223,8 @@ end --- Set grid anchor. Default anchor is equal to anchor of grid parent node --- @tparam StaticGrid self StaticGrid --- @tparam vector3 anchor Anchor +---@param self StaticGrid StaticGrid +---@param anchor vector3 Anchor function M:set_anchor(anchor) self.anchor = anchor self:_update() @@ -232,7 +232,7 @@ end --- Update grid content --- @tparam StaticGrid self StaticGrid +---@param self StaticGrid StaticGrid function M:refresh() self:_update(true) end @@ -270,11 +270,11 @@ end --- Add new item to the grid --- @tparam StaticGrid self StaticGrid --- @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 +---@param self StaticGrid StaticGrid +---@param item node GUI node +---@param index number|nil The item position. By default add as last item +---@param shift_policy number|nil How shift nodes, if required. Default: const.SHIFT.RIGHT +---@param is_instant boolean|nil If true, update node positions instantly function M:add(item, index, shift_policy, is_instant) index = index or ((self.last_index or 0) + 1) @@ -295,8 +295,8 @@ end --- Set new items to the grid. All previous items will be removed --- @tparam StaticGrid self StaticGrid --- @tparam node[] nodes The new grid nodes +---@param self StaticGrid StaticGrid +---@param nodes node[] The new grid nodes -- @tparam[opt=false] boolean is_instant If true, update node positions instantly function M:set_items(nodes, is_instant) self.nodes = nodes @@ -312,10 +312,10 @@ 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 number|nil shift_policy How shift nodes, if required. Default: const.SHIFT.RIGHT --- @tparam boolean|nil is_instant If true, update node positions instantly +---@param self StaticGrid StaticGrid +---@param index number The grid node index to remove +---@param shift_policy number|nil How shift nodes, if required. Default: const.SHIFT.RIGHT +---@param is_instant boolean|nil If true, update node positions instantly -- @treturn node The deleted gui node from grid function M:remove(index, shift_policy, is_instant) assert(self.nodes[index], "No grid item at given index " .. index) @@ -333,7 +333,7 @@ end --- Return grid content size --- @tparam StaticGrid self StaticGrid +---@param self StaticGrid StaticGrid -- @treturn vector3 The grid content size function M:get_size() return vmath.vector3( @@ -366,7 +366,7 @@ end --- Return grid content borders --- @tparam StaticGrid self StaticGrid +---@param self StaticGrid StaticGrid -- @treturn vector3 The grid content borders function M:get_borders() return self.border @@ -374,7 +374,7 @@ end --- Return array of all node positions --- @tparam StaticGrid self StaticGrid +---@param self StaticGrid StaticGrid -- @treturn vector3[] All grid node positions function M:get_all_pos() local result = {} @@ -388,8 +388,8 @@ end --- Change set position function for grid nodes. It will call on -- update poses on grid elements. Default: gui.set_position --- @tparam StaticGrid self StaticGrid --- @tparam function callback Function on node set position +---@param self StaticGrid StaticGrid +---@param callback function Function on node set position -- @treturn druid.static_grid Current grid instance function M:set_position_function(callback) self._set_position_function = callback or gui.set_position @@ -400,7 +400,7 @@ end --- Clear grid nodes array. GUI nodes will be not deleted! -- If you want to delete GUI nodes, use static_grid.nodes array before grid:clear --- @tparam StaticGrid self StaticGrid +---@param self StaticGrid StaticGrid -- @treturn druid.static_grid Current grid instance function M:clear() self.border.x = 0 @@ -419,7 +419,7 @@ end --- Return StaticGrid offset, where StaticGrid content starts. --- @tparam StaticGrid self StaticGrid The StaticGrid instance +---@param self StaticGrid StaticGrid The StaticGrid instance -- @treturn vector3 The StaticGrid offset function M:get_offset() local borders = self:get_borders() @@ -435,8 +435,8 @@ end --- Set new in_row elements for grid --- @tparam StaticGrid self StaticGrid --- @tparam number in_row The new in_row value +---@param self StaticGrid StaticGrid +---@param in_row number The new in_row value -- @treturn druid.static_grid Current grid instance function M:set_in_row(in_row) self.in_row = in_row @@ -454,7 +454,7 @@ end --- Set new node size for grid --- @tparam StaticGrid self StaticGrid +---@param self StaticGrid StaticGrid -- @tparam[opt] number width The new node width -- @tparam[opt] number height The new node height -- @treturn druid.static_grid Current grid instance @@ -479,8 +479,8 @@ end --- Sort grid nodes by custom comparator function --- @tparam StaticGrid self StaticGrid --- @tparam function comparator The comparator function. (a, b) -> boolean +---@param self StaticGrid StaticGrid +---@param comparator function The comparator function. (a, b) -> boolean -- @treturn druid.static_grid Current grid instance function M:sort_nodes(comparator) table.sort(self.nodes, comparator) @@ -489,8 +489,8 @@ end --- Update grid inner state --- @tparam StaticGrid self StaticGrid --- @tparam boolean|nil is_instant If true, node position update instantly, otherwise with set_position_function callback +---@param self StaticGrid StaticGrid +---@param is_instant boolean|nil If true, node position update instantly, otherwise with set_position_function callback ---@private function M:_update(is_instant) self:_update_indexes() @@ -500,7 +500,7 @@ end --- Update first and last indexes of grid nodes --- @tparam StaticGrid self StaticGrid +---@param self StaticGrid StaticGrid ---@private function M:_update_indexes() self.first_index = nil @@ -516,7 +516,7 @@ end --- Update grid content borders, recalculate min and max values --- @tparam StaticGrid self StaticGrid +---@param self StaticGrid StaticGrid ---@private function M:_update_borders() if not self.first_index then @@ -535,8 +535,8 @@ end --- Update grid nodes position --- @tparam StaticGrid self StaticGrid --- @tparam boolean|nil is_instant If true, node position update instantly, otherwise with set_position_function callback +---@param self StaticGrid StaticGrid +---@param is_instant boolean|nil If true, node position update instantly, otherwise with set_position_function callback ---@private function M:_update_pos(is_instant) local zero_offset = self:_get_zero_offset() diff --git a/druid/base/text.lua b/druid/base/text.lua index e63ab86..002f7e9 100755 --- a/druid/base/text.lua +++ b/druid/base/text.lua @@ -288,10 +288,10 @@ end --- The Text constructor --- @tparam Text self Text --- @tparam string|node node Node name or GUI Text Node itself --- @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 +---@param self Text Text +---@param node string|node Node name or GUI Text Node itself +---@param value string|nil Initial text. Default value is node text from GUI scene. Default: nil +---@param adjust_type string|nil Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference. Default: DOWNSCALE function M:init(node, value, adjust_type) self.node = self:get_node(node) self.pos = gui.get_position(self.node) @@ -335,8 +335,8 @@ end --- Calculate text width with font with respect to trailing space --- @tparam Text self Text --- @tparam string text|nil +---@param self Text Text +---@param text|nil string -- @treturn number Width -- @treturn number Height function M:get_text_size(text) @@ -360,8 +360,8 @@ end --- Get chars count by width --- @tparam Text self Text --- @tparam number width +---@param self Text Text +---@param width number -- @treturn number Chars count function M:get_text_index_by_width(width) local text = self.last_value @@ -394,8 +394,8 @@ end --- Set text to text field --- @tparam Text self Text --- @tparam string set_to Text for node +---@param self Text Text +---@param set_to string Text for node -- @treturn Text Current text instance function M:set_to(set_to) set_to = set_to or "" @@ -412,8 +412,8 @@ end --- Set text area size --- @tparam Text self Text --- @tparam vector3 size The new text area size +---@param self Text Text +---@param size vector3 The new text area size -- @treturn Text Current text instance function M:set_size(size) self.start_size = size @@ -425,8 +425,8 @@ end --- Set color --- @tparam Text self Text --- @tparam vector4 color Color for node +---@param self Text Text +---@param color vector4 Color for node -- @treturn Text Current text instance function M:set_color(color) self.color = color @@ -437,8 +437,8 @@ end --- Set alpha --- @tparam Text self Text --- @tparam number alpha Alpha for node +---@param self Text Text +---@param alpha number Alpha for node -- @treturn Text Current text instance function M:set_alpha(alpha) self.color.w = alpha @@ -449,8 +449,8 @@ end --- Set scale --- @tparam Text self Text --- @tparam vector3 scale Scale for node +---@param self Text Text +---@param scale vector3 Scale for node -- @treturn Text Current text instance function M:set_scale(scale) self.last_scale = scale @@ -461,8 +461,8 @@ end --- Set text pivot. Text will re-anchor inside text area --- @tparam Text self Text --- @tparam number pivot The gui.PIVOT_* constant +---@param self Text Text +---@param pivot number The gui.PIVOT_* constant -- @treturn Text Current text instance function M:set_pivot(pivot) local prev_pivot = gui.get_pivot(self.node) @@ -487,7 +487,7 @@ end --- Return true, if text with line break --- @tparam Text self Text +---@param self Text Text -- @treturn boolean Is text node with line break function M:is_multiline() return gui.get_line_break(self.node) @@ -495,9 +495,9 @@ end --- Set text adjust, refresh the current text visuals, if needed --- @tparam Text self Text --- @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 +---@param self Text Text +---@param adjust_type string|nil See const.TEXT_ADJUST. If pass nil - use current adjust type +---@param minimal_scale number|nil If pass nil - not use minimal scale -- @treturn Text Current text instance function M:set_text_adjust(adjust_type, minimal_scale) self.adjust_type = adjust_type @@ -509,8 +509,8 @@ end --- Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types --- @tparam Text self Text --- @tparam number minimal_scale If pass nil - not use minimal scale +---@param self Text Text +---@param minimal_scale number If pass nil - not use minimal scale -- @treturn Text Current text instance function M:set_minimal_scale(minimal_scale) self._minimal_scale = minimal_scale diff --git a/druid/component.lua b/druid/component.lua index 05c7e0d..02fc151 100644 --- a/druid/component.lua +++ b/druid/component.lua @@ -278,11 +278,11 @@ end --- Setup component context and his style table --- @tparam BaseComponent self BaseComponent --- @tparam table druid_instance The parent druid instance --- @tparam table context Druid context. Usually it is self of script --- @tparam table style Druid style module --- @tparam table instance_class The component instance class +---@param self BaseComponent BaseComponent +---@param druid_instance table The parent druid instance +---@param context table Druid context. Usually it is self of script +---@param style table Druid style module +---@param instance_class table The component instance class -- @treturn component BaseComponent itself ---@private function M:setup_component(druid_instance, context, style, instance_class) @@ -310,7 +310,7 @@ end --- Return true, if input priority was changed --- @tparam BaseComponent self BaseComponent +---@param self BaseComponent BaseComponent ---@private function M._is_input_priority_changed(self) return self._component._is_input_priority_changed @@ -318,7 +318,7 @@ end --- Reset is_input_priority_changed field --- @tparam BaseComponent self BaseComponent +---@param self BaseComponent BaseComponent ---@private function M._reset_input_priority_changed(self) self._component._is_input_priority_changed = false @@ -326,7 +326,7 @@ end --- Get current component interests --- @tparam BaseComponent self BaseComponent +---@param self BaseComponent BaseComponent -- @treturn table List of component interests ---@private function M.__get_interests(self) @@ -369,8 +369,8 @@ end --- Remove child from component children list --- @tparam BaseComponent self BaseComponent --- @tparam component child The druid component instance +---@param self BaseComponent BaseComponent +---@param child component The druid component instance ---@private function M.__remove_child(self, child) for i = #self._meta.children, 1, -1 do @@ -383,7 +383,7 @@ end --- Return all children components, recursive --- @tparam BaseComponent self BaseComponent +---@param self BaseComponent BaseComponent -- @treturn table Array of childrens if the Druid component instance function M.get_childrens(self) local childrens = {} diff --git a/druid/custom/rich_input/rich_input.lua b/druid/custom/rich_input/rich_input.lua index a1f18ab..4831148 100644 --- a/druid/custom/rich_input/rich_input.lua +++ b/druid/custom/rich_input/rich_input.lua @@ -263,8 +263,8 @@ end --- Set placeholder text --- @tparam RichInput self RichInput --- @tparam string placeholder_text The placeholder text +---@param self RichInput RichInput +---@param placeholder_text string The placeholder text function M:set_placeholder(placeholder_text) self.placeholder:set_to(placeholder_text) return self @@ -272,16 +272,16 @@ end --- Select input field --- @tparam RichInput self RichInput +---@param self RichInput RichInput function M:select() self.input:select() end --- Set input field text --- @tparam RichInput self RichInput +---@param self RichInput RichInput -- @treturn druid.input Current input instance --- @tparam string text The input text +---@param text string The input text function M:set_text(text) self.input:set_text(text) gui.set_enabled(self.placeholder.node, true and #self.input:get_text() == 0) @@ -291,8 +291,8 @@ end --- Set input field font --- @tparam RichInput self RichInput --- @tparam hash font The font hash +---@param self RichInput RichInput +---@param font hash The font hash -- @treturn druid.input Current input instance function M:set_font(font) gui.set_font(self.input.text.node, font) @@ -303,7 +303,7 @@ end --- Set input field text --- @tparam RichInput self RichInput +---@param self RichInput RichInput function M:get_text() return self.input:get_text() end @@ -312,8 +312,8 @@ 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 +---@param self RichInput RichInput +---@param characters string Regulax exp. for validate user input -- @treturn RichInput Current instance function M:set_allowed_characters(characters) self.input:set_allowed_characters(characters) diff --git a/druid/custom/rich_text/rich_text.lua b/druid/custom/rich_text/rich_text.lua index e2a2d5c..99719ba 100644 --- a/druid/custom/rich_text/rich_text.lua +++ b/druid/custom/rich_text/rich_text.lua @@ -85,9 +85,9 @@ local M = component.create("rich_text") --- The RichText constructor --- @tparam RichText self RichText --- @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) +---@param self RichText RichText +---@param text_node node|string The text node to make Rich Text +---@param value string|nil The initial text value. Default will be gui.get_text(text_node) function M:init(text_node, value) self.root = self:get_node(text_node) self.text_prefab = self.root @@ -126,8 +126,8 @@ end --- Set text for Rich Text --- @tparam RichText self RichText --- @tparam string|nil text The text to set +---@param self RichText RichText +---@param text string|nil The text to set -- @treturn druid.rich_text.word[] words -- @treturn druid.rich_text.lines_metrics line_metrics -- @usage @@ -189,7 +189,7 @@ end --- Get current text --- @tparam RichText self RichText +---@param self RichText RichText -- @treturn string text function M:get_text() return self._last_value @@ -214,8 +214,8 @@ end --- Get all words, which has a passed tag. --- @tparam RichText self RichText --- @tparam string tag +---@param self RichText RichText +---@param tag string -- @treturn druid.rich_text.word[] words function M:tagged(tag) if not self._words then @@ -227,8 +227,8 @@ end ---Split a word into it's characters --- @tparam RichText self RichText --- @tparam druid.rich_text.word word +---@param self RichText RichText +---@param word druid.rich_text.word -- @treturn druid.rich_text.word[] characters function M:characters(word) return rich_text.characters(word) diff --git a/druid/extended/data_list.lua b/druid/extended/data_list.lua index c81109a..c6b4d55 100644 --- a/druid/extended/data_list.lua +++ b/druid/extended/data_list.lua @@ -56,10 +56,10 @@ local M = component.create("data_list") --- The DataList constructor --- @tparam DataList self DataList --- @tparam Scroll scroll The Scroll 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]) +---@param self DataList DataList +---@param scroll Scroll The Scroll instance for Data List component +---@param grid StaticGrid The StaticGrid} or @{DynamicGrid instance for Data List component +---@param create_function function The create function callback(self, data, index, data_list). Function should return (node, [component]) function M:init(scroll, grid, create_function) self.scroll = scroll self.grid = grid @@ -87,7 +87,7 @@ end --- Druid System on_remove function --- @tparam DataList self DataList +---@param self DataList DataList function M:on_remove() self:clear() self.scroll.on_scroll:unsubscribe(self._refresh, self) @@ -95,8 +95,8 @@ 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 +---@param self DataList DataList +---@param is_use_cache boolean Use cache version of DataList. Requires make setup of components in on_element_add callback and clean in on_element_remove -- @treturn druid.data_list Current DataList instance function M:set_use_cache(is_use_cache) self._is_use_cache = is_use_cache @@ -105,8 +105,8 @@ end --- Set new data set for DataList component --- @tparam DataList self DataList --- @tparam table data The new data array +---@param self DataList DataList +---@param data table The new data array -- @treturn druid.data_list Current DataList instance function M:set_data(data) self._data = data or {} @@ -117,7 +117,7 @@ end --- Return current data from DataList component --- @tparam DataList self DataList +---@param self DataList DataList -- @treturn table The current data array function M:get_data() return self._data @@ -125,10 +125,10 @@ end --- Add element to DataList. Currenly untested --- @tparam DataList self DataList --- @tparam table data --- @tparam number|nil index --- @tparam number|nil shift_policy The constant from const.SHIFT.* +---@param self DataList DataList +---@param data table +---@param index number|nil +---@param shift_policy number|nil The constant from const.SHIFT.* function M:add(data, index, shift_policy) index = index or #self._data + 1 shift_policy = shift_policy or const.SHIFT.RIGHT @@ -139,9 +139,9 @@ end --- Remove element from DataList. Currenly untested --- @tparam DataList self DataList --- @tparam number|nil index --- @tparam number|nil shift_policy The constant from const.SHIFT.* +---@param self DataList DataList +---@param index number|nil +---@param shift_policy number|nil The constant from const.SHIFT.* function M:remove(index, shift_policy) helper.remove_with_shift(self._data, index, shift_policy) self:_refresh() @@ -149,9 +149,9 @@ end --- Remove element from DataList by data value. Currenly untested --- @tparam DataList self DataList --- @tparam table data --- @tparam number|nil shift_policy The constant from const.SHIFT.* +---@param self DataList DataList +---@param data table +---@param shift_policy number|nil The constant from const.SHIFT.* function M:remove_by_data(data, shift_policy) local index = helper.contains(self._data, data) if index then @@ -162,7 +162,7 @@ end --- Clear the DataList and refresh visuals --- @tparam DataList self DataList +---@param self DataList DataList function M:clear() self._data = {} self:_refresh() @@ -170,8 +170,8 @@ end --- Return index for data value --- @tparam DataList self DataList --- @tparam table data +---@param self DataList DataList +---@param data table function M:get_index(data) for index, value in pairs(self._data) do if value == data then @@ -184,7 +184,7 @@ end --- Return all currenly created nodes in DataList --- @tparam DataList self DataList +---@param self DataList DataList -- @treturn node[] List of created nodes function M:get_created_nodes() local nodes = {} @@ -198,7 +198,7 @@ end --- Return all currenly created components in DataList --- @tparam DataList self DataList +---@param self DataList DataList -- @treturn druid.base_component[] List of created nodes function M:get_created_components() local components = {} @@ -212,8 +212,8 @@ end --- Instant scroll to element with passed index --- @tparam DataList self DataList --- @tparam number index +---@param self DataList DataList +---@param index number function M:scroll_to_index(index) local pos = self.grid:get_pos(index) self.scroll:scroll_to(pos) @@ -221,8 +221,8 @@ end --- Add element at passed index using cache or create new --- @tparam DataList self DataList --- @tparam number index +---@param self DataList DataList +---@param index number ---@private function M:_add_at(index) if self._data_visual[index] then @@ -255,8 +255,8 @@ end --- Remove element from passed index and add it to cache if applicable --- @tparam DataList self DataList --- @tparam number index +---@param self DataList DataList +---@param index number ---@private function M:_remove_at(index) self.grid:remove(index, const.SHIFT.NO_SHIFT) @@ -286,7 +286,7 @@ end --- Refresh all elements in DataList --- @tparam DataList self DataList +---@param self DataList DataList ---@private function M:_refresh() self.scroll:set_size(self.grid:get_size_for(#self._data)) diff --git a/druid/extended/hotkey.lua b/druid/extended/hotkey.lua index 5177c5a..2823528 100644 --- a/druid/extended/hotkey.lua +++ b/druid/extended/hotkey.lua @@ -38,10 +38,10 @@ local M = component.create("hotkey") --- 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 any|nil callback_argument The argument to pass into the callback function +---@param self Hotkey Hotkey +---@param keys string[]|string The keys to be pressed for trigger callback. Should contains one key and any modificator keys +---@param callback function The callback function +---@param callback_argument any|nil The argument to pass into the callback function function M:init(keys, callback, callback_argument) self.druid = self:get_druid() @@ -73,9 +73,9 @@ 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 any|nil callback_argument The argument to pass into the callback function +---@param self Hotkey Hotkey +---@param keys string[]|hash[]|string|hash that have to be pressed before key pressed to activate +---@param callback_argument any|nil The argument to pass into the callback function -- @treturn Hotkey Current instance function M:add_hotkey(keys, callback_argument) keys = keys or {} @@ -174,8 +174,8 @@ end --- If true, the callback will be triggered on action.repeated --- @tparam Hotkey self Hotkey --- @tparam bool is_enabled_repeated The flag value +---@param self Hotkey Hotkey +---@param is_enabled_repeated bool The flag value -- @treturn Hotkey function M:set_repeat(is_enabled_repeated) self._is_process_repeated = is_enabled_repeated diff --git a/druid/extended/input.lua b/druid/extended/input.lua index be0c1a5..d60c3b7 100755 --- a/druid/extended/input.lua +++ b/druid/extended/input.lua @@ -109,8 +109,8 @@ M.ALLOWED_ACTIONS = { } --- Mask text by replacing every character with a mask character --- @tparam string text --- @tparam string mask +---@param text string +---@param mask string -- @treturn string Masked text local function mask_text(text, mask) mask = mask or "*" @@ -156,10 +156,10 @@ end --- 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 number|nil keyboard_type Gui keyboard type for input field +---@param self Input Input +---@param click_node node Node to enabled input component +---@param text_node node|Text Text node what will be changed on user input. You can pass text component instead of text node name Text +---@param keyboard_type number|nil Gui keyboard type for input field function M:init(click_node, text_node, keyboard_type) self.druid = self:get_druid() @@ -328,8 +328,8 @@ function M:get_text_selected() end --- Replace selected text with new text --- @tparam Input self Input --- @tparam string text The text to replace selected text +---@param self Input Input +---@param text string The text to replace selected text -- @treturn string New input text function M:get_text_selected_replaced(text) local left_part = utf8.sub(self.value, 1, self.start_index) @@ -346,8 +346,8 @@ end --- Set text for input field --- @tparam Input self Input --- @tparam string input_text The string to apply for input field +---@param self Input Input +---@param input_text string The string to apply for input field function M:set_text(input_text) input_text = tostring(input_text or "") @@ -395,7 +395,7 @@ end --- Select input field. It will show the keyboard and trigger on_select events --- @tparam Input self Input +---@param self Input Input function M:select() gui.reset_keyboard() self.marked_value = "" @@ -420,7 +420,7 @@ end --- Remove selection from input. It will hide the keyboard and trigger on_unselect events --- @tparam Input self Input +---@param self Input Input function M:unselect() gui.reset_keyboard() self.marked_value = "" @@ -439,7 +439,7 @@ end --- Return current input field text --- @tparam Input self Input +---@param self Input Input -- @treturn string The current input field text function M:get_text() if self.marked_value ~= "" then @@ -452,8 +452,8 @@ end --- Set maximum length for input field. -- Pass nil to make input field unliminted (by default) --- @tparam Input self Input --- @tparam number max_length Maximum length for input text field +---@param self Input Input +---@param max_length number Maximum length for input text field -- @treturn druid.input Current input instance function M:set_max_length(max_length) self.max_length = max_length @@ -464,8 +464,8 @@ end --- Set allowed charaters for input field. -- See: https://defold.com/ref/stable/string/ -- ex: [%a%d] for alpha and numeric --- @tparam Input self Input --- @tparam string characters Regulax exp. for validate user input +---@param self Input Input +---@param characters string Regulax exp. for validate user input -- @treturn druid.input Current input instance function M:set_allowed_characters(characters) self.allowed_characters = characters @@ -474,7 +474,7 @@ end --- Reset current input selection and return previous value --- @tparam Input self Input +---@param self Input Input -- @treturn druid.input Current input instance function M:reset_changes() self:set_text(self.previous_value) @@ -484,10 +484,10 @@ 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 +---@param self Input Input +---@param cursor_index number|nil Cursor index for cursor position, if nil - will be set to the end of the text +---@param start_index number|nil Start index for cursor position, if nil - will be set to the end of the text +---@param end_index number|nil End index for cursor position, if nil - will be set to the start_index -- @treturn druid.input Current input instance function M:select_cursor(cursor_index, start_index, end_index) local len = utf8.len(self.value) @@ -507,10 +507,10 @@ 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) +---@param self Input Input +---@param delta number side for cursor position, -1 for left, 1 for right +---@param is_add_to_selection boolean (Shift key) +---@param is_move_to_end boolean (Ctrl key) function M:move_selection(delta, is_add_to_selection, is_move_to_end) local len = utf8.len(self.value) local cursor_index = self.cursor_index diff --git a/druid/extended/lang_text.lua b/druid/extended/lang_text.lua index 2e4c968..ad1ade8 100755 --- a/druid/extended/lang_text.lua +++ b/druid/extended/lang_text.lua @@ -42,10 +42,10 @@ local M = component.create("lang_text") --- The LangText constructor --- @tparam LangText self LangText --- @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 +---@param self LangText LangText +---@param node string|node The node_id or gui.get_node(node_id) +---@param locale_id string|nil Default locale id or text from node as default +---@param adjust_type string|nil Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference function M:init(node, locale_id, adjust_type) self.druid = self:get_druid() self.text = self.druid:new_text(node, locale_id, adjust_type) @@ -69,8 +69,8 @@ end --- Setup raw text to lang_text component --- @tparam LangText self LangText --- @tparam string text Text for text node +---@param self LangText LangText +---@param text string Text for text node -- @treturn LangText Current instance function M:set_to(text) self.last_locale = false @@ -82,15 +82,15 @@ end --- Translate the text by locale_id --- @tparam LangText self LangText --- @tparam string locale_id Locale id --- @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 +---@param self LangText LangText +---@param locale_id string Locale id +---@param a string|nil Optional param to string.format +---@param b string|nil Optional param to string.format +---@param c string|nil Optional param to string.format +---@param d string|nil Optional param to string.format +---@param e string|nil Optional param to string.format +---@param f string|nil Optional param to string.format +---@param g string|nil Optional param to string.format -- @treturn LangText Current instance function M:translate(locale_id, a, b, c, d, e, f, g) self.last_locale_args = { a, b, c, d, e, f, g } @@ -102,14 +102,14 @@ end --- Format string with new text params on localized text --- @tparam LangText self LangText --- @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 +---@param self LangText LangText +---@param a string|nil Optional param to string.format +---@param b string|nil Optional param to string.format +---@param c string|nil Optional param to string.format +---@param d string|nil Optional param to string.format +---@param e string|nil Optional param to string.format +---@param f string|nil Optional param to string.format +---@param g string|nil Optional param to string.format -- @treturn LangText Current instance function M:format(a, b, c, d, e, f, g) self.last_locale_args = { a, b, c, d, e, f, g } diff --git a/druid/extended/progress.lua b/druid/extended/progress.lua index a5061b2..36be55c 100644 --- a/druid/extended/progress.lua +++ b/druid/extended/progress.lua @@ -131,10 +131,10 @@ end --- 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 number|nil init_value Initial value of progress bar. Default: 1 +---@param self Progress Progress +---@param node string|node Node name or GUI Node itself. +---@param key string Progress bar direction: const.SIDE.X or const.SIDE.Y +---@param init_value number|nil Initial value of progress bar. Default: 1 function M:init(node, key, init_value) assert(key == const.SIDE.X or const.SIDE.Y, "Progress bar key should be 'x' or 'y'") @@ -193,22 +193,22 @@ end --- Fill a progress bar and stop progress animation --- @tparam Progress self Progress +---@param self Progress Progress function M:fill() set_bar_to(self, 1, true) end --- Empty a progress bar --- @tparam Progress self Progress +---@param self Progress Progress function M:empty() set_bar_to(self, 0, true) end --- Instant fill progress bar to value --- @tparam Progress self Progress --- @tparam number to Progress bar value, from 0 to 1 +---@param self Progress Progress +---@param to number Progress bar value, from 0 to 1 function M:set_to(to) to = helper.clamp(to, 0, 1) set_bar_to(self, to) @@ -216,16 +216,16 @@ end --- Return current progress bar value --- @tparam Progress self Progress +---@param self Progress Progress function M:get() return self.last_value end --- Set points on progress bar to fire the callback --- @tparam Progress self Progress --- @tparam number[] steps Array of progress bar values --- @tparam function callback Callback on intersect step value +---@param self Progress Progress +---@param steps number[] Array of progress bar values +---@param callback function Callback on intersect step value -- @usage progress:set_steps({0, 0.3, 0.6, 1}, function(self, step) end) function M:set_steps(steps, callback) self.steps = steps @@ -234,9 +234,9 @@ end --- Start animation of a progress bar --- @tparam Progress self Progress --- @tparam number to value between 0..1 --- @tparam function|nil callback Callback on animation ends +---@param self Progress Progress +---@param to number value between 0..1 +---@param callback function|nil Callback on animation ends function M:to(to, callback) to = helper.clamp(to, 0, 1) -- cause of float error @@ -253,8 +253,8 @@ end --- Set progress bar max node size --- @tparam Progress self Progress --- @tparam vector3 max_size The new node maximum (full) size +---@param self Progress Progress +---@param max_size vector3 The new node maximum (full) size -- @treturn Progress Progress function M:set_max_size(max_size) self.max_size[self.key] = max_size[self.key] diff --git a/druid/extended/slider.lua b/druid/extended/slider.lua index 352a630..c302cfc 100644 --- a/druid/extended/slider.lua +++ b/druid/extended/slider.lua @@ -69,10 +69,10 @@ end --- The Slider constructor --- @tparam Slider self Slider --- @tparam node node Gui pin node --- @tparam vector3 end_pos The end position of slider --- @tparam function|nil callback On slider change callback +---@param self Slider Slider +---@param node node Gui pin node +---@param end_pos vector3 The end position of slider +---@param callback function|nil On slider change callback function M:init(node, end_pos, callback) self.node = self:get_node(node) @@ -197,9 +197,9 @@ end --- Set value for slider --- @tparam Slider self Slider --- @tparam number value Value from 0 to 1 --- @tparam boolean|nil is_silent Don't trigger event if true +---@param self Slider Slider +---@param value number Value from 0 to 1 +---@param is_silent boolean|nil Don't trigger event if true function M:set(value, is_silent) value = helper.clamp(value, 0, 1) set_position(self, value) @@ -212,8 +212,8 @@ end --- Set slider steps. Pin node will -- apply closest step position --- @tparam Slider self Slider --- @tparam number[] steps Array of steps +---@param self Slider Slider +---@param steps number[] Array of steps -- @usage slider:set_steps({0, 0.2, 0.6, 1}) -- @treturn Slider Slider function M:set_steps(steps) @@ -226,8 +226,8 @@ end -- User can touch any place of node, pin instantly will -- move at this position and node drag will start. -- This function require the Defold version 1.3.0+ --- @tparam Slider self Slider --- @tparam node|string|nil input_node +---@param self Slider Slider +---@param input_node node|string|nil -- @treturn Slider Slider function M:set_input_node(input_node) self._input_node = self:get_node(input_node) @@ -236,15 +236,15 @@ end --- Set Slider input enabled or disabled --- @tparam Slider self Slider --- @tparam boolean is_enabled +---@param self Slider Slider +---@param is_enabled boolean function M:set_enabled(is_enabled) self._is_enabled = is_enabled end --- Check if Slider component is enabled --- @tparam Slider self Slider +---@param self Slider Slider -- @treturn boolean function M:is_enabled() return self._is_enabled diff --git a/druid/extended/swipe.lua b/druid/extended/swipe.lua index 4c9fc53..ea8010b 100644 --- a/druid/extended/swipe.lua +++ b/druid/extended/swipe.lua @@ -10,10 +10,10 @@ -- @alias druid.swipe --- Swipe node --- @tparam node node +---@param node node --- Restriction zone --- @tparam node|nil click_zone +---@param click_zone node|nil --- Trigger on swipe event(self, swipe_side, dist, delta_time) -- @tfield druid.event on_swipe) druid.event @@ -160,8 +160,8 @@ end --- Strict swipe click area. Useful for -- restrict events outside stencil node --- @tparam Swipe self Swipe --- @tparam node|string|nil zone Gui node +---@param self Swipe Swipe +---@param zone node|string|nil Gui node function M:set_click_zone(zone) self.click_zone = self:get_node(zone) end From b5ccd802159927bceb19bfeb1e31698256088d19 Mon Sep 17 00:00:00 2001 From: Insality Date: Thu, 7 Nov 2024 18:35:06 +0100 Subject: [PATCH 10/50] Replace treturn --- druid/base/hover.lua | 6 +++--- druid/base/scroll.lua | 24 ++++++++++----------- druid/base/static_grid.lua | 30 +++++++++++++------------- druid/base/text.lua | 26 +++++++++++----------- druid/component.lua | 6 +++--- druid/custom/rich_input/rich_input.lua | 6 +++--- druid/custom/rich_text/rich_text.lua | 14 ++++++------ druid/extended/data_list.lua | 10 ++++----- druid/extended/hotkey.lua | 4 ++-- druid/extended/input.lua | 14 ++++++------ druid/extended/lang_text.lua | 6 +++--- druid/extended/progress.lua | 2 +- druid/extended/slider.lua | 6 +++--- 13 files changed, 77 insertions(+), 77 deletions(-) diff --git a/druid/base/hover.lua b/druid/base/hover.lua index 0433432..83883d0 100644 --- a/druid/base/hover.lua +++ b/druid/base/hover.lua @@ -133,7 +133,7 @@ end --- Return current hover state. True if touch action was on the node at current time ---@param self Hover Hover --- @treturn boolean The current hovered state +---@return boolean The current hovered state function M:is_hovered() return self._is_hovered end @@ -158,7 +158,7 @@ end --- Return current hover state. True if nil action_id (usually desktop mouse) was on the node at current time ---@param self Hover Hover --- @treturn boolean The current hovered state +---@return boolean The current hovered state function M:is_mouse_hovered() return self._is_mouse_hovered end @@ -194,7 +194,7 @@ end --- Return current hover enabled state ---@param self Hover Hover --- @treturn boolean The hover enabled state +---@return boolean The hover enabled state function M:is_enabled() return self._is_enabled end diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index d53be7d..b71a06c 100755 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -337,7 +337,7 @@ end --- Return current scroll progress status. -- Values will be in [0..1] interval ---@param self Scroll Scroll --- @treturn vector3 New vector with scroll progress values +---@return vector3 New vector with scroll progress values function M:get_percent() local x_perc = 1 - inverse_lerp(self.available_pos.x, self.available_pos.z, self.position.x) local y_perc = inverse_lerp(self.available_pos.w, self.available_pos.y, self.position.y) @@ -351,7 +351,7 @@ end ---@param self Scroll Scroll ---@param size vector3 The new size for content node ---@param offset vector3|nil Offset value to set, where content is starts --- @treturn druid.scroll Current scroll instance +---@return druid.scroll Current scroll instance function M:set_size(size, offset) if offset then self._offset = offset @@ -366,7 +366,7 @@ end --- Set new scroll view size in case the node size was changed. ---@param self Scroll Scroll ---@param size vector3 The new size for view node --- @treturn druid.scroll Current scroll instance +---@return druid.scroll Current scroll instance function M:set_view_size(size) gui.set_size(self.view_node, size) self.view_size = size @@ -393,7 +393,7 @@ end -- If no points, just simple drag without inertion ---@param self Scroll Scroll ---@param state boolean|nil Inert scroll state --- @treturn druid.scroll Current scroll instance +---@return druid.scroll Current scroll instance function M:set_inert(state) self._is_inert = state @@ -403,7 +403,7 @@ end --- Return if scroll have inertion. ---@param self Scroll Scroll --- @treturn boolean @If scroll have inertion +---@return boolean @If scroll have inertion function M:is_inert() return self._is_inert end @@ -413,7 +413,7 @@ end -- Set 0 to disable stretching effect ---@param self Scroll Scroll ---@param stretch_size number|nil Size in pixels of additional scroll area --- @treturn druid.scroll Current scroll instance +---@return druid.scroll Current scroll instance function M:set_extra_stretch_size(stretch_size) self.style.EXTRA_STRETCH_SIZE = stretch_size or 0 self:_update_size() @@ -424,7 +424,7 @@ end --- Return vector of scroll size with width and height. ---@param self Scroll Scroll --- @treturn vector3 Available scroll size +---@return vector3 Available scroll size function M:get_scroll_size() return self.available_size end @@ -434,7 +434,7 @@ end -- Scroll will always centered on closer points ---@param self Scroll Scroll ---@param points table Array of vector3 points --- @treturn druid.scroll Current scroll instance +---@return druid.scroll Current scroll instance function M:set_points(points) self.points = points @@ -451,7 +451,7 @@ end --- Lock or unlock horizontal scroll ---@param self Scroll Scroll ---@param state boolean|nil True, if horizontal scroll is enabled --- @treturn druid.scroll Current scroll instance +---@return druid.scroll Current scroll instance function M:set_horizontal_scroll(state) self._is_horizontal_scroll = state self.drag.can_x = self.available_size.x > 0 and state @@ -462,7 +462,7 @@ end --- Lock or unlock vertical scroll ---@param self Scroll Scroll ---@param state boolean|nil True, if vertical scroll is enabled --- @treturn druid.scroll Current scroll instance +---@return druid.scroll Current scroll instance function M:set_vertical_scroll(state) self._is_vertical_scroll = state self.drag.can_y = self.available_size.y > 0 and state @@ -474,7 +474,7 @@ end -- Extra border is not affected. Return true for elements in extra scroll zone ---@param self Scroll Scroll ---@param node node The node to check --- @treturn boolean True if node in visible scroll area +---@return boolean True if node in visible scroll area function M:is_node_in_view(node) local node_offset_for_view = gui.get_position(node) local parent = gui.get_parent(node) @@ -515,7 +515,7 @@ end -- scroll size on grid changes ---@param self Scroll Scroll ---@param grid StaticGrid Druid grid component --- @treturn druid.scroll Current scroll instance +---@return druid.scroll Current scroll instance function M:bind_grid(grid) if self._grid_on_change then self._grid_on_change:unsubscribe(self._grid_on_change_callback) diff --git a/druid/base/static_grid.lua b/druid/base/static_grid.lua index 8e7caf3..a7a9533 100644 --- a/druid/base/static_grid.lua +++ b/druid/base/static_grid.lua @@ -167,7 +167,7 @@ local _temp_pos = vmath.vector3(0) --- Return pos for grid node index ---@param self StaticGrid StaticGrid ---@param index number The grid element index --- @treturn vector3 @Node position +---@return vector3 @Node position function M:get_pos(index) local row = math.ceil(index / self.in_row) - 1 local col = (index - row * self.in_row) - 1 @@ -185,7 +185,7 @@ end --- Return index for grid pos ---@param self StaticGrid StaticGrid ---@param pos vector3 The node position in the grid --- @treturn number The node index +---@return number The node index function M:get_index(pos) -- Offset to left-top corner from node pivot local node_offset_x = self.node_size.x * (-0.5 + self.node_pivot.x) @@ -205,7 +205,7 @@ end --- Return grid index by node ---@param self StaticGrid StaticGrid ---@param node node The gui node in the grid --- @treturn number The node index +---@return number The node index function M:get_index_by_node(node) for index, grid_node in pairs(self.nodes) do if node == grid_node then @@ -316,7 +316,7 @@ end ---@param index number The grid node index to remove ---@param shift_policy number|nil How shift nodes, if required. Default: const.SHIFT.RIGHT ---@param is_instant boolean|nil If true, update node positions instantly --- @treturn node The deleted gui node from grid +---@return node The deleted gui node from grid function M:remove(index, shift_policy, is_instant) assert(self.nodes[index], "No grid item at given index " .. index) @@ -334,7 +334,7 @@ end --- Return grid content size ---@param self StaticGrid StaticGrid --- @treturn vector3 The grid content size +---@return vector3 The grid content size function M:get_size() return vmath.vector3( self.border.z - self.border.x, @@ -367,7 +367,7 @@ end --- Return grid content borders ---@param self StaticGrid StaticGrid --- @treturn vector3 The grid content borders +---@return vector3 The grid content borders function M:get_borders() return self.border end @@ -375,7 +375,7 @@ end --- Return array of all node positions ---@param self StaticGrid StaticGrid --- @treturn vector3[] All grid node positions +---@return vector3[] All grid node positions function M:get_all_pos() local result = {} for i, node in pairs(self.nodes) do @@ -390,7 +390,7 @@ end -- update poses on grid elements. Default: gui.set_position ---@param self StaticGrid StaticGrid ---@param callback function Function on node set position --- @treturn druid.static_grid Current grid instance +---@return druid.static_grid Current grid instance function M:set_position_function(callback) self._set_position_function = callback or gui.set_position @@ -401,7 +401,7 @@ end --- Clear grid nodes array. GUI nodes will be not deleted! -- If you want to delete GUI nodes, use static_grid.nodes array before grid:clear ---@param self StaticGrid StaticGrid --- @treturn druid.static_grid Current grid instance +---@return druid.static_grid Current grid instance function M:clear() self.border.x = 0 self.border.y = 0 @@ -420,7 +420,7 @@ end --- Return StaticGrid offset, where StaticGrid content starts. ---@param self StaticGrid StaticGrid The StaticGrid instance --- @treturn vector3 The StaticGrid offset +---@return vector3 The StaticGrid offset function M:get_offset() local borders = self:get_borders() local size = self:get_size() @@ -437,7 +437,7 @@ end --- Set new in_row elements for grid ---@param self StaticGrid StaticGrid ---@param in_row number The new in_row value --- @treturn druid.static_grid Current grid instance +---@return druid.static_grid Current grid instance function M:set_in_row(in_row) self.in_row = in_row self._grid_horizonal_offset = self.node_size.x * (self.in_row - 1) * self.anchor.x @@ -457,7 +457,7 @@ end ---@param self StaticGrid StaticGrid -- @tparam[opt] number width The new node width -- @tparam[opt] number height The new node height --- @treturn druid.static_grid Current grid instance +---@return druid.static_grid Current grid instance function M:set_item_size(width, height) if width then self.node_size.x = width @@ -481,7 +481,7 @@ end --- Sort grid nodes by custom comparator function ---@param self StaticGrid StaticGrid ---@param comparator function The comparator function. (a, b) -> boolean --- @treturn druid.static_grid Current grid instance +---@return druid.static_grid Current grid instance function M:sort_nodes(comparator) table.sort(self.nodes, comparator) self:_update(true) @@ -559,7 +559,7 @@ end --- Return elements offset for correct posing nodes. Correct posing at -- parent pivot node (0:0) with adjusting of node sizes and anchoring --- @treturn vector3 The offset vector +---@return vector3 The offset vector ---@private function M:_get_zero_offset() if not self.style.IS_DYNAMIC_NODE_POSES then @@ -576,7 +576,7 @@ end --- Return offset x for last row in grid. Used to align this row accorting to grid's anchor --- @treturn number The offset x value +---@return number The offset x value ---@private function M:_get_zero_offset_x(row_index) if not self.style.IS_DYNAMIC_NODE_POSES or not self.style.IS_ALIGN_LAST_ROW then diff --git a/druid/base/text.lua b/druid/base/text.lua index 002f7e9..8b7d177 100755 --- a/druid/base/text.lua +++ b/druid/base/text.lua @@ -337,8 +337,8 @@ end --- Calculate text width with font with respect to trailing space ---@param self Text Text ---@param text|nil string --- @treturn number Width --- @treturn number Height +---@return number Width +---@return number Height function M:get_text_size(text) text = text or self.last_value local font_name = gui.get_font(self.node) @@ -362,7 +362,7 @@ end --- Get chars count by width ---@param self Text Text ---@param width number --- @treturn number Chars count +---@return number Chars count function M:get_text_index_by_width(width) local text = self.last_value local font_name = gui.get_font(self.node) @@ -396,7 +396,7 @@ end --- Set text to text field ---@param self Text Text ---@param set_to string Text for node --- @treturn Text Current text instance +---@return Text Current text instance function M:set_to(set_to) set_to = set_to or "" @@ -414,7 +414,7 @@ end --- Set text area size ---@param self Text Text ---@param size vector3 The new text area size --- @treturn Text Current text instance +---@return Text Current text instance function M:set_size(size) self.start_size = size self.text_area = vmath.vector3(size) @@ -427,7 +427,7 @@ end --- Set color ---@param self Text Text ---@param color vector4 Color for node --- @treturn Text Current text instance +---@return Text Current text instance function M:set_color(color) self.color = color gui.set_color(self.node, color) @@ -439,7 +439,7 @@ end --- Set alpha ---@param self Text Text ---@param alpha number Alpha for node --- @treturn Text Current text instance +---@return Text Current text instance function M:set_alpha(alpha) self.color.w = alpha gui.set_color(self.node, self.color) @@ -451,7 +451,7 @@ end --- Set scale ---@param self Text Text ---@param scale vector3 Scale for node --- @treturn Text Current text instance +---@return Text Current text instance function M:set_scale(scale) self.last_scale = scale gui.set_scale(self.node, scale) @@ -463,7 +463,7 @@ end --- Set text pivot. Text will re-anchor inside text area ---@param self Text Text ---@param pivot number The gui.PIVOT_* constant --- @treturn Text Current text instance +---@return Text Current text instance function M:set_pivot(pivot) local prev_pivot = gui.get_pivot(self.node) local prev_offset = const.PIVOTS[prev_pivot] @@ -488,7 +488,7 @@ end --- Return true, if text with line break ---@param self Text Text --- @treturn boolean Is text node with line break +---@return boolean Is text node with line break function M:is_multiline() return gui.get_line_break(self.node) end @@ -498,7 +498,7 @@ end ---@param self Text Text ---@param adjust_type string|nil See const.TEXT_ADJUST. If pass nil - use current adjust type ---@param minimal_scale number|nil If pass nil - not use minimal scale --- @treturn Text Current text instance +---@return Text Current text instance function M:set_text_adjust(adjust_type, minimal_scale) self.adjust_type = adjust_type self._minimal_scale = minimal_scale @@ -511,7 +511,7 @@ end --- Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types ---@param self Text Text ---@param minimal_scale number If pass nil - not use minimal scale --- @treturn Text Current text instance +---@return Text Current text instance function M:set_minimal_scale(minimal_scale) self._minimal_scale = minimal_scale @@ -520,7 +520,7 @@ end --- Return current text adjust type --- @treturn number The current text adjust type +---@return number The current text adjust type function M:get_text_adjust(adjust_type) return self.adjust_type end diff --git a/druid/component.lua b/druid/component.lua index 02fc151..32e859e 100644 --- a/druid/component.lua +++ b/druid/component.lua @@ -283,7 +283,7 @@ end ---@param context table Druid context. Usually it is self of script ---@param style table Druid style module ---@param instance_class table The component instance class --- @treturn component BaseComponent itself +---@return component BaseComponent itself ---@private function M:setup_component(druid_instance, context, style, instance_class) self._meta = { @@ -327,7 +327,7 @@ end --- Get current component interests ---@param self BaseComponent BaseComponent --- @treturn table List of component interests +---@return table List of component interests ---@private function M.__get_interests(self) local instance_class = self._meta.instance_class @@ -384,7 +384,7 @@ end --- Return all children components, recursive ---@param self BaseComponent BaseComponent --- @treturn table Array of childrens if the Druid component instance +---@return table Array of childrens if the Druid component instance function M.get_childrens(self) local childrens = {} diff --git a/druid/custom/rich_input/rich_input.lua b/druid/custom/rich_input/rich_input.lua index 4831148..d93b738 100644 --- a/druid/custom/rich_input/rich_input.lua +++ b/druid/custom/rich_input/rich_input.lua @@ -280,7 +280,7 @@ end --- Set input field text ---@param self RichInput RichInput --- @treturn druid.input Current input instance +---@return druid.input Current input instance ---@param text string The input text function M:set_text(text) self.input:set_text(text) @@ -293,7 +293,7 @@ end --- Set input field font ---@param self RichInput RichInput ---@param font hash The font hash --- @treturn druid.input Current input instance +---@return druid.input Current input instance function M:set_font(font) gui.set_font(self.input.text.node, font) gui.set_font(self.placeholder.node, font) @@ -314,7 +314,7 @@ end -- ex: [%a%d] for alpha and numeric ---@param self RichInput RichInput ---@param characters string Regulax exp. for validate user input --- @treturn RichInput Current instance +---@return RichInput Current instance function M:set_allowed_characters(characters) self.input:set_allowed_characters(characters) diff --git a/druid/custom/rich_text/rich_text.lua b/druid/custom/rich_text/rich_text.lua index 99719ba..6e482ef 100644 --- a/druid/custom/rich_text/rich_text.lua +++ b/druid/custom/rich_text/rich_text.lua @@ -128,8 +128,8 @@ end --- Set text for Rich Text ---@param self RichText RichText ---@param text string|nil The text to set --- @treturn druid.rich_text.word[] words --- @treturn druid.rich_text.lines_metrics line_metrics +---@return druid.rich_text.word[] words +---@return druid.rich_text.lines_metrics line_metrics -- @usage -- • color: Change text color -- @@ -190,7 +190,7 @@ end --- Get current text ---@param self RichText RichText --- @treturn string text +---@return string text function M:get_text() return self._last_value end @@ -216,7 +216,7 @@ end --- Get all words, which has a passed tag. ---@param self RichText RichText ---@param tag string --- @treturn druid.rich_text.word[] words +---@return druid.rich_text.word[] words function M:tagged(tag) if not self._words then return @@ -229,21 +229,21 @@ end ---Split a word into it's characters ---@param self RichText RichText ---@param word druid.rich_text.word --- @treturn druid.rich_text.word[] characters +---@return druid.rich_text.word[] characters function M:characters(word) return rich_text.characters(word) end --- Get all current words. --- @treturn table druid.rich_text.word[] +---@return table druid.rich_text.word[] function M:get_words() return self._words end --- Get current line metrics ---- @treturn druid.rich_text.lines_metrics +----@return druid.rich_text.lines_metrics function M:get_line_metric() return self._line_metrics end diff --git a/druid/extended/data_list.lua b/druid/extended/data_list.lua index c6b4d55..995753c 100644 --- a/druid/extended/data_list.lua +++ b/druid/extended/data_list.lua @@ -97,7 +97,7 @@ end --- Set refresh function for DataList component ---@param self DataList DataList ---@param is_use_cache boolean Use cache version of DataList. Requires make setup of components in on_element_add callback and clean in on_element_remove --- @treturn druid.data_list Current DataList instance +---@return druid.data_list Current DataList instance function M:set_use_cache(is_use_cache) self._is_use_cache = is_use_cache return self @@ -107,7 +107,7 @@ end --- Set new data set for DataList component ---@param self DataList DataList ---@param data table The new data array --- @treturn druid.data_list Current DataList instance +---@return druid.data_list Current DataList instance function M:set_data(data) self._data = data or {} self:_refresh() @@ -118,7 +118,7 @@ end --- Return current data from DataList component ---@param self DataList DataList --- @treturn table The current data array +---@return table The current data array function M:get_data() return self._data end @@ -185,7 +185,7 @@ end --- Return all currenly created nodes in DataList ---@param self DataList DataList --- @treturn node[] List of created nodes +---@return node[] List of created nodes function M:get_created_nodes() local nodes = {} @@ -199,7 +199,7 @@ end --- Return all currenly created components in DataList ---@param self DataList DataList --- @treturn druid.base_component[] List of created nodes +---@return druid.base_component[] List of created nodes function M:get_created_components() local components = {} diff --git a/druid/extended/hotkey.lua b/druid/extended/hotkey.lua index 2823528..3564f7c 100644 --- a/druid/extended/hotkey.lua +++ b/druid/extended/hotkey.lua @@ -76,7 +76,7 @@ end ---@param self Hotkey Hotkey ---@param keys string[]|hash[]|string|hash that have to be pressed before key pressed to activate ---@param callback_argument any|nil The argument to pass into the callback function --- @treturn Hotkey Current instance +---@return Hotkey Current instance function M:add_hotkey(keys, callback_argument) keys = keys or {} if type(keys) == "string" then @@ -176,7 +176,7 @@ end --- If true, the callback will be triggered on action.repeated ---@param self Hotkey Hotkey ---@param is_enabled_repeated bool The flag value --- @treturn Hotkey +---@return Hotkey function M:set_repeat(is_enabled_repeated) self._is_process_repeated = is_enabled_repeated return self diff --git a/druid/extended/input.lua b/druid/extended/input.lua index d60c3b7..21f3f90 100755 --- a/druid/extended/input.lua +++ b/druid/extended/input.lua @@ -111,7 +111,7 @@ M.ALLOWED_ACTIONS = { --- Mask text by replacing every character with a mask character ---@param text string ---@param mask string --- @treturn string Masked text +---@return string Masked text local function mask_text(text, mask) mask = mask or "*" local masked_text = "" @@ -330,7 +330,7 @@ end --- Replace selected text with new text ---@param self Input Input ---@param text string The text to replace selected text --- @treturn string New input text +---@return string New input text function M:get_text_selected_replaced(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)) @@ -440,7 +440,7 @@ end --- Return current input field text ---@param self Input Input --- @treturn string The current input field text +---@return string The current input field text function M:get_text() if self.marked_value ~= "" then return self.value .. self.marked_value @@ -454,7 +454,7 @@ end -- Pass nil to make input field unliminted (by default) ---@param self Input Input ---@param max_length number Maximum length for input text field --- @treturn druid.input Current input instance +---@return druid.input Current input instance function M:set_max_length(max_length) self.max_length = max_length return self @@ -466,7 +466,7 @@ end -- ex: [%a%d] for alpha and numeric ---@param self Input Input ---@param characters string Regulax exp. for validate user input --- @treturn druid.input Current input instance +---@return druid.input Current input instance function M:set_allowed_characters(characters) self.allowed_characters = characters return self @@ -475,7 +475,7 @@ end --- Reset current input selection and return previous value ---@param self Input Input --- @treturn druid.input Current input instance +---@return druid.input Current input instance function M:reset_changes() self:set_text(self.previous_value) self:unselect() @@ -488,7 +488,7 @@ end ---@param cursor_index number|nil Cursor index for cursor position, if nil - will be set to the end of the text ---@param start_index number|nil Start index for cursor position, if nil - will be set to the end of the text ---@param end_index number|nil End index for cursor position, if nil - will be set to the start_index --- @treturn druid.input Current input instance +---@return druid.input Current input instance function M:select_cursor(cursor_index, start_index, end_index) local len = utf8.len(self.value) diff --git a/druid/extended/lang_text.lua b/druid/extended/lang_text.lua index ad1ade8..f326f7b 100755 --- a/druid/extended/lang_text.lua +++ b/druid/extended/lang_text.lua @@ -71,7 +71,7 @@ end --- Setup raw text to lang_text component ---@param self LangText LangText ---@param text string Text for text node --- @treturn LangText Current instance +---@return LangText Current instance function M:set_to(text) self.last_locale = false self.text:set_to(text) @@ -91,7 +91,7 @@ end ---@param e string|nil Optional param to string.format ---@param f string|nil Optional param to string.format ---@param g string|nil Optional param to string.format --- @treturn LangText Current instance +---@return LangText Current instance function M:translate(locale_id, a, b, c, d, e, f, g) self.last_locale_args = { a, b, c, d, e, f, g } self.last_locale = locale_id or self.last_locale @@ -110,7 +110,7 @@ end ---@param e string|nil Optional param to string.format ---@param f string|nil Optional param to string.format ---@param g string|nil Optional param to string.format --- @treturn LangText Current instance +---@return LangText Current instance function M:format(a, b, c, d, e, f, g) self.last_locale_args = { a, b, c, d, e, f, g } self.text:set_to(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "") diff --git a/druid/extended/progress.lua b/druid/extended/progress.lua index 36be55c..90c61fc 100644 --- a/druid/extended/progress.lua +++ b/druid/extended/progress.lua @@ -255,7 +255,7 @@ end --- Set progress bar max node size ---@param self Progress Progress ---@param max_size vector3 The new node maximum (full) size --- @treturn Progress Progress +---@return Progress Progress function M:set_max_size(max_size) self.max_size[self.key] = max_size[self.key] self:set_to(self.last_value) diff --git a/druid/extended/slider.lua b/druid/extended/slider.lua index c302cfc..67904b5 100644 --- a/druid/extended/slider.lua +++ b/druid/extended/slider.lua @@ -215,7 +215,7 @@ end ---@param self Slider Slider ---@param steps number[] Array of steps -- @usage slider:set_steps({0, 0.2, 0.6, 1}) --- @treturn Slider Slider +---@return Slider Slider function M:set_steps(steps) self.steps = steps return self @@ -228,7 +228,7 @@ end -- This function require the Defold version 1.3.0+ ---@param self Slider Slider ---@param input_node node|string|nil --- @treturn Slider Slider +---@return Slider Slider function M:set_input_node(input_node) self._input_node = self:get_node(input_node) return self @@ -245,7 +245,7 @@ end --- Check if Slider component is enabled ---@param self Slider Slider --- @treturn boolean +---@return boolean function M:is_enabled() return self._is_enabled end From 56ef92a1b541d6a7f0fbbde14b92b9b5989b5205 Mon Sep 17 00:00:00 2001 From: Insality Date: Sun, 10 Nov 2024 20:34:30 +0100 Subject: [PATCH 11/50] Update annotations --- druid/base/hover.lua | 8 ---- druid/base/scroll.lua | 20 +------- druid/base/static_grid.lua | 22 --------- druid/base/text.lua | 12 ----- druid/component.lua | 53 ++++++++-------------- druid/custom/rich_input/rich_input.lua | 6 --- druid/custom/rich_text/rich_text.lua | 5 -- druid/extended/data_list.lua | 16 ------- druid/extended/hotkey.lua | 3 -- druid/extended/input.lua | 11 ----- druid/extended/lang_text.lua | 4 -- druid/extended/progress.lua | 8 ---- druid/extended/slider.lua | 6 --- druid/extended/swipe.lua | 1 - druid/extended/timer.lua | 3 -- example/components/container/container.lua | 1 - 16 files changed, 21 insertions(+), 158 deletions(-) diff --git a/druid/base/hover.lua b/druid/base/hover.lua index 83883d0..b157fbb 100644 --- a/druid/base/hover.lua +++ b/druid/base/hover.lua @@ -35,7 +35,6 @@ local M = component.create("hover") --- The Hover constructor ----@param self Hover Hover ---@param node node Gui node ---@param on_hover_callback function Hover callback ---@param on_mouse_hover function On mouse hover callback @@ -115,7 +114,6 @@ end --- Set hover state ----@param self Hover Hover ---@param state boolean|nil The hover state function M:set_hover(state) if self._is_hovered == state then @@ -132,7 +130,6 @@ end --- Return current hover state. True if touch action was on the node at current time ----@param self Hover Hover ---@return boolean The current hovered state function M:is_hovered() return self._is_hovered @@ -140,7 +137,6 @@ end --- Set mouse hover state ----@param self Hover Hover ---@param state boolean|nil The mouse hover state function M:set_mouse_hover(state) if self._is_mouse_hovered == state then @@ -157,7 +153,6 @@ end --- Return current hover state. True if nil action_id (usually desktop mouse) was on the node at current time ----@param self Hover Hover ---@return boolean The current hovered state function M:is_mouse_hovered() return self._is_mouse_hovered @@ -166,7 +161,6 @@ end --- Strict hover click area. Useful for -- no click events outside stencil node ----@param self Hover Hover ---@param zone node|string|nil Gui node function M:set_click_zone(zone) self.click_zone = self:get_node(zone) @@ -176,7 +170,6 @@ end --- Set enable state of hover component. -- If hover is not enabled, it will not generate -- any hover events ----@param self Hover Hover ---@param state boolean|nil The hover enabled state function M:set_enabled(state) self._is_enabled = state @@ -193,7 +186,6 @@ end --- Return current hover enabled state ----@param self Hover Hover ---@return boolean The hover enabled state function M:is_enabled() return self._is_enabled diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index b71a06c..55f632a 100755 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -171,7 +171,6 @@ end --- The Scroll constructor ----@param self Scroll Scroll ---@param view_node string|node GUI view scroll node ---@param content_node string|node GUI content scroll node function M:init(view_node, content_node) @@ -253,7 +252,6 @@ end --- Start scroll to target point. ----@param self Scroll Scroll ---@param point vector3 Target point ---@param is_instant boolean|nil Instant scroll flag -- @usage scroll:scroll_to(vmath.vector3(0, 50, 0)) @@ -287,7 +285,6 @@ end --- Scroll to item in scroll by point index. ----@param self Scroll Scroll ---@param index number Point index ---@param skip_cb boolean|nil If true, skip the point callback function M:scroll_to_index(index, skip_cb) @@ -310,7 +307,6 @@ end --- Start scroll to target scroll percent ----@param self Scroll Scroll ---@param percent vector3 target percent ---@param is_instant boolean|nil instant scroll flag -- @usage scroll:scroll_to_percent(vmath.vector3(0.5, 0, 0)) @@ -336,7 +332,6 @@ end --- Return current scroll progress status. -- Values will be in [0..1] interval ----@param self Scroll Scroll ---@return vector3 New vector with scroll progress values function M:get_percent() local x_perc = 1 - inverse_lerp(self.available_pos.x, self.available_pos.z, self.position.x) @@ -348,7 +343,6 @@ end --- Set scroll content size. -- It will change content gui node size ----@param self Scroll Scroll ---@param size vector3 The new size for content node ---@param offset vector3|nil Offset value to set, where content is starts ---@return druid.scroll Current scroll instance @@ -364,7 +358,6 @@ end --- Set new scroll view size in case the node size was changed. ----@param self Scroll Scroll ---@param size vector3 The new size for view node ---@return druid.scroll Current scroll instance function M:set_view_size(size) @@ -378,7 +371,6 @@ end --- Refresh scroll view size ----@param self Scroll Scroll function M:update_view_size() self.view_size = helper.get_scaled_size(self.view_node) self.view_border = helper.get_border(self.view_node) @@ -391,7 +383,6 @@ end --- Enable or disable scroll inert. -- If disabled, scroll through points (if exist) -- If no points, just simple drag without inertion ----@param self Scroll Scroll ---@param state boolean|nil Inert scroll state ---@return druid.scroll Current scroll instance function M:set_inert(state) @@ -402,7 +393,6 @@ end --- Return if scroll have inertion. ----@param self Scroll Scroll ---@return boolean @If scroll have inertion function M:is_inert() return self._is_inert @@ -411,7 +401,6 @@ end --- Set extra size for scroll stretching. -- Set 0 to disable stretching effect ----@param self Scroll Scroll ---@param stretch_size number|nil Size in pixels of additional scroll area ---@return druid.scroll Current scroll instance function M:set_extra_stretch_size(stretch_size) @@ -423,7 +412,6 @@ end --- Return vector of scroll size with width and height. ----@param self Scroll Scroll ---@return vector3 Available scroll size function M:get_scroll_size() return self.available_size @@ -432,7 +420,6 @@ end --- Set points of interest. -- Scroll will always centered on closer points ----@param self Scroll Scroll ---@param points table Array of vector3 points ---@return druid.scroll Current scroll instance function M:set_points(points) @@ -449,7 +436,6 @@ end --- Lock or unlock horizontal scroll ----@param self Scroll Scroll ---@param state boolean|nil True, if horizontal scroll is enabled ---@return druid.scroll Current scroll instance function M:set_horizontal_scroll(state) @@ -460,7 +446,6 @@ end --- Lock or unlock vertical scroll ----@param self Scroll Scroll ---@param state boolean|nil True, if vertical scroll is enabled ---@return druid.scroll Current scroll instance function M:set_vertical_scroll(state) @@ -472,7 +457,6 @@ end --- Check node if it visible now on scroll. -- Extra border is not affected. Return true for elements in extra scroll zone ----@param self Scroll Scroll ---@param node node The node to check ---@return boolean True if node in visible scroll area function M:is_node_in_view(node) @@ -513,8 +497,7 @@ end --- Bind the grid component (Static or Dynamic) to recalculate -- scroll size on grid changes ----@param self Scroll Scroll ----@param grid StaticGrid Druid grid component +---@param grid druid.grid Druid grid component ---@return druid.scroll Current scroll instance function M:bind_grid(grid) if self._grid_on_change then @@ -542,7 +525,6 @@ end --- Strict drag scroll area. Useful for -- restrict events outside stencil node ----@param self Drag ---@param node node|string Gui node function M:set_click_zone(node) self.drag:set_click_zone(node) diff --git a/druid/base/static_grid.lua b/druid/base/static_grid.lua index a7a9533..51589f4 100644 --- a/druid/base/static_grid.lua +++ b/druid/base/static_grid.lua @@ -128,7 +128,6 @@ end --- The StaticGrid constructor ----@param self StaticGrid StaticGrid ---@param parent string|node The GUI Node container, where grid's items will be placed ---@param element node Element prefab. Need to get it size ---@param in_row number|nil How many nodes in row can be placed. By default 1 @@ -165,7 +164,6 @@ end local _temp_pos = vmath.vector3(0) --- Return pos for grid node index ----@param self StaticGrid StaticGrid ---@param index number The grid element index ---@return vector3 @Node position function M:get_pos(index) @@ -183,7 +181,6 @@ end --- Return index for grid pos ----@param self StaticGrid StaticGrid ---@param pos vector3 The node position in the grid ---@return number The node index function M:get_index(pos) @@ -203,7 +200,6 @@ end --- Return grid index by node ----@param self StaticGrid StaticGrid ---@param node node The gui node in the grid ---@return number The node index function M:get_index_by_node(node) @@ -223,7 +219,6 @@ end --- Set grid anchor. Default anchor is equal to anchor of grid parent node ----@param self StaticGrid StaticGrid ---@param anchor vector3 Anchor function M:set_anchor(anchor) self.anchor = anchor @@ -232,7 +227,6 @@ end --- Update grid content ----@param self StaticGrid StaticGrid function M:refresh() self:_update(true) end @@ -270,7 +264,6 @@ end --- Add new item to the grid ----@param self StaticGrid StaticGrid ---@param item node GUI node ---@param index number|nil The item position. By default add as last item ---@param shift_policy number|nil How shift nodes, if required. Default: const.SHIFT.RIGHT @@ -295,7 +288,6 @@ end --- Set new items to the grid. All previous items will be removed ----@param self StaticGrid StaticGrid ---@param nodes node[] The new grid nodes -- @tparam[opt=false] boolean is_instant If true, update node positions instantly function M:set_items(nodes, is_instant) @@ -312,7 +304,6 @@ end --- Remove the item from the grid. Note that gui node will be not deleted ----@param self StaticGrid StaticGrid ---@param index number The grid node index to remove ---@param shift_policy number|nil How shift nodes, if required. Default: const.SHIFT.RIGHT ---@param is_instant boolean|nil If true, update node positions instantly @@ -333,7 +324,6 @@ end --- Return grid content size ----@param self StaticGrid StaticGrid ---@return vector3 The grid content size function M:get_size() return vmath.vector3( @@ -366,7 +356,6 @@ end --- Return grid content borders ----@param self StaticGrid StaticGrid ---@return vector3 The grid content borders function M:get_borders() return self.border @@ -374,7 +363,6 @@ end --- Return array of all node positions ----@param self StaticGrid StaticGrid ---@return vector3[] All grid node positions function M:get_all_pos() local result = {} @@ -388,7 +376,6 @@ end --- Change set position function for grid nodes. It will call on -- update poses on grid elements. Default: gui.set_position ----@param self StaticGrid StaticGrid ---@param callback function Function on node set position ---@return druid.static_grid Current grid instance function M:set_position_function(callback) @@ -400,7 +387,6 @@ end --- Clear grid nodes array. GUI nodes will be not deleted! -- If you want to delete GUI nodes, use static_grid.nodes array before grid:clear ----@param self StaticGrid StaticGrid ---@return druid.static_grid Current grid instance function M:clear() self.border.x = 0 @@ -419,7 +405,6 @@ end --- Return StaticGrid offset, where StaticGrid content starts. ----@param self StaticGrid StaticGrid The StaticGrid instance ---@return vector3 The StaticGrid offset function M:get_offset() local borders = self:get_borders() @@ -435,7 +420,6 @@ end --- Set new in_row elements for grid ----@param self StaticGrid StaticGrid ---@param in_row number The new in_row value ---@return druid.static_grid Current grid instance function M:set_in_row(in_row) @@ -454,7 +438,6 @@ end --- Set new node size for grid ----@param self StaticGrid StaticGrid -- @tparam[opt] number width The new node width -- @tparam[opt] number height The new node height ---@return druid.static_grid Current grid instance @@ -479,7 +462,6 @@ end --- Sort grid nodes by custom comparator function ----@param self StaticGrid StaticGrid ---@param comparator function The comparator function. (a, b) -> boolean ---@return druid.static_grid Current grid instance function M:sort_nodes(comparator) @@ -489,7 +471,6 @@ end --- Update grid inner state ----@param self StaticGrid StaticGrid ---@param is_instant boolean|nil If true, node position update instantly, otherwise with set_position_function callback ---@private function M:_update(is_instant) @@ -500,7 +481,6 @@ end --- Update first and last indexes of grid nodes ----@param self StaticGrid StaticGrid ---@private function M:_update_indexes() self.first_index = nil @@ -516,7 +496,6 @@ end --- Update grid content borders, recalculate min and max values ----@param self StaticGrid StaticGrid ---@private function M:_update_borders() if not self.first_index then @@ -535,7 +514,6 @@ end --- Update grid nodes position ----@param self StaticGrid StaticGrid ---@param is_instant boolean|nil If true, node position update instantly, otherwise with set_position_function callback ---@private function M:_update_pos(is_instant) diff --git a/druid/base/text.lua b/druid/base/text.lua index 8b7d177..f00b506 100755 --- a/druid/base/text.lua +++ b/druid/base/text.lua @@ -288,7 +288,6 @@ end --- The Text constructor ----@param self Text Text ---@param node string|node Node name or GUI Text Node itself ---@param value string|nil Initial text. Default value is node text from GUI scene. Default: nil ---@param adjust_type string|nil Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference. Default: DOWNSCALE @@ -335,7 +334,6 @@ end --- Calculate text width with font with respect to trailing space ----@param self Text Text ---@param text|nil string ---@return number Width ---@return number Height @@ -360,7 +358,6 @@ end --- Get chars count by width ----@param self Text Text ---@param width number ---@return number Chars count function M:get_text_index_by_width(width) @@ -394,7 +391,6 @@ end --- Set text to text field ----@param self Text Text ---@param set_to string Text for node ---@return Text Current text instance function M:set_to(set_to) @@ -412,7 +408,6 @@ end --- Set text area size ----@param self Text Text ---@param size vector3 The new text area size ---@return Text Current text instance function M:set_size(size) @@ -425,7 +420,6 @@ end --- Set color ----@param self Text Text ---@param color vector4 Color for node ---@return Text Current text instance function M:set_color(color) @@ -437,7 +431,6 @@ end --- Set alpha ----@param self Text Text ---@param alpha number Alpha for node ---@return Text Current text instance function M:set_alpha(alpha) @@ -449,7 +442,6 @@ end --- Set scale ----@param self Text Text ---@param scale vector3 Scale for node ---@return Text Current text instance function M:set_scale(scale) @@ -461,7 +453,6 @@ end --- Set text pivot. Text will re-anchor inside text area ----@param self Text Text ---@param pivot number The gui.PIVOT_* constant ---@return Text Current text instance function M:set_pivot(pivot) @@ -487,7 +478,6 @@ end --- Return true, if text with line break ----@param self Text Text ---@return boolean Is text node with line break function M:is_multiline() return gui.get_line_break(self.node) @@ -495,7 +485,6 @@ end --- Set text adjust, refresh the current text visuals, if needed ----@param self Text Text ---@param adjust_type string|nil See const.TEXT_ADJUST. If pass nil - use current adjust type ---@param minimal_scale number|nil If pass nil - not use minimal scale ---@return Text Current text instance @@ -509,7 +498,6 @@ end --- Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types ----@param self Text Text ---@param minimal_scale number If pass nil - not use minimal scale ---@return Text Current text instance function M:set_minimal_scale(minimal_scale) diff --git a/druid/component.lua b/druid/component.lua index 32e859e..37e12ce 100644 --- a/druid/component.lua +++ b/druid/component.lua @@ -90,7 +90,7 @@ end ---@param self T ---@param druid_style table|nil ---@return T self The component itself for chaining -function M.set_style(self, druid_style) +function M:set_style(druid_style) ---@cast self druid.base_component self._meta.style = druid_style or {} @@ -111,7 +111,7 @@ end ---@param self T ---@param template string|nil ---@return T self The component itself for chaining -function M.set_template(self, template) +function M:set_template(template) ---@cast self druid.base_component template = template or "" @@ -142,7 +142,7 @@ end ---Set current component nodes, returned from `gui.clone_tree` function. ---@param nodes table ---@return druid.base_component -function M.set_nodes(self, nodes) +function M:set_nodes(nodes) self._meta.nodes = nodes return self end @@ -150,7 +150,7 @@ end ---Return current component context ---@return any context Usually it's self of script but can be any other Druid component -function M.get_context(self) +function M:get_context() return self._meta.context end @@ -158,15 +158,8 @@ end ---Get component node by node_id. Respect to current template and nodes. ---@param node_id string|node ---@return node -function M.get_node(self, node_id) - if type(node_id) ~= "string" then - -- Assume it's already node from gui.get_node - return node_id - end - - local template_name = self:get_template() - local nodes = self:get_nodes() - return helper.get_node(node_id, template_name, nodes) +function M:get_node(node_id) + return helper.get_node(node_id, self:get_template(), self:get_nodes()) end @@ -192,14 +185,14 @@ end ---Get component name ---@return string name The component name + uid -function M.get_name(self) +function M:get_name() return self._component.name .. M.create_uid() end ---Get parent component name ---@return string|nil parent_name The parent component name if exist or nil -function M.get_parent_name(self) +function M:get_parent_name() local parent = self:get_parent_component() return parent and parent:get_name() end @@ -207,7 +200,7 @@ end ---Get component input priority, the bigger number processed first. Default value: 10 ---@return number -function M.get_input_priority(self) +function M:get_input_priority() return self._component.input_priority end @@ -216,7 +209,7 @@ end ---@param value number ---@param is_temporary boolean|nil If true, the reset input priority will return to previous value ---@return druid.base_component self The component itself for chaining -function M.set_input_priority(self, value, is_temporary) +function M:set_input_priority(value, is_temporary) assert(value) if self._component.input_priority == value then @@ -241,7 +234,7 @@ end ---Reset component input priority to it's default value, that was set in `create` function or `set_input_priority` ---@return druid.base_component self The component itself for chaining -function M.reset_input_priority(self) +function M:reset_input_priority() self:set_input_priority(self._component.default_input_priority) return self end @@ -249,7 +242,7 @@ end ---Get component UID, unique identifier created in component creation order. ---@return number uid The component uid -function M.get_uid(self) +function M:get_uid() return self._component._uid end @@ -259,7 +252,7 @@ end ---Recursive for all children components. ---@param state boolean ---@return druid.base_component self The component itself for chaining -function M.set_input_enabled(self, state) +function M:set_input_enabled(state) self._meta.input_enabled = state for index = 1, #self._meta.children do @@ -272,13 +265,12 @@ end ---Get parent component ---@return druid.base_component|nil parent The parent component if exist or nil -function M.get_parent_component(self) +function M:get_parent_component() return self._meta.parent end --- Setup component context and his style table ----@param self BaseComponent BaseComponent ---@param druid_instance table The parent druid instance ---@param context table Druid context. Usually it is self of script ---@param style table Druid style module @@ -310,26 +302,23 @@ end --- Return true, if input priority was changed ----@param self BaseComponent BaseComponent ---@private -function M._is_input_priority_changed(self) +function M:_is_input_priority_changed() return self._component._is_input_priority_changed end --- Reset is_input_priority_changed field ----@param self BaseComponent BaseComponent ---@private -function M._reset_input_priority_changed(self) +function M:_reset_input_priority_changed() self._component._is_input_priority_changed = false end --- Get current component interests ----@param self BaseComponent BaseComponent ---@return table List of component interests ---@private -function M.__get_interests(self) +function M:__get_interests() local instance_class = self._meta.instance_class if INTERESTS[instance_class] then return INTERESTS[instance_class] @@ -350,7 +339,7 @@ end ---Get current component nodes ---@return table -function M.get_nodes(self) +function M:get_nodes() local nodes = self._meta.nodes local parent = self:get_parent_component() if parent then @@ -369,10 +358,9 @@ end --- Remove child from component children list ----@param self BaseComponent BaseComponent ---@param child component The druid component instance ---@private -function M.__remove_child(self, child) +function M:__remove_child(child) for i = #self._meta.children, 1, -1 do if self._meta.children[i] == child then table.remove(self._meta.children, i) @@ -383,9 +371,8 @@ end --- Return all children components, recursive ----@param self BaseComponent BaseComponent ---@return table Array of childrens if the Druid component instance -function M.get_childrens(self) +function M:get_childrens() local childrens = {} for i = 1, #self._meta.children do diff --git a/druid/custom/rich_input/rich_input.lua b/druid/custom/rich_input/rich_input.lua index d93b738..36f9491 100644 --- a/druid/custom/rich_input/rich_input.lua +++ b/druid/custom/rich_input/rich_input.lua @@ -263,7 +263,6 @@ end --- Set placeholder text ----@param self RichInput RichInput ---@param placeholder_text string The placeholder text function M:set_placeholder(placeholder_text) self.placeholder:set_to(placeholder_text) @@ -272,14 +271,12 @@ end --- Select input field ----@param self RichInput RichInput function M:select() self.input:select() end --- Set input field text ----@param self RichInput RichInput ---@return druid.input Current input instance ---@param text string The input text function M:set_text(text) @@ -291,7 +288,6 @@ end --- Set input field font ----@param self RichInput RichInput ---@param font hash The font hash ---@return druid.input Current input instance function M:set_font(font) @@ -303,7 +299,6 @@ end --- Set input field text ----@param self RichInput RichInput function M:get_text() return self.input:get_text() end @@ -312,7 +307,6 @@ end --- Set allowed charaters for input field. -- See: https://defold.com/ref/stable/string/ -- ex: [%a%d] for alpha and numeric ----@param self RichInput RichInput ---@param characters string Regulax exp. for validate user input ---@return RichInput Current instance function M:set_allowed_characters(characters) diff --git a/druid/custom/rich_text/rich_text.lua b/druid/custom/rich_text/rich_text.lua index 6e482ef..e36b67a 100644 --- a/druid/custom/rich_text/rich_text.lua +++ b/druid/custom/rich_text/rich_text.lua @@ -85,7 +85,6 @@ local M = component.create("rich_text") --- The RichText constructor ----@param self RichText RichText ---@param text_node node|string The text node to make Rich Text ---@param value string|nil The initial text value. Default will be gui.get_text(text_node) function M:init(text_node, value) @@ -126,7 +125,6 @@ end --- Set text for Rich Text ----@param self RichText RichText ---@param text string|nil The text to set ---@return druid.rich_text.word[] words ---@return druid.rich_text.lines_metrics line_metrics @@ -189,7 +187,6 @@ end --- Get current text ----@param self RichText RichText ---@return string text function M:get_text() return self._last_value @@ -214,7 +211,6 @@ end --- Get all words, which has a passed tag. ----@param self RichText RichText ---@param tag string ---@return druid.rich_text.word[] words function M:tagged(tag) @@ -227,7 +223,6 @@ end ---Split a word into it's characters ----@param self RichText RichText ---@param word druid.rich_text.word ---@return druid.rich_text.word[] characters function M:characters(word) diff --git a/druid/extended/data_list.lua b/druid/extended/data_list.lua index 995753c..b6bb1a4 100644 --- a/druid/extended/data_list.lua +++ b/druid/extended/data_list.lua @@ -56,7 +56,6 @@ local M = component.create("data_list") --- The DataList constructor ----@param self DataList DataList ---@param scroll Scroll The Scroll instance for Data List component ---@param grid StaticGrid The StaticGrid} or @{DynamicGrid instance for Data List component ---@param create_function function The create function callback(self, data, index, data_list). Function should return (node, [component]) @@ -87,7 +86,6 @@ end --- Druid System on_remove function ----@param self DataList DataList function M:on_remove() self:clear() self.scroll.on_scroll:unsubscribe(self._refresh, self) @@ -95,7 +93,6 @@ end --- Set refresh function for DataList component ----@param self DataList DataList ---@param is_use_cache boolean Use cache version of DataList. Requires make setup of components in on_element_add callback and clean in on_element_remove ---@return druid.data_list Current DataList instance function M:set_use_cache(is_use_cache) @@ -105,7 +102,6 @@ end --- Set new data set for DataList component ----@param self DataList DataList ---@param data table The new data array ---@return druid.data_list Current DataList instance function M:set_data(data) @@ -117,7 +113,6 @@ end --- Return current data from DataList component ----@param self DataList DataList ---@return table The current data array function M:get_data() return self._data @@ -125,7 +120,6 @@ end --- Add element to DataList. Currenly untested ----@param self DataList DataList ---@param data table ---@param index number|nil ---@param shift_policy number|nil The constant from const.SHIFT.* @@ -139,7 +133,6 @@ end --- Remove element from DataList. Currenly untested ----@param self DataList DataList ---@param index number|nil ---@param shift_policy number|nil The constant from const.SHIFT.* function M:remove(index, shift_policy) @@ -149,7 +142,6 @@ end --- Remove element from DataList by data value. Currenly untested ----@param self DataList DataList ---@param data table ---@param shift_policy number|nil The constant from const.SHIFT.* function M:remove_by_data(data, shift_policy) @@ -162,7 +154,6 @@ end --- Clear the DataList and refresh visuals ----@param self DataList DataList function M:clear() self._data = {} self:_refresh() @@ -170,7 +161,6 @@ end --- Return index for data value ----@param self DataList DataList ---@param data table function M:get_index(data) for index, value in pairs(self._data) do @@ -184,7 +174,6 @@ end --- Return all currenly created nodes in DataList ----@param self DataList DataList ---@return node[] List of created nodes function M:get_created_nodes() local nodes = {} @@ -198,7 +187,6 @@ end --- Return all currenly created components in DataList ----@param self DataList DataList ---@return druid.base_component[] List of created nodes function M:get_created_components() local components = {} @@ -212,7 +200,6 @@ end --- Instant scroll to element with passed index ----@param self DataList DataList ---@param index number function M:scroll_to_index(index) local pos = self.grid:get_pos(index) @@ -221,7 +208,6 @@ end --- Add element at passed index using cache or create new ----@param self DataList DataList ---@param index number ---@private function M:_add_at(index) @@ -255,7 +241,6 @@ end --- Remove element from passed index and add it to cache if applicable ----@param self DataList DataList ---@param index number ---@private function M:_remove_at(index) @@ -286,7 +271,6 @@ end --- Refresh all elements in DataList ----@param self DataList DataList ---@private function M:_refresh() self.scroll:set_size(self.grid:get_size_for(#self._data)) diff --git a/druid/extended/hotkey.lua b/druid/extended/hotkey.lua index 3564f7c..871cb17 100644 --- a/druid/extended/hotkey.lua +++ b/druid/extended/hotkey.lua @@ -38,7 +38,6 @@ local M = component.create("hotkey") --- The Hotkey constructor ----@param self Hotkey Hotkey ---@param keys string[]|string The keys to be pressed for trigger callback. Should contains one key and any modificator keys ---@param callback function The callback function ---@param callback_argument any|nil The argument to pass into the callback function @@ -73,7 +72,6 @@ end --- Add hotkey for component callback ----@param self Hotkey Hotkey ---@param keys string[]|hash[]|string|hash that have to be pressed before key pressed to activate ---@param callback_argument any|nil The argument to pass into the callback function ---@return Hotkey Current instance @@ -174,7 +172,6 @@ end --- If true, the callback will be triggered on action.repeated ----@param self Hotkey Hotkey ---@param is_enabled_repeated bool The flag value ---@return Hotkey function M:set_repeat(is_enabled_repeated) diff --git a/druid/extended/input.lua b/druid/extended/input.lua index 21f3f90..2febd79 100755 --- a/druid/extended/input.lua +++ b/druid/extended/input.lua @@ -156,7 +156,6 @@ end --- The Input constructor ----@param self Input Input ---@param click_node node Node to enabled input component ---@param text_node node|Text Text node what will be changed on user input. You can pass text component instead of text node name Text ---@param keyboard_type number|nil Gui keyboard type for input field @@ -328,7 +327,6 @@ function M:get_text_selected() end --- Replace selected text with new text ----@param self Input Input ---@param text string The text to replace selected text ---@return string New input text function M:get_text_selected_replaced(text) @@ -346,7 +344,6 @@ end --- Set text for input field ----@param self Input Input ---@param input_text string The string to apply for input field function M:set_text(input_text) input_text = tostring(input_text or "") @@ -395,7 +392,6 @@ end --- Select input field. It will show the keyboard and trigger on_select events ----@param self Input Input function M:select() gui.reset_keyboard() self.marked_value = "" @@ -420,7 +416,6 @@ end --- Remove selection from input. It will hide the keyboard and trigger on_unselect events ----@param self Input Input function M:unselect() gui.reset_keyboard() self.marked_value = "" @@ -439,7 +434,6 @@ end --- Return current input field text ----@param self Input Input ---@return string The current input field text function M:get_text() if self.marked_value ~= "" then @@ -452,7 +446,6 @@ end --- Set maximum length for input field. -- Pass nil to make input field unliminted (by default) ----@param self Input Input ---@param max_length number Maximum length for input text field ---@return druid.input Current input instance function M:set_max_length(max_length) @@ -464,7 +457,6 @@ end --- Set allowed charaters for input field. -- See: https://defold.com/ref/stable/string/ -- ex: [%a%d] for alpha and numeric ----@param self Input Input ---@param characters string Regulax exp. for validate user input ---@return druid.input Current input instance function M:set_allowed_characters(characters) @@ -474,7 +466,6 @@ end --- Reset current input selection and return previous value ----@param self Input Input ---@return druid.input Current input instance function M:reset_changes() self:set_text(self.previous_value) @@ -484,7 +475,6 @@ end --- Set cursor position in input field ----@param self Input Input ---@param cursor_index number|nil Cursor index for cursor position, if nil - will be set to the end of the text ---@param start_index number|nil Start index for cursor position, if nil - will be set to the end of the text ---@param end_index number|nil End index for cursor position, if nil - will be set to the start_index @@ -507,7 +497,6 @@ end --- Change cursor position by delta ----@param self Input Input ---@param delta number side for cursor position, -1 for left, 1 for right ---@param is_add_to_selection boolean (Shift key) ---@param is_move_to_end boolean (Ctrl key) diff --git a/druid/extended/lang_text.lua b/druid/extended/lang_text.lua index f326f7b..fdcebee 100755 --- a/druid/extended/lang_text.lua +++ b/druid/extended/lang_text.lua @@ -42,7 +42,6 @@ local M = component.create("lang_text") --- The LangText constructor ----@param self LangText LangText ---@param node string|node The node_id or gui.get_node(node_id) ---@param locale_id string|nil Default locale id or text from node as default ---@param adjust_type string|nil Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference @@ -69,7 +68,6 @@ end --- Setup raw text to lang_text component ----@param self LangText LangText ---@param text string Text for text node ---@return LangText Current instance function M:set_to(text) @@ -82,7 +80,6 @@ end --- Translate the text by locale_id ----@param self LangText LangText ---@param locale_id string Locale id ---@param a string|nil Optional param to string.format ---@param b string|nil Optional param to string.format @@ -102,7 +99,6 @@ end --- Format string with new text params on localized text ----@param self LangText LangText ---@param a string|nil Optional param to string.format ---@param b string|nil Optional param to string.format ---@param c string|nil Optional param to string.format diff --git a/druid/extended/progress.lua b/druid/extended/progress.lua index 90c61fc..d524357 100644 --- a/druid/extended/progress.lua +++ b/druid/extended/progress.lua @@ -131,7 +131,6 @@ end --- The Progress constructor ----@param self Progress Progress ---@param node string|node Node name or GUI Node itself. ---@param key string Progress bar direction: const.SIDE.X or const.SIDE.Y ---@param init_value number|nil Initial value of progress bar. Default: 1 @@ -193,21 +192,18 @@ end --- Fill a progress bar and stop progress animation ----@param self Progress Progress function M:fill() set_bar_to(self, 1, true) end --- Empty a progress bar ----@param self Progress Progress function M:empty() set_bar_to(self, 0, true) end --- Instant fill progress bar to value ----@param self Progress Progress ---@param to number Progress bar value, from 0 to 1 function M:set_to(to) to = helper.clamp(to, 0, 1) @@ -216,14 +212,12 @@ end --- Return current progress bar value ----@param self Progress Progress function M:get() return self.last_value end --- Set points on progress bar to fire the callback ----@param self Progress Progress ---@param steps number[] Array of progress bar values ---@param callback function Callback on intersect step value -- @usage progress:set_steps({0, 0.3, 0.6, 1}, function(self, step) end) @@ -234,7 +228,6 @@ end --- Start animation of a progress bar ----@param self Progress Progress ---@param to number value between 0..1 ---@param callback function|nil Callback on animation ends function M:to(to, callback) @@ -253,7 +246,6 @@ end --- Set progress bar max node size ----@param self Progress Progress ---@param max_size vector3 The new node maximum (full) size ---@return Progress Progress function M:set_max_size(max_size) diff --git a/druid/extended/slider.lua b/druid/extended/slider.lua index 67904b5..8f66f25 100644 --- a/druid/extended/slider.lua +++ b/druid/extended/slider.lua @@ -69,7 +69,6 @@ end --- The Slider constructor ----@param self Slider Slider ---@param node node Gui pin node ---@param end_pos vector3 The end position of slider ---@param callback function|nil On slider change callback @@ -197,7 +196,6 @@ end --- Set value for slider ----@param self Slider Slider ---@param value number Value from 0 to 1 ---@param is_silent boolean|nil Don't trigger event if true function M:set(value, is_silent) @@ -212,7 +210,6 @@ end --- Set slider steps. Pin node will -- apply closest step position ----@param self Slider Slider ---@param steps number[] Array of steps -- @usage slider:set_steps({0, 0.2, 0.6, 1}) ---@return Slider Slider @@ -226,7 +223,6 @@ end -- User can touch any place of node, pin instantly will -- move at this position and node drag will start. -- This function require the Defold version 1.3.0+ ----@param self Slider Slider ---@param input_node node|string|nil ---@return Slider Slider function M:set_input_node(input_node) @@ -236,7 +232,6 @@ end --- Set Slider input enabled or disabled ----@param self Slider Slider ---@param is_enabled boolean function M:set_enabled(is_enabled) self._is_enabled = is_enabled @@ -244,7 +239,6 @@ end --- Check if Slider component is enabled ----@param self Slider Slider ---@return boolean function M:is_enabled() return self._is_enabled diff --git a/druid/extended/swipe.lua b/druid/extended/swipe.lua index ea8010b..3f6a77d 100644 --- a/druid/extended/swipe.lua +++ b/druid/extended/swipe.lua @@ -160,7 +160,6 @@ end --- Strict swipe click area. Useful for -- restrict events outside stencil node ----@param self Swipe Swipe ---@param zone node|string|nil Gui node function M:set_click_zone(zone) self.click_zone = self:get_node(zone) diff --git a/druid/extended/timer.lua b/druid/extended/timer.lua index 8bd9ae3..b6eee00 100644 --- a/druid/extended/timer.lua +++ b/druid/extended/timer.lua @@ -78,7 +78,6 @@ function M:on_layout_change() end ----@param self druid.timer ---@param set_to number Value in seconds ---@return druid.timer self function M:set_to(set_to) @@ -89,7 +88,6 @@ function M:set_to(set_to) end ----@param self druid.timer ---@param is_on boolean|nil Timer enable state ---@return druid.timer self function M:set_state(is_on) @@ -100,7 +98,6 @@ function M:set_state(is_on) end ----@param self druid.timer ---@param from number Start time in seconds ---@param to number Target time in seconds ---@return druid.timer self diff --git a/example/components/container/container.lua b/example/components/container/container.lua index d425c45..ba8753f 100644 --- a/example/components/container/container.lua +++ b/example/components/container/container.lua @@ -207,7 +207,6 @@ function M:fit_into_window() end ----@param self druid.container function M:on_window_resized() local x_koef, y_koef = helper.get_screen_aspect_koef() self.x_koef = x_koef From f3fad8bd921c4c61d66688f3aead901ff5477cef Mon Sep 17 00:00:00 2001 From: Insality Date: Mon, 18 Nov 2024 21:48:08 +0200 Subject: [PATCH 12/50] Add test widget stubs --- README.md | 20 +- druid/widget/debug_panel/debug_panel.gui | 16 + .../properties/property_button.gui | 328 ++++++++++++++++++ .../properties/property_button.lua | 33 ++ .../properties/property_checkbox.gui | 120 +++++++ .../properties/property_checkbox.lua | 59 ++++ .../properties/property_slider.gui | 211 +++++++++++ .../properties/property_slider.lua | 75 ++++ .../properties_panel/properties_panel.gui | 295 ++++++++++++++++ .../properties_panel/properties_panel.lua | 126 +++++++ 10 files changed, 1282 insertions(+), 1 deletion(-) create mode 100644 druid/widget/debug_panel/debug_panel.gui create mode 100644 druid/widget/properties_panel/properties/property_button.gui create mode 100644 druid/widget/properties_panel/properties/property_button.lua create mode 100644 druid/widget/properties_panel/properties/property_checkbox.gui create mode 100644 druid/widget/properties_panel/properties/property_checkbox.lua create mode 100644 druid/widget/properties_panel/properties/property_slider.gui create mode 100644 druid/widget/properties_panel/properties/property_slider.lua create mode 100644 druid/widget/properties_panel/properties_panel.gui create mode 100644 druid/widget/properties_panel/properties_panel.lua diff --git a/README.md b/README.md index b72efc3..77a9bee 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,8 @@ For all **Druid** instance functions, [see here](https://insality.github.io/drui ### Default GUI Script +Put the following code in your GUI script to start using **Druid**. + ```lua local druid = require("druid.druid") @@ -116,11 +118,27 @@ function on_message(self, message_id, message, sender) end function on_input(self, action_id, action) - self.druid:on_input(action_id, action) + return self.druid:on_input(action_id, action) end ``` +### Default Widget Template + +Create a new lua file to create a new widget class. This widget can be created with `self.druid:new_widget(widget_class, [template], [nodes])` + +```lua +local M = {} + +function M:init() + self.druid = self:get_druid() + self.root = self:get_node("root") +end + +return M +``` + + ### API Documentation **Druid** offers a wide range of components and functions. To facilitate usage, **Druid** provides comprehensive API documentation with examples and annotations. diff --git a/druid/widget/debug_panel/debug_panel.gui b/druid/widget/debug_panel/debug_panel.gui new file mode 100644 index 0000000..e925213 --- /dev/null +++ b/druid/widget/debug_panel/debug_panel.gui @@ -0,0 +1,16 @@ +textures { + name: "druid" + texture: "/druid/druid.atlas" +} +nodes { + size { + x: 200.0 + y: 100.0 + } + type: TYPE_BOX + id: "root" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties/property_button.gui b/druid/widget/properties_panel/properties/property_button.gui new file mode 100644 index 0000000..d9ab2a3 --- /dev/null +++ b/druid/widget/properties_panel/properties/property_button.gui @@ -0,0 +1,328 @@ +script: "" +fonts { + name: "text_bold" + font: "/druid/fonts/text_bold.font" +} +textures { + name: "druid" + texture: "/druid/druid.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: 400.0 + y: 40.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: "druid/empty" + id: "root" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_NW + adjust_mode: ADJUST_MODE_STRETCH + 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_MANUAL + custom_type: 0 + enabled: true + visible: false + material: "" +} +nodes { + position { + x: 0.0 + y: -20.0 + z: 0.0 + w: 1.0 + } + rotation { + x: 0.0 + y: 0.0 + z: 0.0 + w: 1.0 + } + scale { + x: 0.65 + y: 0.65 + z: 1.0 + w: 1.0 + } + size { + x: 200.0 + y: 40.0 + z: 0.0 + w: 1.0 + } + color { + x: 0.463 + y: 0.475 + z: 0.49 + w: 1.0 + } + type: TYPE_TEXT + blend_mode: BLEND_MODE_ALPHA + text: "Button" + font: "text_bold" + id: "text_name" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_W + outline { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + adjust_mode: ADJUST_MODE_FIT + line_break: false + parent: "root" + layer: "" + inherit_alpha: true + alpha: 1.0 + outline_alpha: 0.0 + shadow_alpha: 0.0 + template_node_child: false + text_leading: 1.0 + text_tracking: 0.0 + custom_type: 0 + enabled: true + visible: true + material: "" +} +nodes { + position { + x: 267.0 + y: -20.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: 226.0 + y: 40.0 + z: 0.0 + w: 1.0 + } + color { + x: 0.463 + y: 0.475 + z: 0.49 + w: 1.0 + } + type: TYPE_BOX + blend_mode: BLEND_MODE_ALPHA + texture: "druid/rect_round2_width1" + id: "button" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + adjust_mode: ADJUST_MODE_FIT + parent: "root" + layer: "" + inherit_alpha: true + slice9 { + x: 4.0 + y: 4.0 + z: 4.0 + w: 4.0 + } + clipping_mode: CLIPPING_MODE_NONE + clipping_visible: true + clipping_inverted: false + alpha: 1.0 + template_node_child: false + size_mode: SIZE_MODE_MANUAL + custom_type: 0 + enabled: true + visible: true + material: "" +} +nodes { + position { + x: 0.0 + y: -20.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: 226.0 + y: 4.0 + z: 0.0 + w: 1.0 + } + color { + x: 0.894 + y: 0.506 + z: 0.333 + w: 1.0 + } + type: TYPE_BOX + blend_mode: BLEND_MODE_ALPHA + texture: "druid/pixel" + id: "selected" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_S + adjust_mode: ADJUST_MODE_STRETCH + parent: "button" + 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_MANUAL + custom_type: 0 + enabled: true + visible: true + material: "" +} +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: 0.65 + y: 0.65 + z: 1.0 + w: 1.0 + } + size { + x: 250.0 + y: 30.0 + z: 0.0 + w: 1.0 + } + color { + x: 0.722 + y: 0.741 + z: 0.761 + w: 1.0 + } + type: TYPE_TEXT + blend_mode: BLEND_MODE_ALPHA + text: "Button" + font: "text_bold" + id: "text_button" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + outline { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + adjust_mode: ADJUST_MODE_FIT + line_break: false + parent: "button" + layer: "" + inherit_alpha: true + alpha: 1.0 + outline_alpha: 0.0 + shadow_alpha: 0.0 + template_node_child: false + text_leading: 1.0 + text_tracking: 0.0 + custom_type: 0 + enabled: true + visible: true + material: "" +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT +max_nodes: 512 diff --git a/druid/widget/properties_panel/properties/property_button.lua b/druid/widget/properties_panel/properties/property_button.lua new file mode 100644 index 0000000..9ffa273 --- /dev/null +++ b/druid/widget/properties_panel/properties/property_button.lua @@ -0,0 +1,33 @@ +local component = require("druid.component") +local lang_text = require("druid.extended.lang_text") + +---@class property_button: druid.base_component +---@field root node +---@field text_name druid.lang_text +---@field button druid.button +---@field text_button druid.text +---@field druid druid_instance +local M = component.create("property_button") + +---@param template string +---@param nodes table +function M:init(template, nodes) + self.druid = self:get_druid(template, nodes) + + self.root = self:get_node("root") + self.text_name = self.druid:new(lang_text, "text_name") --[[@as druid.lang_text]] + self.selected = self:get_node("selected") + gui.set_alpha(self.selected, 0) + + self.button = self.druid:new_button("button", self.on_click) + self.text_button = self.druid:new_text("text_button") +end + + +function M:on_click() + gui.set_alpha(self.selected, 1) + gui.animate(self.selected, "color.w", 0, gui.EASING_INSINE, 0.16) +end + + +return M diff --git a/druid/widget/properties_panel/properties/property_checkbox.gui b/druid/widget/properties_panel/properties/property_checkbox.gui new file mode 100644 index 0000000..777a6d3 --- /dev/null +++ b/druid/widget/properties_panel/properties/property_checkbox.gui @@ -0,0 +1,120 @@ +fonts { + name: "text_bold" + font: "/druid/fonts/text_bold.font" +} +textures { + name: "druid" + texture: "/druid/druid.atlas" +} +nodes { + size { + x: 400.0 + y: 40.0 + } + type: TYPE_BOX + texture: "druid/empty" + id: "root" + pivot: PIVOT_NW + adjust_mode: ADJUST_MODE_STRETCH + inherit_alpha: true + visible: false +} +nodes { + position { + y: -20.0 + } + scale { + x: 0.65 + y: 0.65 + } + size { + x: 200.0 + y: 40.0 + } + color { + x: 0.463 + y: 0.475 + z: 0.49 + } + type: TYPE_TEXT + text: "Checkbox" + font: "text_bold" + id: "text_name" + pivot: PIVOT_W + outline { + x: 1.0 + y: 1.0 + z: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + } + parent: "root" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} +nodes { + position { + x: 174.0 + y: -20.0 + } + size { + x: 40.0 + y: 40.0 + } + color { + x: 0.463 + y: 0.475 + z: 0.49 + } + type: TYPE_BOX + texture: "druid/rect_round2_width1" + id: "button" + parent: "root" + inherit_alpha: true + slice9 { + x: 4.0 + y: 4.0 + z: 4.0 + w: 4.0 + } +} +nodes { + color { + x: 0.722 + y: 0.741 + z: 0.761 + } + type: TYPE_BOX + texture: "druid/ui_circle_16" + id: "icon" + parent: "button" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} +nodes { + position { + y: -20.0 + } + size { + x: 40.0 + y: 4.0 + } + color { + x: 0.894 + y: 0.506 + z: 0.333 + } + type: TYPE_BOX + texture: "druid/pixel" + id: "selected" + pivot: PIVOT_S + adjust_mode: ADJUST_MODE_STRETCH + parent: "button" + inherit_alpha: true +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties/property_checkbox.lua b/druid/widget/properties_panel/properties/property_checkbox.lua new file mode 100644 index 0000000..fbe92c5 --- /dev/null +++ b/druid/widget/properties_panel/properties/property_checkbox.lua @@ -0,0 +1,59 @@ +local component = require("druid.component") +local container = require("example.components.container.container") +local lang_text = require("druid.extended.lang_text") + +---@class property_checkbox: druid.base_component +---@field druid druid_instance +---@field root druid.container +---@field text_name druid.lang_text +---@field button druid.button +---@field selected node +local M = component.create("property_checkbox") + + +---@param template string +---@param nodes table +function M:init(template, nodes) + self.druid = self:get_druid(template, nodes) + self.root = self.druid:new(container, "root") --[[@as druid.container]] + + self.icon = self:get_node("icon") + gui.set_enabled(self.icon, false) + + self.selected = self:get_node("selected") + gui.set_alpha(self.selected, 0) + + self.text_name = self.druid:new(lang_text, "text_name") --[[@as druid.lang_text]] + + self.button = self.druid:new_button("button", self.on_click) +end + + +---@param value boolean +function M:set_value(value, is_instant) + if self._value == value then + return + end + + self._value = value + gui.set_enabled(self.icon, value) + + if not is_instant then + gui.set_alpha(self.selected, 1) + gui.animate(self.selected, "color.w", 0, gui.EASING_INSINE, 0.16) + end +end + + +---@return boolean +function M:get_value() + return self._value +end + + +function M:on_click() + self:set_value(not self:get_value()) +end + + +return M diff --git a/druid/widget/properties_panel/properties/property_slider.gui b/druid/widget/properties_panel/properties/property_slider.gui new file mode 100644 index 0000000..bef97ac --- /dev/null +++ b/druid/widget/properties_panel/properties/property_slider.gui @@ -0,0 +1,211 @@ +fonts { + name: "text_bold" + font: "/druid/fonts/text_bold.font" +} +textures { + name: "druid" + texture: "/druid/druid.atlas" +} +nodes { + size { + x: 400.0 + y: 40.0 + } + type: TYPE_BOX + texture: "druid/empty" + id: "root" + pivot: PIVOT_NW + adjust_mode: ADJUST_MODE_STRETCH + inherit_alpha: true + visible: false +} +nodes { + position { + y: -20.0 + } + scale { + x: 0.65 + y: 0.65 + } + size { + x: 200.0 + y: 40.0 + } + color { + x: 0.463 + y: 0.475 + z: 0.49 + } + type: TYPE_TEXT + text: "Slider" + font: "text_bold" + id: "text_name" + pivot: PIVOT_W + outline { + x: 1.0 + y: 1.0 + z: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + } + parent: "root" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} +nodes { + position { + x: 234.0 + y: -20.0 + } + size { + x: 160.0 + y: 40.0 + } + color { + x: 0.129 + y: 0.141 + z: 0.157 + } + type: TYPE_BOX + texture: "druid/empty" + id: "slider" + parent: "root" + inherit_alpha: true +} +nodes { + size { + x: 160.0 + y: 8.0 + } + color { + x: 0.129 + y: 0.141 + z: 0.157 + } + type: TYPE_BOX + texture: "druid/ui_circle_8" + id: "slider_back" + parent: "slider" + inherit_alpha: true + slice9 { + x: 4.0 + y: 4.0 + z: 4.0 + w: 4.0 + } +} +nodes { + position { + x: -68.0 + } + size { + x: 24.0 + y: 24.0 + } + color { + x: 0.722 + y: 0.741 + z: 0.761 + } + type: TYPE_BOX + texture: "druid/ui_circle_8" + id: "slider_pin" + parent: "slider" + inherit_alpha: true + slice9 { + x: 4.0 + y: 4.0 + z: 4.0 + w: 4.0 + } +} +nodes { + position { + x: 380.0 + y: -20.0 + } + size { + x: 60.0 + y: 40.0 + } + color { + x: 0.463 + y: 0.475 + z: 0.49 + } + type: TYPE_BOX + texture: "druid/rect_round2_width1" + id: "button" + pivot: PIVOT_E + parent: "root" + inherit_alpha: true + slice9 { + x: 4.0 + y: 4.0 + z: 4.0 + w: 4.0 + } +} +nodes { + position { + y: -20.0 + } + size { + x: 60.0 + y: 4.0 + } + color { + x: 0.894 + y: 0.506 + z: 0.333 + } + type: TYPE_BOX + texture: "druid/pixel" + id: "selected" + pivot: PIVOT_SE + adjust_mode: ADJUST_MODE_STRETCH + parent: "button" + inherit_alpha: true +} +nodes { + position { + x: -30.0 + } + scale { + x: 0.55 + y: 0.55 + } + size { + x: 100.0 + y: 40.0 + } + color { + x: 0.722 + y: 0.741 + z: 0.761 + } + type: TYPE_TEXT + text: "25 %" + font: "text_bold" + id: "text_value" + outline { + x: 1.0 + y: 1.0 + z: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + } + parent: "button" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties/property_slider.lua b/druid/widget/properties_panel/properties/property_slider.lua new file mode 100644 index 0000000..d5ada5f --- /dev/null +++ b/druid/widget/properties_panel/properties/property_slider.lua @@ -0,0 +1,75 @@ +local component = require("druid.component") +local container = require("example.components.container.container") +local lang_text = require("druid.extended.lang_text") +local slider = require("druid.extended.slider") + +---@class property_slider: druid.base_component +---@field druid druid_instance +---@field root druid.container +---@field text_name druid.lang_text +---@field text_value druid.text +---@field slider druid.slider +local M = component.create("property_slider") + + +---@param template string +---@param nodes table +function M:init(template, nodes) + self.druid = self:get_druid(template, nodes) + + self.root = self.druid:new(container, "root") --[[@as druid.container]] + self.selected = self:get_node("selected") + gui.set_alpha(self.selected, 0) + self._value = 0 + + self.text_name = self.druid:new(lang_text, "text_name") --[[@as druid.lang_text]] + self.text_value = self.druid:new_text("text_value") + self.slider = self.druid:new(slider, "slider_pin", vmath.vector3(68, 0, 0), self._on_slider_change_by_user) --[[@as druid.slider]] + self.slider:set_input_node("slider") + + self:set_text_function(function(value) + return math.floor(value * 100) .. "%" + end) +end + + +---@param callback fun(value:number):string +function M:set_text_function(callback) + self._text_function = callback + self.text_value:set_to(self._text_function(self._value)) +end + + +---@param value number +function M:set_value(value, is_instant) + if self._value == value then + return + end + + self._value = value + self.slider:set(value, true) + self.text_value:set_to(self._text_function(value)) + + if not is_instant then + gui.set_alpha(self.selected, 1) + gui.animate(self.selected, "color.w", 0, gui.EASING_INSINE, 0.16) + end +end + + +---@return number +function M:get_value() + return self._value +end + + +function M:_on_slider_change_by_user(value) + self._value = value + self.text_value:set_to(self._text_function(value)) + + gui.set_alpha(self.selected, 1) + gui.animate(self.selected, "color.w", 0, gui.EASING_INSINE, 0.16) +end + + +return M diff --git a/druid/widget/properties_panel/properties_panel.gui b/druid/widget/properties_panel/properties_panel.gui new file mode 100644 index 0000000..da08017 --- /dev/null +++ b/druid/widget/properties_panel/properties_panel.gui @@ -0,0 +1,295 @@ +fonts { + name: "text_regular" + font: "/druid/fonts/text_regular.font" +} +textures { + name: "druid" + texture: "/druid/druid.atlas" +} +nodes { + size { + x: 440.0 + y: 350.0 + } + color { + x: 0.173 + y: 0.184 + z: 0.204 + } + type: TYPE_BOX + texture: "druid/pixel" + id: "root" + adjust_mode: ADJUST_MODE_STRETCH + layer: "druid" + inherit_alpha: true +} +nodes { + position { + x: -210.0 + y: 165.0 + } + scale { + x: 0.9 + y: 0.9 + } + size { + x: 245.0 + y: 50.0 + } + color { + x: 0.463 + y: 0.475 + z: 0.49 + } + type: TYPE_TEXT + text: "Properties" + font: "text_regular" + id: "text_header" + pivot: PIVOT_NW + outline { + x: 1.0 + y: 1.0 + z: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + } + parent: "root" + layer: "text_regular" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} +nodes { + position { + x: -200.0 + y: 115.0 + } + size { + x: 400.0 + y: 290.0 + } + type: TYPE_BOX + texture: "druid/empty" + id: "scroll_view" + xanchor: XANCHOR_LEFT + pivot: PIVOT_NW + adjust_mode: ADJUST_MODE_STRETCH + parent: "root" + layer: "druid" + inherit_alpha: true + clipping_mode: CLIPPING_MODE_STENCIL +} +nodes { + size { + x: 400.0 + y: 290.0 + } + type: TYPE_BOX + texture: "druid/empty" + id: "scroll_content" + pivot: PIVOT_NW + adjust_mode: ADJUST_MODE_STRETCH + parent: "scroll_view" + layer: "druid" + inherit_alpha: true + visible: false +} +nodes { + position { + x: -200.0 + y: 115.0 + } + scale { + x: 0.7 + y: 0.7 + } + size { + x: 570.0 + y: 50.0 + } + color { + x: 0.31 + y: 0.318 + z: 0.322 + } + type: TYPE_TEXT + text: "No properties for this example" + font: "text_regular" + id: "text_no_properties" + pivot: PIVOT_NW + outline { + x: 1.0 + y: 1.0 + z: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + } + parent: "root" + layer: "text_regular" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 + enabled: false +} +nodes { + position { + x: -200.0 + y: 100.0 + } + type: TYPE_BOX + texture: "druid/empty" + id: "propeties" + parent: "root" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO + visible: false +} +nodes { + type: TYPE_TEMPLATE + id: "property_slider" + parent: "propeties" + inherit_alpha: true + template: "/druid/widget/properties_panel/properties/property_slider.gui" +} +nodes { + type: TYPE_BOX + id: "property_slider/root" + parent: "property_slider" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_slider/text_name" + parent: "property_slider/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_slider/slider" + parent: "property_slider/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_slider/slider_back" + parent: "property_slider/slider" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_slider/slider_pin" + parent: "property_slider/slider" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_slider/button" + parent: "property_slider/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_slider/selected" + parent: "property_slider/button" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_slider/text_value" + parent: "property_slider/button" + template_node_child: true +} +nodes { + position { + y: -50.0 + } + type: TYPE_TEMPLATE + id: "property_checkbox" + parent: "propeties" + inherit_alpha: true + template: "/druid/widget/properties_panel/properties/property_checkbox.gui" +} +nodes { + type: TYPE_BOX + id: "property_checkbox/root" + parent: "property_checkbox" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_checkbox/text_name" + parent: "property_checkbox/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_checkbox/button" + parent: "property_checkbox/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_checkbox/icon" + parent: "property_checkbox/button" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_checkbox/selected" + parent: "property_checkbox/button" + template_node_child: true +} +nodes { + position { + y: -100.0 + } + type: TYPE_TEMPLATE + id: "property_button" + parent: "propeties" + inherit_alpha: true + template: "/druid/widget/properties_panel/properties/property_button.gui" +} +nodes { + type: TYPE_BOX + id: "property_button/root" + parent: "property_button" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_button/text_name" + parent: "property_button/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_button/button" + parent: "property_button/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_button/selected" + parent: "property_button/button" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_button/text_button" + parent: "property_button/button" + template_node_child: true +} +layers { + name: "druid" +} +layers { + name: "text_regular" +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties_panel.lua b/druid/widget/properties_panel/properties_panel.lua new file mode 100644 index 0000000..6a6496b --- /dev/null +++ b/druid/widget/properties_panel/properties_panel.lua @@ -0,0 +1,126 @@ +local container = require("example.components.container.container") +local lang_text = require("druid.extended.lang_text") + +local property_checkbox = require("example.components.properties_panel.properties.property_checkbox") +local property_slider = require("example.components.properties_panel.properties.property_slider") +local property_button = require("example.components.properties_panel.properties.property_button") + +---@class properties_panel: druid.widget +---@field root node +---@field text_no_properties druid.lang_text +---@field scroll druid.scroll +---@field druid druid_instance +local M = {} + +---@param template string +---@param nodes table +function M:init(template, nodes) + self.druid = self:get_druid(template, nodes) + + --self.root = self.druid:new(container, "root") --[[@as druid.container]] + --self.root:add_container("text_header") + --self.root:add_container("separator") + self.root = self:get_node("root") + + self.properties = {} + + self.druid:new(lang_text, "text_header", "ui_properties_panel") + self.text_no_properties = self.druid:new(lang_text, "text_no_properties", "ui_no_properties") --[[@as druid.lang_text]] + + self.scroll = self.druid:new_scroll("scroll_view", "scroll_content") + self.layout = self.druid:new_layout("scroll_content", "item_size") + + self.grid = self.druid:new_static_grid("scroll_content", "item_size", 1) + self.scroll:bind_grid(self.grid) + + self.property_checkbox_prefab = self:get_node("property_checkbox/root") + gui.set_enabled(self.property_checkbox_prefab, false) + + self.property_slider_prefab = self:get_node("property_slider/root") + gui.set_enabled(self.property_slider_prefab, false) + + self.property_button_prefab = self:get_node("property_button/root") + gui.set_enabled(self.property_button_prefab, false) +end + + +function M:clear() + for index = 1, #self.properties do + self.druid:remove(self.properties[index]) + end + self.properties = {} + + local nodes = self.grid.nodes + for index = 1, #nodes do + gui.delete_node(nodes[index]) + end + self.grid:clear() + + gui.set_enabled(self.text_no_properties.text.node, true) +end + + +---@param text_id string +---@param initial_value boolean +---@param on_change_callback function +---@return property_checkbox +function M:add_checkbox(text_id, initial_value, on_change_callback) + local nodes = gui.clone_tree(self.property_checkbox_prefab) + local instance = self.druid:new(property_checkbox, "property_checkbox", nodes) --[[@as property_checkbox]] + instance.text_name:translate(text_id) + instance:set_value(initial_value, true) + instance.button.on_click:subscribe(function() + on_change_callback(instance:get_value()) + end) + + gui.set_enabled(instance.root.node, true) + self.grid:add(instance.root.node) + table.insert(self.properties, instance) + gui.set_enabled(self.text_no_properties.text.node, false) + + return instance +end + + +---@param text_id string +---@param initial_value number +---@param on_change_callback function +---@return property_slider +function M:add_slider(text_id, initial_value, on_change_callback) + local nodes = gui.clone_tree(self.property_slider_prefab) + local instance = self.druid:new(property_slider, "property_slider", nodes) --[[@as property_slider]] + instance.text_name:translate(text_id) + instance:set_value(initial_value, true) + + gui.set_enabled(instance.root.node, true) + self.grid:add(instance.root.node) + table.insert(self.properties, instance) + gui.set_enabled(self.text_no_properties.text.node, false) + + instance.slider.on_change_value:subscribe(function(_, value) + on_change_callback(value) + end) + + return instance +end + + +---@param text_id string +---@param on_click_callback function +function M:add_button(text_id, on_click_callback) + local nodes = gui.clone_tree(self.property_button_prefab) + local instance = self.druid:new(property_button, "property_button", nodes) --[[@as property_button]] + instance.text_name:translate(text_id) + + gui.set_enabled(instance.root, true) + self.grid:add(instance.root) + table.insert(self.properties, instance) + gui.set_enabled(self.text_no_properties.text.node, false) + + instance.button.on_click:subscribe(on_click_callback) + + return instance +end + + +return M From 3fca582197b1c50caa3f13fc0f55c4937332f5f4 Mon Sep 17 00:00:00 2001 From: Insality Date: Mon, 18 Nov 2024 21:51:26 +0200 Subject: [PATCH 13/50] All components now included --- druid/helper.lua | 27 ---------------- druid/system/druid_instance.lua | 57 +++++++++++++++------------------ 2 files changed, 25 insertions(+), 59 deletions(-) diff --git a/druid/helper.lua b/druid/helper.lua index 3819219..14a89b2 100644 --- a/druid/helper.lua +++ b/druid/helper.lua @@ -522,31 +522,4 @@ function M.remove_with_shift(array, index, shift_policy) end -local _deprecated_messages = {} - ----Show deprecated message. Once time per message ----@param message string The deprecated message -function M.deprecated(message) - if _deprecated_messages[message] then - return - end - - print("[Druid]: " .. message) - _deprecated_messages[message] = true -end - - ----Show message to require component ----@param component_name string ----@param component_type string|nil -function M.require_component_message(component_name, component_type) - component_type = component_type or "extended" - - print(string.format("[Druid]: The component %s is %s component. You have to register it via druid.register to use it", component_name, component_type)) - print("[Druid]: Use next code:") - print(string.format('local %s = require("druid.%s.%s")', component_name, component_type, component_name)) - print(string.format('druid.register("%s", %s)', component_name, component_name)) -end - - return M diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index f71835e..4fcd954 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -29,14 +29,17 @@ local blocker = require("druid.base.blocker") local static_grid = require("druid.base.static_grid") local back_handler = require("druid.base.back_handler") --- To use this components, you should register them first --- local input = require("druid.extended.input") --- local swipe = require("druid.extended.swipe") --- local slider = require("druid.extended.slider") --- local progress = require("druid.extended.progress") --- local data_list = require("druid.extended.data_list") --- local lang_text = require("druid.extended.lang_text") --- local timer_component = require("druid.extended.timer") + local input = require("druid.extended.input") + local swipe = require("druid.extended.swipe") + local slider = require("druid.extended.slider") + local progress = require("druid.extended.progress") + local data_list = require("druid.extended.data_list") + local lang_text = require("druid.extended.lang_text") + local timer_component = require("druid.extended.timer") + local layout = require("druid.extended.layout") + local hotkey = require("druid.extended.hotkey") + local rich_input = require("druid.extended.rich_input") + local rich_text = require("druid.extended.rich_text") ---@class druid_instance ---@field components_all druid.base_component[] All created components @@ -592,22 +595,12 @@ function M:new_text(node, value, no_adjust) end ----Create StaticGrid component ----@param parent_node string|node The node_id or gui.get_node(node_id). Parent of all Grid items. ----@param item node Element prefab. Required to get grid's item size. Can be adjusted separately. ----@param in_row number|nil How many nodes in row can be placed ----@return druid.grid StaticGrid component -function M:new_grid(parent_node, item, in_row) - return self:new(static_grid, parent_node, item, in_row) -end - - ----Create StaticGrid component +---Create Grid component ---@param parent_node string|node The node_id or gui.get_node(node_id). Parent of all Grid items. ---@param item string|node Item prefab. Required to get grid's item size. Can be adjusted separately. ---@param in_row number|nil How many nodes in row can be placed ----@return druid.grid StaticGrid component -function M:new_static_grid(parent_node, item, in_row) +---@return druid.grid grid component +function M:new_grid(parent_node, item, in_row) return self:new(static_grid, parent_node, item, in_row) end @@ -635,7 +628,7 @@ end ---@param on_swipe_callback function|nil Swipe callback for on_swipe_end event ---@return druid.swipe Swipe component function M:new_swipe(node, on_swipe_callback) - return helper.require_component_message("swipe") --[[@as druid.swipe]] + return self:new(swipe, node, on_swipe_callback) end @@ -645,7 +638,7 @@ end ---@param adjust_type string|nil Adjust type for text node. Default: const.TEXT_ADJUST.DOWNSCALE ---@return druid.lang_text LangText component function M:new_lang_text(node, locale_id, adjust_type) - return helper.require_component_message("lang_text") --[[@as druid.lang_text]] + return self:new(lang_text, node, locale_id, adjust_type) end @@ -655,7 +648,7 @@ end ---@param callback function|nil On slider change callback ---@return druid.slider Slider component function M:new_slider(pin_node, end_pos, callback) - return helper.require_component_message("slider") --[[@as druid.slider]] + return self:new(slider, pin_node, end_pos, callback) end ---Create Input component @@ -664,7 +657,7 @@ end ---@param keyboard_type number|nil Gui keyboard type for input field ---@return druid.input Input component function M:new_input(click_node, text_node, keyboard_type) - return helper.require_component_message("input") --[[@as druid.input]] + return self:new(input, click_node, text_node, keyboard_type) end @@ -674,7 +667,7 @@ end ---@param create_function function The create function callback(self, data, index, data_list). Function should return (node, [component]) ---@return druid.data_list DataList component function M:new_data_list(druid_scroll, druid_grid, create_function) - return helper.require_component_message("data_list") --[[@as druid.data_list]] + return self:new(data_list, druid_scroll, druid_grid, create_function) end @@ -685,7 +678,7 @@ end ---@param callback function|nil Function on timer end ---@return druid.timer Timer component function M:new_timer(node, seconds_from, seconds_to, callback) - return helper.require_component_message("timer") --[[@as druid.timer]] + return self:new(timer_component, node, seconds_from, seconds_to, callback) end @@ -696,7 +689,7 @@ end ---@param init_value number|nil Initial value of progress bar. Default: 1 ---@return druid.progress Progress component function M:new_progress(node, key, init_value) - return helper.require_component_message("progress") --[[@as druid.progress]] + return self:new(progress, node, key, init_value) end @@ -705,7 +698,7 @@ end ---@param mode string The layout mode ---@return druid.layout Layout component function M:new_layout(node, mode) - return helper.require_component_message("layout") --[[@as druid.layout]] + return self:new(layout, node, mode) end @@ -715,7 +708,7 @@ end ---@param callback_argument any|nil The argument to pass into the callback function ---@return druid.hotkey Hotkey component function M:new_hotkey(keys_array, callback, callback_argument) - return helper.require_component_message("hotkey") --[[@as druid.hotkey]] + return self:new(hotkey, keys_array, callback, callback_argument) end @@ -724,7 +717,7 @@ end ---@param value string|nil The initial text value. Default will be gui.get_text(text_node) ---@return druid.rich_text RichText component function M:new_rich_text(text_node, value) - return helper.require_component_message("rich_text", "custom") --[[@as druid.rich_text]] + return self:new(rich_text, text_node, value) end @@ -734,7 +727,7 @@ end ---@param nodes table Nodes table from gui.clone_tree ---@return druid.rich_input RichInput component function M:new_rich_input(template, nodes) - return helper.require_component_message("rich_input", "custom") --[[@as druid.rich_input]] + return self:new(rich_input, template, nodes) end From 99f75dd626caa5d0f7d88f7f47fb9716b09fd9d1 Mon Sep 17 00:00:00 2001 From: Insality Date: Mon, 18 Nov 2024 22:03:04 +0200 Subject: [PATCH 14/50] Update widgets --- druid/extended/container.lua | 527 ++++++++++++++++++ druid/system/druid_instance.lua | 53 +- .../properties/property_button.lua | 7 +- .../properties/property_checkbox.lua | 12 +- .../properties/property_slider.lua | 15 +- .../properties_panel/properties_panel.gui | 11 - .../properties_panel/properties_panel.lua | 39 +- 7 files changed, 585 insertions(+), 79 deletions(-) create mode 100644 druid/extended/container.lua diff --git a/druid/extended/container.lua b/druid/extended/container.lua new file mode 100644 index 0000000..3223f5c --- /dev/null +++ b/druid/extended/container.lua @@ -0,0 +1,527 @@ +--- Container component +-- Container setup in GUI +-- parent container - container that contains this container. If not, then it's a window default container or parent node +-- container pivot - the point of the parent container that will be used as a pivot point for positioning +-- node_offset - position offset from parent container pivot point (vector4 - offset in pixels from each side) +-- adjust mode FIT - container will keep it's size and will be positioned inside parent container +-- adjust mode STRETCH - container will have percentage of parent container size +-- adjust mode STRETCH_X - container will have percentage of parent container size (only x side) +-- adjust mode STRETCH_Y - container will have percentage of parent container size (only y side) +-- Adjust Stretch and x_anchor == None: container will be positioned by pivot point with one side fixed margin, stretched to pivot side by percentage +-- Adjust stretch and x_anchor ~= None: container will be positioned by pivot point, stretched to pivot side by percentage, but with fixed margins + +local const = require("druid.const") +local helper = require("druid.helper") +local component = require("druid.component") +local Event = require("druid.event") + +---@class druid.container: druid.base_component +---@field node node +---@field druid druid_instance +---@field node_offset vector4 +---@field origin_size vector3 +---@field size vector3 +---@field origin_position vector3 +---@field position vector3 +---@field pivot_offset vector3 +---@field center_offset vector3 +---@field mode string +---@field fit_size vector3 +---@field min_size_x number|nil +---@field min_size_y number|nil +---@field on_size_changed druid.event @function on_size_changed(size) +---@field _parent_container druid.container +---@field _containers table +---@field _draggable_corners table +local M = component.create("container") + +local abs = math.abs +local min = math.min +local max = math.max + +local CORNER_PIVOTS = { + gui.PIVOT_NE, + gui.PIVOT_NW, + gui.PIVOT_SE, + gui.PIVOT_SW, +} + + +--- The Container init +---@param node node Gui node +---@param mode string Layout mode +---@param callback fun(self: druid.container, size: vector3)|nil Callback on size changed +function M:init(node, mode, callback) + self.node = self:get_node(node) + self.druid = self:get_druid() + + self.min_size_x = 0 + self.min_size_y = 0 + self._containers = {} + self._draggable_corners = {} + self.node_offset = vmath.vector4(0) + self.node_fill_x = nil + self.node_fill_y = nil + self._position = gui.get_position(self.node) + local x_koef, y_koef = helper.get_screen_aspect_koef() + self.x_koef = x_koef + self.y_koef = y_koef + + self.x_anchor = gui.get_xanchor(self.node) + self.y_anchor = gui.get_yanchor(self.node) + + -- Can be changed + self.origin_size = gui.get_size(self.node) + self.size = gui.get_size(self.node) + self.position = gui.get_position(self.node) + self.origin_position = gui.get_position(self.node) + + local adjust_mode = gui.get_adjust_mode(self.node) + self.mode = mode or (adjust_mode == gui.ADJUST_FIT) and const.LAYOUT_MODE.FIT or const.LAYOUT_MODE.STRETCH + + gui.set_size_mode(self.node, gui.SIZE_MODE_MANUAL) + gui.set_adjust_mode(self.node, gui.ADJUST_FIT) + + self.on_size_changed = Event(callback) + + self.pivot_offset = helper.get_pivot_offset(gui.get_pivot(self.node)) + self.center_offset = -vmath.vector3(self.size.x * self.pivot_offset.x, self.size.y * self.pivot_offset.y, 0) + self:set_size(self.size.x, self.size.y) +end + + +function M:on_late_init() + if not gui.get_parent(self.node) then + -- TODO: Scale issue here, in fit into window! + self:fit_into_window() + end +end + + +function M:on_remove() + self:clear_draggable_corners() +end + + +function M:refresh_origins() + self.origin_size = gui.get_size(self.node) + self.origin_position = gui.get_position(self.node) + self:set_pivot(gui.get_pivot(self.node)) +end + + +---@param pivot constant +function M:set_pivot(pivot) + gui.set_pivot(self.node, pivot) + self.pivot_offset = helper.get_pivot_offset(pivot) + self.center_offset = -vmath.vector3(self.size.x * self.pivot_offset.x, self.size.y * self.pivot_offset.y, 0) +end + + +--- Component style params. +-- You can override this component styles params in Druid styles table +-- or create your own style +-- @table style +-- @tfield[opt=vector3(24, 24, 0)] vector3 DRAGGABLE_CORNER_SIZE Size of box node for debug draggable corners +-- @tfield[opt=vector4(1)] vector4 DRAGGABLE_CORNER_COLOR Color of debug draggable corners +function M:on_style_change(style) + self.style = {} + self.style.DRAGGABLE_CORNER_SIZE = style.DRAGGABLE_CORNER_SIZE or vmath.vector3(24, 24, 0) + self.style.DRAGGABLE_CORNER_COLOR = style.DRAGGABLE_CORNER_COLOR or vmath.vector4(10) +end + + +--- Set new size of layout node +---@param width number|nil +---@param height number|nil +---@return druid.container Container +function M:set_size(width, height) + width = width or self.size.x + height = height or self.size.y + + if self.min_size_x then + width = max(width, self.min_size_x) + end + if self.min_size_y then + height = max(height, self.min_size_y) + end + + if (width and width ~= self.size.x) or (height and height ~= self.size.y) then + self.center_offset.x = -width * self.pivot_offset.x + self.center_offset.y = -height * self.pivot_offset.y + self.size.x = width + self.size.y = height + self.size.z = 0 + gui.set_size(self.node, self.size) + + self:update_child_containers() + self.on_size_changed:trigger(self:get_context(), self.size) + end + + return self +end + + +---@param pos_x number +---@param pos_y number +function M:set_position(pos_x, pos_y) + if self._position.x == pos_x and self._position.y == pos_y then + return + end + + self._position.x = pos_x + self._position.y = pos_y + gui.set_position(self.node, self._position) +end + + +---Get current size of layout node +---@return vector3 size +function M:get_size() + return self.size +end + + +---Get current scale of layout node +---@return vector3 scale +function M:get_scale() + return helper.get_scene_scale(self.node, true) --[[@as vector3]] +end + + +--- Set size for layout node to fit inside it +---@param target_size vector3 +---@return druid.container Container +function M:fit_into_size(target_size) + self.fit_size = target_size + self:refresh() + + return self +end + + +--- Set current size for layout node to fit inside it +---@return druid.container Container +function M:fit_into_window() + return self:fit_into_size(vmath.vector3(gui.get_width(), gui.get_height(), 0)) +end + + +function M:on_window_resized() + local x_koef, y_koef = helper.get_screen_aspect_koef() + self.x_koef = x_koef + self.y_koef = y_koef + + if not self._parent_container then + self:refresh() + end +end + + +---@param node_or_container node|string|druid.container|table +---@param mode string|nil stretch, fit, stretch_x, stretch_y. Default: Pick from node, "fit" or "stretch" +---@param on_resize_callback fun(self: userdata, size: vector3)|nil +---@return druid.container Container New created layout instance +function M:add_container(node_or_container, mode, on_resize_callback) + local container = nil + local node = node_or_container + + -- Check it's a container components instead of node + if type(node_or_container) == "table" and node_or_container._component then + node = node_or_container.node + container = node_or_container + mode = mode or container.mode + end + + -- Covert node_id to node if needed + node = self:get_node(node) + + container = container or self.druid:new(M, node, mode) + container:set_parent_container(self) + if on_resize_callback then + container.on_size_changed:subscribe(on_resize_callback) + end + table.insert(self._containers, container) + + return container +end + + +---@return druid.container|nil +function M:remove_container_by_node(node) + for index = 1, #self._containers do + local container = self._containers[index] + if container.node == node then + table.remove(self._containers, index) + self.druid:remove(container) + return container + end + end + + return nil +end + + +---@param parent_container druid.container|nil +function M:set_parent_container(parent_container) + if not parent_container then + self._parent_container = nil + gui.set_parent(self.node, nil) + self:refresh() + return + end + + -- TODO: Just check it's already parent + gui.set_parent(self.node, parent_container.node, true) + + -- Node offset - fixed distance from parent side to the child side + local parent_left = parent_container.center_offset.x - parent_container.origin_size.x * 0.5 + local parent_right = parent_container.center_offset.x + parent_container.origin_size.x * 0.5 + local parent_top = parent_container.center_offset.y + parent_container.origin_size.y * 0.5 + local parent_bottom = parent_container.center_offset.y - parent_container.origin_size.y * 0.5 + + local node_left = self.origin_position.x + self.center_offset.x - self.origin_size.x * 0.5 + local node_right = self.origin_position.x + self.center_offset.x + self.origin_size.x * 0.5 + local node_top = self.origin_position.y + self.center_offset.y + self.origin_size.y * 0.5 + local node_bottom = self.origin_position.y + self.center_offset.y - self.origin_size.y * 0.5 + + self.node_offset.x = node_left - parent_left + self.node_offset.y = node_top - parent_top + self.node_offset.z = node_right - parent_right + self.node_offset.w = node_bottom - parent_bottom + self._parent_container = parent_container + + local offset_x = (self.node_offset.x + self.node_offset.z)/2 + local offset_y = (self.node_offset.y + self.node_offset.w)/2 + + if self.pivot_offset.x < 0 then + offset_x = self.node_offset.x + end + if self.pivot_offset.x > 0 then + offset_x = self.node_offset.z + end + if self.pivot_offset.y < 0 then + offset_y = self.node_offset.w + end + if self.pivot_offset.y > 0 then + offset_y = self.node_offset.y + end + + local koef_x = (parent_container.origin_size.x - abs(offset_x)) + self.node_fill_x = koef_x ~= 0 and self.origin_size.x / koef_x or 1 + local x_anchor = gui.get_xanchor(self.node) + if x_anchor ~= gui.ANCHOR_NONE then + self.node_fill_x = 1 + end + + local koef_y = (parent_container.origin_size.y - abs(offset_y)) + self.node_fill_y = koef_y ~= 0 and self.origin_size.y / koef_y or 1 + local y_anchor = gui.get_yanchor(self.node) + if y_anchor ~= gui.ANCHOR_NONE then + self.node_fill_y = 1 + end + + self:refresh() +end + + +-- Glossary +-- Center Offset - vector from node position to visual center of node +function M:refresh() + local x_koef, y_koef = self.x_koef, self.y_koef + self:refresh_scale() + + if self._parent_container then + local parent = self._parent_container + local offset_x = (self.node_offset.x + self.node_offset.z) / 2 + local offset_y = (self.node_offset.y + self.node_offset.w) / 2 + + if self.pivot_offset.x < 0 then + offset_x = self.node_offset.x + end + if self.pivot_offset.x > 0 then + offset_x = self.node_offset.z + end + if self.pivot_offset.y < 0 then + offset_y = self.node_offset.w + end + if self.pivot_offset.y > 0 then + offset_y = self.node_offset.y + end + + local stretch_side_x = parent.size.x - abs(offset_x) + local stretch_side_y = parent.size.y - abs(offset_y) + + do + local parent_pivot_x = parent.center_offset.x + (parent.size.x * self.pivot_offset.x) + local parent_pivot_y = parent.center_offset.y + (parent.size.y * self.pivot_offset.y) + local pos_x = parent_pivot_x + offset_x + local pos_y = parent_pivot_y + offset_y + self:set_position(pos_x, pos_y) + end + + do + if self.x_anchor ~= gui.ANCHOR_NONE then + stretch_side_x = parent.size.x - (abs(self.node_offset.x) + abs(self.node_offset.z)) + end + + if self.y_anchor ~= gui.ANCHOR_NONE then + stretch_side_y = parent.size.y - (abs(self.node_offset.y) + abs(self.node_offset.w)) + end + + ---- Size Update (for stretch) + if self.mode == const.LAYOUT_MODE.STRETCH then + self:set_size( + abs(stretch_side_x * self.node_fill_x), + abs(stretch_side_y * self.node_fill_y)) + end + + if self.mode == const.LAYOUT_MODE.STRETCH_X then + self:set_size(abs(stretch_side_x * self.node_fill_x), nil) + end + + if self.mode == const.LAYOUT_MODE.STRETCH_Y then + self:set_size(nil, abs(stretch_side_y * self.node_fill_y)) + end + end + else + if self.fit_size then + x_koef = self.fit_size.x / self.origin_size.x * x_koef + y_koef = self.fit_size.y / self.origin_size.y * y_koef + + if self.mode == const.LAYOUT_MODE.STRETCH then + self:set_size(self.origin_size.x * x_koef, self.origin_size.y * y_koef) + end + end + end + + self:update_child_containers() +end + + +function M:refresh_scale() + if self._fit_node then + local fit_node_size = gui.get_size(self._fit_node) + + local scale = vmath.vector3(1) + scale.x = min(fit_node_size.x / self.size.x, 1) + scale.y = min(fit_node_size.y / self.size.y, 1) + + scale.x = min(scale.x, scale.y) + scale.y = min(scale.x, scale.y) + + gui.set_scale(self.node, scale) + end +end + + +function M:update_child_containers() + for index = 1, #self._containers do + self._containers[index]:refresh() + end +end + + +---@return druid.container Container +function M:create_draggable_corners() + self:clear_draggable_corners() + + for _, corner_pivot in pairs(CORNER_PIVOTS) do + local corner_offset = helper.get_pivot_offset(corner_pivot) + local anchor_position = vmath.vector3( + self.center_offset.x + (self.size.x) * corner_offset.x, + self.center_offset.y + (self.size.y) * corner_offset.y, + 0) + + local new_draggable_node = gui.new_box_node(anchor_position, self.style.DRAGGABLE_CORNER_SIZE) + gui.set_color(new_draggable_node, self.style.DRAGGABLE_CORNER_COLOR) + gui.set_pivot(new_draggable_node, corner_pivot) + gui.set_parent(new_draggable_node, self.node) + self:add_container(new_draggable_node) + + ---@type druid.drag + local drag = self.druid:new_drag(new_draggable_node, function(_, x, y) + self:_on_corner_drag(x, y, corner_offset) + end) + table.insert(self._draggable_corners, drag) + + drag.style.DRAG_DEADZONE = 0 + end + + return self +end + + +---@return druid.container Container +function M:clear_draggable_corners() + for index = 1, #self._draggable_corners do + local drag_component = self._draggable_corners[index] + self.druid:remove(drag_component) + self:remove_container_by_node(drag_component.node) + gui.delete_node(drag_component.node) + end + + self._draggable_corners = {} + + return self +end + + +function M:_on_corner_drag(x, y, corner_offset) + x = corner_offset.x >= 0 and x or -x + y = corner_offset.y >= 0 and y or -y + + local size = self:get_size() + if self.min_size_x and size.x + x < self.min_size_x then + x = self.min_size_x - size.x + end + if self.min_size_y and size.y + y < self.min_size_y then + y = self.min_size_y - size.y + end + + if corner_offset.x < 0 then + self.node_offset.x = self.node_offset.x - x + end + if corner_offset.x > 0 then + self.node_offset.z = self.node_offset.z - x + end + if corner_offset.y < 0 then + self.node_offset.w = self.node_offset.w - y + end + if corner_offset.y > 0 then + self.node_offset.y = self.node_offset.y - y + end + + local pivot = gui.get_pivot(self.node) + local pivot_offset = helper.get_pivot_offset(pivot) + + local center_pos_x = self._position.x + (x * (pivot_offset.x + corner_offset.x)) + local center_pos_y = self._position.y + (y * (pivot_offset.y + corner_offset.y)) + + self:set_position(center_pos_x, center_pos_y) + self:set_size(size.x + x, size.y + y) +end + + +--- Set node for layout node to fit inside it. Pass nil to reset +---@param node string|node The node_id or gui.get_node(node_id) +---@return druid.container Layout +function M:fit_into_node(node) + self._fit_node = self:get_node(node) + self:refresh_scale() + return self +end + + +---@param min_size_x number|nil +---@param min_size_y number|nil +function M:set_min_size(min_size_x, min_size_y) + self.min_size_x = min_size_x or self.min_size_x + self.min_size_y = min_size_y or self.min_size_y + self:refresh() + + return self +end + + +return M diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index 4fcd954..db62255 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -20,27 +20,6 @@ local helper = require("druid.helper") local settings = require("druid.system.settings") local base_component = require("druid.component") -local drag = require("druid.base.drag") -local text = require("druid.base.text") -local hover = require("druid.base.hover") -local scroll = require("druid.base.scroll") -local button = require("druid.base.button") -local blocker = require("druid.base.blocker") -local static_grid = require("druid.base.static_grid") -local back_handler = require("druid.base.back_handler") - - local input = require("druid.extended.input") - local swipe = require("druid.extended.swipe") - local slider = require("druid.extended.slider") - local progress = require("druid.extended.progress") - local data_list = require("druid.extended.data_list") - local lang_text = require("druid.extended.lang_text") - local timer_component = require("druid.extended.timer") - local layout = require("druid.extended.layout") - local hotkey = require("druid.extended.hotkey") - local rich_input = require("druid.extended.rich_input") - local rich_text = require("druid.extended.rich_text") - ---@class druid_instance ---@field components_all druid.base_component[] All created components ---@field components_interest table All components sorted by interest @@ -547,6 +526,7 @@ function M:new_widget(widget, template, nodes, ...) end +local button = require("druid.base.button") ---Create Button component ---@param node string|node The node_id or gui.get_node(node_id) ---@param callback function|nil Button callback @@ -558,6 +538,7 @@ function M:new_button(node, callback, params, anim_node) end +local blocker = require("druid.base.blocker") ---Create Blocker component ---@param node string|node The node_id or gui.get_node(node_id) ---@return druid.blocker Blocker component @@ -566,6 +547,7 @@ function M:new_blocker(node) end +local back_handler = require("druid.base.back_handler") ---Create BackHandler component ---@param callback function|nil The callback(self, custom_args) to call on back event ---@param params any|nil Callback argument @@ -575,6 +557,7 @@ function M:new_back_handler(callback, params) end +local hover = require("druid.base.hover") ---Create Hover component ---@param node string|node The node_id or gui.get_node(node_id) ---@param on_hover_callback function|nil Hover callback @@ -585,6 +568,7 @@ function M:new_hover(node, on_hover_callback, on_mouse_hover_callback) end +local text = require("druid.base.text") ---Create Text component ---@param node string|node The node_id or gui.get_node(node_id) ---@param value string|nil Initial text. Default value is node text from GUI scene. @@ -595,6 +579,7 @@ function M:new_text(node, value, no_adjust) end +local static_grid = require("druid.base.static_grid") ---Create Grid component ---@param parent_node string|node The node_id or gui.get_node(node_id). Parent of all Grid items. ---@param item string|node Item prefab. Required to get grid's item size. Can be adjusted separately. @@ -605,6 +590,7 @@ function M:new_grid(parent_node, item, in_row) end +local scroll = require("druid.base.scroll") ---Create Scroll component ---@param view_node string|node The node_id or gui.get_node(node_id). Will used as user input node. ---@param content_node string|node The node_id or gui.get_node(node_id). Will used as scrollable node inside view_node. @@ -614,6 +600,7 @@ function M:new_scroll(view_node, content_node) end +local drag = require("druid.base.drag") ---Create Drag component ---@param node string|node The node_id or gui.get_node(node_id). Will used as user input node. ---@param on_drag_callback function|nil Callback for on_drag_event(self, dx, dy) @@ -623,6 +610,7 @@ function M:new_drag(node, on_drag_callback) end +local swipe = require("druid.extended.swipe") ---Create Swipe component ---@param node string|node The node_id or gui.get_node(node_id). Will used as user input node. ---@param on_swipe_callback function|nil Swipe callback for on_swipe_end event @@ -632,6 +620,7 @@ function M:new_swipe(node, on_swipe_callback) end +local lang_text = require("druid.extended.lang_text") ---Create LangText component ---@param node string|node The_node id or gui.get_node(node_id) ---@param locale_id string|nil Default locale id or text from node as default @@ -642,6 +631,7 @@ function M:new_lang_text(node, locale_id, adjust_type) end +local slider = require("druid.extended.slider") ---Create Slider component ---@param pin_node string|node The_node id or gui.get_node(node_id). ---@param end_pos vector3 The end position of slider @@ -651,6 +641,8 @@ function M:new_slider(pin_node, end_pos, callback) return self:new(slider, pin_node, end_pos, callback) end + +local input = require("druid.extended.input") ---Create Input component ---@param click_node string|node Button node to enabled input component ---@param text_node string|node|druid.text Text node what will be changed on user input @@ -661,6 +653,7 @@ function M:new_input(click_node, text_node, keyboard_type) end +local data_list = require("druid.extended.data_list") ---Create DataList component ---@param druid_scroll druid.scroll The Scroll instance for Data List component ---@param druid_grid druid.grid The StaticGrid} or @{DynamicGrid instance for Data List component @@ -671,6 +664,7 @@ function M:new_data_list(druid_scroll, druid_grid, create_function) end +local timer_component = require("druid.extended.timer") ---Create Timer component ---@param node string|node Gui text node ---@param seconds_from number Start timer value in seconds @@ -682,7 +676,7 @@ function M:new_timer(node, seconds_from, seconds_to, callback) end - +local progress = require("druid.extended.progress") ---Create Progress component ---@param node string|node Progress bar fill node or node name ---@param key string Progress bar direction: const.SIDE.X or const.SIDE.Y @@ -693,6 +687,7 @@ function M:new_progress(node, key, init_value) end +local layout = require("druid.extended.layout") ---Create Layout component ---@param node string|node The_node id or gui.get_node(node_id). ---@param mode string The layout mode @@ -702,6 +697,18 @@ function M:new_layout(node, mode) end +local container = require("druid.extended.container") +---Create Container component +---@param node string|node The_node id or gui.get_node(node_id). +---@param mode string|nil Layout mode +---@param callback fun(self: druid.container, size: vector3)|nil Callback on size changed +---@return druid.container Container component +function M:new_container(node, mode, callback) + return self:new(container, node, mode, callback) +end + + +local hotkey = require("druid.extended.hotkey") ---Create Hotkey component ---@param keys_array string|string[] Keys for trigger action. Should contains one action key and any amount of modificator keys ---@param callback function The callback function @@ -712,6 +719,7 @@ function M:new_hotkey(keys_array, callback, callback_argument) end +local rich_text = require("druid.custom.rich_text.rich_text") ---Create RichText component. ---@param text_node string|node The text node to make Rich Text ---@param value string|nil The initial text value. Default will be gui.get_text(text_node) @@ -721,6 +729,7 @@ function M:new_rich_text(text_node, value) end +local rich_input = require("druid.custom.rich_input.rich_input") ---Create RichInput component. -- As a template please check rich_input.gui layout. ---@param template string The template string name diff --git a/druid/widget/properties_panel/properties/property_button.lua b/druid/widget/properties_panel/properties/property_button.lua index 9ffa273..a691e61 100644 --- a/druid/widget/properties_panel/properties/property_button.lua +++ b/druid/widget/properties_panel/properties/property_button.lua @@ -1,13 +1,10 @@ -local component = require("druid.component") -local lang_text = require("druid.extended.lang_text") - ---@class property_button: druid.base_component ---@field root node ---@field text_name druid.lang_text ---@field button druid.button ---@field text_button druid.text ---@field druid druid_instance -local M = component.create("property_button") +local M = {} ---@param template string ---@param nodes table @@ -15,7 +12,7 @@ function M:init(template, nodes) self.druid = self:get_druid(template, nodes) self.root = self:get_node("root") - self.text_name = self.druid:new(lang_text, "text_name") --[[@as druid.lang_text]] + self.text_name = self.druid:new_lang_text("text_name") self.selected = self:get_node("selected") gui.set_alpha(self.selected, 0) diff --git a/druid/widget/properties_panel/properties/property_checkbox.lua b/druid/widget/properties_panel/properties/property_checkbox.lua index fbe92c5..8177957 100644 --- a/druid/widget/properties_panel/properties/property_checkbox.lua +++ b/druid/widget/properties_panel/properties/property_checkbox.lua @@ -1,21 +1,17 @@ -local component = require("druid.component") -local container = require("example.components.container.container") -local lang_text = require("druid.extended.lang_text") - ----@class property_checkbox: druid.base_component +---@class property_checkbox: druid.widget ---@field druid druid_instance ---@field root druid.container ---@field text_name druid.lang_text ---@field button druid.button ---@field selected node -local M = component.create("property_checkbox") +local M = {} ---@param template string ---@param nodes table function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.root = self.druid:new(container, "root") --[[@as druid.container]] + self.root = self.druid:new_container("root") self.icon = self:get_node("icon") gui.set_enabled(self.icon, false) @@ -23,7 +19,7 @@ function M:init(template, nodes) self.selected = self:get_node("selected") gui.set_alpha(self.selected, 0) - self.text_name = self.druid:new(lang_text, "text_name") --[[@as druid.lang_text]] + self.text_name = self.druid:new_lang_text("text_name") self.button = self.druid:new_button("button", self.on_click) end diff --git a/druid/widget/properties_panel/properties/property_slider.lua b/druid/widget/properties_panel/properties/property_slider.lua index d5ada5f..60d635a 100644 --- a/druid/widget/properties_panel/properties/property_slider.lua +++ b/druid/widget/properties_panel/properties/property_slider.lua @@ -1,15 +1,10 @@ -local component = require("druid.component") -local container = require("example.components.container.container") -local lang_text = require("druid.extended.lang_text") -local slider = require("druid.extended.slider") - ----@class property_slider: druid.base_component +---@class property_slider: druid.widget ---@field druid druid_instance ---@field root druid.container ---@field text_name druid.lang_text ---@field text_value druid.text ---@field slider druid.slider -local M = component.create("property_slider") +local M = {} ---@param template string @@ -17,14 +12,14 @@ local M = component.create("property_slider") function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.root = self.druid:new(container, "root") --[[@as druid.container]] + self.root = self.druid:new_container("root") --[[@as druid.container]] self.selected = self:get_node("selected") gui.set_alpha(self.selected, 0) self._value = 0 - self.text_name = self.druid:new(lang_text, "text_name") --[[@as druid.lang_text]] + self.text_name = self.druid:new_lang_text("text_name") --[[@as druid.lang_text]] self.text_value = self.druid:new_text("text_value") - self.slider = self.druid:new(slider, "slider_pin", vmath.vector3(68, 0, 0), self._on_slider_change_by_user) --[[@as druid.slider]] + self.slider = self.druid:new_slider("slider_pin", vmath.vector3(68, 0, 0), self._on_slider_change_by_user) --[[@as druid.slider]] self.slider:set_input_node("slider") self:set_text_function(function(value) diff --git a/druid/widget/properties_panel/properties_panel.gui b/druid/widget/properties_panel/properties_panel.gui index da08017..bde0940 100644 --- a/druid/widget/properties_panel/properties_panel.gui +++ b/druid/widget/properties_panel/properties_panel.gui @@ -20,7 +20,6 @@ nodes { texture: "druid/pixel" id: "root" adjust_mode: ADJUST_MODE_STRETCH - layer: "druid" inherit_alpha: true } nodes { @@ -57,7 +56,6 @@ nodes { z: 1.0 } parent: "root" - layer: "text_regular" inherit_alpha: true outline_alpha: 0.0 shadow_alpha: 0.0 @@ -78,7 +76,6 @@ nodes { pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH parent: "root" - layer: "druid" inherit_alpha: true clipping_mode: CLIPPING_MODE_STENCIL } @@ -93,7 +90,6 @@ nodes { pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH parent: "scroll_view" - layer: "druid" inherit_alpha: true visible: false } @@ -131,7 +127,6 @@ nodes { z: 1.0 } parent: "root" - layer: "text_regular" inherit_alpha: true outline_alpha: 0.0 shadow_alpha: 0.0 @@ -285,11 +280,5 @@ nodes { parent: "property_button/button" template_node_child: true } -layers { - name: "druid" -} -layers { - name: "text_regular" -} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties_panel.lua b/druid/widget/properties_panel/properties_panel.lua index 6a6496b..557879e 100644 --- a/druid/widget/properties_panel/properties_panel.lua +++ b/druid/widget/properties_panel/properties_panel.lua @@ -1,9 +1,6 @@ -local container = require("example.components.container.container") -local lang_text = require("druid.extended.lang_text") - -local property_checkbox = require("example.components.properties_panel.properties.property_checkbox") -local property_slider = require("example.components.properties_panel.properties.property_slider") -local property_button = require("example.components.properties_panel.properties.property_button") +local property_checkbox = require("druid.widget.properties_panel.properties.property_checkbox") +local property_slider = require("druid.widget.properties_panel.properties.property_slider") +local property_button = require("druid.widget.properties_panel.properties.property_button") ---@class properties_panel: druid.widget ---@field root node @@ -17,21 +14,17 @@ local M = {} function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - --self.root = self.druid:new(container, "root") --[[@as druid.container]] - --self.root:add_container("text_header") - --self.root:add_container("separator") + --self.root = self.druid:new_container("root") self.root = self:get_node("root") + --self.root:add_container("text_header") self.properties = {} - self.druid:new(lang_text, "text_header", "ui_properties_panel") - self.text_no_properties = self.druid:new(lang_text, "text_no_properties", "ui_no_properties") --[[@as druid.lang_text]] - self.scroll = self.druid:new_scroll("scroll_view", "scroll_content") - self.layout = self.druid:new_layout("scroll_content", "item_size") + --self.layout = self.druid:new_layout("scroll_content") - self.grid = self.druid:new_static_grid("scroll_content", "item_size", 1) - self.scroll:bind_grid(self.grid) + --self.grid = self.druid:new_grid("scroll_content", "item_size", 1) + --self.scroll:bind_grid(self.grid) self.property_checkbox_prefab = self:get_node("property_checkbox/root") gui.set_enabled(self.property_checkbox_prefab, false) @@ -50,11 +43,11 @@ function M:clear() end self.properties = {} - local nodes = self.grid.nodes - for index = 1, #nodes do - gui.delete_node(nodes[index]) - end - self.grid:clear() + --local nodes = self.grid.nodes + --for index = 1, #nodes do + -- gui.delete_node(nodes[index]) + --end + --self.grid:clear() gui.set_enabled(self.text_no_properties.text.node, true) end @@ -74,7 +67,7 @@ function M:add_checkbox(text_id, initial_value, on_change_callback) end) gui.set_enabled(instance.root.node, true) - self.grid:add(instance.root.node) + --self.grid:add(instance.root.node) table.insert(self.properties, instance) gui.set_enabled(self.text_no_properties.text.node, false) @@ -93,7 +86,7 @@ function M:add_slider(text_id, initial_value, on_change_callback) instance:set_value(initial_value, true) gui.set_enabled(instance.root.node, true) - self.grid:add(instance.root.node) + --self.grid:add(instance.root.node) table.insert(self.properties, instance) gui.set_enabled(self.text_no_properties.text.node, false) @@ -113,7 +106,7 @@ function M:add_button(text_id, on_click_callback) instance.text_name:translate(text_id) gui.set_enabled(instance.root, true) - self.grid:add(instance.root) + --self.grid:add(instance.root) table.insert(self.properties, instance) gui.set_enabled(self.text_no_properties.text.node, false) From 299f8501e8c60f7da203ce4be0b9f213d00c052d Mon Sep 17 00:00:00 2001 From: Insality Date: Mon, 18 Nov 2024 22:50:42 +0200 Subject: [PATCH 15/50] Widgets WIP --- druid/druid.atlas | 3 + druid/druid.lua | 9 + druid/event.lua | 8 +- druid/extended/container.lua | 20 +- druid/extended/layout.lua | 24 +++ druid/images/panels/rect_round2_width2.png | Bin 0 -> 183 bytes druid/styles/default/style.lua | 2 +- druid/system/druid_instance.lua | 2 +- druid/widget/debug_panel/debug_panel.gui | 16 -- .../properties/property_button.gui | 198 +----------------- .../properties/property_button.lua | 6 +- .../properties/property_checkbox.lua | 4 +- .../properties/property_slider.lua | 4 +- .../properties_panel/properties_panel.gui | 60 ++++-- .../properties_panel/properties_panel.lua | 90 +++++--- 15 files changed, 181 insertions(+), 265 deletions(-) create mode 100644 druid/images/panels/rect_round2_width2.png delete mode 100644 druid/widget/debug_panel/debug_panel.gui diff --git a/druid/druid.atlas b/druid/druid.atlas index ce36b4e..59904d2 100644 --- a/druid/druid.atlas +++ b/druid/druid.atlas @@ -19,4 +19,7 @@ images { images { image: "/druid/images/pixel.png" } +images { + image: "/druid/images/panels/rect_round2_width2.png" +} extrude_borders: 2 diff --git a/druid/druid.lua b/druid/druid.lua index 1172f34..6fb3d68 100644 --- a/druid/druid.lua +++ b/druid/druid.lua @@ -80,6 +80,15 @@ function M.set_sound_function(callback) end +---Subscribe Druid to the window listener. It will override your previous +---window listener, so if you have one, you should call M.on_window_callback manually. +function M.init_window_listener() + window.set_listener(function(_, window_event) + M.on_window_callback(window_event) + end) +end + + ---Set the window callback to enable Druid window events. ---@param event constant Event param from window listener function M.on_window_callback(event) diff --git a/druid/event.lua b/druid/event.lua index 9da6a6c..7bac8dc 100644 --- a/druid/event.lua +++ b/druid/event.lua @@ -13,7 +13,7 @@ local tinsert = table.insert local tremove = table.remove --- Return new event instance ----@param callback fun()|nil Subscribe the callback on new event, if callback exist +---@param callback function|nil Subscribe the callback on new event, if callback exist ---@param callback_context any|nil Additional context as first param to callback call ---@return druid.event ---@nodiscard @@ -30,7 +30,7 @@ end --- Check is event subscribed. ----@param callback fun() Callback itself +---@param callback function Callback itself ---@param callback_context any|nil Additional context as first param to callback call ---@return boolean, number|nil Is event subscribed, return index of callback in event as second param function M:is_subscribed(callback, callback_context) @@ -50,7 +50,7 @@ end ---Subscribe callback on event ----@param callback fun() Callback itself +---@param callback function Callback itself ---@param callback_context any|nil Additional context as first param to callback call, usually it's self ---@return boolean function M:subscribe(callback, callback_context) @@ -67,7 +67,7 @@ end ---Unsubscribe callback on event ----@param callback fun() Callback itself +---@param callback function Callback itself ---@param callback_context any|nil Additional context as first param to callback call ---@return boolean function M:unsubscribe(callback, callback_context) diff --git a/druid/extended/container.lua b/druid/extended/container.lua index 3223f5c..3a4a17f 100644 --- a/druid/extended/container.lua +++ b/druid/extended/container.lua @@ -134,8 +134,9 @@ end --- Set new size of layout node ---@param width number|nil ---@param height number|nil +---@param anchor_pivot constant|nil If set will keep the corner possition relative to the new size ---@return druid.container Container -function M:set_size(width, height) +function M:set_size(width, height, anchor_pivot) width = width or self.size.x height = height or self.size.y @@ -149,11 +150,23 @@ function M:set_size(width, height) if (width and width ~= self.size.x) or (height and height ~= self.size.y) then self.center_offset.x = -width * self.pivot_offset.x self.center_offset.y = -height * self.pivot_offset.y + local dx = self.size.x - width + local dy = self.size.y - height self.size.x = width self.size.y = height self.size.z = 0 gui.set_size(self.node, self.size) + if anchor_pivot then + local pivot = gui.get_pivot(self.node) + local pivot_offset = helper.get_pivot_offset(pivot) + local new_pivot_offset = helper.get_pivot_offset(anchor_pivot) + + local position_dx = dx * (pivot_offset.x - new_pivot_offset.x) + local position_dy = dy * (pivot_offset.y - new_pivot_offset.y) + self:set_position(self._position.x + position_dx, self._position.y - position_dy) + end + self:update_child_containers() self.on_size_changed:trigger(self:get_context(), self.size) end @@ -162,6 +175,11 @@ function M:set_size(width, height) end +function M:get_position() + return self._position +end + + ---@param pos_x number ---@param pos_y number function M:set_position(pos_x, pos_y) diff --git a/druid/extended/layout.lua b/druid/extended/layout.lua index 457c17c..e51931b 100644 --- a/druid/extended/layout.lua +++ b/druid/extended/layout.lua @@ -1,8 +1,12 @@ +local event = require("druid.event") local helper = require("druid.helper") local component = require("druid.component") ---@alias druid.layout.mode "horizontal"|"vertical"|"horizontal_wrap" +---@class druid.event.on_size_changed: druid.event +---@field subscribe fun(_, callback: fun(new_size: vector3), context: any|nil) + ---@class druid.layout.row_data ---@field width number ---@field height number @@ -25,6 +29,7 @@ local component = require("druid.component") ---@field is_resize_width boolean ---@field is_resize_height boolean ---@field is_justify boolean +---@field on_size_changed druid.event.on_size_changed local M = component.create("layout") ---Layout component constructor @@ -46,6 +51,8 @@ function M:init(node_or_node_id, layout_type) self.is_resize_width = false self.is_resize_height = false self.is_justify = false + + self.on_size_changed = event.create() end @@ -145,6 +152,21 @@ function M:add(node_or_node_id) end +function M:remove(node_or_node_id) + local node = type(node_or_node_id) == "table" and node_or_node_id.node or self:get_node(node_or_node_id) + + for index = #self.entities, 1, -1 do + if self.entities[index] == node then + table.remove(self.entities, index) + self.is_dirty = true + break + end + end + + return self +end + + ---@return druid.layout function M:refresh_layout() local layout_node = self.node @@ -273,6 +295,8 @@ function M:refresh_layout() size.y = rows_data.total_height + padding.y + padding.w end gui.set_size(layout_node, size) + + self.on_size_changed(size) end self.is_dirty = false diff --git a/druid/images/panels/rect_round2_width2.png b/druid/images/panels/rect_round2_width2.png new file mode 100644 index 0000000000000000000000000000000000000000..80841144f6c3e8b72ecf73de649a8c6596344de7 GIT binary patch literal 183 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4aTa()7Bet#3xhBt!>l*8o|0J>k`97X5jv*C{S0|q2Wl-c{J{z_{^@3yxpR5DB z+O!A9zostHm}n%gt{}OF>$-}iA2UP0ZK#r|WpY~2-*)dffvLM9{`1F${khS<%jtXv ZZ>K=q63&vR20(KeJYD@<);T3K0RS~vGspk{ literal 0 HcmV?d00001 diff --git a/druid/styles/default/style.lua b/druid/styles/default/style.lua index 0f74a66..7398c74 100644 --- a/druid/styles/default/style.lua +++ b/druid/styles/default/style.lua @@ -61,7 +61,7 @@ M["hover"] = { } M["drag"] = { - DRAG_DEADZONE = 10, -- Size in pixels of drag deadzone + DRAG_DEADZONE = 4, -- Size in pixels of drag deadzone NO_USE_SCREEN_KOEF = false, } diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index db62255..87357ae 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -690,7 +690,7 @@ end local layout = require("druid.extended.layout") ---Create Layout component ---@param node string|node The_node id or gui.get_node(node_id). ----@param mode string The layout mode +---@param mode string vertical|horizontal|horizontal_wrap ---@return druid.layout Layout component function M:new_layout(node, mode) return self:new(layout, node, mode) diff --git a/druid/widget/debug_panel/debug_panel.gui b/druid/widget/debug_panel/debug_panel.gui deleted file mode 100644 index e925213..0000000 --- a/druid/widget/debug_panel/debug_panel.gui +++ /dev/null @@ -1,16 +0,0 @@ -textures { - name: "druid" - texture: "/druid/druid.atlas" -} -nodes { - size { - x: 200.0 - y: 100.0 - } - type: TYPE_BOX - id: "root" - inherit_alpha: true - size_mode: SIZE_MODE_AUTO -} -material: "/builtins/materials/gui.material" -adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties/property_button.gui b/druid/widget/properties_panel/properties/property_button.gui index d9ab2a3..b8a4bb0 100644 --- a/druid/widget/properties_panel/properties/property_button.gui +++ b/druid/widget/properties_panel/properties/property_button.gui @@ -1,4 +1,3 @@ -script: "" fonts { name: "text_bold" font: "/druid/fonts/text_bold.font" @@ -7,322 +6,135 @@ textures { name: "druid" texture: "/druid/druid.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: 400.0 y: 40.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: "druid/empty" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { - x: 0.0 y: -20.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 } scale { x: 0.65 y: 0.65 - z: 1.0 - w: 1.0 } size { x: 200.0 y: 40.0 - z: 0.0 - w: 1.0 } color { x: 0.463 y: 0.475 z: 0.49 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Button" font: "text_bold" id: "text_name" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_W outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "root" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: 267.0 y: -20.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: 226.0 y: 40.0 - z: 0.0 - w: 1.0 } color { x: 0.463 y: 0.475 z: 0.49 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/rect_round2_width1" + texture: "druid/rect_round2_width2" id: "button" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "root" - layer: "" inherit_alpha: true slice9 { - x: 4.0 - y: 4.0 - z: 4.0 - w: 4.0 + x: 5.0 + y: 5.0 + z: 5.0 + w: 5.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -20.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: 226.0 y: 4.0 - z: 0.0 - w: 1.0 } color { x: 0.894 y: 0.506 z: 0.333 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/pixel" id: "selected" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_S adjust_mode: ADJUST_MODE_STRETCH parent: "button" - 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_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 0.65 y: 0.65 - z: 1.0 - w: 1.0 } size { x: 250.0 y: 30.0 - z: 0.0 - w: 1.0 } color { x: 0.722 y: 0.741 z: 0.761 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Button" font: "text_bold" id: "text_button" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "button" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/druid/widget/properties_panel/properties/property_button.lua b/druid/widget/properties_panel/properties/property_button.lua index a691e61..0c7add5 100644 --- a/druid/widget/properties_panel/properties/property_button.lua +++ b/druid/widget/properties_panel/properties/property_button.lua @@ -1,6 +1,6 @@ ----@class property_button: druid.base_component +---@class property_button: druid.widget ---@field root node ----@field text_name druid.lang_text +---@field text_name druid.text ---@field button druid.button ---@field text_button druid.text ---@field druid druid_instance @@ -12,7 +12,7 @@ function M:init(template, nodes) self.druid = self:get_druid(template, nodes) self.root = self:get_node("root") - self.text_name = self.druid:new_lang_text("text_name") + self.text_name = self.druid:new_text("text_name") self.selected = self:get_node("selected") gui.set_alpha(self.selected, 0) diff --git a/druid/widget/properties_panel/properties/property_checkbox.lua b/druid/widget/properties_panel/properties/property_checkbox.lua index 8177957..6887283 100644 --- a/druid/widget/properties_panel/properties/property_checkbox.lua +++ b/druid/widget/properties_panel/properties/property_checkbox.lua @@ -1,6 +1,6 @@ ---@class property_checkbox: druid.widget +---@field root node ---@field druid druid_instance ----@field root druid.container ---@field text_name druid.lang_text ---@field button druid.button ---@field selected node @@ -11,7 +11,7 @@ local M = {} ---@param nodes table function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.root = self.druid:new_container("root") + self.root = self:get_node("root") self.icon = self:get_node("icon") gui.set_enabled(self.icon, false) diff --git a/druid/widget/properties_panel/properties/property_slider.lua b/druid/widget/properties_panel/properties/property_slider.lua index 60d635a..92f7e3d 100644 --- a/druid/widget/properties_panel/properties/property_slider.lua +++ b/druid/widget/properties_panel/properties/property_slider.lua @@ -1,6 +1,6 @@ ---@class property_slider: druid.widget +---@field root node ---@field druid druid_instance ----@field root druid.container ---@field text_name druid.lang_text ---@field text_value druid.text ---@field slider druid.slider @@ -12,7 +12,7 @@ local M = {} function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.root = self.druid:new_container("root") --[[@as druid.container]] + self.root = self:get_node("root") self.selected = self:get_node("selected") gui.set_alpha(self.selected, 0) self._value = 0 diff --git a/druid/widget/properties_panel/properties_panel.gui b/druid/widget/properties_panel/properties_panel.gui index bde0940..9bdcdd3 100644 --- a/druid/widget/properties_panel/properties_panel.gui +++ b/druid/widget/properties_panel/properties_panel.gui @@ -2,14 +2,18 @@ fonts { name: "text_regular" font: "/druid/fonts/text_regular.font" } +fonts { + name: "text_bold" + font: "/druid/fonts/text_bold.font" +} textures { name: "druid" texture: "/druid/druid.atlas" } nodes { size { - x: 440.0 - y: 350.0 + x: 400.0 + y: 240.0 } color { x: 0.173 @@ -17,19 +21,24 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid/ui_circle_16" id: "root" - adjust_mode: ADJUST_MODE_STRETCH inherit_alpha: true + slice9 { + x: 8.0 + y: 8.0 + z: 8.0 + w: 8.0 + } } nodes { position { - x: -210.0 - y: 165.0 + x: -196.0 + y: 116.0 } scale { - x: 0.9 - y: 0.9 + x: 0.8 + y: 0.8 } size { x: 245.0 @@ -62,12 +71,12 @@ nodes { } nodes { position { - x: -200.0 - y: 115.0 + x: -196.0 + y: 70.0 } size { - x: 400.0 - y: 290.0 + x: 392.0 + y: 190.0 } type: TYPE_BOX texture: "druid/empty" @@ -81,16 +90,19 @@ nodes { } nodes { size { - x: 400.0 - y: 290.0 + x: 392.0 + y: 186.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid/pixel" id: "scroll_content" pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH parent: "scroll_view" inherit_alpha: true + slice9 { + w: 6.0 + } visible: false } nodes { @@ -280,5 +292,23 @@ nodes { parent: "property_button/button" template_node_child: true } +nodes { + position { + x: 192.0 + y: 112.0 + } + color { + x: 0.129 + y: 0.141 + z: 0.157 + } + type: TYPE_BOX + texture: "druid/ui_circle_32" + id: "icon_drag" + pivot: PIVOT_NE + parent: "root" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties_panel.lua b/druid/widget/properties_panel/properties_panel.lua index 557879e..d08e657 100644 --- a/druid/widget/properties_panel/properties_panel.lua +++ b/druid/widget/properties_panel/properties_panel.lua @@ -4,7 +4,7 @@ local property_button = require("druid.widget.properties_panel.properties.proper ---@class properties_panel: druid.widget ---@field root node ----@field text_no_properties druid.lang_text +---@field text_no_properties node ---@field scroll druid.scroll ---@field druid druid_instance local M = {} @@ -16,15 +16,18 @@ function M:init(template, nodes) --self.root = self.druid:new_container("root") self.root = self:get_node("root") + self.text_no_properties = self:get_node("text_no_properties") --self.root:add_container("text_header") self.properties = {} self.scroll = self.druid:new_scroll("scroll_view", "scroll_content") - --self.layout = self.druid:new_layout("scroll_content") + self.layout = self.druid:new_layout("scroll_content", "vertical") + :set_hug_content(false, true) - --self.grid = self.druid:new_grid("scroll_content", "item_size", 1) - --self.scroll:bind_grid(self.grid) + self.layout.on_size_changed:subscribe(self.on_size_changed, self) + + self.drag_corner = self.druid:new_drag("icon_drag", self.on_drag_corner) self.property_checkbox_prefab = self:get_node("property_checkbox/root") gui.set_enabled(self.property_checkbox_prefab, false) @@ -34,6 +37,18 @@ function M:init(template, nodes) self.property_button_prefab = self:get_node("property_button/root") gui.set_enabled(self.property_button_prefab, false) + + self.container = self.druid:new_container(self.root) + self.container:add_container("text_header") + self.container:add_container("icon_drag") + local container_scroll_view = self.container:add_container("scroll_view") + container_scroll_view:add_container("scroll_content") +end + + +function M:on_drag_corner(dx, dy) + local position = self.container:get_position() + self.container:set_position(position.x + dx, position.y + dy) end @@ -42,14 +57,15 @@ function M:clear() self.druid:remove(self.properties[index]) end self.properties = {} + gui.set_enabled(self.text_no_properties, true) +end - --local nodes = self.grid.nodes - --for index = 1, #nodes do - -- gui.delete_node(nodes[index]) - --end - --self.grid:clear() - gui.set_enabled(self.text_no_properties.text.node, true) +function M:on_size_changed(new_size) + new_size.x = new_size.x + 8 + new_size.y = new_size.y + 50 + 8 + + self.container:set_size(new_size.x, new_size.y, gui.PIVOT_N) end @@ -59,17 +75,17 @@ end ---@return property_checkbox function M:add_checkbox(text_id, initial_value, on_change_callback) local nodes = gui.clone_tree(self.property_checkbox_prefab) - local instance = self.druid:new(property_checkbox, "property_checkbox", nodes) --[[@as property_checkbox]] - instance.text_name:translate(text_id) + local instance = self.druid:new_widget(property_checkbox, "property_checkbox", nodes) + instance.text_name:set_to(text_id) instance:set_value(initial_value, true) instance.button.on_click:subscribe(function() on_change_callback(instance:get_value()) end) - gui.set_enabled(instance.root.node, true) - --self.grid:add(instance.root.node) + gui.set_enabled(instance.root, true) + self.layout:add(instance.root) table.insert(self.properties, instance) - gui.set_enabled(self.text_no_properties.text.node, false) + gui.set_enabled(self.text_no_properties, false) return instance end @@ -81,14 +97,14 @@ end ---@return property_slider function M:add_slider(text_id, initial_value, on_change_callback) local nodes = gui.clone_tree(self.property_slider_prefab) - local instance = self.druid:new(property_slider, "property_slider", nodes) --[[@as property_slider]] - instance.text_name:translate(text_id) + local instance = self.druid:new_widget(property_slider, "property_slider", nodes) + instance.text_name:set_to(text_id) instance:set_value(initial_value, true) - gui.set_enabled(instance.root.node, true) - --self.grid:add(instance.root.node) + gui.set_enabled(instance.root, true) + self.layout:add(instance.root) table.insert(self.properties, instance) - gui.set_enabled(self.text_no_properties.text.node, false) + gui.set_enabled(self.text_no_properties, false) instance.slider.on_change_value:subscribe(function(_, value) on_change_callback(value) @@ -99,21 +115,41 @@ end ---@param text_id string ----@param on_click_callback function -function M:add_button(text_id, on_click_callback) +---@param on_click_callback function|nil +---@param callback_context any|nil +function M:add_button(text_id, on_click_callback, callback_context) local nodes = gui.clone_tree(self.property_button_prefab) - local instance = self.druid:new(property_button, "property_button", nodes) --[[@as property_button]] - instance.text_name:translate(text_id) + local instance = self.druid:new_widget(property_button, "property_button", nodes) + instance.text_name:set_to(text_id) gui.set_enabled(instance.root, true) - --self.grid:add(instance.root) + self.layout:add(instance.root) table.insert(self.properties, instance) - gui.set_enabled(self.text_no_properties.text.node, false) + gui.set_enabled(self.text_no_properties, false) - instance.button.on_click:subscribe(on_click_callback) + if on_click_callback then + instance.button.on_click:subscribe(on_click_callback, callback_context) + end return instance end +function M:remove(widget) + for index = 1, #self.properties do + if self.properties[index] == widget then + self.druid:remove(widget) + self.layout:remove(widget.root) + gui.delete_node(widget.root) + table.remove(self.properties, index) + break + end + end + + if #self.properties == 0 then + gui.set_enabled(self.text_no_properties, true) + end +end + + return M From dc8f3b99bbb562666dcd9ab00581b086dd72c581 Mon Sep 17 00:00:00 2001 From: Insality Date: Mon, 18 Nov 2024 23:06:04 +0200 Subject: [PATCH 16/50] Widgets WIP --- druid/extended/layout.lua | 12 +++++++++++- .../properties/property_button.gui | 11 +++++++---- .../properties/property_button.lua | 5 +++++ .../properties/property_checkbox.gui | 6 ++---- .../properties/property_checkbox.lua | 4 ++++ .../properties/property_slider.gui | 15 ++++++--------- .../properties/property_slider.lua | 8 +++++++- .../widget/properties_panel/properties_panel.lua | 16 ++++++++++------ 8 files changed, 52 insertions(+), 25 deletions(-) diff --git a/druid/extended/layout.lua b/druid/extended/layout.lua index e51931b..ec5c8cb 100644 --- a/druid/extended/layout.lua +++ b/druid/extended/layout.lua @@ -41,6 +41,7 @@ function M:init(node_or_node_id, layout_type) self.is_dirty = true self.entities = {} + self.size = gui.get_size(self.node) self.padding = gui.get_slice9(self.node) self.margin = { x = self.padding.z, y = self.padding.w } @@ -52,7 +53,7 @@ function M:init(node_or_node_id, layout_type) self.is_resize_height = false self.is_justify = false - self.on_size_changed = event.create() + self.on_size_changed = event.create() --[[@as druid.event.on_size_changed]] end @@ -152,6 +153,9 @@ function M:add(node_or_node_id) end +---Remove node from layout +---@param node_or_node_id node|string node_or_node_id +---@return druid.layout self for chaining function M:remove(node_or_node_id) local node = type(node_or_node_id) == "table" and node_or_node_id.node or self:get_node(node_or_node_id) @@ -167,6 +171,11 @@ function M:remove(node_or_node_id) end +---@return vector3 +function M:get_size() + return self.size +end + ---@return druid.layout function M:refresh_layout() local layout_node = self.node @@ -295,6 +304,7 @@ function M:refresh_layout() size.y = rows_data.total_height + padding.y + padding.w end gui.set_size(layout_node, size) + self.size = size self.on_size_changed(size) end diff --git a/druid/widget/properties_panel/properties/property_button.gui b/druid/widget/properties_panel/properties/property_button.gui index b8a4bb0..7e20961 100644 --- a/druid/widget/properties_panel/properties/property_button.gui +++ b/druid/widget/properties_panel/properties/property_button.gui @@ -14,14 +14,13 @@ nodes { type: TYPE_BOX texture: "druid/empty" id: "root" - pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH inherit_alpha: true visible: false } nodes { position { - y: -20.0 + x: -200.0 } scale { x: 0.65 @@ -58,8 +57,7 @@ nodes { } nodes { position { - x: 267.0 - y: -20.0 + x: 200.0 } size { x: 226.0 @@ -73,6 +71,7 @@ nodes { type: TYPE_BOX texture: "druid/rect_round2_width2" id: "button" + pivot: PIVOT_E parent: "root" inherit_alpha: true slice9 { @@ -84,6 +83,7 @@ nodes { } nodes { position { + x: -113.0 y: -20.0 } size { @@ -104,6 +104,9 @@ nodes { inherit_alpha: true } nodes { + position { + x: -113.0 + } scale { x: 0.65 y: 0.65 diff --git a/druid/widget/properties_panel/properties/property_button.lua b/druid/widget/properties_panel/properties/property_button.lua index 0c7add5..7e89478 100644 --- a/druid/widget/properties_panel/properties/property_button.lua +++ b/druid/widget/properties_panel/properties/property_button.lua @@ -1,5 +1,6 @@ ---@class property_button: druid.widget ---@field root node +---@field container druid.container ---@field text_name druid.text ---@field button druid.button ---@field text_button druid.text @@ -18,6 +19,10 @@ function M:init(template, nodes) self.button = self.druid:new_button("button", self.on_click) self.text_button = self.druid:new_text("text_button") + + self.container = self.druid:new_container(self.root) + self.container:add_container("text_name") + self.container:add_container("button") end diff --git a/druid/widget/properties_panel/properties/property_checkbox.gui b/druid/widget/properties_panel/properties/property_checkbox.gui index 777a6d3..15af0cb 100644 --- a/druid/widget/properties_panel/properties/property_checkbox.gui +++ b/druid/widget/properties_panel/properties/property_checkbox.gui @@ -14,14 +14,13 @@ nodes { type: TYPE_BOX texture: "druid/empty" id: "root" - pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH inherit_alpha: true visible: false } nodes { position { - y: -20.0 + x: -200.0 } scale { x: 0.65 @@ -58,8 +57,7 @@ nodes { } nodes { position { - x: 174.0 - y: -20.0 + x: -20.0 } size { x: 40.0 diff --git a/druid/widget/properties_panel/properties/property_checkbox.lua b/druid/widget/properties_panel/properties/property_checkbox.lua index 6887283..451df85 100644 --- a/druid/widget/properties_panel/properties/property_checkbox.lua +++ b/druid/widget/properties_panel/properties/property_checkbox.lua @@ -22,6 +22,10 @@ function M:init(template, nodes) self.text_name = self.druid:new_lang_text("text_name") self.button = self.druid:new_button("button", self.on_click) + + self.container = self.druid:new_container(self.root) + self.container:add_container("text_name") + self.container:add_container("button") end diff --git a/druid/widget/properties_panel/properties/property_slider.gui b/druid/widget/properties_panel/properties/property_slider.gui index bef97ac..3a4d4b0 100644 --- a/druid/widget/properties_panel/properties/property_slider.gui +++ b/druid/widget/properties_panel/properties/property_slider.gui @@ -14,14 +14,13 @@ nodes { type: TYPE_BOX texture: "druid/empty" id: "root" - pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH inherit_alpha: true visible: false } nodes { position { - y: -20.0 + x: -200.0 } scale { x: 0.65 @@ -58,11 +57,10 @@ nodes { } nodes { position { - x: 234.0 - y: -20.0 + x: 40.0 } size { - x: 160.0 + x: 190.0 y: 40.0 } color { @@ -78,7 +76,7 @@ nodes { } nodes { size { - x: 160.0 + x: 166.0 y: 8.0 } color { @@ -100,7 +98,7 @@ nodes { } nodes { position { - x: -68.0 + x: -83.0 } size { x: 24.0 @@ -125,8 +123,7 @@ nodes { } nodes { position { - x: 380.0 - y: -20.0 + x: 200.0 } size { x: 60.0 diff --git a/druid/widget/properties_panel/properties/property_slider.lua b/druid/widget/properties_panel/properties/property_slider.lua index 92f7e3d..568b417 100644 --- a/druid/widget/properties_panel/properties/property_slider.lua +++ b/druid/widget/properties_panel/properties/property_slider.lua @@ -1,5 +1,6 @@ ---@class property_slider: druid.widget ---@field root node +---@field container druid.container ---@field druid druid_instance ---@field text_name druid.lang_text ---@field text_value druid.text @@ -19,12 +20,17 @@ function M:init(template, nodes) self.text_name = self.druid:new_lang_text("text_name") --[[@as druid.lang_text]] self.text_value = self.druid:new_text("text_value") - self.slider = self.druid:new_slider("slider_pin", vmath.vector3(68, 0, 0), self._on_slider_change_by_user) --[[@as druid.slider]] + self.slider = self.druid:new_slider("slider_pin", vmath.vector3(183, 0, 0), self._on_slider_change_by_user) --[[@as druid.slider]] self.slider:set_input_node("slider") self:set_text_function(function(value) return math.floor(value * 100) .. "%" end) + + self.container = self.druid:new_container(self.root) + self.container:add_container("text_name") + self.container:add_container("slider") + self.container:add_container("button") end diff --git a/druid/widget/properties_panel/properties_panel.lua b/druid/widget/properties_panel/properties_panel.lua index d08e657..0795b7a 100644 --- a/druid/widget/properties_panel/properties_panel.lua +++ b/druid/widget/properties_panel/properties_panel.lua @@ -41,8 +41,9 @@ function M:init(template, nodes) self.container = self.druid:new_container(self.root) self.container:add_container("text_header") self.container:add_container("icon_drag") - local container_scroll_view = self.container:add_container("scroll_view") - container_scroll_view:add_container("scroll_content") + + self.container_scroll_view = self.container:add_container("scroll_view") + self.contaienr_scroll_content = self.container_scroll_view:add_container("scroll_content") end @@ -62,10 +63,7 @@ end function M:on_size_changed(new_size) - new_size.x = new_size.x + 8 - new_size.y = new_size.y + 50 + 8 - - self.container:set_size(new_size.x, new_size.y, gui.PIVOT_N) + self.container:set_size(new_size.x + 8, new_size.y + 50 + 8, gui.PIVOT_N) end @@ -85,6 +83,8 @@ function M:add_checkbox(text_id, initial_value, on_change_callback) gui.set_enabled(instance.root, true) self.layout:add(instance.root) table.insert(self.properties, instance) + instance.container:set_size(self.layout:get_size().x) + gui.set_enabled(self.text_no_properties, false) return instance @@ -104,6 +104,8 @@ function M:add_slider(text_id, initial_value, on_change_callback) gui.set_enabled(instance.root, true) self.layout:add(instance.root) table.insert(self.properties, instance) + instance.container:set_size(self.layout:get_size().x) + gui.set_enabled(self.text_no_properties, false) instance.slider.on_change_value:subscribe(function(_, value) @@ -125,6 +127,8 @@ function M:add_button(text_id, on_click_callback, callback_context) gui.set_enabled(instance.root, true) self.layout:add(instance.root) table.insert(self.properties, instance) + instance.container:set_size(self.layout:get_size().x) + gui.set_enabled(self.text_no_properties, false) if on_click_callback then From 6cb2c9ca9a9f99da2966a6a078cc9525ff874a2b Mon Sep 17 00:00:00 2001 From: Insality Date: Mon, 18 Nov 2024 23:28:34 +0200 Subject: [PATCH 17/50] Widgets WIP --- druid/extended/layout.lua | 9 ++++ .../properties/property_button.gui | 27 ++++++++---- .../properties/property_button.lua | 2 +- .../properties/property_checkbox.gui | 30 ++++++++++---- .../properties/property_checkbox.lua | 2 +- .../properties/property_slider.gui | 32 +++++++++++---- .../properties/property_slider.lua | 5 +-- .../properties_panel/properties_panel.gui | 41 ++++++++++++++----- .../properties_panel/properties_panel.lua | 21 +++++++--- 9 files changed, 124 insertions(+), 45 deletions(-) diff --git a/druid/extended/layout.lua b/druid/extended/layout.lua index ec5c8cb..8eb657c 100644 --- a/druid/extended/layout.lua +++ b/druid/extended/layout.lua @@ -21,6 +21,7 @@ local component = require("druid.component") ---@class druid.layout: druid.base_component ---@field node node +---@field rows_data druid.layout.rows_data Last calculated rows data ---@field is_dirty boolean ---@field entities node[] ---@field margin {x: number, y: number} @@ -176,6 +177,14 @@ function M:get_size() return self.size end + +---@return vector3 +function M:get_content_size() + local rows_data = self:calculate_rows_data() + return vmath.vector3(rows_data.total_width, rows_data.total_height, 0) +end + + ---@return druid.layout function M:refresh_layout() local layout_node = self.node diff --git a/druid/widget/properties_panel/properties/property_button.gui b/druid/widget/properties_panel/properties/property_button.gui index 7e20961..8876f9e 100644 --- a/druid/widget/properties_panel/properties/property_button.gui +++ b/druid/widget/properties_panel/properties/property_button.gui @@ -60,7 +60,23 @@ nodes { x: 200.0 } size { - x: 226.0 + x: 200.0 + y: 40.0 + } + type: TYPE_BOX + id: "E_Anchor" + pivot: PIVOT_E + parent: "root" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO + visible: false +} +nodes { + position { + x: -100.0 + } + size { + x: 200.0 y: 40.0 } color { @@ -71,8 +87,7 @@ nodes { type: TYPE_BOX texture: "druid/rect_round2_width2" id: "button" - pivot: PIVOT_E - parent: "root" + parent: "E_Anchor" inherit_alpha: true slice9 { x: 5.0 @@ -83,11 +98,10 @@ nodes { } nodes { position { - x: -113.0 y: -20.0 } size { - x: 226.0 + x: 200.0 y: 4.0 } color { @@ -104,9 +118,6 @@ nodes { inherit_alpha: true } nodes { - position { - x: -113.0 - } scale { x: 0.65 y: 0.65 diff --git a/druid/widget/properties_panel/properties/property_button.lua b/druid/widget/properties_panel/properties/property_button.lua index 7e89478..71b30f6 100644 --- a/druid/widget/properties_panel/properties/property_button.lua +++ b/druid/widget/properties_panel/properties/property_button.lua @@ -22,7 +22,7 @@ function M:init(template, nodes) self.container = self.druid:new_container(self.root) self.container:add_container("text_name") - self.container:add_container("button") + self.container:add_container("E_Anchor") end diff --git a/druid/widget/properties_panel/properties/property_checkbox.gui b/druid/widget/properties_panel/properties/property_checkbox.gui index 15af0cb..a8b5ba0 100644 --- a/druid/widget/properties_panel/properties/property_checkbox.gui +++ b/druid/widget/properties_panel/properties/property_checkbox.gui @@ -57,7 +57,23 @@ nodes { } nodes { position { - x: -20.0 + x: 200.0 + } + size { + x: 200.0 + y: 40.0 + } + type: TYPE_BOX + id: "E_Anchor" + pivot: PIVOT_E + parent: "root" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO + visible: false +} +nodes { + position { + x: -180.0 } size { x: 40.0 @@ -69,15 +85,15 @@ nodes { z: 0.49 } type: TYPE_BOX - texture: "druid/rect_round2_width1" + texture: "druid/rect_round2_width2" id: "button" - parent: "root" + parent: "E_Anchor" inherit_alpha: true slice9 { - x: 4.0 - y: 4.0 - z: 4.0 - w: 4.0 + x: 5.0 + y: 5.0 + z: 5.0 + w: 5.0 } } nodes { diff --git a/druid/widget/properties_panel/properties/property_checkbox.lua b/druid/widget/properties_panel/properties/property_checkbox.lua index 451df85..30f1793 100644 --- a/druid/widget/properties_panel/properties/property_checkbox.lua +++ b/druid/widget/properties_panel/properties/property_checkbox.lua @@ -25,7 +25,7 @@ function M:init(template, nodes) self.container = self.druid:new_container(self.root) self.container:add_container("text_name") - self.container:add_container("button") + self.container:add_container("E_Anchor") end diff --git a/druid/widget/properties_panel/properties/property_slider.gui b/druid/widget/properties_panel/properties/property_slider.gui index 3a4d4b0..89c26a1 100644 --- a/druid/widget/properties_panel/properties/property_slider.gui +++ b/druid/widget/properties_panel/properties/property_slider.gui @@ -57,10 +57,27 @@ nodes { } nodes { position { - x: 40.0 + x: 200.0 } size { - x: 190.0 + x: 200.0 + y: 40.0 + } + type: TYPE_BOX + id: "E_Anchor" + pivot: PIVOT_E + adjust_mode: ADJUST_MODE_STRETCH + parent: "root" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO + visible: false +} +nodes { + position { + x: -133.0 + } + size { + x: 134.0 y: 40.0 } color { @@ -71,12 +88,12 @@ nodes { type: TYPE_BOX texture: "druid/empty" id: "slider" - parent: "root" + parent: "E_Anchor" inherit_alpha: true } nodes { size { - x: 166.0 + x: 134.0 y: 8.0 } color { @@ -98,7 +115,7 @@ nodes { } nodes { position { - x: -83.0 + x: -55.0 } size { x: 24.0 @@ -122,9 +139,6 @@ nodes { } } nodes { - position { - x: 200.0 - } size { x: 60.0 y: 40.0 @@ -138,7 +152,7 @@ nodes { texture: "druid/rect_round2_width1" id: "button" pivot: PIVOT_E - parent: "root" + parent: "E_Anchor" inherit_alpha: true slice9 { x: 4.0 diff --git a/druid/widget/properties_panel/properties/property_slider.lua b/druid/widget/properties_panel/properties/property_slider.lua index 568b417..90156a0 100644 --- a/druid/widget/properties_panel/properties/property_slider.lua +++ b/druid/widget/properties_panel/properties/property_slider.lua @@ -20,7 +20,7 @@ function M:init(template, nodes) self.text_name = self.druid:new_lang_text("text_name") --[[@as druid.lang_text]] self.text_value = self.druid:new_text("text_value") - self.slider = self.druid:new_slider("slider_pin", vmath.vector3(183, 0, 0), self._on_slider_change_by_user) --[[@as druid.slider]] + self.slider = self.druid:new_slider("slider_pin", vmath.vector3(55, 0, 0), self._on_slider_change_by_user) --[[@as druid.slider]] self.slider:set_input_node("slider") self:set_text_function(function(value) @@ -29,8 +29,7 @@ function M:init(template, nodes) self.container = self.druid:new_container(self.root) self.container:add_container("text_name") - self.container:add_container("slider") - self.container:add_container("button") + self.container:add_container("E_Anchor") end diff --git a/druid/widget/properties_panel/properties_panel.gui b/druid/widget/properties_panel/properties_panel.gui index 9bdcdd3..4365bd7 100644 --- a/druid/widget/properties_panel/properties_panel.gui +++ b/druid/widget/properties_panel/properties_panel.gui @@ -33,7 +33,7 @@ nodes { } nodes { position { - x: -196.0 + x: -192.0 y: 116.0 } scale { @@ -71,11 +71,11 @@ nodes { } nodes { position { - x: -196.0 + x: -200.0 y: 70.0 } size { - x: 392.0 + x: 400.0 y: 190.0 } type: TYPE_BOX @@ -90,8 +90,8 @@ nodes { } nodes { size { - x: 392.0 - y: 186.0 + x: 400.0 + y: 190.0 } type: TYPE_BOX texture: "druid/pixel" @@ -101,6 +101,8 @@ nodes { parent: "scroll_view" inherit_alpha: true slice9 { + x: 8.0 + y: 8.0 w: 6.0 } visible: false @@ -146,8 +148,7 @@ nodes { } nodes { position { - x: -200.0 - y: 100.0 + y: 50.0 } type: TYPE_BOX texture: "druid/empty" @@ -178,10 +179,16 @@ nodes { } nodes { type: TYPE_BOX - id: "property_slider/slider" + id: "property_slider/E_Anchor" parent: "property_slider/root" template_node_child: true } +nodes { + type: TYPE_BOX + id: "property_slider/slider" + parent: "property_slider/E_Anchor" + template_node_child: true +} nodes { type: TYPE_BOX id: "property_slider/slider_back" @@ -197,7 +204,7 @@ nodes { nodes { type: TYPE_BOX id: "property_slider/button" - parent: "property_slider/root" + parent: "property_slider/E_Anchor" template_node_child: true } nodes { @@ -236,10 +243,16 @@ nodes { } nodes { type: TYPE_BOX - id: "property_checkbox/button" + id: "property_checkbox/E_Anchor" parent: "property_checkbox/root" template_node_child: true } +nodes { + type: TYPE_BOX + id: "property_checkbox/button" + parent: "property_checkbox/E_Anchor" + template_node_child: true +} nodes { type: TYPE_BOX id: "property_checkbox/icon" @@ -276,10 +289,16 @@ nodes { } nodes { type: TYPE_BOX - id: "property_button/button" + id: "property_button/E_Anchor" parent: "property_button/root" template_node_child: true } +nodes { + type: TYPE_BOX + id: "property_button/button" + parent: "property_button/E_Anchor" + template_node_child: true +} nodes { type: TYPE_BOX id: "property_button/selected" diff --git a/druid/widget/properties_panel/properties_panel.lua b/druid/widget/properties_panel/properties_panel.lua index 0795b7a..5502ff8 100644 --- a/druid/widget/properties_panel/properties_panel.lua +++ b/druid/widget/properties_panel/properties_panel.lua @@ -17,7 +17,6 @@ function M:init(template, nodes) --self.root = self.druid:new_container("root") self.root = self:get_node("root") self.text_no_properties = self:get_node("text_no_properties") - --self.root:add_container("text_header") self.properties = {} @@ -41,6 +40,7 @@ function M:init(template, nodes) self.container = self.druid:new_container(self.root) self.container:add_container("text_header") self.container:add_container("icon_drag") + --self.container:create_draggable_corners() self.container_scroll_view = self.container:add_container("scroll_view") self.contaienr_scroll_content = self.container_scroll_view:add_container("scroll_content") @@ -63,7 +63,12 @@ end function M:on_size_changed(new_size) - self.container:set_size(new_size.x + 8, new_size.y + 50 + 8, gui.PIVOT_N) + self.container:set_size(new_size.x, new_size.y + 50, gui.PIVOT_N) + + local width = self.layout:get_size().x - self.layout.padding.x - self.layout.padding.z + for index = 1, #self.properties do + self.properties[index].container:set_size(width) + end end @@ -83,7 +88,9 @@ function M:add_checkbox(text_id, initial_value, on_change_callback) gui.set_enabled(instance.root, true) self.layout:add(instance.root) table.insert(self.properties, instance) - instance.container:set_size(self.layout:get_size().x) + + local width = self.layout:get_size().x - self.layout.padding.x - self.layout.padding.z + instance.container:set_size(width) gui.set_enabled(self.text_no_properties, false) @@ -104,7 +111,9 @@ function M:add_slider(text_id, initial_value, on_change_callback) gui.set_enabled(instance.root, true) self.layout:add(instance.root) table.insert(self.properties, instance) - instance.container:set_size(self.layout:get_size().x) + + local width = self.layout:get_size().x - self.layout.padding.x - self.layout.padding.z + instance.container:set_size(width) gui.set_enabled(self.text_no_properties, false) @@ -127,7 +136,9 @@ function M:add_button(text_id, on_click_callback, callback_context) gui.set_enabled(instance.root, true) self.layout:add(instance.root) table.insert(self.properties, instance) - instance.container:set_size(self.layout:get_size().x) + + local width = self.layout:get_size().x - self.layout.padding.x - self.layout.padding.z + instance.container:set_size(width) gui.set_enabled(self.text_no_properties, false) From 37190684c471be5860d64476111ed8bd204848fc Mon Sep 17 00:00:00 2001 From: Insality Date: Tue, 19 Nov 2024 00:48:15 +0200 Subject: [PATCH 18/50] Add more widgets --- druid/color.lua | 222 +++++++++++++++++++++ druid/extended/layout.lua | 12 +- druid/widget/memory_panel/memory_panel.gui | 58 ++++++ druid/widget/memory_panel/memory_panel.lua | 22 ++ druid/widget/mini_graph/mini_graph.gui | 171 ++++++++++++++++ druid/widget/mini_graph/mini_graph.lua | 88 ++++++++ 6 files changed, 570 insertions(+), 3 deletions(-) create mode 100644 druid/color.lua create mode 100644 druid/widget/memory_panel/memory_panel.gui create mode 100644 druid/widget/memory_panel/memory_panel.lua create mode 100644 druid/widget/mini_graph/mini_graph.gui create mode 100644 druid/widget/mini_graph/mini_graph.lua diff --git a/druid/color.lua b/druid/color.lua new file mode 100644 index 0000000..d677233 --- /dev/null +++ b/druid/color.lua @@ -0,0 +1,222 @@ +---@type table> +local PALETTE_DATA +local CURRENT_PALETTE = "default" +local DEFAULT_COLOR = vmath.vector4(1, 1, 1, 1) +local COLOR_X = hash("color.x") +local COLOR_Y = hash("color.y") +local COLOR_Z = hash("color.z") + +local M = {} + + +---Get color color by id +---@param color_id string +---@return vector4 +function M.get(color_id) + return PALETTE_DATA[CURRENT_PALETTE] and PALETTE_DATA[CURRENT_PALETTE][color_id] or DEFAULT_COLOR +end + + +---Add palette to palette data +---@param palette_name string +---@param palette_data table +function M.add_palette(palette_name, palette_data) + PALETTE_DATA[palette_name] = PALETTE_DATA[palette_name] or {} + local palette = PALETTE_DATA[palette_name] + + for color_id, color in pairs(palette_data) do + if type(color) == "string" then + palette[color_id] = M.hex2vector4(color) + else + palette[color_id] = color + end + end +end + + +function M.set_palette(palette_name) + if PALETTE_DATA[palette_name] then + CURRENT_PALETTE = palette_name + end +end + + +function M.get_palette() + return CURRENT_PALETTE +end + + +---Set color of gui node without changing alpha +---@param gui_node node +---@param color vector4|vector3|string Color in vector4, vector3 or color id from palette +function M.set_color(gui_node, color) + if type(color) == "string" then + color = M.get(color) + end + + gui.set(gui_node, COLOR_X, color.x) + gui.set(gui_node, COLOR_Y, color.y) + gui.set(gui_node, COLOR_Z, color.z) +end + + +function M.get_random_color() + return vmath.vector4(math.random(), math.random(), math.random(), 1) +end + + +---Lerp colors via color HSB values +function M.lerp(t, color1, color2) + local h1, s1, v1 = M.rgb2hsb(color1.x, color1.y, color1.z) + local h2, s2, v2 = M.rgb2hsb(color2.x, color2.y, color2.z) + + local h = h1 + (h2 - h1) * t + local s = s1 + (s2 - s1) * t + local v = v1 + (v2 - v1) * t + + local r, g, b, a = M.hsb2rgb(h, s, v) + a = a or 1 + return vmath.vector4(r, g, b, a) +end + + +---@param hex string +---@param alpha number|nil +---@return number, number, number, number +function M.hex2rgb(hex, alpha) + alpha = alpha or 1 + if alpha > 1 then + alpha = alpha / 100 + end + + -- Remove leading # + if string.sub(hex, 1, 1) == "#" then + hex = string.sub(hex, 2) + end + + -- Expand 3-digit hex codes to 6 digits + if #hex == 3 then + hex = string.rep(string.sub(hex, 1, 1), 2) .. + string.rep(string.sub(hex, 2, 2), 2) .. + string.rep(string.sub(hex, 3, 3), 2) + end + + local r = tonumber("0x" .. string.sub(hex, 1, 2)) / 255 + local g = tonumber("0x" .. string.sub(hex, 3, 4)) / 255 + local b = tonumber("0x" .. string.sub(hex, 5, 6)) / 255 + return r, g, b, alpha +end + + +---@param hex string +---@param alpha number|nil +---@return vector4 +function M.hex2vector4(hex, alpha) + local r, g, b, a = M.hex2rgb(hex, alpha) + return vmath.vector4(r, g, b, a) +end + + +---Convert hsb color to rgb color +---@param r number @Red value +---@param g number @Green value +---@param b number @Blue value +---@param alpha number|nil @Alpha value. Default is 1 +function M.rgb2hsb(r, g, b, alpha) + alpha = alpha or 1 + local min, max = math.min(r, g, b), math.max(r, g, b) + local delta = max - min + local h, s, v = 0, max, max + + s = max ~= 0 and delta / max or 0 + + if delta ~= 0 then + if r == max then + h = (g - b) / delta + elseif g == max then + h = 2 + (b - r) / delta + else + h = 4 + (r - g) / delta + end + h = (h / 6) % 1 + end + + alpha = alpha > 1 and alpha / 100 or alpha + + return h, s, v, alpha +end + + +---Convert hsb color to rgb color +---@param h number @Hue +---@param s number @Saturation +---@param v number @Value +---@param alpha number|nil @Alpha value. Default is 1 +function M.hsb2rgb(h, s, v, alpha) + local r, g, b + local i = math.floor(h * 6) + local f = h * 6 - i + local p = v * (1 - s) + local q = v * (1 - f * s) + local t = v * (1 - (1 - f) * s) + + i = i % 6 + + if i == 0 then r, g, b = v, t, p + elseif i == 1 then r, g, b = q, v, p + elseif i == 2 then r, g, b = p, v, t + elseif i == 3 then r, g, b = p, q, v + elseif i == 4 then r, g, b = t, p, v + elseif i == 5 then r, g, b = v, p, q + end + + return r, g, b, alpha +end + + +---Convert rgb color to hex color +---@param red number @Red value +---@param green number @Green value +---@param blue number @Blue value +function M.rgb2hex(red, green, blue) + local r = string.format("%x", math.floor(red * 255)) + local g = string.format("%x", math.floor(green * 255)) + local b = string.format("%x", math.floor(blue * 255)) + return string.upper((#r == 1 and "0" or "") .. r .. (#g == 1 and "0" or "") .. g .. (#b == 1 and "0" or "") .. b) +end + + +function M.load_palette() + local PALETTE_PATH = sys.get_config_string("fluid.palette") + if PALETTE_PATH then + PALETTE_DATA = M.load_json(PALETTE_PATH) --[[@as table>]] + end + PALETTE_DATA = PALETTE_DATA or {} + + for _, palette_data in pairs(PALETTE_DATA) do + for color_id, color in pairs(palette_data) do + if type(color) == "string" then + palette_data[color_id] = M.hex2vector4(color) + end + end + end +end + + +---Load JSON file from game resources folder (by relative path to game.project) +---Return nil if file not found or error +---@param json_path string +---@return table|nil +function M.load_json(json_path) + local resource, is_error = sys.load_resource(json_path) + if is_error or not resource then + return nil + end + + return json.decode(resource) +end + + +M.load_palette() + +return M \ No newline at end of file diff --git a/druid/extended/layout.lua b/druid/extended/layout.lua index 8eb657c..804e518 100644 --- a/druid/extended/layout.lua +++ b/druid/extended/layout.lua @@ -80,10 +80,16 @@ function M:set_margin(margin_x, margin_y) end ----@param padding vector4 The vector4 with padding values, where x - left, y - top, z - right, w - bottom +---@param padding_x number|nil +---@param padding_y number|nil +---@param padding_z number|nil +---@param padding_w number|nil ---@return druid.layout -function M:set_padding(padding) - self.padding = padding +function M:set_padding(padding_x, padding_y, padding_z, padding_w) + self.padding.x = padding_x or self.padding.x + self.padding.y = padding_y or self.padding.y + self.padding.z = padding_z or padding_x or self.padding.z + self.padding.w = padding_w or padding_y or self.padding.w self.is_dirty = true return self diff --git a/druid/widget/memory_panel/memory_panel.gui b/druid/widget/memory_panel/memory_panel.gui new file mode 100644 index 0000000..c1ed80a --- /dev/null +++ b/druid/widget/memory_panel/memory_panel.gui @@ -0,0 +1,58 @@ +nodes { + size { + x: 200.0 + y: 100.0 + } + type: TYPE_BOX + id: "root" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO + visible: false +} +nodes { + type: TYPE_TEMPLATE + id: "mini_graph" + parent: "root" + inherit_alpha: true + template: "/druid/widget/mini_graph/mini_graph.gui" +} +nodes { + type: TYPE_BOX + id: "mini_graph/root" + parent: "mini_graph" + template_node_child: true +} +nodes { + type: TYPE_TEXT + text: "Memory Panel" + id: "mini_graph/text_header" + parent: "mini_graph/root" + overridden_fields: 8 + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "mini_graph/icon_drag" + parent: "mini_graph/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "mini_graph/panel_diagram" + parent: "mini_graph/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "mini_graph/prefab_line" + parent: "mini_graph/panel_diagram" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "mini_graph/text_value" + parent: "mini_graph/root" + template_node_child: true +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/memory_panel/memory_panel.lua b/druid/widget/memory_panel/memory_panel.lua new file mode 100644 index 0000000..800447a --- /dev/null +++ b/druid/widget/memory_panel/memory_panel.lua @@ -0,0 +1,22 @@ +local mini_graph = require("druid.widget.mini_graph.mini_graph") + +---@class widget.memory_panel: druid.widget +---@field root node +local M = {} + + +function M:init() + self.druid = self:get_druid() + self.mini_graph = self.druid:new_widget(mini_graph, "mini_graph") + + --for index = 1, 32 do + -- self.mini_graph:set_line_value(index, 0) + --end + + timer.delay(0.1, true, function() + self.mini_graph:push_line_value(math.random()) + end) +end + + +return M \ No newline at end of file diff --git a/druid/widget/mini_graph/mini_graph.gui b/druid/widget/mini_graph/mini_graph.gui new file mode 100644 index 0000000..1de9224 --- /dev/null +++ b/druid/widget/mini_graph/mini_graph.gui @@ -0,0 +1,171 @@ +fonts { + name: "text_regular" + font: "/druid/fonts/text_regular.font" +} +fonts { + name: "text_bold" + font: "/druid/fonts/text_bold.font" +} +textures { + name: "druid" + texture: "/druid/druid.atlas" +} +nodes { + size { + x: 200.0 + y: 140.0 + } + color { + x: 0.173 + y: 0.184 + z: 0.204 + } + type: TYPE_BOX + texture: "druid/ui_circle_16" + id: "root" + inherit_alpha: true + slice9 { + x: 8.0 + y: 8.0 + z: 8.0 + w: 8.0 + } +} +nodes { + position { + x: -92.0 + y: 63.0 + } + scale { + x: 0.5 + y: 0.5 + } + size { + x: 260.0 + y: 50.0 + } + color { + x: 0.463 + y: 0.475 + z: 0.49 + } + type: TYPE_TEXT + text: "Mini Graph" + font: "text_regular" + id: "text_header" + pivot: PIVOT_NW + outline { + x: 1.0 + y: 1.0 + z: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + } + parent: "root" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} +nodes { + position { + x: 92.0 + y: 67.0 + } + color { + x: 0.129 + y: 0.141 + z: 0.157 + } + type: TYPE_BOX + texture: "druid/ui_circle_32" + id: "icon_drag" + pivot: PIVOT_NE + parent: "root" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} +nodes { + position { + y: -70.0 + } + size { + x: 200.0 + y: 100.0 + } + color { + x: 0.129 + y: 0.141 + z: 0.157 + } + type: TYPE_BOX + texture: "druid/ui_circle_16" + id: "panel_diagram" + pivot: PIVOT_S + parent: "root" + inherit_alpha: true + slice9 { + x: 8.0 + y: 8.0 + z: 8.0 + w: 8.0 + } + clipping_mode: CLIPPING_MODE_STENCIL +} +nodes { + size { + x: 8.0 + y: 70.0 + } + color { + x: 0.957 + y: 0.608 + z: 0.608 + } + type: TYPE_BOX + texture: "druid/pixel" + id: "prefab_line" + pivot: PIVOT_S + parent: "panel_diagram" + inherit_alpha: true +} +nodes { + position { + y: 12.0 + } + scale { + x: 0.7 + y: 0.7 + } + size { + x: 260.0 + y: 40.0 + } + color { + x: 0.463 + y: 0.475 + z: 0.49 + } + type: TYPE_TEXT + text: "120.23 KB" + font: "text_bold" + id: "text_value" + outline { + x: 1.0 + y: 1.0 + z: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + } + parent: "root" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/mini_graph/mini_graph.lua b/druid/widget/mini_graph/mini_graph.lua new file mode 100644 index 0000000..553a1b8 --- /dev/null +++ b/druid/widget/mini_graph/mini_graph.lua @@ -0,0 +1,88 @@ +local color = require("druid.color") + +---@class widget.mini_graph: druid.widget +local M = {} + +local SIZE_Y = hash("size.y") + + +function M:init() + self.druid = self:get_druid() + self.root = self:get_node("root") + self.container = self.druid:new_container(self.root) + self.text_header = self.druid:new_text("text_header") + self.text_value = self.druid:new_text("text_value") + self.drag_corner = self.druid:new_drag("icon_drag", self.on_drag_corner) + self.layout = self.druid:new_layout("panel_diagram", "horizontal") + :set_margin(0, 0) + :set_padding(0, 0, 0, 0) + + self.prefab_line = self:get_node("prefab_line") + gui.set_enabled(self.prefab_line, false) + + self.color_zero = color.hex2vector4("#8ED59E") + self.color_one = color.hex2vector4("#F49B9B") + + self.lines = {} + self.values = {} + self.samples = 64 + local line_width = self.layout:get_size().x / self.samples + for index = 1, self.samples do + local line = gui.clone(self.prefab_line) + gui.set_enabled(line, true) + gui.set(line, "size.x", line_width) + self.layout:add(line) + table.insert(self.lines, line) + end + + for index = 1, self.samples do + local outsine = index/self.samples + self:set_line_value(index, outsine) + end +end + + +---@param index number +---@param value number The normalized value from 0 to 1 +function M:set_line_value(index, value) + local line = self.lines[index] + if not line then + return + end + + local target_color = color.lerp(value * value, self.color_zero, self.color_one) + gui.set(line, SIZE_Y, value * 70) + gui.set_color(line, target_color) + + self.values[index] = value +end + + +---@return number +function M:get_line_value(index) + return self.values[index] +end + + +function M:push_line_value(value) + for index = 1, self.samples - 1 do + self:set_line_value(index, self:get_line_value(index + 1), true) + end + + self:set_line_value(self.samples, value, true) +end + + +---@param text string +function M:set_text(text) + self.text_value:set_to(text) +end + + +function M:on_drag_corner(dx, dy) + local position = self.container:get_position() + self.container:set_position(position.x + dx, position.y + dy) +end + + +return M \ No newline at end of file From c35dfc70660d2507e09363c682af49238b647da9 Mon Sep 17 00:00:00 2001 From: Insality Date: Tue, 19 Nov 2024 23:06:57 +0200 Subject: [PATCH 19/50] More widgets stuff, cleaning code --- druid/base/drag.lua | 16 + druid/base/scroll.lua | 2 + druid/base/text.lua | 30 +- druid/bindings.lua | 48 +++ druid/color.lua | 7 + druid/custom/rich_input/rich_input.gui | 285 ++---------------- druid/druid.atlas | 6 + druid/editor_scripts/widget.lua_template | 15 + druid/extended/container.lua | 2 +- druid/extended/layout.lua | 9 +- druid/images/icons/icon_arrow.png | Bin 0 -> 330 bytes druid/images/icons/icon_drag.png | Bin 0 -> 200 bytes druid/materials/stencil/gui_stencil.fp | 18 ++ druid/materials/stencil/gui_stencil.material | 8 + druid/materials/stencil/gui_stencil.vp | 20 ++ druid/styles/default/style.lua | 2 +- druid/system/druid_annotations.lua | 2 + druid/system/druid_instance.lua | 2 +- druid/widget/fps_panel/fps_panel.gui | 222 ++++++++++++++ druid/widget/fps_panel/fps_panel.lua | 84 ++++++ druid/widget/memory_panel/memory_panel.gui | 202 ++++++++++++- druid/widget/memory_panel/memory_panel.lua | 68 ++++- druid/widget/mini_graph/mini_graph.gui | 81 ++--- druid/widget/mini_graph/mini_graph.lua | 101 +++++-- .../properties/property_button.gui | 15 +- .../properties/property_button.lua | 25 +- .../properties/property_checkbox.gui | 6 +- .../properties/property_checkbox.lua | 9 +- .../properties/property_input.gui | 143 +++++++++ .../properties/property_input.lua | 38 +++ .../properties/property_slider.gui | 6 +- .../properties/property_slider.lua | 12 +- .../properties/property_text.gui | 96 ++++++ .../properties/property_text.lua | 39 +++ .../properties_panel/properties_panel.gui | 225 ++++++++++---- .../properties_panel/properties_panel.lua | 158 ++++++---- 36 files changed, 1494 insertions(+), 508 deletions(-) create mode 100644 druid/bindings.lua create mode 100644 druid/editor_scripts/widget.lua_template create mode 100644 druid/images/icons/icon_arrow.png create mode 100644 druid/images/icons/icon_drag.png create mode 100644 druid/materials/stencil/gui_stencil.fp create mode 100644 druid/materials/stencil/gui_stencil.material create mode 100644 druid/materials/stencil/gui_stencil.vp create mode 100644 druid/system/druid_annotations.lua create mode 100644 druid/widget/fps_panel/fps_panel.gui create mode 100644 druid/widget/fps_panel/fps_panel.lua create mode 100644 druid/widget/properties_panel/properties/property_input.gui create mode 100644 druid/widget/properties_panel/properties/property_input.lua create mode 100644 druid/widget/properties_panel/properties/property_text.gui create mode 100644 druid/widget/properties_panel/properties/property_text.lua diff --git a/druid/base/drag.lua b/druid/base/drag.lua index 5458900..0b0b36f 100644 --- a/druid/base/drag.lua +++ b/druid/base/drag.lua @@ -212,7 +212,9 @@ end ---@param node_or_node_id node|string ---@param on_drag_callback function function M:init(node_or_node_id, on_drag_callback) + self.druid = self:get_druid() self.node = self:get_node(node_or_node_id) + self.hover = self.druid:new_hover(self.node) self.dx = 0 self.dy = 0 @@ -239,6 +241,20 @@ function M:init(node_or_node_id, on_drag_callback) self.on_drag_end = Event() self:on_window_resized() + self:set_drag_cursors(true) +end + + +---Set Drag component enabled state. +---@param is_enabled boolean +function M:set_drag_cursors(is_enabled) + if defos and is_enabled then + self.hover.style.ON_HOVER_CURSOR = defos.CURSOR_CROSSHAIR + self.hover.style.ON_MOUSE_HOVER_CURSOR = defos.CURSOR_HAND + else + self.hover.style.ON_HOVER_CURSOR = nil + self.hover.style.ON_MOUSE_HOVER_CURSOR = nil + end end diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index 55f632a..077dc8f 100755 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -796,6 +796,8 @@ function M:_update_size() self:_set_scroll_position(self.position.x, self.position.y) self.target_position.x = self.position.x self.target_position.y = self.position.y + + self.drag:set_drag_cursors(self.drag.can_x or self.drag.can_y) end diff --git a/druid/base/text.lua b/druid/base/text.lua index f00b506..1c9e9d3 100755 --- a/druid/base/text.lua +++ b/druid/base/text.lua @@ -391,10 +391,11 @@ end --- Set text to text field +---@deprecated ---@param set_to string Text for node ----@return Text Current text instance +---@return druid.text Current text instance function M:set_to(set_to) - set_to = set_to or "" + set_to = tostring(set_to or "") self.last_value = set_to gui.set_text(self.node, set_to) @@ -407,9 +408,20 @@ function M:set_to(set_to) end +function M:set_text(new_text) +---@diagnostic disable-next-line: deprecated + return self:set_to(new_text) +end + + +function M:get_text() + return self.last_value +end + + --- Set text area size ---@param size vector3 The new text area size ----@return Text Current text instance +---@return druid.text Current text instance function M:set_size(size) self.start_size = size self.text_area = vmath.vector3(size) @@ -421,7 +433,7 @@ end --- Set color ---@param color vector4 Color for node ----@return Text Current text instance +---@return druid.text Current text instance function M:set_color(color) self.color = color gui.set_color(self.node, color) @@ -432,7 +444,7 @@ end --- Set alpha ---@param alpha number Alpha for node ----@return Text Current text instance +---@return druid.text Current text instance function M:set_alpha(alpha) self.color.w = alpha gui.set_color(self.node, self.color) @@ -443,7 +455,7 @@ end --- Set scale ---@param scale vector3 Scale for node ----@return Text Current text instance +---@return druid.text Current text instance function M:set_scale(scale) self.last_scale = scale gui.set_scale(self.node, scale) @@ -454,7 +466,7 @@ end --- Set text pivot. Text will re-anchor inside text area ---@param pivot number The gui.PIVOT_* constant ----@return Text Current text instance +---@return druid.text Current text instance function M:set_pivot(pivot) local prev_pivot = gui.get_pivot(self.node) local prev_offset = const.PIVOTS[prev_pivot] @@ -487,7 +499,7 @@ end --- Set text adjust, refresh the current text visuals, if needed ---@param adjust_type string|nil See const.TEXT_ADJUST. If pass nil - use current adjust type ---@param minimal_scale number|nil If pass nil - not use minimal scale ----@return Text Current text instance +---@return druid.text Current text instance function M:set_text_adjust(adjust_type, minimal_scale) self.adjust_type = adjust_type self._minimal_scale = minimal_scale @@ -499,7 +511,7 @@ end --- Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types ---@param minimal_scale number If pass nil - not use minimal scale ----@return Text Current text instance +---@return druid.text Current text instance function M:set_minimal_scale(minimal_scale) self._minimal_scale = minimal_scale diff --git a/druid/bindings.lua b/druid/bindings.lua new file mode 100644 index 0000000..15f87a4 --- /dev/null +++ b/druid/bindings.lua @@ -0,0 +1,48 @@ +local event = require("event.event") + +local M = {} +local WRAPPED_WIDGETS = {} + +---Set a widget to the current game object. The game object can acquire the widget by calling `bindings.get_widget` +---It wraps only top level functions, so no access to nested widgets +---@param widget druid.widget +function M.set_widget(widget) + local object = msg.url() + object.fragment = nil + + -- Make a copy of the widget with all functions wrapped in events + -- It makes available to call gui functions from game objects + local wrapped_widget = setmetatable({}, { __index = widget }) + local parent_table = getmetatable(widget).__index + + -- Go through all functions and wrap them in events + for key, value in pairs(parent_table) do + if type(value) == "function" then + wrapped_widget[key] = event.create(function(_, ...) + return value(widget, ...) + end) + end + end + + WRAPPED_WIDGETS[object.socket] = WRAPPED_WIDGETS[object.socket] or {} + WRAPPED_WIDGETS[object.socket][object.path] = wrapped_widget +end + + +---@param object_url string|userdata|url @root object +---@return druid.widget|nil +function M.get_widget(object_url) + assert(object_url, "You must provide an object_url") + + object_url = msg.url(object_url --[[@as string]]) + + local socket_widgets = WRAPPED_WIDGETS[object_url.socket] + if not socket_widgets then + return nil + end + + return socket_widgets[object_url.path] +end + + +return M diff --git a/druid/color.lua b/druid/color.lua index d677233..8a1ccc9 100644 --- a/druid/color.lua +++ b/druid/color.lua @@ -13,6 +13,13 @@ local M = {} ---@param color_id string ---@return vector4 function M.get(color_id) + -- Check is it hex: starts with "#" or contains only 3 or 6 hex symbols + if type(color_id) == "string" then + if string.sub(color_id, 1, 1) == "#" or string.match(color_id, "^[0-9a-fA-F]+$") then + return M.hex2vector4(color_id) + end + end + return PALETTE_DATA[CURRENT_PALETTE] and PALETTE_DATA[CURRENT_PALETTE][color_id] or DEFAULT_COLOR end diff --git a/druid/custom/rich_input/rich_input.gui b/druid/custom/rich_input/rich_input.gui index 5467ee9..46c7d7f 100644 --- a/druid/custom/rich_input/rich_input.gui +++ b/druid/custom/rich_input/rich_input.gui @@ -1,117 +1,35 @@ -script: "" fonts { name: "text_bold" - font: "/example/assets/fonts/text_bold.font" + font: "/druid/fonts/text_bold.font" } textures { name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + texture: "/druid/druid.atlas" } 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: 500.0 - y: 80.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 + x: 200.0 + y: 40.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "" 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 500.0 - y: 80.0 - z: 0.0 - w: 1.0 + x: 200.0 + y: 40.0 } color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 + x: 0.31 + y: 0.318 + z: 0.322 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/rect_round2_width1" + texture: "druid/rect_round2_width2" id: "button" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "root" - layer: "" inherit_alpha: true slice9 { x: 4.0 @@ -119,192 +37,89 @@ nodes { z: 4.0 w: 4.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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 + x: 0.5 + y: 0.5 } size { - x: 480.0 - y: 60.0 - z: 0.0 - w: 1.0 + x: 380.0 + y: 50.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Placeholder" font: "text_bold" id: "placeholder_text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 0.4 y: 0.4 z: 0.4 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false - parent: "button" - layer: "" + parent: "root" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } 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 + x: 0.5 + y: 0.5 } size { - x: 480.0 - y: 60.0 - z: 0.0 - w: 1.0 + x: 380.0 + y: 50.0 } color { x: 0.722 y: 0.741 z: 0.761 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "User input" font: "text_bold" id: "input_text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false - parent: "button" - layer: "" + parent: "root" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 118.0 - y: 0.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 + x: 61.0 } scale { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 + x: 0.5 + y: 0.5 } size { x: 16.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.631 y: 0.843 z: 0.961 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_16" id: "cursor_node" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT - parent: "button" - layer: "" + parent: "root" inherit_alpha: true slice9 { x: 8.0 @@ -312,84 +127,34 @@ nodes { z: 8.0 w: 8.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false alpha: 0.5 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 + x: -1.4 y: 4.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } - scale { - x: 1.2 - y: 1.2 - z: 1.0 - w: 1.0 } size { x: 20.0 y: 40.0 - z: 0.0 - w: 1.0 } color { x: 0.722 y: 0.741 z: 0.761 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "|" font: "text_bold" id: "cursor_text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "cursor_node" - layer: "" - inherit_alpha: false - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/druid/druid.atlas b/druid/druid.atlas index 59904d2..10868c4 100644 --- a/druid/druid.atlas +++ b/druid/druid.atlas @@ -22,4 +22,10 @@ images { images { image: "/druid/images/panels/rect_round2_width2.png" } +images { + image: "/druid/images/icons/icon_drag.png" +} +images { + image: "/druid/images/icons/icon_arrow.png" +} extrude_borders: 2 diff --git a/druid/editor_scripts/widget.lua_template b/druid/editor_scripts/widget.lua_template new file mode 100644 index 0000000..18875f6 --- /dev/null +++ b/druid/editor_scripts/widget.lua_template @@ -0,0 +1,15 @@ +---@class widget.TEMPLATE: druid.widget +local M = {} + +function M:init() + self.root = self:get_node("root") + self.button = self.druid:new_button("button"), self.on_button, self) +end + + +function M:on_button() + print("Root node", self.root) +end + + +return M \ No newline at end of file diff --git a/druid/extended/container.lua b/druid/extended/container.lua index 3a4a17f..317e2bb 100644 --- a/druid/extended/container.lua +++ b/druid/extended/container.lua @@ -196,7 +196,7 @@ end ---Get current size of layout node ---@return vector3 size function M:get_size() - return self.size + return vmath.vector3(self.size) end diff --git a/druid/extended/layout.lua b/druid/extended/layout.lua index 804e518..c06752e 100644 --- a/druid/extended/layout.lua +++ b/druid/extended/layout.lua @@ -88,8 +88,8 @@ end function M:set_padding(padding_x, padding_y, padding_z, padding_w) self.padding.x = padding_x or self.padding.x self.padding.y = padding_y or self.padding.y - self.padding.z = padding_z or padding_x or self.padding.z - self.padding.w = padding_w or padding_y or self.padding.w + self.padding.z = padding_z or self.padding.z + self.padding.w = padding_w or self.padding.w self.is_dirty = true return self @@ -153,7 +153,6 @@ function M:add(node_or_node_id) ---@cast node node table.insert(self.entities, node) gui.set_parent(node, self.node) - self.is_dirty = true return self @@ -229,7 +228,7 @@ function M:refresh_layout() 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 + if node_width > 0 or node_height > 0 then -- Calculate position for current node local position_x, position_y @@ -396,7 +395,7 @@ function M:calculate_rows_data() rows_data.nodes_height[node] = node_height end - if node_width > 0 and node_height > 0 then + if node_width > 0 or 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) diff --git a/druid/images/icons/icon_arrow.png b/druid/images/icons/icon_arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..40fbf2a8dbb946fad836f98e07fae61eac6d44a3 GIT binary patch literal 330 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?3oVGw3ym^DWND9BhG zN6VhIDT3pdFnG@l6 z!1nN6^Y%4r1y@_5IZbXAa5pM9N#5(4B+)3_6n;s(=6-yg^Hv_l`PXKgcUSv7`3@sr XWA2+%6SdX?y~^O}>gTe~DWM4fs?T{W literal 0 HcmV?d00001 diff --git a/druid/images/icons/icon_drag.png b/druid/images/icons/icon_drag.png new file mode 100644 index 0000000000000000000000000000000000000000..3bd2c35abb6704ce93a317cf37f1ae2f21abea59 GIT binary patch literal 200 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?3oVGw3ym^DWND9BhG zC zJntUf4{vOxG)?yTJ85v(iwZI9nYvqFm#= self.collect_time do + -- Remove last + local removed_value = table.remove(self.fps_samples) + self.collect_time_counter = self.collect_time_counter - removed_value + end +end + + +function M:push_fps_value() + if #self.fps_samples == 0 then + return + end + + local max_frame_time = 0 + local average_frame_time = 0 + local average_samples_count = self.delta_time + local average_collected = 0 + for index = 1, #self.fps_samples do + if average_frame_time < average_samples_count then + average_frame_time = average_frame_time + self.fps_samples[index] + average_collected = average_collected + 1 + end + max_frame_time = math.max(max_frame_time, self.fps_samples[index]) + end + + average_frame_time = average_frame_time / average_collected + + self.mini_graph:push_line_value(1 / average_frame_time) + + self.text_fps:set_to(tostring(math.ceil(1 / average_frame_time) .. " FPS")) + local lowest_value = math.ceil(self.mini_graph:get_lowest_value()) + self.text_min_fps:set_to(lowest_value .. " lowest") +end + + +return M \ No newline at end of file diff --git a/druid/widget/memory_panel/memory_panel.gui b/druid/widget/memory_panel/memory_panel.gui index c1ed80a..d0c9c9a 100644 --- a/druid/widget/memory_panel/memory_panel.gui +++ b/druid/widget/memory_panel/memory_panel.gui @@ -1,3 +1,15 @@ +fonts { + name: "text_regular" + font: "/druid/fonts/text_regular.font" +} +fonts { + name: "text_bold" + font: "/druid/fonts/text_bold.font" +} +textures { + name: "druid" + texture: "/druid/druid.atlas" +} nodes { size { x: 200.0 @@ -23,36 +35,208 @@ nodes { template_node_child: true } nodes { - type: TYPE_TEXT - text: "Memory Panel" - id: "mini_graph/text_header" + type: TYPE_BOX + id: "mini_graph/header" parent: "mini_graph/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + text: "Memory" + id: "mini_graph/text_header" + parent: "mini_graph/header" overridden_fields: 8 template_node_child: true } nodes { type: TYPE_BOX id: "mini_graph/icon_drag" - parent: "mini_graph/root" + parent: "mini_graph/header" template_node_child: true } nodes { type: TYPE_BOX - id: "mini_graph/panel_diagram" + id: "mini_graph/content" parent: "mini_graph/root" template_node_child: true } nodes { type: TYPE_BOX id: "mini_graph/prefab_line" - parent: "mini_graph/panel_diagram" + parent: "mini_graph/content" template_node_child: true } nodes { - type: TYPE_TEXT - id: "mini_graph/text_value" - parent: "mini_graph/root" + type: TYPE_BOX + id: "mini_graph/color_low" + parent: "mini_graph/content" template_node_child: true } +nodes { + size { + x: 200.0 + y: 100.0 + } + type: TYPE_BOX + id: "content" + parent: "root" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO + visible: false +} +nodes { + position { + x: -96.0 + y: 12.0 + } + scale { + x: 0.3 + y: 0.3 + } + size { + x: 200.0 + y: 40.0 + } + color { + x: 0.463 + y: 0.475 + z: 0.49 + } + type: TYPE_TEXT + text: "120.23 KB" + font: "text_regular" + id: "text_max_value" + pivot: PIVOT_W + outline { + x: 1.0 + y: 1.0 + z: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + } + parent: "content" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} +nodes { + position { + x: 96.0 + y: 12.0 + } + scale { + x: 0.3 + y: 0.3 + } + size { + x: 200.0 + y: 40.0 + } + color { + x: 0.463 + y: 0.475 + z: 0.49 + } + type: TYPE_TEXT + text: "120 KB/s" + font: "text_regular" + id: "text_per_second" + pivot: PIVOT_E + outline { + x: 1.0 + y: 1.0 + z: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + } + parent: "content" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} +nodes { + position { + x: -33.4 + y: 30.0 + } + size { + x: 3.0 + y: 8.0 + } + color { + x: 0.173 + y: 0.184 + z: 0.204 + } + type: TYPE_BOX + texture: "druid/pixel" + id: "line_second_1" + pivot: PIVOT_N + parent: "content" + inherit_alpha: true +} +nodes { + position { + x: 33.2 + y: 30.0 + } + size { + x: 3.0 + y: 8.0 + } + color { + x: 0.173 + y: 0.184 + z: 0.204 + } + type: TYPE_BOX + texture: "druid/pixel" + id: "line_second_2" + pivot: PIVOT_N + parent: "content" + inherit_alpha: true +} +nodes { + position { + y: 12.0 + } + scale { + x: 0.3 + y: 0.3 + } + size { + x: 200.0 + y: 40.0 + } + color { + x: 0.463 + y: 0.475 + z: 0.49 + } + type: TYPE_TEXT + text: "120 KB" + font: "text_bold" + id: "text_memory" + outline { + x: 1.0 + y: 1.0 + z: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + } + parent: "content" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/memory_panel/memory_panel.lua b/druid/widget/memory_panel/memory_panel.lua index 800447a..672751a 100644 --- a/druid/widget/memory_panel/memory_panel.lua +++ b/druid/widget/memory_panel/memory_panel.lua @@ -4,19 +4,73 @@ local mini_graph = require("druid.widget.mini_graph.mini_graph") ---@field root node local M = {} - function M:init() - self.druid = self:get_druid() + self.delta_time = 0.1 + self.samples_count = 30 + self.memory_limit = 100 + self.mini_graph = self.druid:new_widget(mini_graph, "mini_graph") + self.mini_graph:set_samples(self.samples_count) + gui.set_parent(self:get_node("content"), self.mini_graph.content, true) - --for index = 1, 32 do - -- self.mini_graph:set_line_value(index, 0) - --end + self.max_value = self.druid:new_text("text_max_value") + self.text_per_second = self.druid:new_text("text_per_second") + self.text_memory = self.druid:new_text("text_memory") - timer.delay(0.1, true, function() - self.mini_graph:push_line_value(math.random()) + self.memory = collectgarbage("count") + self.memory_samples = {} + + self:update_text_memory() + + self.timer_id = timer.delay(self.delta_time, true, function() + self:push_next_value() end) end +function M:set_low_memory_limit(limit) + self.memory_limit = limit +end + + +function M:push_next_value() + local memory = collectgarbage("count") + local diff = math.max(0, memory - self.memory) + self.memory = memory + self:update_text_memory() + + table.insert(self.memory_samples, diff) + if #self.memory_samples > self.samples_count then + table.remove(self.memory_samples, 1) + end + + self.mini_graph:push_line_value(diff) + + local max_value = math.max(unpack(self.memory_samples)) + max_value = math.max(max_value, self.memory_limit) -- low limit to display + self.mini_graph:set_max_value(max_value) + + local max_memory = math.ceil(self.mini_graph:get_highest_value()) + self.max_value:set_to(max_memory .. " KB") + + local last_second = 0 + local last_second_samples = math.ceil(1 / self.delta_time) + for index = #self.memory_samples - last_second_samples + 1, #self.memory_samples do + last_second = last_second + (self.memory_samples[index] or 0) + end + self.text_per_second:set_to(math.ceil(last_second) .. " KB/s") +end + + +function M:update_text_memory() + local memory = math.ceil(collectgarbage("count")) -- in KB + if memory > 1024 then + memory = memory / 1024 + self.text_memory:set_to(string.format("%.2f", memory) .. " MB") + else + self.text_memory:set_to(memory .. " KB") + end +end + + return M \ No newline at end of file diff --git a/druid/widget/mini_graph/mini_graph.gui b/druid/widget/mini_graph/mini_graph.gui index 1de9224..ceefa96 100644 --- a/druid/widget/mini_graph/mini_graph.gui +++ b/druid/widget/mini_graph/mini_graph.gui @@ -31,10 +31,26 @@ nodes { w: 8.0 } } +nodes { + position { + y: 70.0 + } + size { + x: 200.0 + y: 40.0 + } + type: TYPE_BOX + id: "header" + pivot: PIVOT_N + parent: "root" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO + visible: false +} nodes { position { x: -92.0 - y: 63.0 + y: -8.0 } scale { x: 0.5 @@ -64,26 +80,26 @@ nodes { y: 1.0 z: 1.0 } - parent: "root" + parent: "header" inherit_alpha: true outline_alpha: 0.0 shadow_alpha: 0.0 } nodes { position { - x: 92.0 - y: 67.0 + x: 96.0 + y: -4.0 } color { - x: 0.129 - y: 0.141 - z: 0.157 + x: 0.306 + y: 0.31 + z: 0.314 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid/icon_drag" id: "icon_drag" pivot: PIVOT_NE - parent: "root" + parent: "header" inherit_alpha: true size_mode: SIZE_MODE_AUTO } @@ -102,7 +118,7 @@ nodes { } type: TYPE_BOX texture: "druid/ui_circle_16" - id: "panel_diagram" + id: "content" pivot: PIVOT_S parent: "root" inherit_alpha: true @@ -113,6 +129,7 @@ nodes { w: 8.0 } clipping_mode: CLIPPING_MODE_STENCIL + material: "gui_stencil" } nodes { size { @@ -128,44 +145,32 @@ nodes { texture: "druid/pixel" id: "prefab_line" pivot: PIVOT_S - parent: "panel_diagram" + parent: "content" inherit_alpha: true } nodes { position { - y: 12.0 - } - scale { - x: 0.7 - y: 0.7 + x: -10.0 + y: 4.0 } size { - x: 260.0 - y: 40.0 + x: 8.0 + y: 8.0 } color { - x: 0.463 - y: 0.475 - z: 0.49 + x: 0.557 + y: 0.835 + z: 0.62 } - type: TYPE_TEXT - text: "120.23 KB" - font: "text_bold" - id: "text_value" - outline { - x: 1.0 - y: 1.0 - z: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - } - parent: "root" + type: TYPE_BOX + texture: "druid/pixel" + id: "color_low" + parent: "content" inherit_alpha: true - outline_alpha: 0.0 - shadow_alpha: 0.0 } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT +materials { + name: "gui_stencil" + material: "/druid/materials/stencil/gui_stencil.material" +} diff --git a/druid/widget/mini_graph/mini_graph.lua b/druid/widget/mini_graph/mini_graph.lua index 553a1b8..cf266fc 100644 --- a/druid/widget/mini_graph/mini_graph.lua +++ b/druid/widget/mini_graph/mini_graph.lua @@ -7,25 +7,46 @@ local SIZE_Y = hash("size.y") function M:init() - self.druid = self:get_druid() self.root = self:get_node("root") self.container = self.druid:new_container(self.root) self.text_header = self.druid:new_text("text_header") - self.text_value = self.druid:new_text("text_value") - self.drag_corner = self.druid:new_drag("icon_drag", self.on_drag_corner) - self.layout = self.druid:new_layout("panel_diagram", "horizontal") + + self.druid:new_drag("header", self.on_drag_widget) + self.druid:new_button("icon_drag", self.toggle_hide) + :set_style(nil) + + self.content = self:get_node("content") + self.layout = self.druid:new_layout(self.content, "horizontal") :set_margin(0, 0) :set_padding(0, 0, 0, 0) self.prefab_line = self:get_node("prefab_line") gui.set_enabled(self.prefab_line, false) - self.color_zero = color.hex2vector4("#8ED59E") - self.color_one = color.hex2vector4("#F49B9B") + local node_color_low = self:get_node("color_low") + self.color_zero = gui.get_color(node_color_low) + self.color_one = gui.get_color(self.prefab_line) + gui.set_enabled(node_color_low, false) + self.is_hidden = false + self.max_value = 1 -- in this value line will be at max height self.lines = {} self.values = {} - self.samples = 64 + + self.container = self.druid:new_container(self.root) + self.container:add_container("header") + self.default_size = self.container:get_size() +end + + +function M:set_samples(samples) + self.samples = samples + self.layout:clear_layout() + for index = 1, #self.lines do + gui.delete_node(self.lines[index]) + end + self.lines = {} + local line_width = self.layout:get_size().x / self.samples for index = 1, self.samples do local line = gui.clone(self.prefab_line) @@ -34,11 +55,6 @@ function M:init() self.layout:add(line) table.insert(self.lines, line) end - - for index = 1, self.samples do - local outsine = index/self.samples - self:set_line_value(index, outsine) - end end @@ -50,39 +66,78 @@ function M:set_line_value(index, value) return end - local target_color = color.lerp(value * value, self.color_zero, self.color_one) - gui.set(line, SIZE_Y, value * 70) - gui.set_color(line, target_color) - self.values[index] = value + + local normalized = vmath.clamp(value/self.max_value, 0, 1) + local target_color = color.lerp(normalized, self.color_zero, self.color_one) + gui.set_color(line, target_color) + self:set_line_height(index) + end ---@return number function M:get_line_value(index) - return self.values[index] + return self.values[index] or 0 end function M:push_line_value(value) for index = 1, self.samples - 1 do - self:set_line_value(index, self:get_line_value(index + 1), true) + self:set_line_value(index, self:get_line_value(index + 1)) end - self:set_line_value(self.samples, value, true) + self:set_line_value(self.samples, value) end ----@param text string -function M:set_text(text) - self.text_value:set_to(text) +function M:set_max_value(max_value) + if self.max_value == max_value then + return + end + + self.max_value = max_value + for index = 1, self.samples do + self:set_line_height(index) + end end -function M:on_drag_corner(dx, dy) +function M:set_line_height(index) + local value = self.values[index] or 0 + local normalized = vmath.clamp(value / self.max_value, 0, 1) + local size_y = normalized * 70 + gui.set(self.lines[index], SIZE_Y, size_y) +end + + +function M:get_lowest_value() + return math.min(unpack(self.values)) +end + + +function M:get_highest_value() + return math.max(unpack(self.values)) +end + + +function M:on_drag_widget(dx, dy) local position = self.container:get_position() self.container:set_position(position.x + dx, position.y + dy) end +function M:toggle_hide() + self.is_hidden = not self.is_hidden + local hidden_size = gui.get_size(self:get_node("header")) + + local new_size = self.is_hidden and hidden_size or self.default_size + self.container:set_size(new_size.x, new_size.y, gui.PIVOT_N) + + gui.set_enabled(self.content, not self.is_hidden) + + return self +end + + return M \ No newline at end of file diff --git a/druid/widget/properties_panel/properties/property_button.gui b/druid/widget/properties_panel/properties/property_button.gui index 8876f9e..6efe3df 100644 --- a/druid/widget/properties_panel/properties/property_button.gui +++ b/druid/widget/properties_panel/properties/property_button.gui @@ -23,11 +23,11 @@ nodes { x: -200.0 } scale { - x: 0.65 - y: 0.65 + x: 0.5 + y: 0.5 } size { - x: 200.0 + x: 350.0 y: 40.0 } color { @@ -50,6 +50,7 @@ nodes { y: 1.0 z: 1.0 } + adjust_mode: ADJUST_MODE_STRETCH parent: "root" inherit_alpha: true outline_alpha: 0.0 @@ -119,12 +120,12 @@ nodes { } nodes { scale { - x: 0.65 - y: 0.65 + x: 0.5 + y: 0.5 } size { - x: 250.0 - y: 30.0 + x: 380.0 + y: 50.0 } color { x: 0.722 diff --git a/druid/widget/properties_panel/properties/property_button.lua b/druid/widget/properties_panel/properties/property_button.lua index 71b30f6..27368bf 100644 --- a/druid/widget/properties_panel/properties/property_button.lua +++ b/druid/widget/properties_panel/properties/property_button.lua @@ -1,3 +1,5 @@ +local color = require("druid.color") + ---@class property_button: druid.widget ---@field root node ---@field container druid.container @@ -7,11 +9,7 @@ ---@field druid druid_instance local M = {} ----@param template string ----@param nodes table -function M:init(template, nodes) - self.druid = self:get_druid(template, nodes) - +function M:init() self.root = self:get_node("root") self.text_name = self.druid:new_text("text_name") self.selected = self:get_node("selected") @@ -21,7 +19,9 @@ function M:init(template, nodes) self.text_button = self.druid:new_text("text_button") self.container = self.druid:new_container(self.root) - self.container:add_container("text_name") + self.container:add_container("text_name", nil, function(_, size) + self.text_button:set_size(size) + end) self.container:add_container("E_Anchor") end @@ -32,4 +32,17 @@ function M:on_click() end +---@param text string +---@return property_button +function M:set_text_button(text) + self.text_button:set_text(text) + return self +end + + +function M:set_color(color_value) + color.set_color(self:get_node("button"), color_value) +end + + return M diff --git a/druid/widget/properties_panel/properties/property_checkbox.gui b/druid/widget/properties_panel/properties/property_checkbox.gui index a8b5ba0..59824fd 100644 --- a/druid/widget/properties_panel/properties/property_checkbox.gui +++ b/druid/widget/properties_panel/properties/property_checkbox.gui @@ -23,11 +23,11 @@ nodes { x: -200.0 } scale { - x: 0.65 - y: 0.65 + x: 0.5 + y: 0.5 } size { - x: 200.0 + x: 360.0 y: 40.0 } color { diff --git a/druid/widget/properties_panel/properties/property_checkbox.lua b/druid/widget/properties_panel/properties/property_checkbox.lua index 30f1793..345e59e 100644 --- a/druid/widget/properties_panel/properties/property_checkbox.lua +++ b/druid/widget/properties_panel/properties/property_checkbox.lua @@ -1,16 +1,13 @@ ---@class property_checkbox: druid.widget ---@field root node ---@field druid druid_instance ----@field text_name druid.lang_text +---@field text_name druid.text ---@field button druid.button ---@field selected node local M = {} ----@param template string ----@param nodes table -function M:init(template, nodes) - self.druid = self:get_druid(template, nodes) +function M:init() self.root = self:get_node("root") self.icon = self:get_node("icon") @@ -19,7 +16,7 @@ function M:init(template, nodes) self.selected = self:get_node("selected") gui.set_alpha(self.selected, 0) - self.text_name = self.druid:new_lang_text("text_name") + self.text_name = self.druid:new_text("text_name") self.button = self.druid:new_button("button", self.on_click) diff --git a/druid/widget/properties_panel/properties/property_input.gui b/druid/widget/properties_panel/properties/property_input.gui new file mode 100644 index 0000000..59b6101 --- /dev/null +++ b/druid/widget/properties_panel/properties/property_input.gui @@ -0,0 +1,143 @@ +fonts { + name: "text_bold" + font: "/druid/fonts/text_bold.font" +} +textures { + name: "druid" + texture: "/druid/druid.atlas" +} +nodes { + size { + x: 400.0 + y: 40.0 + } + type: TYPE_BOX + texture: "druid/empty" + id: "root" + adjust_mode: ADJUST_MODE_STRETCH + inherit_alpha: true + visible: false +} +nodes { + position { + x: -200.0 + } + scale { + x: 0.5 + y: 0.5 + } + size { + x: 350.0 + y: 50.0 + } + color { + x: 0.463 + y: 0.475 + z: 0.49 + } + type: TYPE_TEXT + text: "Button" + font: "text_bold" + id: "text_name" + pivot: PIVOT_W + outline { + x: 1.0 + y: 1.0 + z: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + } + parent: "root" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} +nodes { + position { + x: 200.0 + } + size { + x: 200.0 + y: 40.0 + } + type: TYPE_BOX + id: "E_Anchor" + pivot: PIVOT_E + parent: "root" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO + visible: false +} +nodes { + position { + x: -100.0 + } + type: TYPE_TEMPLATE + id: "rich_input" + parent: "E_Anchor" + inherit_alpha: true + template: "/druid/custom/rich_input/rich_input.gui" +} +nodes { + type: TYPE_BOX + id: "rich_input/root" + parent: "rich_input" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "rich_input/button" + parent: "rich_input/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "rich_input/placeholder_text" + parent: "rich_input/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "rich_input/input_text" + parent: "rich_input/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "rich_input/cursor_node" + parent: "rich_input/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "rich_input/cursor_text" + parent: "rich_input/cursor_node" + template_node_child: true +} +nodes { + position { + x: -100.0 + y: -20.0 + } + size { + x: 200.0 + y: 4.0 + } + color { + x: 0.894 + y: 0.506 + z: 0.333 + } + type: TYPE_BOX + texture: "druid/pixel" + id: "selected" + pivot: PIVOT_S + adjust_mode: ADJUST_MODE_STRETCH + parent: "E_Anchor" + inherit_alpha: true +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties/property_input.lua b/druid/widget/properties_panel/properties/property_input.lua new file mode 100644 index 0000000..ede2073 --- /dev/null +++ b/druid/widget/properties_panel/properties/property_input.lua @@ -0,0 +1,38 @@ +---@class property_input: druid.widget +---@field root node +---@field container druid.container +---@field text_name druid.text +---@field button druid.button +---@field text_button druid.text +---@field druid druid_instance +local M = {} + +function M:init() + self.root = self:get_node("root") + self.text_name = self.druid:new_text("text_name") + self.selected = self:get_node("selected") + gui.set_alpha(self.selected, 0) + + self.rich_input = self.druid:new_rich_input("rich_input") + + self.container = self.druid:new_container(self.root) + self.container:add_container("text_name") + self.container:add_container("E_Anchor") +end + + +function M:on_click() + gui.set_alpha(self.selected, 1) + gui.animate(self.selected, "color.w", 0, gui.EASING_INSINE, 0.16) +end + + +---@param text string +---@return property_input +function M:set_text_button(text) + self.text_button:set_text(text) + return self +end + + +return M diff --git a/druid/widget/properties_panel/properties/property_slider.gui b/druid/widget/properties_panel/properties/property_slider.gui index 89c26a1..a0bb0a4 100644 --- a/druid/widget/properties_panel/properties/property_slider.gui +++ b/druid/widget/properties_panel/properties/property_slider.gui @@ -23,11 +23,11 @@ nodes { x: -200.0 } scale { - x: 0.65 - y: 0.65 + x: 0.5 + y: 0.5 } size { - x: 200.0 + x: 380.0 y: 40.0 } color { diff --git a/druid/widget/properties_panel/properties/property_slider.lua b/druid/widget/properties_panel/properties/property_slider.lua index 90156a0..cb89b09 100644 --- a/druid/widget/properties_panel/properties/property_slider.lua +++ b/druid/widget/properties_panel/properties/property_slider.lua @@ -2,23 +2,19 @@ ---@field root node ---@field container druid.container ---@field druid druid_instance ----@field text_name druid.lang_text +---@field text_name druid.text ---@field text_value druid.text ---@field slider druid.slider local M = {} ----@param template string ----@param nodes table -function M:init(template, nodes) - self.druid = self:get_druid(template, nodes) - +function M:init() self.root = self:get_node("root") self.selected = self:get_node("selected") gui.set_alpha(self.selected, 0) self._value = 0 - self.text_name = self.druid:new_lang_text("text_name") --[[@as druid.lang_text]] + self.text_name = self.druid:new_text("text_name") self.text_value = self.druid:new_text("text_value") self.slider = self.druid:new_slider("slider_pin", vmath.vector3(55, 0, 0), self._on_slider_change_by_user) --[[@as druid.slider]] self.slider:set_input_node("slider") @@ -36,7 +32,7 @@ end ---@param callback fun(value:number):string function M:set_text_function(callback) self._text_function = callback - self.text_value:set_to(self._text_function(self._value)) + self.text_value:set_text(self._text_function(self._value)) end diff --git a/druid/widget/properties_panel/properties/property_text.gui b/druid/widget/properties_panel/properties/property_text.gui new file mode 100644 index 0000000..8966c90 --- /dev/null +++ b/druid/widget/properties_panel/properties/property_text.gui @@ -0,0 +1,96 @@ +fonts { + name: "text_bold" + font: "/druid/fonts/text_bold.font" +} +textures { + name: "druid" + texture: "/druid/druid.atlas" +} +nodes { + size { + x: 400.0 + y: 40.0 + } + type: TYPE_BOX + texture: "druid/empty" + id: "root" + adjust_mode: ADJUST_MODE_STRETCH + inherit_alpha: true + visible: false +} +nodes { + position { + x: -200.0 + } + scale { + x: 0.5 + y: 0.5 + } + size { + x: 400.0 + y: 50.0 + } + color { + x: 0.463 + y: 0.475 + z: 0.49 + } + type: TYPE_TEXT + text: "Text" + font: "text_bold" + id: "text_name" + pivot: PIVOT_W + outline { + x: 1.0 + y: 1.0 + z: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + } + parent: "root" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} +nodes { + position { + x: 200.0 + } + scale { + x: 0.5 + y: 0.5 + } + size { + x: 350.0 + y: 50.0 + } + color { + x: 0.722 + y: 0.741 + z: 0.761 + } + type: TYPE_TEXT + text: "Text" + font: "text_bold" + id: "text_right" + pivot: PIVOT_E + outline { + x: 1.0 + y: 1.0 + z: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + } + parent: "root" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties/property_text.lua b/druid/widget/properties_panel/properties/property_text.lua new file mode 100644 index 0000000..0f8b69d --- /dev/null +++ b/druid/widget/properties_panel/properties/property_text.lua @@ -0,0 +1,39 @@ +---@class property_text: druid.widget +---@field root node +---@field container druid.container +---@field text_name druid.text +---@field text_right druid.text +local M = {} + +function M:init() + self.root = self:get_node("root") + self.text_name = self.druid:new_text("text_name") + self.text_right = self.druid:new_text("text_right", "") + + self.container = self.druid:new_container(self.root) + self.container:add_container("text_name", nil, function(_, size) + self.text_name:set_size(size) + end) + self.container:add_container("text_right", nil, function(_, size) + self.text_right:set_size(size) + end) +end + + +---@param text string +---@return property_text +function M:set_text(text) + self.text_name:set_text(text) + return self +end + + +---@param text string +---@return property_text +function M:set_right_text(text) + self.text_right:set_text(text or "") + return self +end + + +return M diff --git a/druid/widget/properties_panel/properties_panel.gui b/druid/widget/properties_panel/properties_panel.gui index 4365bd7..2df907a 100644 --- a/druid/widget/properties_panel/properties_panel.gui +++ b/druid/widget/properties_panel/properties_panel.gui @@ -33,15 +33,31 @@ nodes { } nodes { position { - x: -192.0 - y: 116.0 - } - scale { - x: 0.8 - y: 0.8 + y: 120.0 } size { - x: 245.0 + x: 400.0 + y: 40.0 + } + type: TYPE_BOX + id: "header" + pivot: PIVOT_N + parent: "root" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO + visible: false +} +nodes { + position { + x: -192.0 + y: -8.0 + } + scale { + x: 0.5 + y: 0.5 + } + size { + x: 500.0 y: 50.0 } color { @@ -64,15 +80,49 @@ nodes { y: 1.0 z: 1.0 } - parent: "root" + parent: "header" inherit_alpha: true outline_alpha: 0.0 shadow_alpha: 0.0 } +nodes { + position { + x: 192.0 + y: -4.0 + } + color { + x: 0.306 + y: 0.31 + z: 0.314 + } + type: TYPE_BOX + texture: "druid/icon_drag" + id: "icon_drag" + pivot: PIVOT_NE + parent: "header" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} +nodes { + position { + y: -120.0 + } + size { + x: 400.0 + y: 190.0 + } + type: TYPE_BOX + id: "content" + pivot: PIVOT_S + parent: "root" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO + visible: false +} nodes { position { x: -200.0 - y: 70.0 + y: 190.0 } size { x: 400.0 @@ -84,7 +134,7 @@ nodes { xanchor: XANCHOR_LEFT pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH - parent: "root" + parent: "content" inherit_alpha: true clipping_mode: CLIPPING_MODE_STENCIL } @@ -109,51 +159,12 @@ nodes { } nodes { position { - x: -200.0 - y: 115.0 - } - scale { - x: 0.7 - y: 0.7 - } - size { - x: 570.0 - y: 50.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - } - type: TYPE_TEXT - text: "No properties for this example" - font: "text_regular" - id: "text_no_properties" - pivot: PIVOT_NW - outline { - x: 1.0 - y: 1.0 - z: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - } - parent: "root" - inherit_alpha: true - outline_alpha: 0.0 - shadow_alpha: 0.0 - enabled: false -} -nodes { - position { - y: 50.0 + y: 170.0 } type: TYPE_BOX texture: "druid/empty" id: "propeties" - parent: "root" + parent: "content" inherit_alpha: true size_mode: SIZE_MODE_AUTO visible: false @@ -313,21 +324,107 @@ nodes { } nodes { position { - x: 192.0 - y: 112.0 + y: -150.0 } - color { - x: 0.129 - y: 0.141 - z: 0.157 - } - type: TYPE_BOX - texture: "druid/ui_circle_32" - id: "icon_drag" - pivot: PIVOT_NE - parent: "root" + type: TYPE_TEMPLATE + id: "property_input" + parent: "propeties" inherit_alpha: true - size_mode: SIZE_MODE_AUTO + template: "/druid/widget/properties_panel/properties/property_input.gui" +} +nodes { + type: TYPE_BOX + id: "property_input/root" + parent: "property_input" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_input/text_name" + parent: "property_input/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_input/E_Anchor" + parent: "property_input/root" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "property_input/rich_input" + parent: "property_input/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_input/rich_input/root" + parent: "property_input/rich_input" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_input/rich_input/button" + parent: "property_input/rich_input/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_input/rich_input/placeholder_text" + parent: "property_input/rich_input/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_input/rich_input/input_text" + parent: "property_input/rich_input/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_input/rich_input/cursor_node" + parent: "property_input/rich_input/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_input/rich_input/cursor_text" + parent: "property_input/rich_input/cursor_node" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_input/selected" + parent: "property_input/E_Anchor" + template_node_child: true +} +nodes { + position { + y: -200.0 + } + type: TYPE_TEMPLATE + id: "property_text" + parent: "propeties" + inherit_alpha: true + template: "/druid/widget/properties_panel/properties/property_text.gui" +} +nodes { + type: TYPE_BOX + id: "property_text/root" + parent: "property_text" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_text/text_name" + parent: "property_text/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_text/text_right" + parent: "property_text/root" + template_node_child: true } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties_panel.lua b/druid/widget/properties_panel/properties_panel.lua index 5502ff8..7cae30d 100644 --- a/druid/widget/properties_panel/properties_panel.lua +++ b/druid/widget/properties_panel/properties_panel.lua @@ -1,32 +1,41 @@ local property_checkbox = require("druid.widget.properties_panel.properties.property_checkbox") local property_slider = require("druid.widget.properties_panel.properties.property_slider") local property_button = require("druid.widget.properties_panel.properties.property_button") +local property_input = require("druid.widget.properties_panel.properties.property_input") +local property_text = require("druid.widget.properties_panel.properties.property_text") ---@class properties_panel: druid.widget ---@field root node ----@field text_no_properties node ---@field scroll druid.scroll ---@field druid druid_instance local M = {} ----@param template string ----@param nodes table -function M:init(template, nodes) - self.druid = self:get_druid(template, nodes) - --self.root = self.druid:new_container("root") +function M:init() self.root = self:get_node("root") - self.text_no_properties = self:get_node("text_no_properties") + self.content = self:get_node("content") + + self.container = self.druid:new_container(self.root) + self.container:add_container("header") + self.container_content = self.container:add_container("content") + self.container_scroll_view = self.container_content:add_container("scroll_view") + self.contaienr_scroll_content = self.container_scroll_view:add_container("scroll_content") + + self.default_size = self.container:get_size() self.properties = {} + self.text_header = self.druid:new_text("text_header") self.scroll = self.druid:new_scroll("scroll_view", "scroll_content") self.layout = self.druid:new_layout("scroll_content", "vertical") :set_hug_content(false, true) + :set_padding(nil, 0) self.layout.on_size_changed:subscribe(self.on_size_changed, self) - self.drag_corner = self.druid:new_drag("icon_drag", self.on_drag_corner) + self.druid:new_drag("header", self.on_drag_widget) + self.druid:new_button("icon_drag", self.toggle_hide) + :set_style(nil) self.property_checkbox_prefab = self:get_node("property_checkbox/root") gui.set_enabled(self.property_checkbox_prefab, false) @@ -37,17 +46,15 @@ function M:init(template, nodes) self.property_button_prefab = self:get_node("property_button/root") gui.set_enabled(self.property_button_prefab, false) - self.container = self.druid:new_container(self.root) - self.container:add_container("text_header") - self.container:add_container("icon_drag") - --self.container:create_draggable_corners() + self.property_input_prefab = self:get_node("property_input/root") + gui.set_enabled(self.property_input_prefab, false) - self.container_scroll_view = self.container:add_container("scroll_view") - self.contaienr_scroll_content = self.container_scroll_view:add_container("scroll_content") + self.property_text_prefab = self:get_node("property_text/root") + gui.set_enabled(self.property_text_prefab, false) end -function M:on_drag_corner(dx, dy) +function M:on_drag_widget(dx, dy) local position = self.container:get_position() self.container:set_position(position.x + dx, position.y + dy) end @@ -55,15 +62,21 @@ end function M:clear() for index = 1, #self.properties do + gui.delete_node(self.properties[index].root) self.druid:remove(self.properties[index]) end + self.layout:clear_layout() self.properties = {} - gui.set_enabled(self.text_no_properties, true) end function M:on_size_changed(new_size) - self.container:set_size(new_size.x, new_size.y + 50, gui.PIVOT_N) + self.container_content:set_size(new_size.x, new_size.y, gui.PIVOT_N) + + self.default_size = vmath.vector3(new_size.x, new_size.y + 50, 0) + if not self.is_hidden then + self.container:set_size(self.default_size.x, self.default_size.y, gui.PIVOT_N) + end local width = self.layout:get_size().x - self.layout.padding.x - self.layout.padding.z for index = 1, #self.properties do @@ -72,51 +85,39 @@ function M:on_size_changed(new_size) end ----@param text_id string +---@param text string ---@param initial_value boolean ---@param on_change_callback function ---@return property_checkbox -function M:add_checkbox(text_id, initial_value, on_change_callback) +function M:add_checkbox(text, initial_value, on_change_callback) + text = tostring(text) + local nodes = gui.clone_tree(self.property_checkbox_prefab) local instance = self.druid:new_widget(property_checkbox, "property_checkbox", nodes) - instance.text_name:set_to(text_id) + self:add_property(instance) + + instance.text_name:set_to(text) instance:set_value(initial_value, true) instance.button.on_click:subscribe(function() on_change_callback(instance:get_value()) end) - gui.set_enabled(instance.root, true) - self.layout:add(instance.root) - table.insert(self.properties, instance) - - local width = self.layout:get_size().x - self.layout.padding.x - self.layout.padding.z - instance.container:set_size(width) - - gui.set_enabled(self.text_no_properties, false) - return instance end ----@param text_id string +---@param text string ---@param initial_value number ---@param on_change_callback function ---@return property_slider -function M:add_slider(text_id, initial_value, on_change_callback) +function M:add_slider(text, initial_value, on_change_callback) + text = tostring(text) local nodes = gui.clone_tree(self.property_slider_prefab) local instance = self.druid:new_widget(property_slider, "property_slider", nodes) - instance.text_name:set_to(text_id) + self:add_property(instance) + + instance.text_name:set_text(text) instance:set_value(initial_value, true) - - gui.set_enabled(instance.root, true) - self.layout:add(instance.root) - table.insert(self.properties, instance) - - local width = self.layout:get_size().x - self.layout.padding.x - self.layout.padding.z - instance.container:set_size(width) - - gui.set_enabled(self.text_no_properties, false) - instance.slider.on_change_value:subscribe(function(_, value) on_change_callback(value) end) @@ -125,23 +126,15 @@ function M:add_slider(text_id, initial_value, on_change_callback) end ----@param text_id string +---@param text string ---@param on_click_callback function|nil ---@param callback_context any|nil -function M:add_button(text_id, on_click_callback, callback_context) +function M:add_button(text, on_click_callback, callback_context) local nodes = gui.clone_tree(self.property_button_prefab) local instance = self.druid:new_widget(property_button, "property_button", nodes) - instance.text_name:set_to(text_id) - - gui.set_enabled(instance.root, true) - self.layout:add(instance.root) - table.insert(self.properties, instance) - - local width = self.layout:get_size().x - self.layout.padding.x - self.layout.padding.z - instance.container:set_size(width) - - gui.set_enabled(self.text_no_properties, false) + self:add_property(instance) + instance.text_name:set_text(text) if on_click_callback then instance.button.on_click:subscribe(on_click_callback, callback_context) end @@ -150,6 +143,48 @@ function M:add_button(text_id, on_click_callback, callback_context) end +function M:add_input(text, initial_value, on_change_callback) + text = tostring(text) + local nodes = gui.clone_tree(self.property_input_prefab) + local instance = self.druid:new_widget(property_input, "property_input", nodes) + self:add_property(instance) + + instance.text_name:set_text(text) + instance.rich_input:set_text(initial_value) + instance.rich_input:set_placeholder("") + instance.rich_input.input.on_input_unselect:subscribe(function(_, value) + on_change_callback(value) + end) +end + + +---@param text string +---@param right_text string|nil +---@return property_text +function M:add_text(text, right_text) + text = tostring(text) + local nodes = gui.clone_tree(self.property_text_prefab) + local instance = self.druid:new_widget(property_text, "property_text", nodes) + self:add_property(instance) + + instance:set_text(text) + instance:set_right_text(right_text) + return instance +end + + +---@private +function M:add_property(widget) + gui.set_enabled(widget.root, true) + self.layout:add(widget.root) + table.insert(self.properties, widget) + local width = self.layout:get_size().x - self.layout.padding.x - self.layout.padding.z + widget.container:set_size(width) + + return widget +end + + function M:remove(widget) for index = 1, #self.properties do if self.properties[index] == widget then @@ -160,10 +195,19 @@ function M:remove(widget) break end end +end - if #self.properties == 0 then - gui.set_enabled(self.text_no_properties, true) - end + +function M:toggle_hide() + self.is_hidden = not self.is_hidden + local hidden_size = gui.get_size(self:get_node("header")) + + local new_size = self.is_hidden and hidden_size or self.default_size + self.container:set_size(new_size.x, new_size.y, gui.PIVOT_N) + + gui.set_enabled(self.content, not self.is_hidden) + + return self end From 37d7168bd6e1266bef4469852aff4627edcbb103 Mon Sep 17 00:00:00 2001 From: Insality Date: Wed, 20 Nov 2024 01:42:12 +0200 Subject: [PATCH 20/50] More widgets, additional adjusts for text --- druid/base/text.lua | 56 ++++- druid/const.lua | 3 + druid/extended/hotkey.lua | 59 +++-- druid/extended/layout.lua | 25 ++- druid/system/druid_instance.lua | 2 +- .../properties/property_button.lua | 6 +- .../properties/property_checkbox.lua | 2 +- .../properties/property_input.gui | 2 +- .../properties/property_input.lua | 2 +- .../property_left_right_selector.gui | 212 ++++++++++++++++++ .../property_left_right_selector.lua | 204 +++++++++++++++++ .../properties/property_slider.lua | 2 +- .../properties/property_text.lua | 9 +- .../properties_panel/properties_panel.gui | 64 ++++++ .../properties_panel/properties_panel.lua | 122 +++++++--- 15 files changed, 698 insertions(+), 72 deletions(-) create mode 100644 druid/widget/properties_panel/properties/property_left_right_selector.gui create mode 100644 druid/widget/properties_panel/properties/property_left_right_selector.lua diff --git a/druid/base/text.lua b/druid/base/text.lua index 1c9e9d3..5396cec 100755 --- a/druid/base/text.lua +++ b/druid/base/text.lua @@ -209,6 +209,8 @@ local function update_text_area_size(self) end +---@param self druid.text +---@param trim_postfix string local function update_text_with_trim(self, trim_postfix) local max_width = self.text_area.x local text_width = self:get_text_size() @@ -231,6 +233,24 @@ local function update_text_with_trim(self, trim_postfix) end end +local function update_text_with_trim_left(self, trim_postfix) + local max_width = self.text_area.x + local text_width = self:get_text_size() + local text_length = utf8.len(self.last_value) + local trim_index = 1 + + if text_width > max_width then + local new_text = self.last_value + while text_width > max_width and trim_index < text_length do + trim_index = trim_index + 1 + new_text = trim_postfix .. utf8.sub(self.last_value, trim_index, text_length) + text_width = self:get_text_size(new_text) + end + + gui.set_text(self.node, new_text) + end +end + local function update_text_with_anchor_shift(self) if self:get_text_size() >= self.text_area.x then @@ -255,6 +275,10 @@ local function update_adjust(self) update_text_with_trim(self, self.style.TRIM_POSTFIX) end + if self.adjust_type == const.TEXT_ADJUST.TRIM_LEFT then + update_text_with_trim_left(self, self.style.TRIM_POSTFIX) + end + if self.adjust_type == const.TEXT_ADJUST.DOWNSCALE_LIMITED then update_text_area_size(self) end @@ -267,6 +291,16 @@ local function update_adjust(self) update_text_area_size(self) update_text_with_anchor_shift(self) end + + if self.adjust_type == const.TEXT_ADJUST.SCALE_THEN_TRIM then + update_text_area_size(self) + update_text_with_trim(self, self.style.TRIM_POSTFIX) + end + + if self.adjust_type == const.TEXT_ADJUST.SCALE_THEN_TRIM_LEFT then + update_text_area_size(self) + update_text_with_trim_left(self, self.style.TRIM_POSTFIX) + end end @@ -312,13 +346,13 @@ function M:init(node, value, adjust_type) self.on_set_pivot = Event() self.on_update_text_scale = Event() - self:set_to(value or gui.get_text(self.node)) + self:set_text(value or gui.get_text(self.node)) return self end function M:on_layout_change() - self:set_to(self.last_value) + self:set_text(self.last_value) end @@ -328,13 +362,13 @@ function M:on_message_input(node_id, message) end if message.action == const.MESSAGE_INPUT.TEXT_SET then - Text.set_to(self, message.value) + M.set_text(self, message.value) end end --- Calculate text width with font with respect to trailing space ----@param text|nil string +---@param text string|nil ---@return number Width ---@return number Height function M:get_text_size(text) @@ -421,13 +455,15 @@ end --- Set text area size ---@param size vector3 The new text area size ----@return druid.text Current text instance +---@return druid.text self Current text instance function M:set_size(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) + + return self end @@ -497,13 +533,15 @@ end --- Set text adjust, refresh the current text visuals, if needed +---Values are: "downscale", "trim", "no_adjust", "downscale_limited", +---"scroll", "scale_then_scroll", "trim_left", "scale_then_trim", "scale_then_trim_left" ---@param adjust_type string|nil See const.TEXT_ADJUST. If pass nil - use current adjust type ---@param minimal_scale number|nil If pass nil - not use minimal scale ----@return druid.text Current text instance +---@return druid.text self Current text instance function M:set_text_adjust(adjust_type, minimal_scale) self.adjust_type = adjust_type self._minimal_scale = minimal_scale - self:set_to(self.last_value) + self:set_text(self.last_value) return self end @@ -520,8 +558,8 @@ end --- Return current text adjust type ----@return number The current text adjust type -function M:get_text_adjust(adjust_type) +---@return string adjust_type The current text adjust type +function M:get_text_adjust() return self.adjust_type end diff --git a/druid/const.lua b/druid/const.lua index 639585f..8bfd3d1 100755 --- a/druid/const.lua +++ b/druid/const.lua @@ -98,6 +98,9 @@ M.SHIFT = { M.TEXT_ADJUST = { DOWNSCALE = "downscale", TRIM = "trim", + TRIM_LEFT = "trim_left", + SCALE_THEN_TRIM = "scale_then_trim", + SCALE_THEN_TRIM_LEFT = "scale_then_trim_left", NO_ADJUST = "no_adjust", DOWNSCALE_LIMITED = "downscale_limited", SCROLL = "scroll", diff --git a/druid/extended/hotkey.lua b/druid/extended/hotkey.lua index 871cb17..8333c5e 100644 --- a/druid/extended/hotkey.lua +++ b/druid/extended/hotkey.lua @@ -74,7 +74,7 @@ end --- Add hotkey for component callback ---@param keys string[]|hash[]|string|hash that have to be pressed before key pressed to activate ---@param callback_argument any|nil The argument to pass into the callback function ----@return Hotkey Current instance +---@return druid.hotkey Current instance function M:add_hotkey(keys, callback_argument) keys = keys or {} if type(keys) == "string" then @@ -86,7 +86,7 @@ function M:add_hotkey(keys, callback_argument) for index = 1, #keys do local key_hash = hash(keys[index]) - if helper.contains(self.style.MODIFICATORS, key_hash) then + if #keys > 1 and helper.contains(self.style.MODIFICATORS, key_hash) then table.insert(modificators, key_hash) else if not key then @@ -114,6 +114,17 @@ function M:add_hotkey(keys, callback_argument) end +function M:is_processing() + for index = 1, #self._hotkeys do + if self._hotkeys[index].is_processing then + return true + end + end + + return false +end + + function M:on_focus_gained() for k, v in pairs(self._modificators) do self._modificators[k] = false @@ -122,32 +133,32 @@ end function M:on_input(action_id, action) - if not action_id or #self._hotkeys == 0 then + if not action_id then return false end - if self._modificators[action_id] ~= nil then - if action.pressed then - self._modificators[action_id] = true - end - if action.released then - self._modificators[action_id] = false - end + if self._modificators[action_id] ~= nil and action.pressed then + self._modificators[action_id] = true end for index = 1, #self._hotkeys do local hotkey = self._hotkeys[index] - if action_id == hotkey.key then + local is_relative_key = helper.contains(self.style.MODIFICATORS, action_id) or action_id == hotkey.key + + if is_relative_key and (action_id == hotkey.key or not hotkey.key) then local is_modificator_ok = true + local is_consume = not not (hotkey.key) -- Check only required modificators pressed - for i = 1, #self.style.MODIFICATORS do - local mod = self.style.MODIFICATORS[i] - if helper.contains(hotkey.modificators, mod) and self._modificators[mod] == false then - is_modificator_ok = false - end - if not helper.contains(hotkey.modificators, mod) and self._modificators[mod] == true then - is_modificator_ok = false + if hotkey.key and #hotkey.modificators > 0 then + for i = 1, #self.style.MODIFICATORS do + local mod = self.style.MODIFICATORS[i] + if helper.contains(hotkey.modificators, mod) and self._modificators[mod] == false then + is_modificator_ok = false + end + if not helper.contains(hotkey.modificators, mod) and self._modificators[mod] == true then + is_modificator_ok = false + end end end @@ -157,23 +168,27 @@ function M:on_input(action_id, action) 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 + return is_consume end if action.released and is_modificator_ok and hotkey.is_processing then - hotkey.is_processing = false self.on_hotkey_released:trigger(self:get_context(), hotkey.callback_argument) - return true + hotkey.is_processing = false + return is_consume end end end + if self._modificators[action_id] ~= nil and action.released then + self._modificators[action_id] = false + end + return false end --- If true, the callback will be triggered on action.repeated ---@param is_enabled_repeated bool The flag value ----@return Hotkey +---@return druid.hotkey function M:set_repeat(is_enabled_repeated) self._is_process_repeated = is_enabled_repeated return self diff --git a/druid/extended/layout.lua b/druid/extended/layout.lua index c06752e..c0d1db7 100644 --- a/druid/extended/layout.lua +++ b/druid/extended/layout.lua @@ -68,6 +68,22 @@ function M:update() end +function M:get_entities() + return self.entities +end + + +function M:set_node_index(node, index) + for i = 1, #self.entities do + if self.entities[i] == node then + table.remove(self.entities, i) + table.insert(self.entities, index, node) + break + end + end +end + + ---@param margin_x number|nil ---@param margin_y number|nil ---@return druid.layout @@ -444,15 +460,16 @@ function M:calculate_rows_data() end +---Will reset z value to 0! +local TEMP_VECTOR = vmath.vector3(0, 0, 0) ---@param node node ---@param x number ---@param y number ---@return node 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) + TEMP_VECTOR.x = x + TEMP_VECTOR.y = y + gui.set_position(node, TEMP_VECTOR) return node end diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index cc30db9..520e76b 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -711,7 +711,7 @@ end local hotkey = require("druid.extended.hotkey") ---Create Hotkey component ---@param keys_array string|string[] Keys for trigger action. Should contains one action key and any amount of modificator keys ----@param callback function The callback function +---@param callback function|nil The callback function ---@param callback_argument any|nil The argument to pass into the callback function ---@return druid.hotkey Hotkey component function M:new_hotkey(keys_array, callback, callback_argument) diff --git a/druid/widget/properties_panel/properties/property_button.lua b/druid/widget/properties_panel/properties/property_button.lua index 27368bf..085a437 100644 --- a/druid/widget/properties_panel/properties/property_button.lua +++ b/druid/widget/properties_panel/properties/property_button.lua @@ -1,6 +1,6 @@ local color = require("druid.color") ----@class property_button: druid.widget +---@class widget.property_button: druid.widget ---@field root node ---@field container druid.container ---@field text_name druid.text @@ -12,6 +12,8 @@ local M = {} function M:init() self.root = self:get_node("root") self.text_name = self.druid:new_text("text_name") + :set_text_adjust("trim_left") + self.selected = self:get_node("selected") gui.set_alpha(self.selected, 0) @@ -33,7 +35,7 @@ end ---@param text string ----@return property_button +---@return widget.property_button function M:set_text_button(text) self.text_button:set_text(text) return self diff --git a/druid/widget/properties_panel/properties/property_checkbox.lua b/druid/widget/properties_panel/properties/property_checkbox.lua index 345e59e..57d82e1 100644 --- a/druid/widget/properties_panel/properties/property_checkbox.lua +++ b/druid/widget/properties_panel/properties/property_checkbox.lua @@ -1,4 +1,4 @@ ----@class property_checkbox: druid.widget +---@class widget.property_checkbox: druid.widget ---@field root node ---@field druid druid_instance ---@field text_name druid.text diff --git a/druid/widget/properties_panel/properties/property_input.gui b/druid/widget/properties_panel/properties/property_input.gui index 59b6101..ac4e786 100644 --- a/druid/widget/properties_panel/properties/property_input.gui +++ b/druid/widget/properties_panel/properties/property_input.gui @@ -36,7 +36,7 @@ nodes { z: 0.49 } type: TYPE_TEXT - text: "Button" + text: "Input" font: "text_bold" id: "text_name" pivot: PIVOT_W diff --git a/druid/widget/properties_panel/properties/property_input.lua b/druid/widget/properties_panel/properties/property_input.lua index ede2073..83c7c0a 100644 --- a/druid/widget/properties_panel/properties/property_input.lua +++ b/druid/widget/properties_panel/properties/property_input.lua @@ -1,4 +1,4 @@ ----@class property_input: druid.widget +---@class widget.property_input: druid.widget ---@field root node ---@field container druid.container ---@field text_name druid.text diff --git a/druid/widget/properties_panel/properties/property_left_right_selector.gui b/druid/widget/properties_panel/properties/property_left_right_selector.gui new file mode 100644 index 0000000..c7d528b --- /dev/null +++ b/druid/widget/properties_panel/properties/property_left_right_selector.gui @@ -0,0 +1,212 @@ +fonts { + name: "text_bold" + font: "/druid/fonts/text_bold.font" +} +textures { + name: "druid" + texture: "/druid/druid.atlas" +} +nodes { + size { + x: 400.0 + y: 40.0 + } + type: TYPE_BOX + texture: "druid/empty" + id: "root" + adjust_mode: ADJUST_MODE_STRETCH + inherit_alpha: true + visible: false +} +nodes { + position { + x: -200.0 + } + scale { + x: 0.5 + y: 0.5 + } + size { + x: 360.0 + y: 40.0 + } + color { + x: 0.463 + y: 0.475 + z: 0.49 + } + type: TYPE_TEXT + text: "Left Right Selector" + font: "text_bold" + id: "text_name" + pivot: PIVOT_W + outline { + x: 1.0 + y: 1.0 + z: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + } + parent: "root" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} +nodes { + position { + x: 200.0 + } + size { + x: 200.0 + y: 40.0 + } + type: TYPE_BOX + id: "E_Anchor" + pivot: PIVOT_E + parent: "root" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO + visible: false +} +nodes { + position { + x: -180.0 + } + size { + x: 40.0 + y: 40.0 + } + color { + x: 0.463 + y: 0.475 + z: 0.49 + } + type: TYPE_BOX + texture: "druid/rect_round2_width2" + id: "button_left" + parent: "E_Anchor" + inherit_alpha: true + slice9 { + x: 5.0 + y: 5.0 + z: 5.0 + w: 5.0 + } +} +nodes { + rotation { + z: 180.0 + } + color { + x: 0.722 + y: 0.741 + z: 0.761 + } + type: TYPE_BOX + texture: "druid/icon_arrow" + id: "icon_left" + parent: "button_left" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} +nodes { + position { + x: -20.0 + } + size { + x: 40.0 + y: 40.0 + } + color { + x: 0.463 + y: 0.475 + z: 0.49 + } + type: TYPE_BOX + texture: "druid/rect_round2_width2" + id: "button_right" + parent: "E_Anchor" + inherit_alpha: true + slice9 { + x: 5.0 + y: 5.0 + z: 5.0 + w: 5.0 + } +} +nodes { + color { + x: 0.722 + y: 0.741 + z: 0.761 + } + type: TYPE_BOX + texture: "druid/icon_arrow" + id: "icon_right" + parent: "button_right" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} +nodes { + position { + x: -100.0 + y: -20.0 + } + size { + x: 120.0 + y: 4.0 + } + color { + x: 0.894 + y: 0.506 + z: 0.333 + } + type: TYPE_BOX + texture: "druid/pixel" + id: "selected" + pivot: PIVOT_S + adjust_mode: ADJUST_MODE_STRETCH + parent: "E_Anchor" + inherit_alpha: true +} +nodes { + position { + x: -100.0 + } + scale { + x: 0.5 + y: 0.5 + } + size { + x: 220.0 + y: 40.0 + } + color { + x: 0.463 + y: 0.475 + z: 0.49 + } + type: TYPE_TEXT + text: "42" + font: "text_bold" + id: "text_value" + outline { + x: 1.0 + y: 1.0 + z: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + } + parent: "E_Anchor" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties/property_left_right_selector.lua b/druid/widget/properties_panel/properties/property_left_right_selector.lua new file mode 100644 index 0000000..b6e5ed7 --- /dev/null +++ b/druid/widget/properties_panel/properties/property_left_right_selector.lua @@ -0,0 +1,204 @@ +local event = require("druid.event") + +---@class widget.property_left_right_selector: druid.widget +---@field root node +---@field druid druid_instance +---@field text_name druid.text +---@field button druid.button +---@field selected node +---@field value string|number +local M = {} + + +function M:init() + self.root = self:get_node("root") + self.selected = self:get_node("selected") + gui.set_alpha(self.selected, 0) + + self.text_name = self.druid:new_text("text_name") + self.text_value = self.druid:new_text("text_value") + self.button_left = self.druid:new_button("button_left", self.on_button_left) + self.button_right = self.druid:new_button("button_right", self.on_button_right) + + self.on_change_value = event.create() + + self.container = self.druid:new_container(self.root) + self.container:add_container("text_name") + self.container:add_container("E_Anchor") +end + + +function M:set_text(text) + self.text_name:set_text(text) + return self +end + + +---Helper to cycle number in range +---@param value number Current value +---@param min number Min range value +---@param max number Max range value +---@param step number Step size +---@param is_loop boolean Is looped +---@return number Cycled value +local function step_number(value, min, max, step, is_loop) + local range = max - min + 1 + if is_loop then + -- Normalize step within range + local effective_step = step + if math.abs(step) >= range then + effective_step = step % range + if effective_step == 0 then + effective_step = step > 0 and range or -range + end + end + + value = value + effective_step + -- Handle wrapping + if max then + while value > max do + value = min + (value - max - 1) + end + end + if min then + while value < min do + value = max - (min - value - 1) + end + end + else + -- Clamp values + value = value + step + if max and value > max then + return max + elseif min and value < min then + return min + end + end + return value +end + + +---Helper to cycle array index with proper step wrapping +---@param array table Array to cycle through +---@param current_value any Current value to find index for +---@param step number Step direction +---@param is_loop boolean If true, cycle values. If false, clamp at ends +---@return any Next value in cycle +local function step_array(array, current_value, step, is_loop) + local index = 1 + for i, v in ipairs(array) do + if v == current_value then + index = i + break + end + end + + if is_loop then + -- Normalize step within array length + local range = #array + local effective_step = step + if math.abs(step) >= range then + effective_step = step % range + if effective_step == 0 then + effective_step = step > 0 and range or -range + end + end + + index = index + effective_step + -- Handle wrapping + while index > range do + index = 1 + (index - range - 1) + end + while index < 1 do + index = range - (1 - index - 1) + end + else + -- Clamp values + index = index + step + if index > #array then + index = #array + elseif index < 1 then + index = 1 + end + end + + return array[index] +end + + +function M:on_button_left() + self:add_value(true) +end + +function M:on_button_right() + self:add_value(false) +end + + +function M:add_value(is_left) + local koef = is_left and -1 or 1 + local array_type = self.array_type + if array_type then + local value = self.value + local new_value = step_array(array_type.array, value, koef * array_type.steps, array_type.is_loop) + self:set_value(new_value) + return + end + + + local number_type = self.number_type + if number_type then + local value = tonumber(self.value) --[[@as number]] + local new_value = step_number(value, number_type.min, number_type.max, koef * number_type.steps, number_type.is_loop) + self:set_value(new_value) + return + end +end + + +function M:set_number_type(min, max, is_loop, steps) + self.number_type = { + min = min, + max = max, + steps = steps or 1, + is_loop = is_loop, + } + return self +end + + +function M:set_array_type(array, is_loop, steps) + self.array_type = { + array = array, + steps = steps or 1, + is_loop = is_loop, + } + + return self +end + + +---@param value string|number +function M:set_value(value, is_instant) + if self.value == value then + return + end + + self.value = value + self.text_value:set_text(tostring(value)) + self.on_change_value:trigger(value) + + if not is_instant then + gui.set_alpha(self.selected, 1) + gui.animate(self.selected, "color.w", 0, gui.EASING_INSINE, 0.16) + end +end + + +---@return string|number +function M:get_value() + return self.value +end + + +return M diff --git a/druid/widget/properties_panel/properties/property_slider.lua b/druid/widget/properties_panel/properties/property_slider.lua index cb89b09..16c74f4 100644 --- a/druid/widget/properties_panel/properties/property_slider.lua +++ b/druid/widget/properties_panel/properties/property_slider.lua @@ -1,4 +1,4 @@ ----@class property_slider: druid.widget +---@class widget.property_slider: druid.widget ---@field root node ---@field container druid.container ---@field druid druid_instance diff --git a/druid/widget/properties_panel/properties/property_text.lua b/druid/widget/properties_panel/properties/property_text.lua index 0f8b69d..a150e7d 100644 --- a/druid/widget/properties_panel/properties/property_text.lua +++ b/druid/widget/properties_panel/properties/property_text.lua @@ -1,4 +1,4 @@ ----@class property_text: druid.widget +---@class widget.property_text: druid.widget ---@field root node ---@field container druid.container ---@field text_name druid.text @@ -8,6 +8,7 @@ local M = {} function M:init() self.root = self:get_node("root") self.text_name = self.druid:new_text("text_name") + :set_text_adjust("scale_when_trim_left", 0.3) self.text_right = self.druid:new_text("text_right", "") self.container = self.druid:new_container(self.root) @@ -21,15 +22,15 @@ end ---@param text string ----@return property_text +---@return widget.property_text function M:set_text(text) self.text_name:set_text(text) return self end ----@param text string ----@return property_text +---@param text string|nil +---@return widget.property_text function M:set_right_text(text) self.text_right:set_text(text or "") return self diff --git a/druid/widget/properties_panel/properties_panel.gui b/druid/widget/properties_panel/properties_panel.gui index 2df907a..0352b4d 100644 --- a/druid/widget/properties_panel/properties_panel.gui +++ b/druid/widget/properties_panel/properties_panel.gui @@ -426,5 +426,69 @@ nodes { parent: "property_text/root" template_node_child: true } +nodes { + position { + y: -250.0 + } + type: TYPE_TEMPLATE + id: "property_left_right_selector" + parent: "propeties" + inherit_alpha: true + template: "/druid/widget/properties_panel/properties/property_left_right_selector.gui" +} +nodes { + type: TYPE_BOX + id: "property_left_right_selector/root" + parent: "property_left_right_selector" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_left_right_selector/text_name" + parent: "property_left_right_selector/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_left_right_selector/E_Anchor" + parent: "property_left_right_selector/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_left_right_selector/button_left" + parent: "property_left_right_selector/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_left_right_selector/icon_left" + parent: "property_left_right_selector/button_left" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_left_right_selector/button_right" + parent: "property_left_right_selector/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_left_right_selector/icon_right" + parent: "property_left_right_selector/button_right" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_left_right_selector/selected" + parent: "property_left_right_selector/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_left_right_selector/text_value" + parent: "property_left_right_selector/E_Anchor" + template_node_child: true +} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties_panel.lua b/druid/widget/properties_panel/properties_panel.lua index 7cae30d..2993b6c 100644 --- a/druid/widget/properties_panel/properties_panel.lua +++ b/druid/widget/properties_panel/properties_panel.lua @@ -3,8 +3,9 @@ local property_slider = require("druid.widget.properties_panel.properties.proper local property_button = require("druid.widget.properties_panel.properties.property_button") local property_input = require("druid.widget.properties_panel.properties.property_input") local property_text = require("druid.widget.properties_panel.properties.property_text") +local property_left_right_selector = require("druid.widget.properties_panel.properties.property_left_right_selector") ----@class properties_panel: druid.widget +---@class widget.properties_panel: druid.widget ---@field root node ---@field scroll druid.scroll ---@field druid druid_instance @@ -24,6 +25,9 @@ function M:init() self.default_size = self.container:get_size() self.properties = {} + self.properties_constructors = {} + self.current_page = 1 + self.properties_per_page = 15 self.text_header = self.druid:new_text("text_header") self.scroll = self.druid:new_scroll("scroll_view", "scroll_content") @@ -51,6 +55,23 @@ function M:init() self.property_text_prefab = self:get_node("property_text/root") gui.set_enabled(self.property_text_prefab, false) + + self.property_left_right_selector_prefab = self:get_node("property_left_right_selector/root") + gui.set_enabled(self.property_left_right_selector_prefab, false) + + self.paginator = self:add_left_right_selector("Page", self.current_page, function(value) + self.current_page = value + self:refresh_page() + end):set_number_type(1, 1, true) + gui.set_enabled(self.paginator.root, false) + + -- Remove paginator from properties + for index = 1, #self.properties do + if self.properties[index] == self.paginator then + table.remove(self.properties, index) + break + end + end end @@ -66,7 +87,12 @@ function M:clear() self.druid:remove(self.properties[index]) end self.layout:clear_layout() + self.layout:add(self.paginator.root) + self.properties = {} + self.properties_constructors = {} + + self:refresh_page() end @@ -88,15 +114,11 @@ end ---@param text string ---@param initial_value boolean ---@param on_change_callback function ----@return property_checkbox +---@return widget.property_checkbox function M:add_checkbox(text, initial_value, on_change_callback) - text = tostring(text) + local instance = self:create_from_prefab(property_checkbox, "property_checkbox", self.property_checkbox_prefab) - local nodes = gui.clone_tree(self.property_checkbox_prefab) - local instance = self.druid:new_widget(property_checkbox, "property_checkbox", nodes) - self:add_property(instance) - - instance.text_name:set_to(text) + instance.text_name:set_text(text) instance:set_value(initial_value, true) instance.button.on_click:subscribe(function() on_change_callback(instance:get_value()) @@ -109,12 +131,9 @@ end ---@param text string ---@param initial_value number ---@param on_change_callback function ----@return property_slider +---@return widget.property_slider function M:add_slider(text, initial_value, on_change_callback) - text = tostring(text) - local nodes = gui.clone_tree(self.property_slider_prefab) - local instance = self.druid:new_widget(property_slider, "property_slider", nodes) - self:add_property(instance) + local instance = self:create_from_prefab(property_slider, "property_slider", self.property_slider_prefab) instance.text_name:set_text(text) instance:set_value(initial_value, true) @@ -129,10 +148,9 @@ end ---@param text string ---@param on_click_callback function|nil ---@param callback_context any|nil +---@return widget.property_button function M:add_button(text, on_click_callback, callback_context) - local nodes = gui.clone_tree(self.property_button_prefab) - local instance = self.druid:new_widget(property_button, "property_button", nodes) - self:add_property(instance) + local instance = self:create_from_prefab(property_button, "property_button", self.property_button_prefab) instance.text_name:set_text(text) if on_click_callback then @@ -143,11 +161,12 @@ function M:add_button(text, on_click_callback, callback_context) end +---@param text string +---@param initial_value string +---@param on_change_callback function +---@return widget.property_input function M:add_input(text, initial_value, on_change_callback) - text = tostring(text) - local nodes = gui.clone_tree(self.property_input_prefab) - local instance = self.druid:new_widget(property_input, "property_input", nodes) - self:add_property(instance) + local instance = self:create_from_prefab(property_input, "property_input", self.property_input_prefab) instance.text_name:set_text(text) instance.rich_input:set_text(initial_value) @@ -155,20 +174,44 @@ function M:add_input(text, initial_value, on_change_callback) instance.rich_input.input.on_input_unselect:subscribe(function(_, value) on_change_callback(value) end) + + return instance end ---@param text string ---@param right_text string|nil ----@return property_text +---@return widget.property_text function M:add_text(text, right_text) - text = tostring(text) - local nodes = gui.clone_tree(self.property_text_prefab) - local instance = self.druid:new_widget(property_text, "property_text", nodes) - self:add_property(instance) + local instance = self:create_from_prefab(property_text, "property_text", self.property_text_prefab) instance:set_text(text) instance:set_right_text(right_text) + + return instance +end + + +---@param text string +---@param value string|number|nil +---@param on_change_callback fun(value: string|number) +---@return widget.property_left_right_selector +function M:add_left_right_selector(text, value, on_change_callback) + local instance = self:create_from_prefab(property_left_right_selector, "property_left_right_selector", self.property_left_right_selector_prefab) + + instance:set_text(text) + instance:set_value(value or 0, true) + instance.on_change_value:subscribe(on_change_callback) + + return instance +end + + +---@private +function M:create_from_prefab(widget_class, widget_name, prefab) + local nodes = gui.clone_tree(prefab) + local instance = self.druid:new_widget(widget_class, widget_name, nodes) + self:add_property(instance) return instance end @@ -177,14 +220,36 @@ end function M:add_property(widget) gui.set_enabled(widget.root, true) self.layout:add(widget.root) + table.insert(self.properties, widget) local width = self.layout:get_size().x - self.layout.padding.x - self.layout.padding.z widget.container:set_size(width) + if #self.properties > self.properties_per_page then + self:refresh_page() + end + return widget end +function M:refresh_page() + local start_index = (self.current_page - 1) * self.properties_per_page + 1 + local end_index = start_index + self.properties_per_page - 1 + + for index = 1, #self.properties do + local is_visible = index >= start_index and index <= end_index + gui.set_enabled(self.properties[index].root, is_visible) + end + + gui.set_enabled(self.paginator.root, #self.properties > self.properties_per_page) + self.paginator:set_number_type(1, math.ceil(#self.properties / self.properties_per_page), true) + self.paginator.text_value:set_text(self.current_page .. " / " .. math.ceil(#self.properties / self.properties_per_page)) + + self.layout:set_dirty() +end + + function M:remove(widget) for index = 1, #self.properties do if self.properties[index] == widget then @@ -206,9 +271,14 @@ function M:toggle_hide() self.container:set_size(new_size.x, new_size.y, gui.PIVOT_N) gui.set_enabled(self.content, not self.is_hidden) - return self end +---@param properties_per_page number +function M:set_properties_per_page(properties_per_page) + self.properties_per_page = properties_per_page +end + + return M From 606f400719a0f1cfedaa4a57a624266d3fd1bc21 Mon Sep 17 00:00:00 2001 From: Insality Date: Wed, 20 Nov 2024 01:55:58 +0200 Subject: [PATCH 21/50] Update widgets --- druid/base/text.lua | 1 + druid/custom/rich_input/rich_input.lua | 16 ++++++++++------ .../properties/property_button.lua | 2 +- .../properties/property_checkbox.lua | 1 + .../properties/property_input.lua | 2 ++ .../properties/property_left_right_selector.lua | 2 ++ .../properties/property_slider.lua | 2 ++ .../properties/property_text.lua | 1 + 8 files changed, 20 insertions(+), 7 deletions(-) diff --git a/druid/base/text.lua b/druid/base/text.lua index 5396cec..773f57d 100755 --- a/druid/base/text.lua +++ b/druid/base/text.lua @@ -261,6 +261,7 @@ local function update_text_with_anchor_shift(self) end +---@param self druid.text local function update_adjust(self) if not self.adjust_type or self.adjust_type == const.TEXT_ADJUST.NO_ADJUST then reset_default_scale(self) diff --git a/druid/custom/rich_input/rich_input.lua b/druid/custom/rich_input/rich_input.lua index 36f9491..db14b7b 100644 --- a/druid/custom/rich_input/rich_input.lua +++ b/druid/custom/rich_input/rich_input.lua @@ -252,12 +252,16 @@ function M:on_input(action_id, action) 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 self.input.is_selected then + if action_id == const.ACTION_LEFT and (action.pressed or action.repeated) then + self.input:move_selection(-1, self.is_lshift, self.is_lctrl) + return true + 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) + if action_id == const.ACTION_RIGHT and (action.pressed or action.repeated) then + self.input:move_selection(1, self.is_lshift, self.is_lctrl) + return true + end end end @@ -265,7 +269,7 @@ end --- Set placeholder text ---@param placeholder_text string The placeholder text function M:set_placeholder(placeholder_text) - self.placeholder:set_to(placeholder_text) + self.placeholder:set_text(placeholder_text) return self end diff --git a/druid/widget/properties_panel/properties/property_button.lua b/druid/widget/properties_panel/properties/property_button.lua index 085a437..d7fa92f 100644 --- a/druid/widget/properties_panel/properties/property_button.lua +++ b/druid/widget/properties_panel/properties/property_button.lua @@ -12,7 +12,7 @@ local M = {} function M:init() self.root = self:get_node("root") self.text_name = self.druid:new_text("text_name") - :set_text_adjust("trim_left") + :set_text_adjust("scale_then_trim_left", 0.3) self.selected = self:get_node("selected") gui.set_alpha(self.selected, 0) diff --git a/druid/widget/properties_panel/properties/property_checkbox.lua b/druid/widget/properties_panel/properties/property_checkbox.lua index 57d82e1..bf4c2dc 100644 --- a/druid/widget/properties_panel/properties/property_checkbox.lua +++ b/druid/widget/properties_panel/properties/property_checkbox.lua @@ -17,6 +17,7 @@ function M:init() gui.set_alpha(self.selected, 0) self.text_name = self.druid:new_text("text_name") + :set_text_adjust("scale_then_trim_left", 0.3) self.button = self.druid:new_button("button", self.on_click) diff --git a/druid/widget/properties_panel/properties/property_input.lua b/druid/widget/properties_panel/properties/property_input.lua index 83c7c0a..7f18847 100644 --- a/druid/widget/properties_panel/properties/property_input.lua +++ b/druid/widget/properties_panel/properties/property_input.lua @@ -10,6 +10,8 @@ local M = {} function M:init() self.root = self:get_node("root") self.text_name = self.druid:new_text("text_name") + :set_text_adjust("scale_then_trim_left", 0.3) + self.selected = self:get_node("selected") gui.set_alpha(self.selected, 0) diff --git a/druid/widget/properties_panel/properties/property_left_right_selector.lua b/druid/widget/properties_panel/properties/property_left_right_selector.lua index b6e5ed7..8a442ed 100644 --- a/druid/widget/properties_panel/properties/property_left_right_selector.lua +++ b/druid/widget/properties_panel/properties/property_left_right_selector.lua @@ -16,6 +16,8 @@ function M:init() gui.set_alpha(self.selected, 0) self.text_name = self.druid:new_text("text_name") + :set_text_adjust("scale_then_trim_left", 0.3) + self.text_value = self.druid:new_text("text_value") self.button_left = self.druid:new_button("button_left", self.on_button_left) self.button_right = self.druid:new_button("button_right", self.on_button_right) diff --git a/druid/widget/properties_panel/properties/property_slider.lua b/druid/widget/properties_panel/properties/property_slider.lua index 16c74f4..91b975c 100644 --- a/druid/widget/properties_panel/properties/property_slider.lua +++ b/druid/widget/properties_panel/properties/property_slider.lua @@ -15,6 +15,8 @@ function M:init() self._value = 0 self.text_name = self.druid:new_text("text_name") + :set_text_adjust("scale_then_trim_left", 0.3) + self.text_value = self.druid:new_text("text_value") self.slider = self.druid:new_slider("slider_pin", vmath.vector3(55, 0, 0), self._on_slider_change_by_user) --[[@as druid.slider]] self.slider:set_input_node("slider") diff --git a/druid/widget/properties_panel/properties/property_text.lua b/druid/widget/properties_panel/properties/property_text.lua index a150e7d..192a99c 100644 --- a/druid/widget/properties_panel/properties/property_text.lua +++ b/druid/widget/properties_panel/properties/property_text.lua @@ -9,6 +9,7 @@ function M:init() self.root = self:get_node("root") self.text_name = self.druid:new_text("text_name") :set_text_adjust("scale_when_trim_left", 0.3) + self.text_right = self.druid:new_text("text_right", "") self.container = self.druid:new_container(self.root) From f2fa5320d2b194331d54562f4482eaeaa897fbd9 Mon Sep 17 00:00:00 2001 From: Insality Date: Wed, 20 Nov 2024 02:44:45 +0200 Subject: [PATCH 22/50] Update --- .../properties/property_left_right_selector.lua | 9 +++++---- .../widget/properties_panel/properties/property_text.lua | 1 + druid/widget/properties_panel/properties_panel.lua | 7 +++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/druid/widget/properties_panel/properties/property_left_right_selector.lua b/druid/widget/properties_panel/properties/property_left_right_selector.lua index 8a442ed..0cc16d9 100644 --- a/druid/widget/properties_panel/properties/property_left_right_selector.lua +++ b/druid/widget/properties_panel/properties/property_left_right_selector.lua @@ -129,16 +129,16 @@ end function M:on_button_left() - self:add_value(true) + self:add_step(-1) end function M:on_button_right() - self:add_value(false) + self:add_step(1) end -function M:add_value(is_left) - local koef = is_left and -1 or 1 +---@param koef number -1 0 1, on 0 will not move +function M:add_step(koef) local array_type = self.array_type if array_type then local value = self.value @@ -165,6 +165,7 @@ function M:set_number_type(min, max, is_loop, steps) steps = steps or 1, is_loop = is_loop, } + return self end diff --git a/druid/widget/properties_panel/properties/property_text.lua b/druid/widget/properties_panel/properties/property_text.lua index 192a99c..20c0e81 100644 --- a/druid/widget/properties_panel/properties/property_text.lua +++ b/druid/widget/properties_panel/properties/property_text.lua @@ -11,6 +11,7 @@ function M:init() :set_text_adjust("scale_when_trim_left", 0.3) self.text_right = self.druid:new_text("text_right", "") + --:set_text_adjust("scale_when_trim_left", 0.3) -- TODO: not works? why? self.container = self.druid:new_container(self.root) self.container:add_container("text_name", nil, function(_, size) diff --git a/druid/widget/properties_panel/properties_panel.lua b/druid/widget/properties_panel/properties_panel.lua index 2993b6c..a8f9da2 100644 --- a/druid/widget/properties_panel/properties_panel.lua +++ b/druid/widget/properties_panel/properties_panel.lua @@ -281,4 +281,11 @@ function M:set_properties_per_page(properties_per_page) end +function M:set_page(page) + self.current_page = page + self.paginator:set_value(self.current_page, true) + self:refresh_page() +end + + return M From 7ea8691fc5b26cb8bce9882c726fad8500c6b685 Mon Sep 17 00:00:00 2001 From: Insality Date: Wed, 20 Nov 2024 23:36:04 +0200 Subject: [PATCH 23/50] Update --- docs_md/01-components.md | 2 +- druid/base/static_grid.lua | 12 +- druid/custom/rich_input/rich_input.gui | 4 +- .../editor_scripts/create_druid_component.py | 9 +- druid/editor_scripts/druid.editor_script | 4 +- druid/editor_scripts/widget.lua_template | 9 +- .../{text_bold.font => druid_text_bold.font} | 0 ...t_regular.font => druid_text_regular.font} | 0 druid/templates/component.template.lua | 20 +- druid/widget/fps_panel/fps_panel.gui | 12 +- druid/widget/fps_panel/fps_panel.lua | 4 +- druid/widget/memory_panel/memory_panel.gui | 14 +- druid/widget/memory_panel/memory_panel.lua | 8 +- druid/widget/mini_graph/mini_graph.gui | 10 +- .../properties/property_button.gui | 4 +- .../properties/property_checkbox.gui | 4 +- .../properties/property_input.gui | 4 +- .../property_left_right_selector.gui | 4 +- .../properties/property_slider.gui | 8 +- .../properties/property_text.gui | 4 +- .../properties_panel/properties_panel.gui | 10 +- .../{druid.atlas => druid_example.atlas} | 0 example/components/druid_logo/druid_logo.gui | 311 +-- .../examples_list_view/examples_list_view.gui | 470 +--- .../examples_list_view/examples_list_view.lua | 4 +- .../examples_list_view_item.gui | 197 +- .../components/output_list/output_list.gui | 4 +- .../components/output_list/output_list.lua | 2 +- .../panel_druid_profiler.gui | 527 +---- .../panel_information/panel_information.gui | 4 +- .../properties/property_button.gui | 192 +- .../properties/property_checkbox.gui | 204 +- .../properties/property_slider.gui | 4 +- .../properties_panel/properties_panel.gui | 1466 +----------- .../properties_panel/properties_panel.lua | 2 +- example/druid.gui | 107 +- .../basic/back_handler/basic_back_handler.gui | 4 +- .../examples/basic/blocker/basic_blocker.gui | 4 +- .../basic/button/basic_button_hold.gui | 4 +- example/examples/basic/checkbox/checkbox.gui | 4 +- .../basic/checkbox_group/checkbox_group.gui | 4 +- example/examples/basic/drag/drag.gui | 208 +- example/examples/basic/drag/drag_to_node.gui | 4 +- example/examples/basic/grid/grid.gui | 211 +- example/examples/basic/grid/grid.lua | 4 +- example/examples/basic/hover/hover.gui | 350 +-- example/examples/basic/input/rich_input.gui | 803 +------ .../basic/progress_bar/basic_progress_bar.gui | 4 +- .../basic_progress_bar_slice9.gui | 4 +- .../basic/radio_group/radio_group.gui | 4 +- .../basic/rich_text/basic_rich_text.gui | 4 +- .../basic/rich_text/rich_text_tags.gui | 4 +- .../basic/rich_text/rich_text_tags_custom.gui | 4 +- example/examples/basic/scroll/scroll.gui | 4 +- .../scroll_bind_grid/scroll_bind_grid.gui | 257 +-- .../scroll_bind_grid/scroll_bind_grid.lua | 4 +- .../scroll_bind_grid_horizontal.gui | 256 +-- .../scroll_bind_grid_horizontal.lua | 4 +- .../scroll_bind_grid_points.gui | 4 +- .../scroll_bind_grid_points.lua | 4 +- .../basic/scroll_slider/scroll_slider.gui | 2019 +---------------- .../examples/basic/slider/basic_slider.gui | 278 +-- .../basic/slider/basic_slider_stepped.gui | 278 +-- .../basic/slider/basic_slider_vertical.gui | 4 +- example/examples/basic/swipe/basic_swipe.gui | 87 +- example/examples/basic/text/basic_text.gui | 135 +- .../examples/basic/text/multiline_text.gui | 134 +- .../data_list_add_remove_clear.gui | 266 +-- .../data_list_add_remove_clear.lua | 2 +- .../data_list/basic/data_list_basic.gui | 266 +-- .../data_list/basic/data_list_basic.lua | 2 +- .../basic/data_list_horizontal_basic.gui | 265 +-- .../basic/data_list_horizontal_basic.lua | 2 +- .../cache_with_component/button_component.gui | 135 +- .../cache_with_component.gui | 345 +-- .../cache_with_component.lua | 2 +- .../gamepad/gamepad_tester/gamepad_tester.gui | 4 +- .../templates/gamepad_button.gui | 131 +- .../templates/gamepad_stick.gui | 4 +- .../templates/gamepad_trigger.gui | 117 +- .../on_screen_control/on_screen_control.gui | 4 +- .../on_screen_control/on_screen_input.gui | 4 +- example/examples/intro/intro/intro.gui | 4 +- .../examples/layout/basic/basic_layout.gui | 133 +- .../animation_blend/animation_blend.gui | 4 +- .../basic_animation/basic_animation.gui | 207 +- example/examples/widgets/examples_list.lua | 8 + .../widgets/hover_hint/hover_hint.gui | 4 +- .../widgets/hover_hint/hover_hint_example.gui | 4 +- .../memory_panel/example_memory_panel.gui | 98 + .../memory_panel/example_memory_panel.lua | 12 + .../window_confirmation.gui | 604 +---- .../windows/window_info/window_info.gui | 460 +--- .../window_language/window_language.gui | 471 +--- .../window_language/window_language.lua | 4 +- example/templates/button_text_blue.gui | 89 +- example/templates/button_text_green.gui | 85 +- example/templates/button_text_red.gui | 85 +- example/templates/button_text_white.gui | 86 +- example/templates/button_text_yellow.gui | 89 +- example/templates/input.gui | 83 +- example/templates/rich_input.gui | 253 +-- example/templates/slider.gui | 126 +- test/tests/test_static_grid.lua | 4 +- 104 files changed, 451 insertions(+), 12743 deletions(-) rename druid/fonts/{text_bold.font => druid_text_bold.font} (100%) rename druid/fonts/{text_regular.font => druid_text_regular.font} (100%) rename example/assets/{druid.atlas => druid_example.atlas} (100%) create mode 100644 example/examples/widgets/memory_panel/example_memory_panel.gui create mode 100644 example/examples/widgets/memory_panel/example_memory_panel.lua diff --git a/docs_md/01-components.md b/docs_md/01-components.md index edb1fa3..ce33f02 100644 --- a/docs_md/01-components.md +++ b/docs_md/01-components.md @@ -216,7 +216,7 @@ Static grid have constant node size, so it possible to calculate node positions Static grid can shift elements on add/remove functions. ### Setup -Create component with druid: `grid = druid:new_static_grid(parent_node, prefab_node, max_in_row_elements)` +Create component with druid: `grid = druid:new_grid(parent_node, prefab_node, max_in_row_elements)` ### Notes - On _add node_ grid will set nodeup parent to _parent_node_ diff --git a/druid/base/static_grid.lua b/druid/base/static_grid.lua index 51589f4..48f0e7d 100644 --- a/druid/base/static_grid.lua +++ b/druid/base/static_grid.lua @@ -34,7 +34,7 @@ -- Example Link -- @module StaticGrid -- @within BaseComponent --- @alias druid.static_grid +-- @alias druid.grid --- On item add callback(self, node, index) -- @tfield druid.event on_add_item druid.event @@ -377,7 +377,7 @@ end --- Change set position function for grid nodes. It will call on -- update poses on grid elements. Default: gui.set_position ---@param callback function Function on node set position ----@return druid.static_grid Current grid instance +---@return druid.grid Current grid instance function M:set_position_function(callback) self._set_position_function = callback or gui.set_position @@ -387,7 +387,7 @@ end --- Clear grid nodes array. GUI nodes will be not deleted! -- If you want to delete GUI nodes, use static_grid.nodes array before grid:clear ----@return druid.static_grid Current grid instance +---@return druid.grid Current grid instance function M:clear() self.border.x = 0 self.border.y = 0 @@ -421,7 +421,7 @@ end --- Set new in_row elements for grid ---@param in_row number The new in_row value ----@return druid.static_grid Current grid instance +---@return druid.grid Current grid instance function M:set_in_row(in_row) self.in_row = in_row self._grid_horizonal_offset = self.node_size.x * (self.in_row - 1) * self.anchor.x @@ -440,7 +440,7 @@ end --- Set new node size for grid -- @tparam[opt] number width The new node width -- @tparam[opt] number height The new node height ----@return druid.static_grid Current grid instance +---@return druid.grid Current grid instance function M:set_item_size(width, height) if width then self.node_size.x = width @@ -463,7 +463,7 @@ end --- Sort grid nodes by custom comparator function ---@param comparator function The comparator function. (a, b) -> boolean ----@return druid.static_grid Current grid instance +---@return druid.grid Current grid instance function M:sort_nodes(comparator) table.sort(self.nodes, comparator) self:_update(true) diff --git a/druid/custom/rich_input/rich_input.gui b/druid/custom/rich_input/rich_input.gui index 46c7d7f..ad0bb1d 100644 --- a/druid/custom/rich_input/rich_input.gui +++ b/druid/custom/rich_input/rich_input.gui @@ -1,6 +1,6 @@ fonts { - name: "text_bold" - font: "/druid/fonts/text_bold.font" + name: "druid_text_bold" + font: "/druid/fonts/druid_text_bold.font" } textures { name: "druid" diff --git a/druid/editor_scripts/create_druid_component.py b/druid/editor_scripts/create_druid_component.py index 195429a..f27d57f 100644 --- a/druid/editor_scripts/create_druid_component.py +++ b/druid/editor_scripts/create_druid_component.py @@ -1,12 +1,9 @@ -# @license MIT, Insality 2021 -# @source https://github.com/Insality/druid - import os import sys import deftree current_filepath = os.path.abspath(os.path.dirname(__file__)) -TEMPLATE_PATH = current_filepath + "/component.lua_template" +TEMPLATE_PATH = current_filepath + "/widget.lua_template" component_annotations = "" component_functions = "" @@ -44,9 +41,9 @@ def process_component(node_name, component_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_annotations += "\n---@field {0} druid.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(\"{1}\", \"prefab_name\", 1)".format(node_name, node_name) + component_define += "\n\tself.{0} = self.druid:new_grid(\"{1}\", \"prefab_name\", 1)".format(node_name, node_name) if node_name.startswith("scroll_view"): field_name = node_name.replace("_view", "") diff --git a/druid/editor_scripts/druid.editor_script b/druid/editor_scripts/druid.editor_script index 27d4adc..96076c5 100644 --- a/druid/editor_scripts/druid.editor_script +++ b/druid/editor_scripts/druid.editor_script @@ -50,7 +50,7 @@ function M.get_commands() }, { - label = "Create Druid Component", + label = "Create Druid Widget", locations = { "Edit", "Assets" }, query = { selection = {type = "resource", cardinality = "one"} }, active = function(opts) @@ -62,7 +62,7 @@ function M.get_commands() print("Run script for", editor.get(file, "path")) save_file_from_dependency('/druid/editor_scripts/run_python_script_on_gui.sh', "./build/run_python_script_on_gui.sh") save_file_from_dependency('/druid/editor_scripts/create_druid_component.py', "./build/create_druid_component.py") - save_file_from_dependency('/druid/editor_scripts/component.lua_template', "./build/component.lua_template") + save_file_from_dependency('/druid/editor_scripts/widget.lua_template', "./build/widget.lua_template") return { { action = "shell", diff --git a/druid/editor_scripts/widget.lua_template b/druid/editor_scripts/widget.lua_template index 18875f6..9d0f2c6 100644 --- a/druid/editor_scripts/widget.lua_template +++ b/druid/editor_scripts/widget.lua_template @@ -1,9 +1,14 @@ ----@class widget.TEMPLATE: druid.widget +---This is a template for a {COMPONENT_NAME} Druid widget. +---Instantiate this template with `druid.new_widget(widget_module, [template_id], [nodes])`. +---Read more about Druid Widgets here: ... + +---@class widget.{COMPONENT_TYPE}: druid.widget local M = {} + function M:init() self.root = self:get_node("root") - self.button = self.druid:new_button("button"), self.on_button, self) + self.button = self.druid:new_button("button", self.on_button, self) end diff --git a/druid/fonts/text_bold.font b/druid/fonts/druid_text_bold.font similarity index 100% rename from druid/fonts/text_bold.font rename to druid/fonts/druid_text_bold.font diff --git a/druid/fonts/text_regular.font b/druid/fonts/druid_text_regular.font similarity index 100% rename from druid/fonts/text_regular.font rename to druid/fonts/druid_text_regular.font diff --git a/druid/templates/component.template.lua b/druid/templates/component.template.lua index 059ef31..202cd42 100644 --- a/druid/templates/component.template.lua +++ b/druid/templates/component.template.lua @@ -1,16 +1,16 @@ -local component = require("druid.component") - ----@class component_name : druid.base_component -local M = component.create("component_name") +---@class widget.TEMPLATE: druid.widget +local M = {} --- Component constructor. Template name and nodes are optional. Pass it if you use it in your component -function M:init(template, nodes) - self.druid = self:get_druid(template, nodes) +function M:init() self.root = self:get_node("root") - - self.button = self.druid:new_button("button", function() end) + self.button = self.druid:new_button("button", self.on_button, self) end -return M +function M:on_button() + print("Root node", self.root) +end + + +return M \ No newline at end of file diff --git a/druid/widget/fps_panel/fps_panel.gui b/druid/widget/fps_panel/fps_panel.gui index fed43d9..bf8b20b 100644 --- a/druid/widget/fps_panel/fps_panel.gui +++ b/druid/widget/fps_panel/fps_panel.gui @@ -1,10 +1,10 @@ fonts { - name: "text_regular" - font: "/druid/fonts/text_regular.font" + name: "druid_text_regular" + font: "/druid/fonts/druid_text_regular.font" } fonts { - name: "text_bold" - font: "/druid/fonts/text_bold.font" + name: "druid_text_bold" + font: "/druid/fonts/druid_text_bold.font" } textures { name: "druid" @@ -122,7 +122,7 @@ nodes { } type: TYPE_TEXT text: "12 FPS" - font: "text_regular" + font: "druid_text_regular" id: "text_min_fps" pivot: PIVOT_W outline { @@ -159,7 +159,7 @@ nodes { } type: TYPE_TEXT text: "60 FPS" - font: "text_bold" + font: "druid_text_bold" id: "text_fps" outline { x: 1.0 diff --git a/druid/widget/fps_panel/fps_panel.lua b/druid/widget/fps_panel/fps_panel.lua index 1517d97..1b0edaa 100644 --- a/druid/widget/fps_panel/fps_panel.lua +++ b/druid/widget/fps_panel/fps_panel.lua @@ -75,9 +75,9 @@ function M:push_fps_value() self.mini_graph:push_line_value(1 / average_frame_time) - self.text_fps:set_to(tostring(math.ceil(1 / average_frame_time) .. " FPS")) + self.text_fps:set_text(tostring(math.ceil(1 / average_frame_time) .. " FPS")) local lowest_value = math.ceil(self.mini_graph:get_lowest_value()) - self.text_min_fps:set_to(lowest_value .. " lowest") + self.text_min_fps:set_text(lowest_value .. " lowest") end diff --git a/druid/widget/memory_panel/memory_panel.gui b/druid/widget/memory_panel/memory_panel.gui index d0c9c9a..99e8cf2 100644 --- a/druid/widget/memory_panel/memory_panel.gui +++ b/druid/widget/memory_panel/memory_panel.gui @@ -1,10 +1,10 @@ fonts { - name: "text_regular" - font: "/druid/fonts/text_regular.font" + name: "druid_text_regular" + font: "/druid/fonts/druid_text_regular.font" } fonts { - name: "text_bold" - font: "/druid/fonts/text_bold.font" + name: "druid_text_bold" + font: "/druid/fonts/druid_text_bold.font" } textures { name: "druid" @@ -104,7 +104,7 @@ nodes { } type: TYPE_TEXT text: "120.23 KB" - font: "text_regular" + font: "druid_text_regular" id: "text_max_value" pivot: PIVOT_W outline { @@ -142,7 +142,7 @@ nodes { } type: TYPE_TEXT text: "120 KB/s" - font: "text_regular" + font: "druid_text_regular" id: "text_per_second" pivot: PIVOT_E outline { @@ -221,7 +221,7 @@ nodes { } type: TYPE_TEXT text: "120 KB" - font: "text_bold" + font: "druid_text_bold" id: "text_memory" outline { x: 1.0 diff --git a/druid/widget/memory_panel/memory_panel.lua b/druid/widget/memory_panel/memory_panel.lua index 672751a..213a3e5 100644 --- a/druid/widget/memory_panel/memory_panel.lua +++ b/druid/widget/memory_panel/memory_panel.lua @@ -51,14 +51,14 @@ function M:push_next_value() self.mini_graph:set_max_value(max_value) local max_memory = math.ceil(self.mini_graph:get_highest_value()) - self.max_value:set_to(max_memory .. " KB") + self.max_value:set_text(max_memory .. " KB") local last_second = 0 local last_second_samples = math.ceil(1 / self.delta_time) for index = #self.memory_samples - last_second_samples + 1, #self.memory_samples do last_second = last_second + (self.memory_samples[index] or 0) end - self.text_per_second:set_to(math.ceil(last_second) .. " KB/s") + self.text_per_second:set_text(math.ceil(last_second) .. " KB/s") end @@ -66,9 +66,9 @@ function M:update_text_memory() local memory = math.ceil(collectgarbage("count")) -- in KB if memory > 1024 then memory = memory / 1024 - self.text_memory:set_to(string.format("%.2f", memory) .. " MB") + self.text_memory:set_text(string.format("%.2f", memory) .. " MB") else - self.text_memory:set_to(memory .. " KB") + self.text_memory:set_text(memory .. " KB") end end diff --git a/druid/widget/mini_graph/mini_graph.gui b/druid/widget/mini_graph/mini_graph.gui index ceefa96..161f0df 100644 --- a/druid/widget/mini_graph/mini_graph.gui +++ b/druid/widget/mini_graph/mini_graph.gui @@ -1,10 +1,10 @@ fonts { - name: "text_regular" - font: "/druid/fonts/text_regular.font" + name: "druid_text_regular" + font: "/druid/fonts/druid_text_regular.font" } fonts { - name: "text_bold" - font: "/druid/fonts/text_bold.font" + name: "druid_text_bold" + font: "/druid/fonts/druid_text_bold.font" } textures { name: "druid" @@ -67,7 +67,7 @@ nodes { } type: TYPE_TEXT text: "Mini Graph" - font: "text_regular" + font: "druid_text_regular" id: "text_header" pivot: PIVOT_NW outline { diff --git a/druid/widget/properties_panel/properties/property_button.gui b/druid/widget/properties_panel/properties/property_button.gui index 6efe3df..2175a1c 100644 --- a/druid/widget/properties_panel/properties/property_button.gui +++ b/druid/widget/properties_panel/properties/property_button.gui @@ -1,6 +1,6 @@ fonts { - name: "text_bold" - font: "/druid/fonts/text_bold.font" + name: "druid_text_bold" + font: "/druid/fonts/druid_text_bold.font" } textures { name: "druid" diff --git a/druid/widget/properties_panel/properties/property_checkbox.gui b/druid/widget/properties_panel/properties/property_checkbox.gui index 59824fd..80740ca 100644 --- a/druid/widget/properties_panel/properties/property_checkbox.gui +++ b/druid/widget/properties_panel/properties/property_checkbox.gui @@ -1,6 +1,6 @@ fonts { - name: "text_bold" - font: "/druid/fonts/text_bold.font" + name: "druid_text_bold" + font: "/druid/fonts/druid_text_bold.font" } textures { name: "druid" diff --git a/druid/widget/properties_panel/properties/property_input.gui b/druid/widget/properties_panel/properties/property_input.gui index ac4e786..e82aaf3 100644 --- a/druid/widget/properties_panel/properties/property_input.gui +++ b/druid/widget/properties_panel/properties/property_input.gui @@ -1,6 +1,6 @@ fonts { - name: "text_bold" - font: "/druid/fonts/text_bold.font" + name: "druid_text_bold" + font: "/druid/fonts/druid_text_bold.font" } textures { name: "druid" diff --git a/druid/widget/properties_panel/properties/property_left_right_selector.gui b/druid/widget/properties_panel/properties/property_left_right_selector.gui index c7d528b..e959dd5 100644 --- a/druid/widget/properties_panel/properties/property_left_right_selector.gui +++ b/druid/widget/properties_panel/properties/property_left_right_selector.gui @@ -1,6 +1,6 @@ fonts { - name: "text_bold" - font: "/druid/fonts/text_bold.font" + name: "druid_text_bold" + font: "/druid/fonts/druid_text_bold.font" } textures { name: "druid" diff --git a/druid/widget/properties_panel/properties/property_slider.gui b/druid/widget/properties_panel/properties/property_slider.gui index a0bb0a4..c0a9564 100644 --- a/druid/widget/properties_panel/properties/property_slider.gui +++ b/druid/widget/properties_panel/properties/property_slider.gui @@ -1,6 +1,6 @@ fonts { - name: "text_bold" - font: "/druid/fonts/text_bold.font" + name: "druid_text_bold" + font: "/druid/fonts/druid_text_bold.font" } textures { name: "druid" @@ -37,7 +37,7 @@ nodes { } type: TYPE_TEXT text: "Slider" - font: "text_bold" + font: "druid_text_bold" id: "text_name" pivot: PIVOT_W outline { @@ -201,7 +201,7 @@ nodes { } type: TYPE_TEXT text: "25 %" - font: "text_bold" + font: "druid_text_bold" id: "text_value" outline { x: 1.0 diff --git a/druid/widget/properties_panel/properties/property_text.gui b/druid/widget/properties_panel/properties/property_text.gui index 8966c90..3ebf171 100644 --- a/druid/widget/properties_panel/properties/property_text.gui +++ b/druid/widget/properties_panel/properties/property_text.gui @@ -1,6 +1,6 @@ fonts { - name: "text_bold" - font: "/druid/fonts/text_bold.font" + name: "druid_text_bold" + font: "/druid/fonts/druid_text_bold.font" } textures { name: "druid" diff --git a/druid/widget/properties_panel/properties_panel.gui b/druid/widget/properties_panel/properties_panel.gui index 0352b4d..70f6db0 100644 --- a/druid/widget/properties_panel/properties_panel.gui +++ b/druid/widget/properties_panel/properties_panel.gui @@ -1,10 +1,10 @@ fonts { - name: "text_regular" - font: "/druid/fonts/text_regular.font" + name: "druid_text_regular" + font: "/druid/fonts/druid_text_regular.font" } fonts { - name: "text_bold" - font: "/druid/fonts/text_bold.font" + name: "druid_text_bold" + font: "/druid/fonts/druid_text_bold.font" } textures { name: "druid" @@ -67,7 +67,7 @@ nodes { } type: TYPE_TEXT text: "Properties" - font: "text_regular" + font: "druid_text_regular" id: "text_header" pivot: PIVOT_NW outline { diff --git a/example/assets/druid.atlas b/example/assets/druid_example.atlas similarity index 100% rename from example/assets/druid.atlas rename to example/assets/druid_example.atlas diff --git a/example/components/druid_logo/druid_logo.gui b/example/components/druid_logo/druid_logo.gui index 15b549d..2347db1 100644 --- a/example/components/druid_logo/druid_logo.gui +++ b/example/components/druid_logo/druid_logo.gui @@ -1,4 +1,3 @@ -script: "" fonts { name: "text_regular" font: "/example/assets/fonts/text_regular.font" @@ -8,434 +7,129 @@ textures { texture: "/example/assets/druid_logo.atlas" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 400.0 y: 170.0 - z: 0.0 - w: 1.0 } color { x: 0.129 y: 0.141 z: 0.157 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/pixel" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT layer: "druid" inherit_alpha: true - slice9 { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 - } clipping_mode: CLIPPING_MODE_STENCIL - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: 200.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: 16.0 y: 16.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: "" id: "E_Anchor" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_E adjust_mode: ADJUST_MODE_STRETCH 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { x: 10.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: 200.0 - y: 100.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: "druid_logo/icon_druid" id: "icon_druid_right" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "E_Anchor" layer: "druid_logo" 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: 0.5 - template_node_child: false size_mode: SIZE_MODE_AUTO - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: -200.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: 16.0 y: 16.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: "" id: "W_Anchor" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_W adjust_mode: ADJUST_MODE_STRETCH 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { x: -10.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: 200.0 - y: 100.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: "druid_logo/icon_druid" id: "icon_druid_left" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "W_Anchor" layer: "druid_logo" 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: 0.5 - template_node_child: false size_mode: SIZE_MODE_AUTO - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 200.0 - y: 100.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: "druid_logo/logo_druid" id: "icon_logo" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "root" layer: "druid_logo" 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 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -50.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 } scale { x: 0.6 y: 0.6 - z: 1.0 - w: 1.0 } size { x: 400.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.463 y: 0.475 z: 0.49 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Defold UI Framework" font: "text_regular" id: "text_description" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "root" layer: "text_regular" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } layers { name: "druid" @@ -448,4 +142,3 @@ layers { } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/components/examples_list_view/examples_list_view.gui b/example/components/examples_list_view/examples_list_view.gui index 750684c..21f5dc5 100644 --- a/example/components/examples_list_view/examples_list_view.gui +++ b/example/components/examples_list_view/examples_list_view.gui @@ -1,605 +1,140 @@ -script: "" fonts { name: "text_regular" font: "/example/assets/fonts/text_regular.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 400.0 y: 910.0 - z: 0.0 - w: 1.0 } color { x: 0.173 y: 0.184 z: 0.204 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/pixel" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER adjust_mode: ADJUST_MODE_STRETCH layer: "druid" 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_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: -190.0 y: 445.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 } scale { x: 0.9 y: 0.9 - z: 1.0 - w: 1.0 } size { x: 250.0 y: 60.0 - z: 0.0 - w: 1.0 } color { x: 0.463 y: 0.475 z: 0.49 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Examples" font: "text_regular" id: "text_header" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_NW outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "root" layer: "text_regular" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: -200.0 y: 395.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: 400.0 y: 850.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: "druid/empty" id: "scroll_view" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH parent: "root" layer: "druid" inherit_alpha: true - slice9 { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 - } clipping_mode: CLIPPING_MODE_STENCIL - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 400.0 y: 850.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: "druid/empty" id: "scroll_content" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH parent: "scroll_view" layer: "druid" 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { - x: 0.0 y: -52.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "examples_list_view_item" parent: "scroll_content" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/components/examples_list_view/examples_list_view_item.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 400.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.173 - y: 0.184 - z: 0.204 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/empty" id: "examples_list_view_item/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_W - adjust_mode: ADJUST_MODE_STRETCH parent: "examples_list_view_item" - layer: "druid" - 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: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: false - material: "" } 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: 400.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/pixel" id: "examples_list_view_item/panel_highlight" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_W - adjust_mode: ADJUST_MODE_FIT parent: "examples_list_view_item/root" - layer: "druid" - 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: 0.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 4.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.894 - y: 0.506 - z: 0.333 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/pixel" id: "examples_list_view_item/panel_selected" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_W - adjust_mode: ADJUST_MODE_FIT parent: "examples_list_view_item/root" - layer: "druid" - 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: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: false - visible: true - material: "" } nodes { - position { - x: 18.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: 0.6 - y: 0.6 - z: 1.0 - w: 1.0 - } - size { - x: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.851 - y: 0.851 - z: 0.851 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/icon_arrow" id: "examples_list_view_item/icon" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "examples_list_view_item/root" - layer: "druid" - 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: true - size_mode: SIZE_MODE_AUTO - custom_type: 0 - enabled: false - visible: true - material: "" } nodes { - position { - x: 36.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: 0.7 - y: 0.7 - z: 1.0 - w: 1.0 - } - size { - x: 500.0 - y: 60.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.463 - y: 0.475 - z: 0.49 - w: 1.0 - } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "Basic" - font: "text_bold" id: "examples_list_view_item/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_W - outline { - x: 0.941 - y: 0.984 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "examples_list_view_item/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } layers { name: "druid" @@ -609,4 +144,3 @@ layers { } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/components/examples_list_view/examples_list_view.lua b/example/components/examples_list_view/examples_list_view.lua index 7f66b4d..9d06af6 100644 --- a/example/components/examples_list_view/examples_list_view.lua +++ b/example/components/examples_list_view/examples_list_view.lua @@ -10,7 +10,7 @@ local examples_list_view_item = require("example.components.examples_list_view.e ---@field root druid.container ---@field druid druid_instance ---@field scroll druid.scroll ----@field grid druid.static_grid +---@field grid druid.grid local M = component.create("examples_list_view") @@ -29,7 +29,7 @@ function M:init(template, nodes) gui.set_enabled(self.prefab, false) self.scroll = self.druid:new_scroll("scroll_view", "scroll_content") - self.grid = self.druid:new_static_grid("scroll_content", self.prefab, 1) + self.grid = self.druid:new_grid("scroll_content", self.prefab, 1) self.scroll:bind_grid(self.grid) self.root:add_container("scroll_view", nil, function(_, size) diff --git a/example/components/examples_list_view/examples_list_view_item.gui b/example/components/examples_list_view/examples_list_view_item.gui index 2cef928..f9ad962 100644 --- a/example/components/examples_list_view/examples_list_view_item.gui +++ b/example/components/examples_list_view/examples_list_view_item.gui @@ -1,319 +1,127 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 400.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.173 y: 0.184 z: 0.204 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/empty" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_W adjust_mode: ADJUST_MODE_STRETCH layer: "druid" 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 400.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/pixel" id: "panel_highlight" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_W - adjust_mode: ADJUST_MODE_FIT parent: "root" layer: "druid" 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: 0.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 4.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.894 y: 0.506 z: 0.333 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/pixel" id: "panel_selected" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_W - adjust_mode: ADJUST_MODE_FIT parent: "root" layer: "druid" 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_MANUAL - custom_type: 0 enabled: false - visible: true - material: "" } nodes { position { x: 18.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: 0.6 y: 0.6 - z: 1.0 - w: 1.0 - } - size { - x: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 } color { x: 0.851 y: 0.851 z: 0.851 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/icon_arrow" id: "icon" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "root" layer: "druid" 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 - custom_type: 0 enabled: false - visible: true - material: "" } nodes { position { x: 36.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: 0.7 y: 0.7 - z: 1.0 - w: 1.0 } size { x: 500.0 y: 60.0 - z: 0.0 - w: 1.0 } color { x: 0.463 y: 0.475 z: 0.49 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Basic" font: "text_bold" id: "text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_W outline { x: 0.941 y: 0.984 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "root" layer: "text_bold" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } layers { name: "druid" @@ -323,4 +131,3 @@ layers { } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/components/output_list/output_list.gui b/example/components/output_list/output_list.gui index 5063895..45b6a06 100644 --- a/example/components/output_list/output_list.gui +++ b/example/components/output_list/output_list.gui @@ -7,8 +7,8 @@ fonts { font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/components/output_list/output_list.lua b/example/components/output_list/output_list.lua index 3dabc2a..39d3323 100644 --- a/example/components/output_list/output_list.lua +++ b/example/components/output_list/output_list.lua @@ -22,7 +22,7 @@ function M:init(template, nodes) self.prefab = self:get_node("text") gui.set_enabled(self.prefab, false) - self.grid = self.druid:new_static_grid("scroll_content", "text", 1) + self.grid = self.druid:new_grid("scroll_content", "text", 1) self.scroll = self.druid:new_scroll("scroll_view", "scroll_content") self.scroll:bind_grid(self.grid) self.scroll:set_horizontal_scroll(false) diff --git a/example/components/panel_druid_profiler/panel_druid_profiler.gui b/example/components/panel_druid_profiler/panel_druid_profiler.gui index e157c46..2470901 100644 --- a/example/components/panel_druid_profiler/panel_druid_profiler.gui +++ b/example/components/panel_druid_profiler/panel_druid_profiler.gui @@ -1,981 +1,459 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 1080.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.129 y: 0.141 z: 0.157 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER adjust_mode: ADJUST_MODE_STRETCH - 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_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: -530.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: 16.0 y: 50.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: "" id: "group_memory" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_W - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { x: 89.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: 0.8 y: 0.8 - z: 1.0 - w: 1.0 } size { x: 200.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.306 y: 0.31 z: 0.314 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Memory" font: "text_bold" id: "text_memory" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "group_memory" layer: "text_bold" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: 199.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: 0.8 y: 0.8 - z: 1.0 - w: 1.0 } size { x: 200.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.463 y: 0.475 z: 0.49 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "2048" font: "text_bold" id: "text_memory_amount" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "group_memory" layer: "text_bold" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: 273.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: 0.8 y: 0.8 - z: 1.0 - w: 1.0 } size { x: 200.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.306 y: 0.31 z: 0.314 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "KB" font: "text_bold" id: "text_memory_kb" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "group_memory" layer: "text_bold" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: -130.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: 16.0 y: 50.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: "druid/empty" id: "group_fps" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { x: -50.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: 0.8 y: 0.8 - z: 1.0 - w: 1.0 } size { x: 120.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.306 y: 0.31 z: 0.314 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "FPS" font: "text_bold" id: "text_fps" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "group_fps" layer: "text_bold" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: 17.0 y: -20.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 } scale { x: 0.8 y: 0.8 - z: 1.0 - w: 1.0 } size { x: 200.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.463 y: 0.475 z: 0.49 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "60" font: "text_bold" id: "text_fps_amount" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_S outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "group_fps" layer: "text_bold" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: 65.0 y: -17.5 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 } scale { x: 0.6 y: 0.6 - z: 1.0 - w: 1.0 } size { x: 100.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "/60" font: "text_bold" id: "text_fps_min" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_S outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "group_fps" layer: "text_bold" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: 130.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: 16.0 y: 50.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: "druid/empty" id: "group_components" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { x: -50.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: 0.8 y: 0.8 - z: 1.0 - w: 1.0 } size { x: 350.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.306 y: 0.31 z: 0.314 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Components" font: "text_bold" id: "text_components" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "group_components" layer: "text_bold" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: 90.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: 0.8 y: 0.8 - z: 1.0 - w: 1.0 } size { x: 200.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.463 y: 0.475 z: 0.49 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "2004" font: "text_bold" id: "text_components_amount" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "group_components" layer: "text_bold" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: 530.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: 16.0 y: 50.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: "" id: "group_events" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_E - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { x: -163.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: 0.8 y: 0.8 - z: 1.0 - w: 1.0 } size { x: 200.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.306 y: 0.31 z: 0.314 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Events" font: "text_bold" id: "text_events" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "group_events" layer: "text_bold" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: -59.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: 0.8 y: 0.8 - z: 1.0 - w: 1.0 } size { x: 200.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.463 y: 0.475 z: 0.49 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "6000" font: "text_bold" id: "text_events_amount" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "group_events" layer: "text_bold" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } layers { name: "druid" @@ -985,4 +463,3 @@ layers { } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/components/panel_information/panel_information.gui b/example/components/panel_information/panel_information.gui index e9df7b8..6e9a8e1 100644 --- a/example/components/panel_information/panel_information.gui +++ b/example/components/panel_information/panel_information.gui @@ -7,8 +7,8 @@ fonts { font: "/example/assets/fonts/text_regular.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/components/properties_panel/properties/property_button.gui b/example/components/properties_panel/properties/property_button.gui index 20e4680..09831f0 100644 --- a/example/components/properties_panel/properties/property_button.gui +++ b/example/components/properties_panel/properties/property_button.gui @@ -1,184 +1,79 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 400.0 y: 40.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: "druid/empty" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { - x: 0.0 y: -20.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 } scale { x: 0.65 y: 0.65 - z: 1.0 - w: 1.0 } size { x: 200.0 y: 40.0 - z: 0.0 - w: 1.0 } color { x: 0.463 y: 0.475 z: 0.49 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Button" font: "text_bold" id: "text_name" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_W outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "root" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: 267.0 y: -20.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: 226.0 y: 40.0 - z: 0.0 - w: 1.0 } color { x: 0.463 y: 0.475 z: 0.49 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/rect_round2_width1" id: "button" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "root" - layer: "" inherit_alpha: true slice9 { x: 4.0 @@ -186,143 +81,60 @@ nodes { z: 4.0 w: 4.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -20.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: 226.0 y: 4.0 - z: 0.0 - w: 1.0 } color { x: 0.894 y: 0.506 z: 0.333 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/pixel" id: "selected" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_S adjust_mode: ADJUST_MODE_STRETCH parent: "button" - 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_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 0.65 y: 0.65 - z: 1.0 - w: 1.0 } size { x: 250.0 y: 30.0 - z: 0.0 - w: 1.0 } color { x: 0.722 y: 0.741 z: 0.761 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Button" font: "text_bold" id: "text_button" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "button" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/components/properties_panel/properties/property_checkbox.gui b/example/components/properties_panel/properties/property_checkbox.gui index 69de501..0a4f7ef 100644 --- a/example/components/properties_panel/properties/property_checkbox.gui +++ b/example/components/properties_panel/properties/property_checkbox.gui @@ -1,184 +1,79 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 400.0 y: 40.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: "druid/empty" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { - x: 0.0 y: -20.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 } scale { x: 0.65 y: 0.65 - z: 1.0 - w: 1.0 } size { x: 200.0 y: 40.0 - z: 0.0 - w: 1.0 } color { x: 0.463 y: 0.475 z: 0.49 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Checkbox" font: "text_bold" id: "text_name" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_W outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "root" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: 174.0 y: -20.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: 40.0 y: 40.0 - z: 0.0 - w: 1.0 } color { x: 0.463 y: 0.475 z: 0.49 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/rect_round2_width1" id: "button" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "root" - layer: "" inherit_alpha: true slice9 { x: 4.0 @@ -186,135 +81,40 @@ nodes { z: 4.0 w: 4.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } color { x: 0.722 y: 0.741 z: 0.761 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/icon_check" id: "icon" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button" - 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 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -20.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: 40.0 y: 4.0 - z: 0.0 - w: 1.0 } color { x: 0.894 y: 0.506 z: 0.333 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/pixel" id: "selected" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_S adjust_mode: ADJUST_MODE_STRETCH parent: "button" - 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_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/components/properties_panel/properties/property_slider.gui b/example/components/properties_panel/properties/property_slider.gui index 4c47d1b..ee3b114 100644 --- a/example/components/properties_panel/properties/property_slider.gui +++ b/example/components/properties_panel/properties/property_slider.gui @@ -3,8 +3,8 @@ fonts { font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/components/properties_panel/properties_panel.gui b/example/components/properties_panel/properties_panel.gui index 49cc600..b7833d5 100644 --- a/example/components/properties_panel/properties_panel.gui +++ b/example/components/properties_panel/properties_panel.gui @@ -1,1791 +1,330 @@ -script: "" fonts { name: "text_regular" font: "/example/assets/fonts/text_regular.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 440.0 y: 350.0 - z: 0.0 - w: 1.0 } color { x: 0.173 y: 0.184 z: 0.204 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/pixel" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER adjust_mode: ADJUST_MODE_STRETCH layer: "druid" 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_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: -210.0 y: 165.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 } scale { x: 0.9 y: 0.9 - z: 1.0 - w: 1.0 } size { x: 245.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.463 y: 0.475 z: 0.49 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Properties" font: "text_regular" id: "text_header" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_NW outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "root" layer: "text_regular" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: -200.0 y: 115.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: 400.0 y: 290.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: "druid/empty" id: "scroll_view" xanchor: XANCHOR_LEFT - yanchor: YANCHOR_NONE pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH parent: "root" layer: "druid" inherit_alpha: true - slice9 { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 - } clipping_mode: CLIPPING_MODE_STENCIL - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 400.0 y: 290.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: "druid/empty" id: "scroll_content" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH parent: "scroll_view" layer: "druid" 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { - x: 0.0 y: -35.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: 400.0 y: 50.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: "" id: "item_size" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_NW - adjust_mode: ADJUST_MODE_FIT parent: "scroll_content" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { - x: 0.0 y: 175.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: 440.0 y: 4.0 - z: 0.0 - w: 1.0 } color { x: 0.129 y: 0.141 z: 0.157 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/pixel" id: "separator" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_N - adjust_mode: ADJUST_MODE_FIT parent: "root" layer: "druid" 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_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: -200.0 y: 100.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: 200.0 - y: 100.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: "druid/empty" id: "propeties" - 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 - custom_type: 0 - enabled: true visible: false - material: "" } 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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } type: TYPE_TEMPLATE id: "property_slider" parent: "propeties" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/components/properties_panel/properties/property_slider.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 400.0 - y: 40.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: "druid/empty" id: "property_slider/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_NW - adjust_mode: ADJUST_MODE_STRETCH parent: "property_slider" - 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: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: false - material: "" } nodes { - position { - x: 0.0 - y: -20.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } - scale { - x: 0.65 - y: 0.65 - z: 1.0 - w: 1.0 - } - size { - x: 200.0 - y: 40.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.463 - y: 0.475 - z: 0.49 - w: 1.0 - } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "Checkbox" - font: "text_bold" id: "property_slider/text_name" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_W - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "property_slider/root" - layer: "" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { - position { - x: 400.0 - y: -20.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: 200.0 - y: 100.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: "druid/empty" id: "property_slider/E_Anchor" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_E - adjust_mode: ADJUST_MODE_STRETCH parent: "property_slider/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: true - size_mode: SIZE_MODE_AUTO - custom_type: 0 - enabled: true - visible: false - material: "" } nodes { - position { - x: -20.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: 60.0 - y: 40.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.463 - y: 0.475 - z: 0.49 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/rect_round2_width1" id: "property_slider/button" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_E - adjust_mode: ADJUST_MODE_FIT parent: "property_slider/E_Anchor" - layer: "" - inherit_alpha: true - slice9 { - x: 4.0 - y: 4.0 - z: 4.0 - w: 4.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { - position { - x: 0.0 - y: -20.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: 60.0 - y: 4.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.894 - y: 0.506 - z: 0.333 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/pixel" id: "property_slider/selected" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_SE - adjust_mode: ADJUST_MODE_STRETCH parent: "property_slider/button" - 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: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { - position { - x: -30.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: 0.55 - y: 0.55 - z: 1.0 - w: 1.0 - } - size { - x: 100.0 - y: 40.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.722 - y: 0.741 - z: 0.761 - w: 1.0 - } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "25 %" - font: "text_bold" id: "property_slider/text_value" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "property_slider/button" - layer: "" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { - position { - x: 234.0 - y: -20.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: 160.0 - y: 40.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.129 - y: 0.141 - z: 0.157 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/empty" id: "property_slider/slider" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "property_slider/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: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 160.0 - y: 8.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.129 - y: 0.141 - z: 0.157 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_8" id: "property_slider/slider_back" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "property_slider/slider" - layer: "" - inherit_alpha: true - slice9 { - x: 4.0 - y: 4.0 - z: 4.0 - w: 4.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { - position { - x: -68.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: 24.0 - y: 24.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.722 - y: 0.741 - z: 0.761 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_8" id: "property_slider/slider_pin" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "property_slider/slider" - layer: "" - inherit_alpha: true - slice9 { - x: 4.0 - y: 4.0 - z: 4.0 - w: 4.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -50.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "property_checkbox" parent: "propeties" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/components/properties_panel/properties/property_checkbox.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 400.0 - y: 40.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: "druid/empty" id: "property_checkbox/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_NW - adjust_mode: ADJUST_MODE_STRETCH parent: "property_checkbox" - 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: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: false - material: "" } nodes { - position { - x: 0.0 - y: -20.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } - scale { - x: 0.65 - y: 0.65 - z: 1.0 - w: 1.0 - } - size { - x: 200.0 - y: 40.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.463 - y: 0.475 - z: 0.49 - w: 1.0 - } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "Checkbox" - font: "text_bold" id: "property_checkbox/text_name" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_W - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "property_checkbox/root" - layer: "" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { - position { - x: 174.0 - y: -20.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: 40.0 - y: 40.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.463 - y: 0.475 - z: 0.49 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/rect_round2_width1" id: "property_checkbox/button" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "property_checkbox/root" - layer: "" - inherit_alpha: true - slice9 { - x: 4.0 - y: 4.0 - z: 4.0 - w: 4.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.722 - y: 0.741 - z: 0.761 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/icon_check" id: "property_checkbox/icon" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "property_checkbox/button" - 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: true - size_mode: SIZE_MODE_AUTO - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { - position { - x: 0.0 - y: -20.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: 40.0 - y: 4.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.894 - y: 0.506 - z: 0.333 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/pixel" id: "property_checkbox/selected" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_S - adjust_mode: ADJUST_MODE_STRETCH parent: "property_checkbox/button" - 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: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -100.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "property_button" parent: "propeties" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/components/properties_panel/properties/property_button.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 400.0 - y: 40.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: "druid/empty" id: "property_button/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_NW - adjust_mode: ADJUST_MODE_STRETCH parent: "property_button" - 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: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: false - material: "" } nodes { - position { - x: 0.0 - y: -20.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } - scale { - x: 0.65 - y: 0.65 - z: 1.0 - w: 1.0 - } - size { - x: 200.0 - y: 40.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.463 - y: 0.475 - z: 0.49 - w: 1.0 - } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "Button" - font: "text_bold" id: "property_button/text_name" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_W - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "property_button/root" - layer: "" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { - position { - x: 267.0 - y: -20.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: 226.0 - y: 40.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.463 - y: 0.475 - z: 0.49 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/rect_round2_width1" id: "property_button/button" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "property_button/root" - layer: "" - inherit_alpha: true - slice9 { - x: 4.0 - y: 4.0 - z: 4.0 - w: 4.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { - position { - x: 0.0 - y: -20.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: 226.0 - y: 4.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.894 - y: 0.506 - z: 0.333 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/pixel" id: "property_button/selected" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_S - adjust_mode: ADJUST_MODE_STRETCH parent: "property_button/button" - 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: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 0.65 - y: 0.65 - z: 1.0 - w: 1.0 - } - size { - x: 250.0 - y: 30.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.722 - y: 0.741 - z: 0.761 - w: 1.0 - } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "Button" - font: "text_bold" id: "property_button/text_button" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "property_button/button" - layer: "" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: -200.0 y: 115.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 } scale { x: 0.7 y: 0.7 - z: 1.0 - w: 1.0 } size { x: 570.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "No properties for this example" font: "text_regular" id: "text_no_properties" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_NW outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "root" layer: "text_regular" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } layers { name: "druid" @@ -1795,4 +334,3 @@ layers { } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/components/properties_panel/properties_panel.lua b/example/components/properties_panel/properties_panel.lua index 60a9f78..667aa93 100644 --- a/example/components/properties_panel/properties_panel.lua +++ b/example/components/properties_panel/properties_panel.lua @@ -31,7 +31,7 @@ function M:init(template, nodes) self.text_no_properties = self.druid:new(lang_text, "text_no_properties", "ui_no_properties") --[[@as druid.lang_text]] self.scroll = self.druid:new_scroll("scroll_view", "scroll_content") - self.grid = self.druid:new_static_grid("scroll_content", "item_size", 1) + self.grid = self.druid:new_grid("scroll_content", "item_size", 1) self.scroll:bind_grid(self.grid) self.property_checkbox_prefab = self:get_node("property_checkbox/root") diff --git a/example/druid.gui b/example/druid.gui index 4918bc8..804ad47 100644 --- a/example/druid.gui +++ b/example/druid.gui @@ -8,8 +8,8 @@ fonts { font: "/example/assets/fonts/text_regular.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } textures { name: "druid_logo" @@ -3919,6 +3919,109 @@ nodes { parent: "property_slider/slider" template_node_child: true } +nodes { + type: TYPE_TEMPLATE + id: "example_memory_panel" + parent: "widgets" + inherit_alpha: true + template: "/example/examples/widgets/memory_panel/example_memory_panel.gui" +} +nodes { + type: TYPE_TEMPLATE + id: "example_memory_panel/memory_panel" + parent: "example_memory_panel" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_memory_panel/memory_panel/root" + parent: "example_memory_panel/memory_panel" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "example_memory_panel/memory_panel/mini_graph" + parent: "example_memory_panel/memory_panel/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_memory_panel/memory_panel/mini_graph/root" + parent: "example_memory_panel/memory_panel/mini_graph" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_memory_panel/memory_panel/mini_graph/header" + parent: "example_memory_panel/memory_panel/mini_graph/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_memory_panel/memory_panel/mini_graph/text_header" + parent: "example_memory_panel/memory_panel/mini_graph/header" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_memory_panel/memory_panel/mini_graph/icon_drag" + parent: "example_memory_panel/memory_panel/mini_graph/header" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_memory_panel/memory_panel/mini_graph/content" + parent: "example_memory_panel/memory_panel/mini_graph/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_memory_panel/memory_panel/mini_graph/prefab_line" + parent: "example_memory_panel/memory_panel/mini_graph/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_memory_panel/memory_panel/mini_graph/color_low" + parent: "example_memory_panel/memory_panel/mini_graph/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_memory_panel/memory_panel/content" + parent: "example_memory_panel/memory_panel/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_memory_panel/memory_panel/text_max_value" + parent: "example_memory_panel/memory_panel/content" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_memory_panel/memory_panel/text_per_second" + parent: "example_memory_panel/memory_panel/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_memory_panel/memory_panel/line_second_1" + parent: "example_memory_panel/memory_panel/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_memory_panel/memory_panel/line_second_2" + parent: "example_memory_panel/memory_panel/content" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_memory_panel/memory_panel/text_memory" + parent: "example_memory_panel/memory_panel/content" + template_node_child: true +} nodes { position { x: -20.0 diff --git a/example/examples/basic/back_handler/basic_back_handler.gui b/example/examples/basic/back_handler/basic_back_handler.gui index 06c7705..c2a132b 100644 --- a/example/examples/basic/back_handler/basic_back_handler.gui +++ b/example/examples/basic/back_handler/basic_back_handler.gui @@ -3,8 +3,8 @@ fonts { font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/basic/blocker/basic_blocker.gui b/example/examples/basic/blocker/basic_blocker.gui index 96a1886..d51775b 100644 --- a/example/examples/basic/blocker/basic_blocker.gui +++ b/example/examples/basic/blocker/basic_blocker.gui @@ -3,8 +3,8 @@ fonts { font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/basic/button/basic_button_hold.gui b/example/examples/basic/button/basic_button_hold.gui index 23d6be9..698b082 100644 --- a/example/examples/basic/button/basic_button_hold.gui +++ b/example/examples/basic/button/basic_button_hold.gui @@ -3,8 +3,8 @@ fonts { font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/basic/checkbox/checkbox.gui b/example/examples/basic/checkbox/checkbox.gui index 287fcdb..3424105 100644 --- a/example/examples/basic/checkbox/checkbox.gui +++ b/example/examples/basic/checkbox/checkbox.gui @@ -3,8 +3,8 @@ fonts { font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/basic/checkbox_group/checkbox_group.gui b/example/examples/basic/checkbox_group/checkbox_group.gui index 275a269..2eeaef4 100644 --- a/example/examples/basic/checkbox_group/checkbox_group.gui +++ b/example/examples/basic/checkbox_group/checkbox_group.gui @@ -3,8 +3,8 @@ fonts { font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/basic/drag/drag.gui b/example/examples/basic/drag/drag.gui index 80572e3..563e9bd 100644 --- a/example/examples/basic/drag/drag.gui +++ b/example/examples/basic/drag/drag.gui @@ -1,241 +1,37 @@ -script: "" textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 1000.0 y: 1000.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: "" 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } type: TYPE_TEMPLATE id: "drag" parent: "root" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_blue.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.631 - y: 0.843 - z: 0.961 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "drag/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "drag" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 - } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Drag Me" - font: "text_bold" id: "drag/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "drag/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 overridden_fields: 8 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/basic/drag/drag_to_node.gui b/example/examples/basic/drag/drag_to_node.gui index ec8257a..156bff0 100644 --- a/example/examples/basic/drag/drag_to_node.gui +++ b/example/examples/basic/drag/drag_to_node.gui @@ -3,8 +3,8 @@ fonts { font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/basic/grid/grid.gui b/example/examples/basic/grid/grid.gui index c649b07..99b7011 100644 --- a/example/examples/basic/grid/grid.gui +++ b/example/examples/basic/grid/grid.gui @@ -1,117 +1,40 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 1000.0 y: 1000.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: "druid/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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { - x: 0.0 y: 300.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: 600.0 y: 600.0 - z: 0.0 - w: 1.0 } color { x: 0.173 y: 0.184 z: 0.204 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "grid" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_N - adjust_mode: ADJUST_MODE_FIT parent: "root" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -119,117 +42,32 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 100.0 y: 100.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: "" id: "prefab" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "grid" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 90.0 y: 90.0 - z: 0.0 - w: 1.0 } color { x: 0.631 y: 0.843 z: 0.961 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "panel" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "prefab" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -237,84 +75,39 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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.5 y: 1.5 - z: 1.0 - w: 1.0 } size { x: 50.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "1" font: "text_bold" id: "text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "prefab" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/basic/grid/grid.lua b/example/examples/basic/grid/grid.lua index b9928b5..db0bd16 100644 --- a/example/examples/basic/grid/grid.lua +++ b/example/examples/basic/grid/grid.lua @@ -1,7 +1,7 @@ local component = require("druid.component") ---@class grid: druid.base_component ----@field grid druid.static_grid +---@field grid druid.grid ---@field text druid.text ---@field druid druid_instance local M = component.create("grid") @@ -17,7 +17,7 @@ function M:init(template, nodes) self.prefab = self:get_node("prefab") gui.set_enabled(self.prefab, false) - self.grid = self.druid:new_static_grid("grid", "prefab", 3) + self.grid = self.druid:new_grid("grid", "prefab", 3) for index = 1, 9 do self:add_element() diff --git a/example/examples/basic/hover/hover.gui b/example/examples/basic/hover/hover.gui index 45adecd..1d6b74e 100644 --- a/example/examples/basic/hover/hover.gui +++ b/example/examples/basic/hover/hover.gui @@ -1,410 +1,64 @@ -script: "" textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 1000.0 y: 1000.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: "" 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { - x: 0.0 y: 100.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "button_mouse_hover" parent: "root" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_green.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.557 - y: 0.835 - z: 0.62 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button_mouse_hover/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button_mouse_hover" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 - } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Mouse Hover" - font: "text_bold" id: "button_mouse_hover/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "button_mouse_hover/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 overridden_fields: 8 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -100.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "button_mobile_hover" parent: "root" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_green.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.557 - y: 0.835 - z: 0.62 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button_mobile_hover/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button_mobile_hover" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 - } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Mobile Hover" - font: "text_bold" id: "button_mobile_hover/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "button_mobile_hover/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 overridden_fields: 8 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/basic/input/rich_input.gui b/example/examples/basic/input/rich_input.gui index 108dc41..1e09607 100644 --- a/example/examples/basic/input/rich_input.gui +++ b/example/examples/basic/input/rich_input.gui @@ -1,918 +1,119 @@ -script: "" textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 1000.0 y: 1000.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: "" 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } type: TYPE_TEMPLATE id: "rich_input" parent: "root" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/rich_input.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 500.0 - y: 80.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: "" id: "rich_input/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "rich_input" - 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: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: false - material: "" } 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: 500.0 - y: 80.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: "druid/rect_round2_width1" id: "rich_input/button" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "rich_input/root" - layer: "" - inherit_alpha: true - slice9 { - x: 4.0 - y: 4.0 - z: 4.0 - w: 4.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: -240.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: 480.0 - y: 60.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "Placeholder" - font: "text_bold" id: "rich_input/placeholder_text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_W - outline { - x: 0.4 - y: 0.4 - z: 0.4 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "rich_input/button" - layer: "" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 overridden_fields: 1 overridden_fields: 14 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: -240.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: 480.0 - y: 60.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.722 - y: 0.741 - z: 0.761 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "User input" - font: "text_bold" id: "rich_input/input_text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_W - outline { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "rich_input/button" - layer: "" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 overridden_fields: 1 overridden_fields: 14 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 16.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.631 - y: 0.843 - z: 0.961 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_16" id: "rich_input/cursor_node" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "rich_input/button" - layer: "" - inherit_alpha: true - slice9 { - x: 8.0 - y: 8.0 - z: 8.0 - w: 8.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 0.5 overridden_fields: 1 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { - position { - x: 0.0 - y: 4.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } - scale { - x: 1.2 - y: 1.2 - z: 1.0 - w: 1.0 - } - size { - x: 20.0 - y: 40.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.722 - y: 0.741 - z: 0.761 - w: 1.0 - } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "|" - font: "text_bold" id: "rich_input/cursor_text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "rich_input/cursor_node" - layer: "" - inherit_alpha: false - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -150.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "rich_input_2" parent: "root" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/rich_input.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 500.0 - y: 80.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: "" id: "rich_input_2/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "rich_input_2" - 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: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: false - material: "" } 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: 500.0 - y: 80.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: "druid/rect_round2_width1" id: "rich_input_2/button" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "rich_input_2/root" - layer: "" - inherit_alpha: true - slice9 { - x: 4.0 - y: 4.0 - z: 4.0 - w: 4.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 480.0 - y: 60.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 - } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "Placeholder" - font: "text_bold" id: "rich_input_2/placeholder_text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 0.4 - y: 0.4 - z: 0.4 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "rich_input_2/button" - layer: "" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 480.0 - y: 60.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.722 - y: 0.741 - z: 0.761 - w: 1.0 - } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "User input" - font: "text_bold" id: "rich_input_2/input_text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "rich_input_2/button" - layer: "" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 16.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.631 - y: 0.843 - z: 0.961 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_16" id: "rich_input_2/cursor_node" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "rich_input_2/button" - layer: "" - inherit_alpha: true - slice9 { - x: 8.0 - y: 8.0 - z: 8.0 - w: 8.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 0.5 overridden_fields: 1 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { - position { - x: 0.0 - y: 4.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } - scale { - x: 1.2 - y: 1.2 - z: 1.0 - w: 1.0 - } - size { - x: 20.0 - y: 40.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.722 - y: 0.741 - z: 0.761 - w: 1.0 - } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "|" - font: "text_bold" id: "rich_input_2/cursor_text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "rich_input_2/cursor_node" - layer: "" - inherit_alpha: false - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/basic/progress_bar/basic_progress_bar.gui b/example/examples/basic/progress_bar/basic_progress_bar.gui index 975d78c..c119df4 100644 --- a/example/examples/basic/progress_bar/basic_progress_bar.gui +++ b/example/examples/basic/progress_bar/basic_progress_bar.gui @@ -3,8 +3,8 @@ fonts { font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/basic/progress_bar/basic_progress_bar_slice9.gui b/example/examples/basic/progress_bar/basic_progress_bar_slice9.gui index cfeff26..271abd2 100644 --- a/example/examples/basic/progress_bar/basic_progress_bar_slice9.gui +++ b/example/examples/basic/progress_bar/basic_progress_bar_slice9.gui @@ -3,8 +3,8 @@ fonts { font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/basic/radio_group/radio_group.gui b/example/examples/basic/radio_group/radio_group.gui index f4b822a..7b7f98c 100644 --- a/example/examples/basic/radio_group/radio_group.gui +++ b/example/examples/basic/radio_group/radio_group.gui @@ -3,8 +3,8 @@ fonts { font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/basic/rich_text/basic_rich_text.gui b/example/examples/basic/rich_text/basic_rich_text.gui index 659924a..f51575b 100644 --- a/example/examples/basic/rich_text/basic_rich_text.gui +++ b/example/examples/basic/rich_text/basic_rich_text.gui @@ -7,8 +7,8 @@ fonts { font: "/example/assets/fonts/text_regular.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/basic/rich_text/rich_text_tags.gui b/example/examples/basic/rich_text/rich_text_tags.gui index de6d63e..f81b596 100644 --- a/example/examples/basic/rich_text/rich_text_tags.gui +++ b/example/examples/basic/rich_text/rich_text_tags.gui @@ -7,8 +7,8 @@ fonts { font: "/example/assets/fonts/text_regular.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } textures { name: "druid_logo" diff --git a/example/examples/basic/rich_text/rich_text_tags_custom.gui b/example/examples/basic/rich_text/rich_text_tags_custom.gui index 3c17183..28981a8 100644 --- a/example/examples/basic/rich_text/rich_text_tags_custom.gui +++ b/example/examples/basic/rich_text/rich_text_tags_custom.gui @@ -7,8 +7,8 @@ fonts { font: "/example/assets/fonts/text_regular.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/basic/scroll/scroll.gui b/example/examples/basic/scroll/scroll.gui index 8931adf..335b0e5 100644 --- a/example/examples/basic/scroll/scroll.gui +++ b/example/examples/basic/scroll/scroll.gui @@ -3,8 +3,8 @@ fonts { font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/basic/scroll_bind_grid/scroll_bind_grid.gui b/example/examples/basic/scroll_bind_grid/scroll_bind_grid.gui index f713ea6..a0eb02f 100644 --- a/example/examples/basic/scroll_bind_grid/scroll_bind_grid.gui +++ b/example/examples/basic/scroll_bind_grid/scroll_bind_grid.gui @@ -1,117 +1,40 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 1000.0 y: 1000.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: "druid/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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { - x: 0.0 y: 400.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: 400.0 y: 800.0 - z: 0.0 - w: 1.0 } color { x: 0.173 y: 0.184 z: 0.204 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "view" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_N - adjust_mode: ADJUST_MODE_FIT parent: "root" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -120,175 +43,48 @@ nodes { w: 16.0 } clipping_mode: CLIPPING_MODE_STENCIL - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 400.0 y: 800.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: "druid/empty" id: "content" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_N - adjust_mode: ADJUST_MODE_FIT parent: "view" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { - x: 0.0 y: -400.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: 300.0 y: 100.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: "" id: "prefab" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "content" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 300.0 y: 90.0 - z: 0.0 - w: 1.0 } color { x: 0.631 y: 0.843 z: 0.961 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "panel" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "prefab" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -296,84 +92,35 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 240.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Grid Item 1" font: "text_bold" id: "text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "prefab" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/basic/scroll_bind_grid/scroll_bind_grid.lua b/example/examples/basic/scroll_bind_grid/scroll_bind_grid.lua index ba62a6e..f026f74 100644 --- a/example/examples/basic/scroll_bind_grid/scroll_bind_grid.lua +++ b/example/examples/basic/scroll_bind_grid/scroll_bind_grid.lua @@ -2,7 +2,7 @@ local component = require("druid.component") ---@class scroll_bind_grid: druid.base_component ---@field scroll druid.scroll ----@field grid druid.static_grid +---@field grid druid.grid ---@field text druid.text ---@field druid druid_instance local M = component.create("scroll_bind_grid") @@ -19,7 +19,7 @@ function M:init(template, nodes) gui.set_enabled(self.prefab, false) self.scroll = self.druid:new_scroll("view", "content") - self.grid = self.druid:new_static_grid("content", "prefab", 1) + self.grid = self.druid:new_grid("content", "prefab", 1) self.scroll:bind_grid(self.grid) for index = 1, 20 do diff --git a/example/examples/basic/scroll_bind_grid/scroll_bind_grid_horizontal.gui b/example/examples/basic/scroll_bind_grid/scroll_bind_grid_horizontal.gui index 7165b82..f16a69e 100644 --- a/example/examples/basic/scroll_bind_grid/scroll_bind_grid_horizontal.gui +++ b/example/examples/basic/scroll_bind_grid/scroll_bind_grid_horizontal.gui @@ -1,117 +1,40 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 1000.0 y: 1000.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: "druid/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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { x: -450.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: 900.0 y: 360.0 - z: 0.0 - w: 1.0 } color { x: 0.173 y: 0.184 z: 0.204 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "view" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_W - adjust_mode: ADJUST_MODE_FIT parent: "root" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -120,175 +43,48 @@ nodes { w: 16.0 } clipping_mode: CLIPPING_MODE_STENCIL - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 900.0 y: 360.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: "druid/empty" id: "content" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_W - adjust_mode: ADJUST_MODE_FIT parent: "view" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { x: 450.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: 200.0 y: 270.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: "" id: "prefab" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "content" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 190.0 y: 250.0 - z: 0.0 - w: 1.0 } color { x: 0.631 y: 0.843 z: 0.961 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "panel" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "prefab" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -296,84 +92,36 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 150.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Grid Item 1" font: "text_bold" id: "text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT line_break: true parent: "prefab" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/basic/scroll_bind_grid/scroll_bind_grid_horizontal.lua b/example/examples/basic/scroll_bind_grid/scroll_bind_grid_horizontal.lua index ce762f5..7e26681 100644 --- a/example/examples/basic/scroll_bind_grid/scroll_bind_grid_horizontal.lua +++ b/example/examples/basic/scroll_bind_grid/scroll_bind_grid_horizontal.lua @@ -2,7 +2,7 @@ local component = require("druid.component") ---@class scroll_bind_grid_horizontal: druid.base_component ---@field scroll druid.scroll ----@field grid druid.static_grid +---@field grid druid.grid ---@field text druid.text ---@field druid druid_instance local M = component.create("scroll_bind_grid_horizontal") @@ -19,7 +19,7 @@ function M:init(template, nodes) gui.set_enabled(self.prefab, false) self.scroll = self.druid:new_scroll("view", "content") - self.grid = self.druid:new_static_grid("content", "prefab", 99999) + self.grid = self.druid:new_grid("content", "prefab", 99999) self.scroll:bind_grid(self.grid) for index = 1, 30 do diff --git a/example/examples/basic/scroll_bind_grid/scroll_bind_grid_points.gui b/example/examples/basic/scroll_bind_grid/scroll_bind_grid_points.gui index 165fbf2..603dbfd 100644 --- a/example/examples/basic/scroll_bind_grid/scroll_bind_grid_points.gui +++ b/example/examples/basic/scroll_bind_grid/scroll_bind_grid_points.gui @@ -3,8 +3,8 @@ fonts { font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/basic/scroll_bind_grid/scroll_bind_grid_points.lua b/example/examples/basic/scroll_bind_grid/scroll_bind_grid_points.lua index d1d6ccc..91f185a 100644 --- a/example/examples/basic/scroll_bind_grid/scroll_bind_grid_points.lua +++ b/example/examples/basic/scroll_bind_grid/scroll_bind_grid_points.lua @@ -2,7 +2,7 @@ local component = require("druid.component") ---@class scroll_bind_grid_points: druid.base_component ---@field scroll druid.scroll ----@field grid druid.static_grid +---@field grid druid.grid ---@field text druid.text ---@field druid druid_instance local M = component.create("scroll_bind_grid_points") @@ -19,7 +19,7 @@ function M:init(template, nodes) gui.set_enabled(self.prefab, false) self.scroll = self.druid:new_scroll("view", "content") - self.grid = self.druid:new_static_grid("content", "prefab", 1) + self.grid = self.druid:new_grid("content", "prefab", 1) self.scroll:bind_grid(self.grid) for index = 1, 20 do diff --git a/example/examples/basic/scroll_slider/scroll_slider.gui b/example/examples/basic/scroll_slider/scroll_slider.gui index caf0a41..c056010 100644 --- a/example/examples/basic/scroll_slider/scroll_slider.gui +++ b/example/examples/basic/scroll_slider/scroll_slider.gui @@ -1,117 +1,35 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 200.0 y: 100.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: "" 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 400.0 y: 1000.0 - z: 0.0 - w: 1.0 } color { x: 0.173 y: 0.184 z: 0.204 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "scroll_view" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "root" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -120,57 +38,25 @@ nodes { w: 16.0 } clipping_mode: CLIPPING_MODE_STENCIL - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: 500.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: 400.0 y: 2600.0 - z: 0.0 - w: 1.0 } color { x: 0.173 y: 0.184 z: 0.204 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/empty" id: "scroll_content" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_N - adjust_mode: ADJUST_MODE_FIT parent: "scroll_view" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -178,2340 +64,450 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { - x: 0.0 y: -100.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "button1" parent: "scroll_content" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_green.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.557 - y: 0.835 - z: 0.62 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button1/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button1" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 0.9 y: 0.9 - z: 1.0 - w: 1.0 - } - size { - x: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Tap to scroll 1" - font: "text_bold" id: "button1/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT line_break: true parent: "button1/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 overridden_fields: 3 overridden_fields: 8 overridden_fields: 18 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -300.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "button2" parent: "scroll_content" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_green.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.557 - y: 0.835 - z: 0.62 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button2/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button2" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 0.9 y: 0.9 - z: 1.0 - w: 1.0 - } - size { - x: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Tap to scroll 2" - font: "text_bold" id: "button2/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT line_break: true parent: "button2/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 overridden_fields: 3 overridden_fields: 8 overridden_fields: 18 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -500.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "button3" parent: "scroll_content" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_green.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.557 - y: 0.835 - z: 0.62 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button3/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button3" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 0.9 y: 0.9 - z: 1.0 - w: 1.0 - } - size { - x: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Tap to scroll 3" - font: "text_bold" id: "button3/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT line_break: true parent: "button3/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 overridden_fields: 3 overridden_fields: 8 overridden_fields: 18 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -700.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "button4" parent: "scroll_content" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_green.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.557 - y: 0.835 - z: 0.62 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button4/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button4" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 0.9 y: 0.9 - z: 1.0 - w: 1.0 - } - size { - x: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Tap to scroll 4" - font: "text_bold" id: "button4/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT line_break: true parent: "button4/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 overridden_fields: 3 overridden_fields: 8 overridden_fields: 18 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -900.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "button5" parent: "scroll_content" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_green.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.557 - y: 0.835 - z: 0.62 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button5/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button5" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 0.9 y: 0.9 - z: 1.0 - w: 1.0 - } - size { - x: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Tap to scroll 5" - font: "text_bold" id: "button5/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT line_break: true parent: "button5/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 overridden_fields: 3 overridden_fields: 8 overridden_fields: 18 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -1100.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "button6" parent: "scroll_content" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_green.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.557 - y: 0.835 - z: 0.62 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button6/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button6" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 0.9 y: 0.9 - z: 1.0 - w: 1.0 - } - size { - x: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Tap to scroll 6" - font: "text_bold" id: "button6/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT line_break: true parent: "button6/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 overridden_fields: 3 overridden_fields: 8 overridden_fields: 18 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -1300.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "button7" parent: "scroll_content" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_green.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.557 - y: 0.835 - z: 0.62 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button7/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button7" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 0.9 y: 0.9 - z: 1.0 - w: 1.0 - } - size { - x: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Tap to scroll 7" - font: "text_bold" id: "button7/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT line_break: true parent: "button7/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 overridden_fields: 3 overridden_fields: 8 overridden_fields: 18 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -1500.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "button8" parent: "scroll_content" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_green.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.557 - y: 0.835 - z: 0.62 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button8/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button8" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 0.9 y: 0.9 - z: 1.0 - w: 1.0 - } - size { - x: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Tap to scroll 8" - font: "text_bold" id: "button8/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT line_break: true parent: "button8/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 overridden_fields: 3 overridden_fields: 8 overridden_fields: 18 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -1700.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "button9" parent: "scroll_content" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_green.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.557 - y: 0.835 - z: 0.62 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button9/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button9" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 0.9 y: 0.9 - z: 1.0 - w: 1.0 - } - size { - x: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Tap to scroll 9" - font: "text_bold" id: "button9/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT line_break: true parent: "button9/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 overridden_fields: 3 overridden_fields: 8 overridden_fields: 18 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -1900.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "button10" parent: "scroll_content" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_green.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.557 - y: 0.835 - z: 0.62 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button10/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button10" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 0.9 y: 0.9 - z: 1.0 - w: 1.0 - } - size { - x: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Tap to scroll 10" - font: "text_bold" id: "button10/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT line_break: true parent: "button10/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 overridden_fields: 3 overridden_fields: 8 overridden_fields: 18 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -2100.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "button11" parent: "scroll_content" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_green.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.557 - y: 0.835 - z: 0.62 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button11/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button11" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 0.9 y: 0.9 - z: 1.0 - w: 1.0 - } - size { - x: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Tap to scroll 11" - font: "text_bold" id: "button11/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT line_break: true parent: "button11/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 overridden_fields: 3 overridden_fields: 8 overridden_fields: 18 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -2300.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "button12" parent: "scroll_content" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_green.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.557 - y: 0.835 - z: 0.62 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button12/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button12" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 0.9 y: 0.9 - z: 1.0 - w: 1.0 - } - size { - x: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Tap to scroll 12" - font: "text_bold" id: "button12/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT line_break: true parent: "button12/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 overridden_fields: 3 overridden_fields: 8 overridden_fields: 18 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -2500.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "button13" parent: "scroll_content" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_green.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.557 - y: 0.835 - z: 0.62 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button13/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button13" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 0.9 y: 0.9 - z: 1.0 - w: 1.0 - } - size { - x: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Tap to scroll 13" - font: "text_bold" id: "button13/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT line_break: true parent: "button13/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 overridden_fields: 3 overridden_fields: 8 overridden_fields: 18 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: 200.0 y: 500.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: 16.0 y: 1000.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/pixel" id: "slider_back" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_NE - adjust_mode: ADJUST_MODE_FIT parent: "scroll_view" - 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_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: -8.0 y: -24.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: 16.0 y: 48.0 - z: 0.0 - w: 1.0 } color { x: 0.463 y: 0.475 z: 0.49 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_16" id: "slider_pin" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "slider_back" - layer: "" inherit_alpha: true slice9 { x: 8.0 @@ -2519,17 +515,6 @@ nodes { z: 8.0 w: 8.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/basic/slider/basic_slider.gui b/example/examples/basic/slider/basic_slider.gui index a8f132a..7b39ff8 100644 --- a/example/examples/basic/slider/basic_slider.gui +++ b/example/examples/basic/slider/basic_slider.gui @@ -1,58 +1,24 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 1000.0 y: 1000.0 - z: 0.0 - w: 1.0 } color { x: 0.173 y: 0.184 z: 0.204 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_64" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT - layer: "" inherit_alpha: true slice9 { x: 32.0 @@ -60,303 +26,63 @@ nodes { z: 32.0 w: 32.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } type: TYPE_TEMPLATE id: "slider" parent: "root" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/slider.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 260.0 - y: 40.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.129 - y: 0.141 - z: 0.157 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/empty" id: "slider/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "slider" - 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: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 260.0 - y: 8.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.129 - y: 0.141 - z: 0.157 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_8" id: "slider/slider_back" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "slider/root" - layer: "" - inherit_alpha: true - slice9 { - x: 4.0 - y: 4.0 - z: 4.0 - w: 4.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { - position { - x: -118.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: 24.0 - y: 24.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.722 - y: 0.741 - z: 0.761 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_8" id: "slider/slider_pin" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "slider/root" - layer: "" - inherit_alpha: true - slice9 { - x: 4.0 - y: 4.0 - z: 4.0 - w: 4.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: 50.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: 150.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.722 y: 0.741 z: 0.761 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "0 %" font: "text_bold" id: "slider_value" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "root" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/basic/slider/basic_slider_stepped.gui b/example/examples/basic/slider/basic_slider_stepped.gui index a8f132a..7b39ff8 100644 --- a/example/examples/basic/slider/basic_slider_stepped.gui +++ b/example/examples/basic/slider/basic_slider_stepped.gui @@ -1,58 +1,24 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 1000.0 y: 1000.0 - z: 0.0 - w: 1.0 } color { x: 0.173 y: 0.184 z: 0.204 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_64" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT - layer: "" inherit_alpha: true slice9 { x: 32.0 @@ -60,303 +26,63 @@ nodes { z: 32.0 w: 32.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } type: TYPE_TEMPLATE id: "slider" parent: "root" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/slider.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 260.0 - y: 40.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.129 - y: 0.141 - z: 0.157 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/empty" id: "slider/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "slider" - 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: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 260.0 - y: 8.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.129 - y: 0.141 - z: 0.157 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_8" id: "slider/slider_back" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "slider/root" - layer: "" - inherit_alpha: true - slice9 { - x: 4.0 - y: 4.0 - z: 4.0 - w: 4.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { - position { - x: -118.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: 24.0 - y: 24.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.722 - y: 0.741 - z: 0.761 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_8" id: "slider/slider_pin" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "slider/root" - layer: "" - inherit_alpha: true - slice9 { - x: 4.0 - y: 4.0 - z: 4.0 - w: 4.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: 50.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: 150.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.722 y: 0.741 z: 0.761 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "0 %" font: "text_bold" id: "slider_value" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "root" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/basic/slider/basic_slider_vertical.gui b/example/examples/basic/slider/basic_slider_vertical.gui index f039094..bcddcd4 100644 --- a/example/examples/basic/slider/basic_slider_vertical.gui +++ b/example/examples/basic/slider/basic_slider_vertical.gui @@ -3,8 +3,8 @@ fonts { font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/basic/swipe/basic_swipe.gui b/example/examples/basic/swipe/basic_swipe.gui index 8faba60..aa45a77 100644 --- a/example/examples/basic/swipe/basic_swipe.gui +++ b/example/examples/basic/swipe/basic_swipe.gui @@ -1,58 +1,24 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 1000.0 y: 1000.0 - z: 0.0 - w: 1.0 } color { x: 0.173 y: 0.184 z: 0.204 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_64" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT - layer: "" inherit_alpha: true slice9 { x: 32.0 @@ -60,84 +26,35 @@ nodes { z: 32.0 w: 32.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 600.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.722 y: 0.741 z: 0.761 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Swipe across area to action" font: "text_bold" id: "swipe_hint" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "root" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/basic/text/basic_text.gui b/example/examples/basic/text/basic_text.gui index 185debb..24b413a 100644 --- a/example/examples/basic/text/basic_text.gui +++ b/example/examples/basic/text/basic_text.gui @@ -1,117 +1,36 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 200.0 y: 100.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: "" 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 - custom_type: 0 - enabled: true visible: false - material: "" } 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: 600.0 y: 100.0 - z: 0.0 - w: 1.0 } color { x: 0.463 y: 0.475 z: 0.49 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "text_area" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "root" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -119,84 +38,34 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 600.0 y: 100.0 - z: 0.0 - w: 1.0 } color { x: 0.941 y: 0.984 - z: 1.0 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Example text with default adjust" font: "text_bold" id: "text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "text_area" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/basic/text/multiline_text.gui b/example/examples/basic/text/multiline_text.gui index 3a66171..5025ac8 100644 --- a/example/examples/basic/text/multiline_text.gui +++ b/example/examples/basic/text/multiline_text.gui @@ -1,117 +1,36 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 200.0 y: 100.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: "" 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 - custom_type: 0 - enabled: true visible: false - material: "" } 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: 600.0 y: 100.0 - z: 0.0 - w: 1.0 } color { x: 0.463 y: 0.475 z: 0.49 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "text_area" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "root" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -119,84 +38,35 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 600.0 y: 100.0 - z: 0.0 - w: 1.0 } color { x: 0.941 y: 0.984 - z: 1.0 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Example multiline text with default adjust" font: "text_bold" id: "text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT line_break: true parent: "text_area" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/data_list/add_remove_clear/data_list_add_remove_clear.gui b/example/examples/data_list/add_remove_clear/data_list_add_remove_clear.gui index c45c867..01a8037 100644 --- a/example/examples/data_list/add_remove_clear/data_list_add_remove_clear.gui +++ b/example/examples/data_list/add_remove_clear/data_list_add_remove_clear.gui @@ -1,294 +1,81 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 200.0 - y: 100.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: "druid/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 - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { - x: 0.0 y: 350.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: 350.0 y: 700.0 - z: 0.0 - w: 1.0 } color { x: 0.173 y: 0.184 z: 0.204 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/pixel" id: "view" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_N - 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_STENCIL - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 350.0 y: 700.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: "druid/empty" id: "content" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_N - adjust_mode: ADJUST_MODE_FIT parent: "view" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { - x: 0.0 y: -400.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: 300.0 y: 100.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: "" id: "prefab" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "content" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 300.0 y: 90.0 - z: 0.0 - w: 1.0 } color { x: 0.631 y: 0.843 z: 0.961 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "panel" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "prefab" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -296,84 +83,35 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 250.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Data Item 1" font: "text_bold" id: "text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "prefab" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/data_list/add_remove_clear/data_list_add_remove_clear.lua b/example/examples/data_list/add_remove_clear/data_list_add_remove_clear.lua index bdc6eca..fb3d95e 100644 --- a/example/examples/data_list/add_remove_clear/data_list_add_remove_clear.lua +++ b/example/examples/data_list/add_remove_clear/data_list_add_remove_clear.lua @@ -17,7 +17,7 @@ function M:init(template, nodes) gui.set_enabled(self.prefab, false) self.scroll = self.druid:new_scroll("view", "content") - self.grid = self.druid:new_static_grid("content", self.prefab, 1) + self.grid = self.druid:new_grid("content", self.prefab, 1) self.data_list = self.druid:new(data_list, self.scroll, self.grid, self.create_item_callback) --[[@as druid.data_list]] local data = {} diff --git a/example/examples/data_list/basic/data_list_basic.gui b/example/examples/data_list/basic/data_list_basic.gui index c45c867..01a8037 100644 --- a/example/examples/data_list/basic/data_list_basic.gui +++ b/example/examples/data_list/basic/data_list_basic.gui @@ -1,294 +1,81 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 200.0 - y: 100.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: "druid/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 - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { - x: 0.0 y: 350.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: 350.0 y: 700.0 - z: 0.0 - w: 1.0 } color { x: 0.173 y: 0.184 z: 0.204 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/pixel" id: "view" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_N - 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_STENCIL - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 350.0 y: 700.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: "druid/empty" id: "content" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_N - adjust_mode: ADJUST_MODE_FIT parent: "view" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { - x: 0.0 y: -400.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: 300.0 y: 100.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: "" id: "prefab" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "content" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 300.0 y: 90.0 - z: 0.0 - w: 1.0 } color { x: 0.631 y: 0.843 z: 0.961 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "panel" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "prefab" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -296,84 +83,35 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 250.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Data Item 1" font: "text_bold" id: "text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "prefab" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/data_list/basic/data_list_basic.lua b/example/examples/data_list/basic/data_list_basic.lua index b3a3d81..b520c1b 100644 --- a/example/examples/data_list/basic/data_list_basic.lua +++ b/example/examples/data_list/basic/data_list_basic.lua @@ -16,7 +16,7 @@ function M:init(template, nodes) gui.set_enabled(self.prefab, false) self.scroll = self.druid:new_scroll("view", "content") - self.grid = self.druid:new_static_grid("content", self.prefab, 1) + self.grid = self.druid:new_grid("content", self.prefab, 1) self.data_list = self.druid:new(data_list, self.scroll, self.grid, self.create_item_callback) --[[@as druid.data_list]] local data = {} diff --git a/example/examples/data_list/basic/data_list_horizontal_basic.gui b/example/examples/data_list/basic/data_list_horizontal_basic.gui index 31f4823..7113e09 100644 --- a/example/examples/data_list/basic/data_list_horizontal_basic.gui +++ b/example/examples/data_list/basic/data_list_horizontal_basic.gui @@ -1,294 +1,81 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 200.0 - y: 100.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: "druid/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 - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { x: -450.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: 900.0 y: 350.0 - z: 0.0 - w: 1.0 } color { x: 0.173 y: 0.184 z: 0.204 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/pixel" id: "view" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_W - 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_STENCIL - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 900.0 y: 350.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: "druid/empty" id: "content" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_W - adjust_mode: ADJUST_MODE_FIT parent: "view" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { x: 450.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: 200.0 y: 270.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: "" id: "prefab" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "content" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 190.0 y: 250.0 - z: 0.0 - w: 1.0 } color { x: 0.631 y: 0.843 z: 0.961 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "panel" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "prefab" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -296,84 +83,36 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 150.0 y: 200.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Data Item 1" font: "text_bold" id: "text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT line_break: true parent: "prefab" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/data_list/basic/data_list_horizontal_basic.lua b/example/examples/data_list/basic/data_list_horizontal_basic.lua index 0f21fc7..2bc5aff 100644 --- a/example/examples/data_list/basic/data_list_horizontal_basic.lua +++ b/example/examples/data_list/basic/data_list_horizontal_basic.lua @@ -15,7 +15,7 @@ function M:init(template, nodes) gui.set_enabled(self.prefab, false) self.scroll = self.druid:new_scroll("view", "content") - self.grid = self.druid:new_static_grid("content", self.prefab, 1000) + self.grid = self.druid:new_grid("content", self.prefab, 1000) self.data_list = self.druid:new(data_list, self.scroll, self.grid, self.create_item_callback) --[[@as druid.data_list]] local data = {} diff --git a/example/examples/data_list/cache_with_component/button_component.gui b/example/examples/data_list/cache_with_component/button_component.gui index f3c8623..108be79 100644 --- a/example/examples/data_list/cache_with_component/button_component.gui +++ b/example/examples/data_list/cache_with_component/button_component.gui @@ -1,117 +1,35 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 300.0 y: 100.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: "" 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 300.0 y: 90.0 - z: 0.0 - w: 1.0 } color { x: 0.631 y: 0.843 z: 0.961 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "panel" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "root" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -119,84 +37,35 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 250.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Data Item 1" font: "text_bold" id: "text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "root" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/data_list/cache_with_component/cache_with_component.gui b/example/examples/data_list/cache_with_component/cache_with_component.gui index f39b933..e5fed03 100644 --- a/example/examples/data_list/cache_with_component/cache_with_component.gui +++ b/example/examples/data_list/cache_with_component/cache_with_component.gui @@ -1,421 +1,80 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 200.0 - y: 100.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: "druid/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 - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { - x: 0.0 y: 350.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: 350.0 y: 700.0 - z: 0.0 - w: 1.0 } color { x: 0.173 y: 0.184 z: 0.204 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/pixel" id: "view" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_N - 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_STENCIL - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 350.0 y: 700.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: "druid/empty" id: "content" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_N - adjust_mode: ADJUST_MODE_FIT parent: "view" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { - x: 0.0 y: -300.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "button_component" parent: "content" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/examples/data_list/cache_with_component/button_component.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 300.0 - y: 100.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: "" id: "button_component/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button_component" - 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: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: false - material: "" } 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: 300.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.631 - y: 0.843 - z: 0.961 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button_component/panel" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button_component/root" - layer: "" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 250.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 - } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "Data Item 1" - font: "text_bold" id: "button_component/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "button_component/root" - layer: "" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/data_list/cache_with_component/cache_with_component.lua b/example/examples/data_list/cache_with_component/cache_with_component.lua index ca308e2..f336a2d 100644 --- a/example/examples/data_list/cache_with_component/cache_with_component.lua +++ b/example/examples/data_list/cache_with_component/cache_with_component.lua @@ -18,7 +18,7 @@ function M:init(template, nodes) gui.set_enabled(self.prefab, false) self.scroll = self.druid:new_scroll("view", "content") - self.grid = self.druid:new_static_grid("content", self.prefab, 1) + self.grid = self.druid:new_grid("content", self.prefab, 1) self.data_list = self.druid:new(data_list, self.scroll, self.grid, self.create_item_callback) --[[@as druid.data_list]] self.data_list:set_use_cache(true) self.data_list.on_element_add:subscribe(self.on_element_add) diff --git a/example/examples/gamepad/gamepad_tester/gamepad_tester.gui b/example/examples/gamepad/gamepad_tester/gamepad_tester.gui index a6904ed..993e543 100644 --- a/example/examples/gamepad/gamepad_tester/gamepad_tester.gui +++ b/example/examples/gamepad/gamepad_tester/gamepad_tester.gui @@ -1,6 +1,6 @@ textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui b/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui index a7f8b55..93d6581 100644 --- a/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui +++ b/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui @@ -1,58 +1,24 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 90.0 y: 90.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "button" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -60,143 +26,50 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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.5 y: 1.5 - z: 1.0 - w: 1.0 } size { x: 40.0 y: 40.0 - z: 0.0 - w: 1.0 } color { x: 0.941 y: 0.984 - z: 1.0 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "X" font: "text_bold" id: "text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "button" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } color { x: 0.941 y: 0.984 - z: 1.0 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/icon_arrow" id: "icon" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button" - 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 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/gamepad/gamepad_tester/templates/gamepad_stick.gui b/example/examples/gamepad/gamepad_tester/templates/gamepad_stick.gui index ffa86d2..3505a94 100644 --- a/example/examples/gamepad/gamepad_tester/templates/gamepad_stick.gui +++ b/example/examples/gamepad/gamepad_tester/templates/gamepad_stick.gui @@ -3,8 +3,8 @@ fonts { font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/gamepad/gamepad_tester/templates/gamepad_trigger.gui b/example/examples/gamepad/gamepad_tester/templates/gamepad_trigger.gui index ffe202d..e057ec9 100644 --- a/example/examples/gamepad/gamepad_tester/templates/gamepad_trigger.gui +++ b/example/examples/gamepad/gamepad_tester/templates/gamepad_trigger.gui @@ -1,58 +1,24 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 180.0 y: 90.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "button" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -60,58 +26,25 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: -90.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: 180.0 y: 90.0 - z: 0.0 - w: 1.0 } color { x: 0.631 y: 0.843 z: 0.961 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "fill" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_W - adjust_mode: ADJUST_MODE_FIT parent: "button" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -119,84 +52,38 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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.5 y: 1.5 - z: 1.0 - w: 1.0 } size { x: 40.0 y: 40.0 - z: 0.0 - w: 1.0 } color { x: 0.941 y: 0.984 - z: 1.0 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "X" font: "text_bold" id: "text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "button" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/gamepad/on_screen_control/on_screen_control.gui b/example/examples/gamepad/on_screen_control/on_screen_control.gui index 63c4bf5..774696e 100644 --- a/example/examples/gamepad/on_screen_control/on_screen_control.gui +++ b/example/examples/gamepad/on_screen_control/on_screen_control.gui @@ -1,6 +1,6 @@ textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/gamepad/on_screen_control/on_screen_input.gui b/example/examples/gamepad/on_screen_control/on_screen_input.gui index b1d3488..f005c06 100644 --- a/example/examples/gamepad/on_screen_control/on_screen_input.gui +++ b/example/examples/gamepad/on_screen_control/on_screen_input.gui @@ -1,6 +1,6 @@ textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/intro/intro/intro.gui b/example/examples/intro/intro/intro.gui index 834e285..61de634 100644 --- a/example/examples/intro/intro/intro.gui +++ b/example/examples/intro/intro/intro.gui @@ -7,8 +7,8 @@ fonts { font: "/example/assets/fonts/text_regular.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } textures { name: "druid_logo" diff --git a/example/examples/layout/basic/basic_layout.gui b/example/examples/layout/basic/basic_layout.gui index 4bb12af..c411061 100644 --- a/example/examples/layout/basic/basic_layout.gui +++ b/example/examples/layout/basic/basic_layout.gui @@ -1,54 +1,20 @@ -script: "" textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 500.0 y: 500.0 - z: 0.0 - w: 1.0 } color { x: 0.173 y: 0.184 z: 0.204 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_64" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT - layer: "" inherit_alpha: true slice9 { x: 32.0 @@ -56,117 +22,33 @@ nodes { z: 32.0 w: 32.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 500.0 y: 500.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: "druid/empty" id: "layout" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 70.0 y: 40.0 - z: 0.0 - w: 1.0 } color { x: 0.631 y: 0.843 z: 0.961 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_16" id: "prefab" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "layout" - layer: "" inherit_alpha: true slice9 { x: 8.0 @@ -174,17 +56,6 @@ nodes { z: 8.0 w: 8.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/panthera/animation_blend/animation_blend.gui b/example/examples/panthera/animation_blend/animation_blend.gui index eb98b38..ee5efc2 100644 --- a/example/examples/panthera/animation_blend/animation_blend.gui +++ b/example/examples/panthera/animation_blend/animation_blend.gui @@ -7,8 +7,8 @@ textures { texture: "/example/examples/panthera/animation_blend/assets/animation_blend.atlas" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/panthera/basic_animation/basic_animation.gui b/example/examples/panthera/basic_animation/basic_animation.gui index fef1c91..0dd7236 100644 --- a/example/examples/panthera/basic_animation/basic_animation.gui +++ b/example/examples/panthera/basic_animation/basic_animation.gui @@ -1,241 +1,38 @@ -script: "" textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 200.0 y: 100.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: "" 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 - custom_type: 0 - enabled: true visible: false - material: "" } 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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } type: TYPE_TEMPLATE id: "button" parent: "root" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_blue.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.631 - y: 0.843 - z: 0.961 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 - } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Hover Me!" - font: "text_bold" id: "button/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "button/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 overridden_fields: 8 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/widgets/examples_list.lua b/example/examples/widgets/examples_list.lua index 6209cdd..5329bc2 100644 --- a/example/examples/widgets/examples_list.lua +++ b/example/examples/widgets/examples_list.lua @@ -53,6 +53,14 @@ function M.get_examples() end) end, }, + { + name_id = "ui_example_widget_memory_panel", + information_text_id = "ui_example_widget_memory_panel_description", + template = "example_memory_panel", + root = "example_memory_panel/root", + code_url = "example/examples/widgets/memory_panel/example_memory_panel.lua", + component_class = require("example.examples.widgets.memory_panel.example_memory_panel"), + }, } end diff --git a/example/examples/widgets/hover_hint/hover_hint.gui b/example/examples/widgets/hover_hint/hover_hint.gui index 9c8190c..ce4b3c2 100644 --- a/example/examples/widgets/hover_hint/hover_hint.gui +++ b/example/examples/widgets/hover_hint/hover_hint.gui @@ -3,8 +3,8 @@ fonts { font: "/example/assets/fonts/text_regular.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/widgets/hover_hint/hover_hint_example.gui b/example/examples/widgets/hover_hint/hover_hint_example.gui index 8bb74a9..61ca0d8 100644 --- a/example/examples/widgets/hover_hint/hover_hint_example.gui +++ b/example/examples/widgets/hover_hint/hover_hint_example.gui @@ -1,6 +1,6 @@ textures { - name: "druid" - texture: "/example/assets/druid.atlas" + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { size { diff --git a/example/examples/widgets/memory_panel/example_memory_panel.gui b/example/examples/widgets/memory_panel/example_memory_panel.gui new file mode 100644 index 0000000..2732694 --- /dev/null +++ b/example/examples/widgets/memory_panel/example_memory_panel.gui @@ -0,0 +1,98 @@ +nodes { + type: TYPE_TEMPLATE + id: "memory_panel" + inherit_alpha: true + template: "/druid/widget/memory_panel/memory_panel.gui" +} +nodes { + type: TYPE_BOX + id: "memory_panel/root" + parent: "memory_panel" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "memory_panel/mini_graph" + parent: "memory_panel/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "memory_panel/mini_graph/root" + parent: "memory_panel/mini_graph" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "memory_panel/mini_graph/header" + parent: "memory_panel/mini_graph/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "memory_panel/mini_graph/text_header" + parent: "memory_panel/mini_graph/header" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "memory_panel/mini_graph/icon_drag" + parent: "memory_panel/mini_graph/header" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "memory_panel/mini_graph/content" + parent: "memory_panel/mini_graph/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "memory_panel/mini_graph/prefab_line" + parent: "memory_panel/mini_graph/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "memory_panel/mini_graph/color_low" + parent: "memory_panel/mini_graph/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "memory_panel/content" + parent: "memory_panel/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "memory_panel/text_max_value" + parent: "memory_panel/content" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "memory_panel/text_per_second" + parent: "memory_panel/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "memory_panel/line_second_1" + parent: "memory_panel/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "memory_panel/line_second_2" + parent: "memory_panel/content" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "memory_panel/text_memory" + parent: "memory_panel/content" + template_node_child: true +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/example/examples/widgets/memory_panel/example_memory_panel.lua b/example/examples/widgets/memory_panel/example_memory_panel.lua new file mode 100644 index 0000000..f42f0f6 --- /dev/null +++ b/example/examples/widgets/memory_panel/example_memory_panel.lua @@ -0,0 +1,12 @@ +local memory_panel = require("druid.widget.memory_panel.memory_panel") + +---@class widget.example_memory_panel: druid.widget +local M = {} + + +function M:init() + self.memory_panel = self.druid:new_widget(memory_panel, "memory_panel") +end + + +return M \ No newline at end of file diff --git a/example/examples/windows/window_confirmation/window_confirmation.gui b/example/examples/windows/window_confirmation/window_confirmation.gui index 27ed7fc..185880f 100644 --- a/example/examples/windows/window_confirmation/window_confirmation.gui +++ b/example/examples/windows/window_confirmation/window_confirmation.gui @@ -4,55 +4,22 @@ fonts { font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { position { x: 960.0 y: 540.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: 700.0 y: 500.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: "druid/empty" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER adjust_mode: ADJUST_MODE_STRETCH - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -60,58 +27,22 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 700.0 y: 500.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "window" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "root" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -119,58 +50,25 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: 250.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: 700.0 y: 92.0 - z: 0.0 - w: 1.0 } color { x: 0.902 y: 0.875 z: 0.624 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_rounded_top_32" id: "panel_header" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_N - adjust_mode: ADJUST_MODE_FIT parent: "window" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -178,663 +76,166 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -46.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 } scale { x: 1.5 y: 1.5 - z: 1.0 - w: 1.0 } size { x: 300.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Confirmation" font: "text_bold" id: "text_header" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "panel_header" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: 300.0 y: -46.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: 100.0 y: 100.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: "" id: "button_close" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "panel_header" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/icon_cross" id: "icon_close" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button_close" - 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 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -45.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: 700.0 y: 400.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: "" id: "content" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { - x: 0.0 y: 75.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 } scale { x: 1.5 y: 1.5 - z: 1.0 - w: 1.0 } size { x: 420.0 y: 140.0 - z: 0.0 - w: 1.0 } color { x: 0.941 y: 0.984 - z: 1.0 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Do you agree with selected action?" font: "text_bold" id: "text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT line_break: true parent: "content" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: -160.0 y: -100.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "button_accept" parent: "content" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_green.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.557 - y: 0.835 - z: 0.62 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button_accept/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button_accept" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 - } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "Confirm" - font: "text_bold" id: "button_accept/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "button_accept/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: 160.0 y: -100.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "button_decline" parent: "content" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_red.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.957 - y: 0.608 - z: 0.608 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button_decline/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button_decline" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 - } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "Cancel" - font: "text_bold" id: "button_decline/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "button_decline/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } layers { name: "druid" @@ -844,4 +245,3 @@ layers { } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/windows/window_info/window_info.gui b/example/examples/windows/window_info/window_info.gui index 1d45e4f..3601b50 100644 --- a/example/examples/windows/window_info/window_info.gui +++ b/example/examples/windows/window_info/window_info.gui @@ -4,55 +4,22 @@ fonts { font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { position { x: 960.0 y: 540.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: 700.0 y: 500.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: "druid/empty" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER adjust_mode: ADJUST_MODE_STRETCH - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -60,58 +27,22 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 700.0 y: 500.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "window" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "root" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -119,58 +50,25 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: 250.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: 700.0 y: 92.0 - z: 0.0 - w: 1.0 } color { x: 0.631 y: 0.843 z: 0.961 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_rounded_top_32" id: "panel_header" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_N - adjust_mode: ADJUST_MODE_FIT parent: "window" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -178,495 +76,142 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -46.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 } scale { x: 1.5 y: 1.5 - z: 1.0 - w: 1.0 } size { x: 300.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Information" font: "text_bold" id: "text_header" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "panel_header" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: 300.0 y: -46.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: 100.0 y: 100.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: "" id: "button_close" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "panel_header" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/icon_cross" id: "icon_close" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button_close" - 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 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -45.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: 700.0 y: 400.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: "" id: "content" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } nodes { position { - x: 0.0 y: 75.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 } scale { x: 1.5 y: 1.5 - z: 1.0 - w: 1.0 } size { x: 420.0 y: 140.0 - z: 0.0 - w: 1.0 } color { x: 0.941 y: 0.984 - z: 1.0 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "You are the best!" font: "text_bold" id: "text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT line_break: true parent: "content" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -100.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "button_accept" parent: "content" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_green.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.557 - y: 0.835 - z: 0.62 - w: 1.0 - } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button_accept/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button_accept" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 - } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "Confirm" - font: "text_bold" id: "button_accept/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "button_accept/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } layers { name: "druid" @@ -676,4 +221,3 @@ layers { } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/windows/window_language/window_language.gui b/example/examples/windows/window_language/window_language.gui index 1076352..4a5bd26 100644 --- a/example/examples/windows/window_language/window_language.gui +++ b/example/examples/windows/window_language/window_language.gui @@ -4,55 +4,22 @@ fonts { font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } nodes { position { x: 960.0 y: 540.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: 600.0 y: 580.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: "druid/empty" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER adjust_mode: ADJUST_MODE_STRETCH - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -60,58 +27,22 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 600.0 y: 580.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "window" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "root" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -119,58 +50,25 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: 290.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: 600.0 y: 92.0 - z: 0.0 - w: 1.0 } color { x: 0.631 y: 0.843 z: 0.961 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_rounded_top_32" id: "panel_header" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_N - adjust_mode: ADJUST_MODE_FIT parent: "window" - layer: "" inherit_alpha: true slice9 { x: 16.0 @@ -178,490 +76,126 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -46.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 } scale { x: 1.5 y: 1.5 - z: 1.0 - w: 1.0 } size { x: 300.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Language" font: "text_bold" id: "text_header" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "panel_header" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: 250.0 y: -46.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: 100.0 y: 100.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: "" id: "button_close" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "panel_header" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/icon_cross" id: "icon_close" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button_close" - 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 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: -45.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: 600.0 y: 470.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: "" id: "content" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 260.0 y: 90.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: "" id: "button_prefab" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "content" - 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } type: TYPE_TEMPLATE id: "button" parent: "button_prefab" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_white.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 240.0 y: 70.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.941 - y: 0.984 - z: 1.0 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" id: "button/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 overridden_fields: 4 template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 220.0 y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "English" - font: "text_bold" id: "button/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "button/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 overridden_fields: 4 overridden_fields: 8 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } layers { name: "druid" @@ -671,4 +205,3 @@ layers { } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/windows/window_language/window_language.lua b/example/examples/windows/window_language/window_language.lua index f5f4120..8f899bc 100644 --- a/example/examples/windows/window_language/window_language.lua +++ b/example/examples/windows/window_language/window_language.lua @@ -12,7 +12,7 @@ local window_animation_panthera = require("example.examples.windows.window_anima ---@field button_close druid.button ---@field druid druid_instance ---@field lang_buttons table ----@field grid druid.static_grid +---@field grid druid.grid ---@field on_language_change druid.event local M = component.create("window_language") @@ -36,7 +36,7 @@ function M:init(template, nodes) self.button_close = self.druid:new_button("button_close", self.on_button_close) self.druid:new(lang_text, "text_header", "ui_language") - self.grid = self.druid:new_static_grid("content", self.prefab, 2) + self.grid = self.druid:new_grid("content", self.prefab, 2) self.grid.style.IS_DYNAMIC_NODE_POSES = true self.animation = panthera.create_gui(window_animation_panthera, self:get_template(), nodes) diff --git a/example/templates/button_text_blue.gui b/example/templates/button_text_blue.gui index ca44671..1560d06 100644 --- a/example/templates/button_text_blue.gui +++ b/example/templates/button_text_blue.gui @@ -1,57 +1,24 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 280.0 y: 90.0 - z: 0.0 - w: 1.0 } color { x: 0.631 y: 0.843 z: 0.961 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT layer: "druid" inherit_alpha: true slice9 { @@ -60,90 +27,42 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 245.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Info" font: "text_bold" id: "text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "root" layer: "text_bold" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } -material: "/builtins/materials/gui.material" -adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 layers { name: "druid" } layers { name: "text_bold" } +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/example/templates/button_text_green.gui b/example/templates/button_text_green.gui index 41d3b0f..543f4fa 100644 --- a/example/templates/button_text_green.gui +++ b/example/templates/button_text_green.gui @@ -1,57 +1,24 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 280.0 y: 90.0 - z: 0.0 - w: 1.0 } color { x: 0.557 y: 0.835 z: 0.62 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT layer: "druid" inherit_alpha: true slice9 { @@ -60,83 +27,36 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 245.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Confirm" font: "text_bold" id: "text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "root" layer: "text_bold" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } layers { name: "druid" @@ -146,4 +66,3 @@ layers { } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/templates/button_text_red.gui b/example/templates/button_text_red.gui index 737878b..07b46e0 100644 --- a/example/templates/button_text_red.gui +++ b/example/templates/button_text_red.gui @@ -1,57 +1,24 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 280.0 y: 90.0 - z: 0.0 - w: 1.0 } color { x: 0.957 y: 0.608 z: 0.608 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT layer: "druid" inherit_alpha: true slice9 { @@ -60,83 +27,36 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 245.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Cancel" font: "text_bold" id: "text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "root" layer: "text_bold" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } layers { name: "druid" @@ -146,4 +66,3 @@ layers { } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/templates/button_text_white.gui b/example/templates/button_text_white.gui index 2935f42..8398f81 100644 --- a/example/templates/button_text_white.gui +++ b/example/templates/button_text_white.gui @@ -1,57 +1,23 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 280.0 y: 90.0 - z: 0.0 - w: 1.0 } color { x: 0.941 y: 0.984 - z: 1.0 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT layer: "druid" inherit_alpha: true slice9 { @@ -60,83 +26,36 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 245.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Action" font: "text_bold" id: "text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "root" layer: "text_bold" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } layers { name: "druid" @@ -146,4 +65,3 @@ layers { } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/templates/button_text_yellow.gui b/example/templates/button_text_yellow.gui index 99593a5..2e06dc6 100644 --- a/example/templates/button_text_yellow.gui +++ b/example/templates/button_text_yellow.gui @@ -1,57 +1,24 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 280.0 y: 90.0 - z: 0.0 - w: 1.0 } color { x: 0.902 y: 0.875 z: 0.624 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_32" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT layer: "druid" inherit_alpha: true slice9 { @@ -60,90 +27,42 @@ nodes { z: 16.0 w: 16.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 245.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Warn" font: "text_bold" id: "text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "root" layer: "text_bold" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } -material: "/builtins/materials/gui.material" -adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 layers { name: "druid" } layers { name: "text_bold" } +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/example/templates/input.gui b/example/templates/input.gui index 776bbbf..4389038 100644 --- a/example/templates/input.gui +++ b/example/templates/input.gui @@ -1,58 +1,24 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 500.0 y: 80.0 - z: 0.0 - w: 1.0 } color { x: 0.463 y: 0.475 z: 0.49 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/rect_round2_width1" id: "root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT - layer: "" inherit_alpha: true slice9 { x: 4.0 @@ -60,84 +26,39 @@ nodes { z: 4.0 w: 4.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: -240.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: 480.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.722 y: 0.741 z: 0.761 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Tap me to input" font: "text_bold" id: "text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_W outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "root" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/templates/rich_input.gui b/example/templates/rich_input.gui index 5467ee9..0f109d7 100644 --- a/example/templates/rich_input.gui +++ b/example/templates/rich_input.gui @@ -1,117 +1,30 @@ -script: "" fonts { name: "text_bold" font: "/example/assets/fonts/text_bold.font" } textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 500.0 y: 80.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: "" 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 500.0 y: 80.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: "druid/rect_round2_width1" id: "button" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "root" - layer: "" inherit_alpha: true slice9 { x: 4.0 @@ -119,192 +32,77 @@ nodes { z: 4.0 w: 4.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 480.0 y: 60.0 - z: 0.0 - w: 1.0 } color { x: 0.31 y: 0.318 z: 0.322 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "Placeholder" font: "text_bold" id: "placeholder_text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER outline { x: 0.4 y: 0.4 z: 0.4 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "button" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 480.0 y: 60.0 - z: 0.0 - w: 1.0 } color { x: 0.722 y: 0.741 z: 0.761 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "User input" font: "text_bold" id: "input_text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "button" - layer: "" inherit_alpha: true - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: 118.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: 16.0 y: 50.0 - z: 0.0 - w: 1.0 } color { x: 0.631 y: 0.843 z: 0.961 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_16" id: "cursor_node" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "button" - layer: "" inherit_alpha: true slice9 { x: 8.0 @@ -312,84 +110,37 @@ nodes { z: 8.0 w: 8.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false alpha: 0.5 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { - x: 0.0 y: 4.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 } scale { x: 1.2 y: 1.2 - z: 1.0 - w: 1.0 } size { x: 20.0 y: 40.0 - z: 0.0 - w: 1.0 } color { x: 0.722 y: 0.741 z: 0.761 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "|" font: "text_bold" id: "cursor_text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "cursor_node" - layer: "" - inherit_alpha: false - alpha: 1.0 outline_alpha: 0.0 shadow_alpha: 0.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/templates/slider.gui b/example/templates/slider.gui index ac7f71e..a1f363a 100644 --- a/example/templates/slider.gui +++ b/example/templates/slider.gui @@ -1,113 +1,36 @@ -script: "" textures { - name: "druid" - texture: "/example/assets/druid.atlas" -} -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 + name: "druid_example" + texture: "/example/assets/druid_example.atlas" } 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: 260.0 y: 40.0 - z: 0.0 - w: 1.0 } color { x: 0.129 y: 0.141 z: 0.157 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/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_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } 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: 260.0 y: 8.0 - z: 0.0 - w: 1.0 } color { x: 0.129 y: 0.141 z: 0.157 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_8" id: "slider_back" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "root" - layer: "" inherit_alpha: true slice9 { x: 4.0 @@ -115,58 +38,24 @@ nodes { z: 4.0 w: 4.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } nodes { position { x: -118.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: 24.0 y: 24.0 - z: 0.0 - w: 1.0 } color { x: 0.722 y: 0.741 z: 0.761 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "druid/ui_circle_8" id: "slider_pin" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "root" - layer: "" inherit_alpha: true slice9 { x: 4.0 @@ -174,17 +63,6 @@ nodes { z: 4.0 w: 4.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/test/tests/test_static_grid.lua b/test/tests/test_static_grid.lua index 4e17ce7..0ffef0c 100644 --- a/test/tests/test_static_grid.lua +++ b/test/tests/test_static_grid.lua @@ -10,7 +10,7 @@ return function() describe("Static Grid component", function() local parent = nil - ---@type druid.static_grid + ---@type druid.grid local grid = nil local prefab = nil @@ -30,7 +30,7 @@ return function() parent = mock_gui.add_box("parent", 0, 0, 50, 50) prefab = mock_gui.add_box("prefab", 50, 50, 25, 25) - grid = druid:new_static_grid(parent, prefab, 3) + grid = druid:new_grid(parent, prefab, 3) end) after(function() From 6552ea5cac4171302110c2de4a17ed96939a7e43 Mon Sep 17 00:00:00 2001 From: Insality Date: Wed, 20 Nov 2024 23:43:39 +0200 Subject: [PATCH 24/50] Update example assets --- example/components/druid_logo/druid_logo.gui | 2 +- .../examples_list_view/examples_list_view.gui | 36 +- .../examples_list_view/examples_list_view.lua | 8 +- .../examples_list_view_item.gui | 8 +- .../components/output_list/output_list.gui | 8 +- .../panel_druid_profiler.gui | 4 +- .../panel_information/panel_information.gui | 68 +-- .../properties/property_button.gui | 6 +- .../properties/property_checkbox.gui | 8 +- .../properties/property_slider.gui | 14 +- .../properties_panel/properties_panel.gui | 124 +---- example/druid.gui | 39 +- .../basic/back_handler/basic_back_handler.gui | 2 +- .../examples/basic/blocker/basic_blocker.gui | 16 +- .../examples/basic/button/basic_button.gui | 216 -------- .../button/basic_button_double_click.gui | 216 -------- .../basic/button/basic_button_hold.gui | 4 +- example/examples/basic/checkbox/checkbox.gui | 6 +- .../basic/checkbox_group/checkbox_group.gui | 72 --- example/examples/basic/drag/drag.gui | 14 - example/examples/basic/drag/drag_to_node.gui | 16 +- example/examples/basic/grid/grid.gui | 6 +- example/examples/basic/hover/hover.gui | 28 -- example/examples/basic/input/basic_input.gui | 377 -------------- .../examples/basic/input/input_password.gui | 14 - example/examples/basic/input/rich_input.gui | 86 ---- .../basic/progress_bar/basic_progress_bar.gui | 4 +- .../basic_progress_bar_slice9.gui | 4 +- .../basic/radio_group/radio_group.gui | 147 ------ .../basic/rich_text/rich_text_tags.gui | 2 +- example/examples/basic/scroll/scroll.gui | 44 +- .../scroll_bind_grid/scroll_bind_grid.gui | 8 +- .../scroll_bind_grid_horizontal.gui | 8 +- .../scroll_bind_grid_points.gui | 8 +- .../basic/scroll_slider/scroll_slider.gui | 281 +---------- .../examples/basic/slider/basic_slider.gui | 20 +- .../basic/slider/basic_slider_stepped.gui | 20 +- .../basic/slider/basic_slider_vertical.gui | 34 +- example/examples/basic/swipe/basic_swipe.gui | 2 +- example/examples/basic/text/basic_text.gui | 2 +- .../examples/basic/text/multiline_text.gui | 2 +- .../data_list_add_remove_clear.gui | 8 +- .../data_list/basic/data_list_basic.gui | 8 +- .../basic/data_list_horizontal_basic.gui | 8 +- .../cache_with_component/button_component.gui | 2 +- .../cache_with_component.gui | 24 +- example/examples/druid_examples.lua | 5 +- .../gamepad/gamepad_tester/gamepad_tester.gui | 468 +----------------- .../templates/gamepad_button.gui | 4 +- .../templates/gamepad_stick.gui | 18 +- .../templates/gamepad_trigger.gui | 4 +- .../on_screen_control/on_screen_control.gui | 90 +--- .../on_screen_control/on_screen_input.gui | 85 ---- example/examples/intro/intro/intro.gui | 8 +- .../examples/layout/basic/basic_layout.gui | 6 +- .../animation_blend/animation_blend.gui | 2 +- .../basic_animation/basic_animation.gui | 14 - .../widgets/hover_hint/hover_hint.gui | 2 +- .../widgets/hover_hint/hover_hint_example.gui | 28 +- .../memory_panel/example_memory_panel.gui | 12 + .../window_confirmation.gui | 32 +- .../windows/window_info/window_info.gui | 20 +- .../window_language/window_language.gui | 32 +- example/templates/button_text_blue.gui | 2 +- example/templates/button_text_green.gui | 2 +- example/templates/button_text_red.gui | 2 +- example/templates/button_text_white.gui | 2 +- example/templates/button_text_yellow.gui | 2 +- example/templates/input.gui | 2 +- example/templates/rich_input.gui | 4 +- example/templates/slider.gui | 6 +- 71 files changed, 199 insertions(+), 2687 deletions(-) diff --git a/example/components/druid_logo/druid_logo.gui b/example/components/druid_logo/druid_logo.gui index 2347db1..7680ab4 100644 --- a/example/components/druid_logo/druid_logo.gui +++ b/example/components/druid_logo/druid_logo.gui @@ -21,7 +21,7 @@ nodes { z: 0.157 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "root" layer: "druid" inherit_alpha: true diff --git a/example/components/examples_list_view/examples_list_view.gui b/example/components/examples_list_view/examples_list_view.gui index 21f5dc5..cadc473 100644 --- a/example/components/examples_list_view/examples_list_view.gui +++ b/example/components/examples_list_view/examples_list_view.gui @@ -17,7 +17,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "root" adjust_mode: ADJUST_MODE_STRETCH layer: "druid" @@ -72,7 +72,7 @@ nodes { y: 850.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "scroll_view" pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH @@ -87,7 +87,7 @@ nodes { y: 850.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "scroll_content" pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH @@ -106,36 +106,6 @@ nodes { inherit_alpha: true template: "/example/components/examples_list_view/examples_list_view_item.gui" } -nodes { - type: TYPE_BOX - id: "examples_list_view_item/root" - parent: "examples_list_view_item" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "examples_list_view_item/panel_highlight" - parent: "examples_list_view_item/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "examples_list_view_item/panel_selected" - parent: "examples_list_view_item/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "examples_list_view_item/icon" - parent: "examples_list_view_item/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "examples_list_view_item/text" - parent: "examples_list_view_item/root" - template_node_child: true -} layers { name: "druid" } diff --git a/example/components/examples_list_view/examples_list_view.lua b/example/components/examples_list_view/examples_list_view.lua index 9d06af6..7ceacb0 100644 --- a/example/components/examples_list_view/examples_list_view.lua +++ b/example/components/examples_list_view/examples_list_view.lua @@ -90,7 +90,13 @@ function M:add_example(examples, druid_example) local root = gui.get_node(example_data.root) gui.set_enabled(root, true) - local instance = druid_example.druid:new(example_data.component_class, example_data.template) + + local instance + if example_data.widget_class then + instance = druid_example.druid:new_widget(example_data.widget_class, example_data.template) + else + instance = druid_example.druid:new(example_data.component_class, example_data.template) + end self.selected_example = { data = example_data, diff --git a/example/components/examples_list_view/examples_list_view_item.gui b/example/components/examples_list_view/examples_list_view_item.gui index f9ad962..b562ad0 100644 --- a/example/components/examples_list_view/examples_list_view_item.gui +++ b/example/components/examples_list_view/examples_list_view_item.gui @@ -17,7 +17,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "root" pivot: PIVOT_W adjust_mode: ADJUST_MODE_STRETCH @@ -36,7 +36,7 @@ nodes { z: 0.322 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "panel_highlight" pivot: PIVOT_W parent: "root" @@ -55,7 +55,7 @@ nodes { z: 0.333 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "panel_selected" pivot: PIVOT_W parent: "root" @@ -77,7 +77,7 @@ nodes { z: 0.851 } type: TYPE_BOX - texture: "druid/icon_arrow" + texture: "druid_example/icon_arrow" id: "icon" parent: "root" layer: "druid" diff --git a/example/components/output_list/output_list.gui b/example/components/output_list/output_list.gui index 45b6a06..19456e3 100644 --- a/example/components/output_list/output_list.gui +++ b/example/components/output_list/output_list.gui @@ -21,7 +21,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "root" adjust_mode: ADJUST_MODE_STRETCH layer: "druid" @@ -76,7 +76,7 @@ nodes { y: 190.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "scroll_view" pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH @@ -91,7 +91,7 @@ nodes { y: 190.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "scroll_content" pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH @@ -150,7 +150,7 @@ nodes { z: 0.157 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "separator" pivot: PIVOT_N parent: "root" diff --git a/example/components/panel_druid_profiler/panel_druid_profiler.gui b/example/components/panel_druid_profiler/panel_druid_profiler.gui index 2470901..80e85df 100644 --- a/example/components/panel_druid_profiler/panel_druid_profiler.gui +++ b/example/components/panel_druid_profiler/panel_druid_profiler.gui @@ -156,7 +156,7 @@ nodes { y: 50.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "group_fps" parent: "root" inherit_alpha: true @@ -286,7 +286,7 @@ nodes { y: 50.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "group_components" parent: "root" inherit_alpha: true diff --git a/example/components/panel_information/panel_information.gui b/example/components/panel_information/panel_information.gui index 6e9a8e1..0c01d7f 100644 --- a/example/components/panel_information/panel_information.gui +++ b/example/components/panel_information/panel_information.gui @@ -21,7 +21,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "root" adjust_mode: ADJUST_MODE_STRETCH layer: "druid" @@ -91,30 +91,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_blue.gui" } -nodes { - size { - x: 240.0 - y: 80.0 - } - type: TYPE_BOX - id: "button_view_code/root" - parent: "button_view_code" - overridden_fields: 4 - template_node_child: true -} -nodes { - scale { - x: 0.75 - y: 0.75 - } - type: TYPE_TEXT - text: "View code" - id: "button_view_code/text" - parent: "button_view_code/root" - overridden_fields: 3 - overridden_fields: 8 - template_node_child: true -} nodes { position { x: 220.0 @@ -142,44 +118,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_yellow.gui" } -nodes { - size { - x: 130.0 - y: 35.0 - } - type: TYPE_BOX - texture: "druid/ui_circle_8" - id: "button_profiler/root" - parent: "button_profiler" - slice9 { - x: 4.0 - y: 4.0 - z: 4.0 - w: 4.0 - } - overridden_fields: 4 - overridden_fields: 9 - overridden_fields: 22 - template_node_child: true -} -nodes { - scale { - x: 0.6 - y: 0.6 - } - size { - x: 190.0 - y: 50.0 - } - type: TYPE_TEXT - text: "Profiler" - id: "button_profiler/text" - parent: "button_profiler/root" - overridden_fields: 3 - overridden_fields: 4 - overridden_fields: 8 - template_node_child: true -} nodes { position { x: -200.0 @@ -190,7 +128,7 @@ nodes { y: 250.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "scroll_view" pivot: PIVOT_NW parent: "root" @@ -203,7 +141,7 @@ nodes { y: 250.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "scroll_content" pivot: PIVOT_NW parent: "scroll_view" diff --git a/example/components/properties_panel/properties/property_button.gui b/example/components/properties_panel/properties/property_button.gui index 09831f0..061bd7a 100644 --- a/example/components/properties_panel/properties/property_button.gui +++ b/example/components/properties_panel/properties/property_button.gui @@ -12,7 +12,7 @@ nodes { y: 40.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "root" pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH @@ -71,7 +71,7 @@ nodes { z: 0.49 } type: TYPE_BOX - texture: "druid/rect_round2_width1" + texture: "druid_example/rect_round2_width1" id: "button" parent: "root" inherit_alpha: true @@ -96,7 +96,7 @@ nodes { z: 0.333 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "selected" pivot: PIVOT_S adjust_mode: ADJUST_MODE_STRETCH diff --git a/example/components/properties_panel/properties/property_checkbox.gui b/example/components/properties_panel/properties/property_checkbox.gui index 0a4f7ef..bcab99a 100644 --- a/example/components/properties_panel/properties/property_checkbox.gui +++ b/example/components/properties_panel/properties/property_checkbox.gui @@ -12,7 +12,7 @@ nodes { y: 40.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "root" pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH @@ -71,7 +71,7 @@ nodes { z: 0.49 } type: TYPE_BOX - texture: "druid/rect_round2_width1" + texture: "druid_example/rect_round2_width1" id: "button" parent: "root" inherit_alpha: true @@ -89,7 +89,7 @@ nodes { z: 0.761 } type: TYPE_BOX - texture: "druid/icon_check" + texture: "druid_example/icon_check" id: "icon" parent: "button" inherit_alpha: true @@ -109,7 +109,7 @@ nodes { z: 0.333 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "selected" pivot: PIVOT_S adjust_mode: ADJUST_MODE_STRETCH diff --git a/example/components/properties_panel/properties/property_slider.gui b/example/components/properties_panel/properties/property_slider.gui index ee3b114..f4579ae 100644 --- a/example/components/properties_panel/properties/property_slider.gui +++ b/example/components/properties_panel/properties/property_slider.gui @@ -12,7 +12,7 @@ nodes { y: 40.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "root" pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH @@ -62,7 +62,7 @@ nodes { y: -20.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "E_Anchor" pivot: PIVOT_E adjust_mode: ADJUST_MODE_STRETCH @@ -85,7 +85,7 @@ nodes { z: 0.49 } type: TYPE_BOX - texture: "druid/rect_round2_width1" + texture: "druid_example/rect_round2_width1" id: "button" pivot: PIVOT_E parent: "E_Anchor" @@ -111,7 +111,7 @@ nodes { z: 0.333 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "selected" pivot: PIVOT_SE adjust_mode: ADJUST_MODE_STRETCH @@ -169,7 +169,7 @@ nodes { z: 0.157 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "slider" parent: "root" inherit_alpha: true @@ -185,7 +185,7 @@ nodes { z: 0.157 } type: TYPE_BOX - texture: "druid/ui_circle_8" + texture: "druid_example/ui_circle_8" id: "slider_back" parent: "slider" inherit_alpha: true @@ -210,7 +210,7 @@ nodes { z: 0.761 } type: TYPE_BOX - texture: "druid/ui_circle_8" + texture: "druid_example/ui_circle_8" id: "slider_pin" parent: "slider" inherit_alpha: true diff --git a/example/components/properties_panel/properties_panel.gui b/example/components/properties_panel/properties_panel.gui index b7833d5..5e59d95 100644 --- a/example/components/properties_panel/properties_panel.gui +++ b/example/components/properties_panel/properties_panel.gui @@ -17,7 +17,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "root" adjust_mode: ADJUST_MODE_STRETCH layer: "druid" @@ -72,7 +72,7 @@ nodes { y: 290.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "scroll_view" xanchor: XANCHOR_LEFT pivot: PIVOT_NW @@ -88,7 +88,7 @@ nodes { y: 290.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "scroll_content" pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH @@ -126,7 +126,7 @@ nodes { z: 0.157 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "separator" pivot: PIVOT_N parent: "root" @@ -139,7 +139,7 @@ nodes { y: 100.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "propeties" parent: "root" inherit_alpha: true @@ -153,60 +153,6 @@ nodes { inherit_alpha: true template: "/example/components/properties_panel/properties/property_slider.gui" } -nodes { - type: TYPE_BOX - id: "property_slider/root" - parent: "property_slider" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "property_slider/text_name" - parent: "property_slider/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "property_slider/E_Anchor" - parent: "property_slider/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "property_slider/button" - parent: "property_slider/E_Anchor" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "property_slider/selected" - parent: "property_slider/button" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "property_slider/text_value" - parent: "property_slider/button" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "property_slider/slider" - parent: "property_slider/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "property_slider/slider_back" - parent: "property_slider/slider" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "property_slider/slider_pin" - parent: "property_slider/slider" - template_node_child: true -} nodes { position { y: -50.0 @@ -217,36 +163,6 @@ nodes { inherit_alpha: true template: "/example/components/properties_panel/properties/property_checkbox.gui" } -nodes { - type: TYPE_BOX - id: "property_checkbox/root" - parent: "property_checkbox" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "property_checkbox/text_name" - parent: "property_checkbox/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "property_checkbox/button" - parent: "property_checkbox/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "property_checkbox/icon" - parent: "property_checkbox/button" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "property_checkbox/selected" - parent: "property_checkbox/button" - template_node_child: true -} nodes { position { y: -100.0 @@ -257,36 +173,6 @@ nodes { inherit_alpha: true template: "/example/components/properties_panel/properties/property_button.gui" } -nodes { - type: TYPE_BOX - id: "property_button/root" - parent: "property_button" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "property_button/text_name" - parent: "property_button/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "property_button/button" - parent: "property_button/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "property_button/selected" - parent: "property_button/button" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "property_button/text_button" - parent: "property_button/button" - template_node_child: true -} nodes { position { x: -200.0 diff --git a/example/druid.gui b/example/druid.gui index 804ad47..0133cfd 100644 --- a/example/druid.gui +++ b/example/druid.gui @@ -39,7 +39,7 @@ nodes { y: 1080.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "container_left" pivot: PIVOT_W adjust_mode: ADJUST_MODE_STRETCH @@ -56,7 +56,7 @@ nodes { y: 170.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "container_logo" pivot: PIVOT_NW parent: "container_left" @@ -125,7 +125,7 @@ nodes { y: 910.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "container_examples" pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH @@ -213,7 +213,7 @@ nodes { y: 1080.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "container_right" pivot: PIVOT_E adjust_mode: ADJUST_MODE_STRETCH @@ -230,7 +230,7 @@ nodes { y: 450.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "container_info" pivot: PIVOT_NE adjust_mode: ADJUST_MODE_STRETCH @@ -336,7 +336,7 @@ nodes { y: 630.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "container_group_settings_output" pivot: PIVOT_SE adjust_mode: ADJUST_MODE_STRETCH @@ -353,7 +353,7 @@ nodes { y: 350.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "container_settings" pivot: PIVOT_NE adjust_mode: ADJUST_MODE_STRETCH @@ -558,7 +558,7 @@ nodes { y: 280.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "container_output" pivot: PIVOT_SE adjust_mode: ADJUST_MODE_STRETCH @@ -635,7 +635,7 @@ nodes { y: 1030.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "container_center" xanchor: XANCHOR_LEFT yanchor: YANCHOR_BOTTOM @@ -683,7 +683,7 @@ nodes { } nodes { type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "intro_examples" parent: "examples" inherit_alpha: true @@ -2447,7 +2447,6 @@ nodes { type: TYPE_BOX id: "window_language/root" parent: "window_language" - overridden_fields: 1 template_node_child: true } nodes { @@ -2521,7 +2520,6 @@ nodes { type: TYPE_BOX id: "window_confirmation/root" parent: "window_confirmation" - overridden_fields: 1 template_node_child: true } nodes { @@ -2613,7 +2611,6 @@ nodes { type: TYPE_BOX id: "window_info/root" parent: "window_info" - overridden_fields: 1 template_node_child: true } nodes { @@ -2868,7 +2865,7 @@ nodes { } nodes { type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "gamepad" parent: "examples" inherit_alpha: true @@ -3673,7 +3670,7 @@ nodes { } nodes { type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "layout" parent: "examples" inherit_alpha: true @@ -3707,7 +3704,7 @@ nodes { } nodes { type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "widgets" parent: "examples" inherit_alpha: true @@ -3926,10 +3923,16 @@ nodes { inherit_alpha: true template: "/example/examples/widgets/memory_panel/example_memory_panel.gui" } +nodes { + type: TYPE_BOX + id: "example_memory_panel/root" + parent: "example_memory_panel" + template_node_child: true +} nodes { type: TYPE_TEMPLATE id: "example_memory_panel/memory_panel" - parent: "example_memory_panel" + parent: "example_memory_panel/root" template_node_child: true } nodes { @@ -4032,7 +4035,7 @@ nodes { y: 50.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "container_status" xanchor: XANCHOR_LEFT pivot: PIVOT_S diff --git a/example/examples/basic/back_handler/basic_back_handler.gui b/example/examples/basic/back_handler/basic_back_handler.gui index c2a132b..0ba266c 100644 --- a/example/examples/basic/back_handler/basic_back_handler.gui +++ b/example/examples/basic/back_handler/basic_back_handler.gui @@ -17,7 +17,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/ui_circle_64" + texture: "druid_example/ui_circle_64" id: "root" inherit_alpha: true slice9 { diff --git a/example/examples/basic/blocker/basic_blocker.gui b/example/examples/basic/blocker/basic_blocker.gui index d51775b..8736e65 100644 --- a/example/examples/basic/blocker/basic_blocker.gui +++ b/example/examples/basic/blocker/basic_blocker.gui @@ -17,7 +17,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/ui_circle_64" + texture: "druid_example/ui_circle_64" id: "root" inherit_alpha: true slice9 { @@ -38,7 +38,7 @@ nodes { z: 0.322 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "blocker" parent: "root" inherit_alpha: true @@ -56,18 +56,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } -nodes { - type: TYPE_BOX - id: "button/root" - parent: "button" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "button/text" - parent: "button/root" - template_node_child: true -} nodes { position { x: -246.0 diff --git a/example/examples/basic/button/basic_button.gui b/example/examples/basic/button/basic_button.gui index d96efe6..b6e5721 100644 --- a/example/examples/basic/button/basic_button.gui +++ b/example/examples/basic/button/basic_button.gui @@ -1,236 +1,20 @@ -script: "" -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: 200.0 y: 100.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: "" 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 - custom_type: 0 - enabled: true visible: false - material: "" } 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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } type: TYPE_TEMPLATE id: "button" parent: "root" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_green.gui" - template_node_child: false - custom_type: 0 - enabled: true -} -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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.557 - y: 0.835 - z: 0.62 - w: 1.0 - } - type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" - id: "button/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT - parent: "button" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" -} -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: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 - } - type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "Confirm" - font: "text_bold" - id: "button/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false - parent: "button/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 - template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/basic/button/basic_button_double_click.gui b/example/examples/basic/button/basic_button_double_click.gui index d96efe6..b6e5721 100644 --- a/example/examples/basic/button/basic_button_double_click.gui +++ b/example/examples/basic/button/basic_button_double_click.gui @@ -1,236 +1,20 @@ -script: "" -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: 200.0 y: 100.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: "" 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 - custom_type: 0 - enabled: true visible: false - material: "" } 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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } type: TYPE_TEMPLATE id: "button" parent: "root" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/button_text_green.gui" - template_node_child: false - custom_type: 0 - enabled: true -} -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: 280.0 - y: 90.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.557 - y: 0.835 - z: 0.62 - w: 1.0 - } - type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/ui_circle_32" - id: "button/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT - parent: "button" - layer: "druid" - inherit_alpha: true - slice9 { - x: 16.0 - y: 16.0 - z: 16.0 - w: 16.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" -} -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: 245.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.31 - y: 0.318 - z: 0.322 - w: 1.0 - } - type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "Confirm" - font: "text_bold" - id: "button/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false - parent: "button/root" - layer: "text_bold" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 - template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/basic/button/basic_button_hold.gui b/example/examples/basic/button/basic_button_hold.gui index 698b082..2234bea 100644 --- a/example/examples/basic/button/basic_button_hold.gui +++ b/example/examples/basic/button/basic_button_hold.gui @@ -28,7 +28,7 @@ nodes { z: 0.624 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "button" parent: "root" inherit_alpha: true @@ -63,7 +63,7 @@ nodes { z: 0.62 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "button_image" parent: "mask" inherit_alpha: true diff --git a/example/examples/basic/checkbox/checkbox.gui b/example/examples/basic/checkbox/checkbox.gui index 3424105..445fc15 100644 --- a/example/examples/basic/checkbox/checkbox.gui +++ b/example/examples/basic/checkbox/checkbox.gui @@ -28,7 +28,7 @@ nodes { z: 0.49 } type: TYPE_BOX - texture: "druid/rect_round2_width1" + texture: "druid_example/rect_round2_width1" id: "button" parent: "root" inherit_alpha: true @@ -46,7 +46,7 @@ nodes { z: 0.761 } type: TYPE_BOX - texture: "druid/icon_check" + texture: "druid_example/icon_check" id: "icon" parent: "button" inherit_alpha: true @@ -66,7 +66,7 @@ nodes { z: 0.333 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "selected" pivot: PIVOT_S adjust_mode: ADJUST_MODE_STRETCH diff --git a/example/examples/basic/checkbox_group/checkbox_group.gui b/example/examples/basic/checkbox_group/checkbox_group.gui index 2eeaef4..a51e797 100644 --- a/example/examples/basic/checkbox_group/checkbox_group.gui +++ b/example/examples/basic/checkbox_group/checkbox_group.gui @@ -27,30 +27,6 @@ nodes { inherit_alpha: true template: "/example/examples/basic/checkbox/checkbox.gui" } -nodes { - type: TYPE_BOX - id: "checkbox_1/root" - parent: "checkbox_1" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "checkbox_1/button" - parent: "checkbox_1/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "checkbox_1/icon" - parent: "checkbox_1/button" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "checkbox_1/selected" - parent: "checkbox_1/button" - template_node_child: true -} nodes { type: TYPE_TEMPLATE id: "checkbox_2" @@ -58,30 +34,6 @@ nodes { inherit_alpha: true template: "/example/examples/basic/checkbox/checkbox.gui" } -nodes { - type: TYPE_BOX - id: "checkbox_2/root" - parent: "checkbox_2" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "checkbox_2/button" - parent: "checkbox_2/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "checkbox_2/icon" - parent: "checkbox_2/button" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "checkbox_2/selected" - parent: "checkbox_2/button" - template_node_child: true -} nodes { position { x: 100.0 @@ -92,29 +44,5 @@ nodes { inherit_alpha: true template: "/example/examples/basic/checkbox/checkbox.gui" } -nodes { - type: TYPE_BOX - id: "checkbox_3/root" - parent: "checkbox_3" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "checkbox_3/button" - parent: "checkbox_3/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "checkbox_3/icon" - parent: "checkbox_3/button" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "checkbox_3/selected" - parent: "checkbox_3/button" - template_node_child: true -} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/example/examples/basic/drag/drag.gui b/example/examples/basic/drag/drag.gui index 563e9bd..c4ea468 100644 --- a/example/examples/basic/drag/drag.gui +++ b/example/examples/basic/drag/drag.gui @@ -19,19 +19,5 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_blue.gui" } -nodes { - type: TYPE_BOX - id: "drag/root" - parent: "drag" - template_node_child: true -} -nodes { - type: TYPE_TEXT - text: "Drag Me" - id: "drag/text" - parent: "drag/root" - overridden_fields: 8 - template_node_child: true -} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/example/examples/basic/drag/drag_to_node.gui b/example/examples/basic/drag/drag_to_node.gui index 156bff0..1bc8e22 100644 --- a/example/examples/basic/drag/drag_to_node.gui +++ b/example/examples/basic/drag/drag_to_node.gui @@ -23,20 +23,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_blue.gui" } -nodes { - type: TYPE_BOX - id: "drag/root" - parent: "drag" - template_node_child: true -} -nodes { - type: TYPE_TEXT - text: "Drag Me" - id: "drag/text" - parent: "drag/root" - overridden_fields: 8 - template_node_child: true -} nodes { position { y: 300.0 @@ -51,7 +37,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/ui_circle_64" + texture: "druid_example/ui_circle_64" id: "zone" parent: "root" inherit_alpha: true diff --git a/example/examples/basic/grid/grid.gui b/example/examples/basic/grid/grid.gui index 99b7011..93a555a 100644 --- a/example/examples/basic/grid/grid.gui +++ b/example/examples/basic/grid/grid.gui @@ -12,7 +12,7 @@ nodes { y: 1000.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "root" inherit_alpha: true visible: false @@ -31,7 +31,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "grid" pivot: PIVOT_N parent: "root" @@ -65,7 +65,7 @@ nodes { z: 0.961 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "panel" parent: "prefab" inherit_alpha: true diff --git a/example/examples/basic/hover/hover.gui b/example/examples/basic/hover/hover.gui index 1d6b74e..30312c1 100644 --- a/example/examples/basic/hover/hover.gui +++ b/example/examples/basic/hover/hover.gui @@ -22,20 +22,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } -nodes { - type: TYPE_BOX - id: "button_mouse_hover/root" - parent: "button_mouse_hover" - template_node_child: true -} -nodes { - type: TYPE_TEXT - text: "Mouse Hover" - id: "button_mouse_hover/text" - parent: "button_mouse_hover/root" - overridden_fields: 8 - template_node_child: true -} nodes { position { y: -100.0 @@ -46,19 +32,5 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } -nodes { - type: TYPE_BOX - id: "button_mobile_hover/root" - parent: "button_mobile_hover" - template_node_child: true -} -nodes { - type: TYPE_TEXT - text: "Mobile Hover" - id: "button_mobile_hover/text" - parent: "button_mobile_hover/root" - overridden_fields: 8 - template_node_child: true -} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/example/examples/basic/input/basic_input.gui b/example/examples/basic/input/basic_input.gui index c4405a8..c13ede9 100644 --- a/example/examples/basic/input/basic_input.gui +++ b/example/examples/basic/input/basic_input.gui @@ -1,406 +1,29 @@ -script: "" -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: 1000.0 y: 1000.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: "" 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_MANUAL - custom_type: 0 - enabled: true visible: false - material: "" } 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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } type: TYPE_TEMPLATE id: "input" parent: "root" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/input.gui" - template_node_child: false - custom_type: 0 - enabled: true } 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: 500.0 - y: 80.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.463 - y: 0.475 - z: 0.49 - w: 1.0 - } - type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/rect_round2_width1" - id: "input/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT - parent: "input" - layer: "" - inherit_alpha: true - slice9 { - x: 4.0 - y: 4.0 - z: 4.0 - w: 4.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" -} -nodes { - position { - x: -240.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: 480.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.722 - y: 0.741 - z: 0.761 - w: 1.0 - } - type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "Tap me to input" - font: "text_bold" - id: "input/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_W - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false - parent: "input/root" - layer: "" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 - template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" -} -nodes { - position { - x: 0.0 y: -150.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: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "input_2" parent: "root" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/example/templates/input.gui" - template_node_child: false - custom_type: 0 - enabled: true -} -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: 500.0 - y: 80.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.463 - y: 0.475 - z: 0.49 - w: 1.0 - } - type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "druid/rect_round2_width1" - id: "input_2/root" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT - parent: "input_2" - layer: "" - inherit_alpha: true - slice9 { - x: 4.0 - y: 4.0 - z: 4.0 - w: 4.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: true - size_mode: SIZE_MODE_MANUAL - custom_type: 0 - enabled: true - visible: true - material: "" -} -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: 480.0 - y: 50.0 - z: 0.0 - w: 1.0 - } - color { - x: 0.722 - y: 0.741 - z: 0.761 - w: 1.0 - } - type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "Tap me to input" - font: "text_bold" - id: "input_2/text" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false - parent: "input_2/root" - layer: "" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 0.0 - overridden_fields: 1 - overridden_fields: 14 - template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 - custom_type: 0 - enabled: true - visible: true - material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/example/examples/basic/input/input_password.gui b/example/examples/basic/input/input_password.gui index c93752a..03bdeef 100644 --- a/example/examples/basic/input/input_password.gui +++ b/example/examples/basic/input/input_password.gui @@ -15,19 +15,5 @@ nodes { inherit_alpha: true template: "/example/templates/input.gui" } -nodes { - type: TYPE_BOX - id: "input/root" - parent: "input" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "input/text" - parent: "input/root" - overridden_fields: 1 - overridden_fields: 14 - template_node_child: true -} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/example/examples/basic/input/rich_input.gui b/example/examples/basic/input/rich_input.gui index 1e09607..89e445d 100644 --- a/example/examples/basic/input/rich_input.gui +++ b/example/examples/basic/input/rich_input.gui @@ -19,55 +19,6 @@ nodes { inherit_alpha: true template: "/example/templates/rich_input.gui" } -nodes { - type: TYPE_BOX - id: "rich_input/root" - parent: "rich_input" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "rich_input/button" - parent: "rich_input/root" - template_node_child: true -} -nodes { - position { - x: -240.0 - } - type: TYPE_TEXT - id: "rich_input/placeholder_text" - pivot: PIVOT_W - parent: "rich_input/button" - overridden_fields: 1 - overridden_fields: 14 - template_node_child: true -} -nodes { - position { - x: -240.0 - } - type: TYPE_TEXT - id: "rich_input/input_text" - pivot: PIVOT_W - parent: "rich_input/button" - overridden_fields: 1 - overridden_fields: 14 - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "rich_input/cursor_node" - parent: "rich_input/button" - overridden_fields: 1 - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "rich_input/cursor_text" - parent: "rich_input/cursor_node" - template_node_child: true -} nodes { position { y: -150.0 @@ -78,42 +29,5 @@ nodes { inherit_alpha: true template: "/example/templates/rich_input.gui" } -nodes { - type: TYPE_BOX - id: "rich_input_2/root" - parent: "rich_input_2" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "rich_input_2/button" - parent: "rich_input_2/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "rich_input_2/placeholder_text" - parent: "rich_input_2/button" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "rich_input_2/input_text" - parent: "rich_input_2/button" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "rich_input_2/cursor_node" - parent: "rich_input_2/button" - overridden_fields: 1 - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "rich_input_2/cursor_text" - parent: "rich_input_2/cursor_node" - template_node_child: true -} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/example/examples/basic/progress_bar/basic_progress_bar.gui b/example/examples/basic/progress_bar/basic_progress_bar.gui index c119df4..a46689f 100644 --- a/example/examples/basic/progress_bar/basic_progress_bar.gui +++ b/example/examples/basic/progress_bar/basic_progress_bar.gui @@ -30,7 +30,7 @@ nodes { z: 0.49 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "progress_bar_back" pivot: PIVOT_W parent: "root" @@ -47,7 +47,7 @@ nodes { z: 0.961 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "progress_bar_fill" pivot: PIVOT_W parent: "progress_bar_back" diff --git a/example/examples/basic/progress_bar/basic_progress_bar_slice9.gui b/example/examples/basic/progress_bar/basic_progress_bar_slice9.gui index 271abd2..133f0c7 100644 --- a/example/examples/basic/progress_bar/basic_progress_bar_slice9.gui +++ b/example/examples/basic/progress_bar/basic_progress_bar_slice9.gui @@ -30,7 +30,7 @@ nodes { z: 0.49 } type: TYPE_BOX - texture: "druid/ui_circle_16" + texture: "druid_example/ui_circle_16" id: "progress_bar_back" pivot: PIVOT_W parent: "root" @@ -53,7 +53,7 @@ nodes { z: 0.961 } type: TYPE_BOX - texture: "druid/ui_circle_16" + texture: "druid_example/ui_circle_16" id: "progress_bar_fill" pivot: PIVOT_W parent: "progress_bar_back" diff --git a/example/examples/basic/radio_group/radio_group.gui b/example/examples/basic/radio_group/radio_group.gui index 7b7f98c..a51e797 100644 --- a/example/examples/basic/radio_group/radio_group.gui +++ b/example/examples/basic/radio_group/radio_group.gui @@ -27,55 +27,6 @@ nodes { inherit_alpha: true template: "/example/examples/basic/checkbox/checkbox.gui" } -nodes { - type: TYPE_BOX - id: "checkbox_1/root" - parent: "checkbox_1" - template_node_child: true -} -nodes { - color { - x: 0.31 - y: 0.318 - z: 0.322 - } - type: TYPE_BOX - texture: "druid/ui_circle_32" - id: "checkbox_1/button" - parent: "checkbox_1/root" - slice9 { - x: 8.0 - y: 8.0 - z: 8.0 - w: 8.0 - } - overridden_fields: 5 - overridden_fields: 9 - overridden_fields: 22 - template_node_child: true -} -nodes { - type: TYPE_BOX - texture: "druid/ui_circle_16" - id: "checkbox_1/icon" - parent: "checkbox_1/button" - overridden_fields: 9 - template_node_child: true -} -nodes { - position { - y: -8.0 - } - type: TYPE_BOX - texture: "druid/ui_circle_16" - id: "checkbox_1/selected" - parent: "checkbox_1/button" - overridden_fields: 1 - overridden_fields: 9 - overridden_fields: 38 - template_node_child: true - size_mode: SIZE_MODE_AUTO -} nodes { type: TYPE_TEMPLATE id: "checkbox_2" @@ -83,55 +34,6 @@ nodes { inherit_alpha: true template: "/example/examples/basic/checkbox/checkbox.gui" } -nodes { - type: TYPE_BOX - id: "checkbox_2/root" - parent: "checkbox_2" - template_node_child: true -} -nodes { - color { - x: 0.31 - y: 0.318 - z: 0.322 - } - type: TYPE_BOX - texture: "druid/ui_circle_32" - id: "checkbox_2/button" - parent: "checkbox_2/root" - slice9 { - x: 8.0 - y: 8.0 - z: 8.0 - w: 8.0 - } - overridden_fields: 5 - overridden_fields: 9 - overridden_fields: 22 - template_node_child: true -} -nodes { - type: TYPE_BOX - texture: "druid/ui_circle_16" - id: "checkbox_2/icon" - parent: "checkbox_2/button" - overridden_fields: 9 - template_node_child: true -} -nodes { - position { - y: -8.0 - } - type: TYPE_BOX - texture: "druid/ui_circle_16" - id: "checkbox_2/selected" - parent: "checkbox_2/button" - overridden_fields: 1 - overridden_fields: 9 - overridden_fields: 38 - template_node_child: true - size_mode: SIZE_MODE_AUTO -} nodes { position { x: 100.0 @@ -142,54 +44,5 @@ nodes { inherit_alpha: true template: "/example/examples/basic/checkbox/checkbox.gui" } -nodes { - type: TYPE_BOX - id: "checkbox_3/root" - parent: "checkbox_3" - template_node_child: true -} -nodes { - color { - x: 0.31 - y: 0.318 - z: 0.322 - } - type: TYPE_BOX - texture: "druid/ui_circle_32" - id: "checkbox_3/button" - parent: "checkbox_3/root" - slice9 { - x: 8.0 - y: 8.0 - z: 8.0 - w: 8.0 - } - overridden_fields: 5 - overridden_fields: 9 - overridden_fields: 22 - template_node_child: true -} -nodes { - type: TYPE_BOX - texture: "druid/ui_circle_16" - id: "checkbox_3/icon" - parent: "checkbox_3/button" - overridden_fields: 9 - template_node_child: true -} -nodes { - position { - y: -8.0 - } - type: TYPE_BOX - texture: "druid/ui_circle_16" - id: "checkbox_3/selected" - parent: "checkbox_3/button" - overridden_fields: 1 - overridden_fields: 9 - overridden_fields: 38 - template_node_child: true - size_mode: SIZE_MODE_AUTO -} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/example/examples/basic/rich_text/rich_text_tags.gui b/example/examples/basic/rich_text/rich_text_tags.gui index f81b596..0105d87 100644 --- a/example/examples/basic/rich_text/rich_text_tags.gui +++ b/example/examples/basic/rich_text/rich_text_tags.gui @@ -35,7 +35,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/ui_circle_64" + texture: "druid_example/ui_circle_64" id: "background" parent: "root" inherit_alpha: true diff --git a/example/examples/basic/scroll/scroll.gui b/example/examples/basic/scroll/scroll.gui index 335b0e5..fe6722b 100644 --- a/example/examples/basic/scroll/scroll.gui +++ b/example/examples/basic/scroll/scroll.gui @@ -27,7 +27,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "scroll_view" parent: "root" inherit_alpha: true @@ -53,7 +53,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "scroll_content" pivot: PIVOT_N parent: "scroll_view" @@ -76,20 +76,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } -nodes { - type: TYPE_BOX - id: "button_tutorial/root" - parent: "button_tutorial" - template_node_child: true -} -nodes { - type: TYPE_TEXT - text: "I do nothing!" - id: "button_tutorial/text" - parent: "button_tutorial/root" - overridden_fields: 8 - template_node_child: true -} nodes { position { x: -185.0 @@ -302,32 +288,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } -nodes { - type: TYPE_BOX - id: "button_stencil/root" - parent: "button_stencil" - template_node_child: true -} -nodes { - scale { - x: 0.8 - y: 0.8 - } - size { - x: 300.0 - y: 50.0 - } - type: TYPE_TEXT - text: "Click outside stencil node" - id: "button_stencil/text" - line_break: true - parent: "button_stencil/root" - overridden_fields: 3 - overridden_fields: 4 - overridden_fields: 8 - overridden_fields: 18 - template_node_child: true -} nodes { position { x: -185.0 diff --git a/example/examples/basic/scroll_bind_grid/scroll_bind_grid.gui b/example/examples/basic/scroll_bind_grid/scroll_bind_grid.gui index a0eb02f..5fabe31 100644 --- a/example/examples/basic/scroll_bind_grid/scroll_bind_grid.gui +++ b/example/examples/basic/scroll_bind_grid/scroll_bind_grid.gui @@ -12,7 +12,7 @@ nodes { y: 1000.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "root" inherit_alpha: true visible: false @@ -31,7 +31,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "view" pivot: PIVOT_N parent: "root" @@ -50,7 +50,7 @@ nodes { y: 800.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "content" pivot: PIVOT_N parent: "view" @@ -82,7 +82,7 @@ nodes { z: 0.961 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "panel" parent: "prefab" inherit_alpha: true diff --git a/example/examples/basic/scroll_bind_grid/scroll_bind_grid_horizontal.gui b/example/examples/basic/scroll_bind_grid/scroll_bind_grid_horizontal.gui index f16a69e..18ad39c 100644 --- a/example/examples/basic/scroll_bind_grid/scroll_bind_grid_horizontal.gui +++ b/example/examples/basic/scroll_bind_grid/scroll_bind_grid_horizontal.gui @@ -12,7 +12,7 @@ nodes { y: 1000.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "root" inherit_alpha: true visible: false @@ -31,7 +31,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "view" pivot: PIVOT_W parent: "root" @@ -50,7 +50,7 @@ nodes { y: 360.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "content" pivot: PIVOT_W parent: "view" @@ -82,7 +82,7 @@ nodes { z: 0.961 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "panel" parent: "prefab" inherit_alpha: true diff --git a/example/examples/basic/scroll_bind_grid/scroll_bind_grid_points.gui b/example/examples/basic/scroll_bind_grid/scroll_bind_grid_points.gui index 603dbfd..a973517 100644 --- a/example/examples/basic/scroll_bind_grid/scroll_bind_grid_points.gui +++ b/example/examples/basic/scroll_bind_grid/scroll_bind_grid_points.gui @@ -12,7 +12,7 @@ nodes { y: 1000.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "root" inherit_alpha: true visible: false @@ -31,7 +31,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "view" pivot: PIVOT_N parent: "root" @@ -50,7 +50,7 @@ nodes { y: 800.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "content" pivot: PIVOT_N parent: "view" @@ -82,7 +82,7 @@ nodes { z: 0.961 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "panel" parent: "prefab" inherit_alpha: true diff --git a/example/examples/basic/scroll_slider/scroll_slider.gui b/example/examples/basic/scroll_slider/scroll_slider.gui index c056010..0766e91 100644 --- a/example/examples/basic/scroll_slider/scroll_slider.gui +++ b/example/examples/basic/scroll_slider/scroll_slider.gui @@ -27,7 +27,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "scroll_view" parent: "root" inherit_alpha: true @@ -53,7 +53,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "scroll_content" pivot: PIVOT_N parent: "scroll_view" @@ -76,27 +76,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } -nodes { - type: TYPE_BOX - id: "button1/root" - parent: "button1" - template_node_child: true -} -nodes { - scale { - x: 0.9 - y: 0.9 - } - type: TYPE_TEXT - text: "Tap to scroll 1" - id: "button1/text" - line_break: true - parent: "button1/root" - overridden_fields: 3 - overridden_fields: 8 - overridden_fields: 18 - template_node_child: true -} nodes { position { y: -300.0 @@ -107,27 +86,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } -nodes { - type: TYPE_BOX - id: "button2/root" - parent: "button2" - template_node_child: true -} -nodes { - scale { - x: 0.9 - y: 0.9 - } - type: TYPE_TEXT - text: "Tap to scroll 2" - id: "button2/text" - line_break: true - parent: "button2/root" - overridden_fields: 3 - overridden_fields: 8 - overridden_fields: 18 - template_node_child: true -} nodes { position { y: -500.0 @@ -138,27 +96,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } -nodes { - type: TYPE_BOX - id: "button3/root" - parent: "button3" - template_node_child: true -} -nodes { - scale { - x: 0.9 - y: 0.9 - } - type: TYPE_TEXT - text: "Tap to scroll 3" - id: "button3/text" - line_break: true - parent: "button3/root" - overridden_fields: 3 - overridden_fields: 8 - overridden_fields: 18 - template_node_child: true -} nodes { position { y: -700.0 @@ -169,27 +106,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } -nodes { - type: TYPE_BOX - id: "button4/root" - parent: "button4" - template_node_child: true -} -nodes { - scale { - x: 0.9 - y: 0.9 - } - type: TYPE_TEXT - text: "Tap to scroll 4" - id: "button4/text" - line_break: true - parent: "button4/root" - overridden_fields: 3 - overridden_fields: 8 - overridden_fields: 18 - template_node_child: true -} nodes { position { y: -900.0 @@ -200,27 +116,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } -nodes { - type: TYPE_BOX - id: "button5/root" - parent: "button5" - template_node_child: true -} -nodes { - scale { - x: 0.9 - y: 0.9 - } - type: TYPE_TEXT - text: "Tap to scroll 5" - id: "button5/text" - line_break: true - parent: "button5/root" - overridden_fields: 3 - overridden_fields: 8 - overridden_fields: 18 - template_node_child: true -} nodes { position { y: -1100.0 @@ -231,27 +126,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } -nodes { - type: TYPE_BOX - id: "button6/root" - parent: "button6" - template_node_child: true -} -nodes { - scale { - x: 0.9 - y: 0.9 - } - type: TYPE_TEXT - text: "Tap to scroll 6" - id: "button6/text" - line_break: true - parent: "button6/root" - overridden_fields: 3 - overridden_fields: 8 - overridden_fields: 18 - template_node_child: true -} nodes { position { y: -1300.0 @@ -262,27 +136,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } -nodes { - type: TYPE_BOX - id: "button7/root" - parent: "button7" - template_node_child: true -} -nodes { - scale { - x: 0.9 - y: 0.9 - } - type: TYPE_TEXT - text: "Tap to scroll 7" - id: "button7/text" - line_break: true - parent: "button7/root" - overridden_fields: 3 - overridden_fields: 8 - overridden_fields: 18 - template_node_child: true -} nodes { position { y: -1500.0 @@ -293,27 +146,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } -nodes { - type: TYPE_BOX - id: "button8/root" - parent: "button8" - template_node_child: true -} -nodes { - scale { - x: 0.9 - y: 0.9 - } - type: TYPE_TEXT - text: "Tap to scroll 8" - id: "button8/text" - line_break: true - parent: "button8/root" - overridden_fields: 3 - overridden_fields: 8 - overridden_fields: 18 - template_node_child: true -} nodes { position { y: -1700.0 @@ -324,27 +156,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } -nodes { - type: TYPE_BOX - id: "button9/root" - parent: "button9" - template_node_child: true -} -nodes { - scale { - x: 0.9 - y: 0.9 - } - type: TYPE_TEXT - text: "Tap to scroll 9" - id: "button9/text" - line_break: true - parent: "button9/root" - overridden_fields: 3 - overridden_fields: 8 - overridden_fields: 18 - template_node_child: true -} nodes { position { y: -1900.0 @@ -355,27 +166,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } -nodes { - type: TYPE_BOX - id: "button10/root" - parent: "button10" - template_node_child: true -} -nodes { - scale { - x: 0.9 - y: 0.9 - } - type: TYPE_TEXT - text: "Tap to scroll 10" - id: "button10/text" - line_break: true - parent: "button10/root" - overridden_fields: 3 - overridden_fields: 8 - overridden_fields: 18 - template_node_child: true -} nodes { position { y: -2100.0 @@ -386,27 +176,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } -nodes { - type: TYPE_BOX - id: "button11/root" - parent: "button11" - template_node_child: true -} -nodes { - scale { - x: 0.9 - y: 0.9 - } - type: TYPE_TEXT - text: "Tap to scroll 11" - id: "button11/text" - line_break: true - parent: "button11/root" - overridden_fields: 3 - overridden_fields: 8 - overridden_fields: 18 - template_node_child: true -} nodes { position { y: -2300.0 @@ -417,27 +186,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } -nodes { - type: TYPE_BOX - id: "button12/root" - parent: "button12" - template_node_child: true -} -nodes { - scale { - x: 0.9 - y: 0.9 - } - type: TYPE_TEXT - text: "Tap to scroll 12" - id: "button12/text" - line_break: true - parent: "button12/root" - overridden_fields: 3 - overridden_fields: 8 - overridden_fields: 18 - template_node_child: true -} nodes { position { y: -2500.0 @@ -448,27 +196,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } -nodes { - type: TYPE_BOX - id: "button13/root" - parent: "button13" - template_node_child: true -} -nodes { - scale { - x: 0.9 - y: 0.9 - } - type: TYPE_TEXT - text: "Tap to scroll 13" - id: "button13/text" - line_break: true - parent: "button13/root" - overridden_fields: 3 - overridden_fields: 8 - overridden_fields: 18 - template_node_child: true -} nodes { position { x: 200.0 @@ -484,7 +211,7 @@ nodes { z: 0.322 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "slider_back" pivot: PIVOT_NE parent: "scroll_view" @@ -505,7 +232,7 @@ nodes { z: 0.49 } type: TYPE_BOX - texture: "druid/ui_circle_16" + texture: "druid_example/ui_circle_16" id: "slider_pin" parent: "slider_back" inherit_alpha: true diff --git a/example/examples/basic/slider/basic_slider.gui b/example/examples/basic/slider/basic_slider.gui index 7b39ff8..7c15e3e 100644 --- a/example/examples/basic/slider/basic_slider.gui +++ b/example/examples/basic/slider/basic_slider.gui @@ -17,7 +17,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/ui_circle_64" + texture: "druid_example/ui_circle_64" id: "root" inherit_alpha: true slice9 { @@ -34,24 +34,6 @@ nodes { inherit_alpha: true template: "/example/templates/slider.gui" } -nodes { - type: TYPE_BOX - id: "slider/root" - parent: "slider" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "slider/slider_back" - parent: "slider/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "slider/slider_pin" - parent: "slider/root" - template_node_child: true -} nodes { position { y: 50.0 diff --git a/example/examples/basic/slider/basic_slider_stepped.gui b/example/examples/basic/slider/basic_slider_stepped.gui index 7b39ff8..7c15e3e 100644 --- a/example/examples/basic/slider/basic_slider_stepped.gui +++ b/example/examples/basic/slider/basic_slider_stepped.gui @@ -17,7 +17,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/ui_circle_64" + texture: "druid_example/ui_circle_64" id: "root" inherit_alpha: true slice9 { @@ -34,24 +34,6 @@ nodes { inherit_alpha: true template: "/example/templates/slider.gui" } -nodes { - type: TYPE_BOX - id: "slider/root" - parent: "slider" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "slider/slider_back" - parent: "slider/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "slider/slider_pin" - parent: "slider/root" - template_node_child: true -} nodes { position { y: 50.0 diff --git a/example/examples/basic/slider/basic_slider_vertical.gui b/example/examples/basic/slider/basic_slider_vertical.gui index bcddcd4..b59f960 100644 --- a/example/examples/basic/slider/basic_slider_vertical.gui +++ b/example/examples/basic/slider/basic_slider_vertical.gui @@ -17,7 +17,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/ui_circle_64" + texture: "druid_example/ui_circle_64" id: "root" inherit_alpha: true slice9 { @@ -34,38 +34,6 @@ nodes { inherit_alpha: true template: "/example/templates/slider.gui" } -nodes { - size { - x: 40.0 - y: 260.0 - } - type: TYPE_BOX - id: "slider/root" - parent: "slider" - overridden_fields: 4 - template_node_child: true -} -nodes { - size { - x: 9.0 - y: 260.0 - } - type: TYPE_BOX - id: "slider/slider_back" - parent: "slider/root" - overridden_fields: 4 - template_node_child: true -} -nodes { - position { - y: 118.0 - } - type: TYPE_BOX - id: "slider/slider_pin" - parent: "slider/root" - overridden_fields: 1 - template_node_child: true -} nodes { position { y: 170.0 diff --git a/example/examples/basic/swipe/basic_swipe.gui b/example/examples/basic/swipe/basic_swipe.gui index aa45a77..5889073 100644 --- a/example/examples/basic/swipe/basic_swipe.gui +++ b/example/examples/basic/swipe/basic_swipe.gui @@ -17,7 +17,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/ui_circle_64" + texture: "druid_example/ui_circle_64" id: "root" inherit_alpha: true slice9 { diff --git a/example/examples/basic/text/basic_text.gui b/example/examples/basic/text/basic_text.gui index 24b413a..0fb22eb 100644 --- a/example/examples/basic/text/basic_text.gui +++ b/example/examples/basic/text/basic_text.gui @@ -28,7 +28,7 @@ nodes { z: 0.49 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "text_area" parent: "root" inherit_alpha: true diff --git a/example/examples/basic/text/multiline_text.gui b/example/examples/basic/text/multiline_text.gui index 5025ac8..b4c491a 100644 --- a/example/examples/basic/text/multiline_text.gui +++ b/example/examples/basic/text/multiline_text.gui @@ -28,7 +28,7 @@ nodes { z: 0.49 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "text_area" parent: "root" inherit_alpha: true diff --git a/example/examples/data_list/add_remove_clear/data_list_add_remove_clear.gui b/example/examples/data_list/add_remove_clear/data_list_add_remove_clear.gui index 01a8037..3fad7ab 100644 --- a/example/examples/data_list/add_remove_clear/data_list_add_remove_clear.gui +++ b/example/examples/data_list/add_remove_clear/data_list_add_remove_clear.gui @@ -8,7 +8,7 @@ textures { } nodes { type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "root" inherit_alpha: true size_mode: SIZE_MODE_AUTO @@ -28,7 +28,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "view" pivot: PIVOT_N parent: "root" @@ -41,7 +41,7 @@ nodes { y: 700.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "content" pivot: PIVOT_N parent: "view" @@ -73,7 +73,7 @@ nodes { z: 0.961 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "panel" parent: "prefab" inherit_alpha: true diff --git a/example/examples/data_list/basic/data_list_basic.gui b/example/examples/data_list/basic/data_list_basic.gui index 01a8037..3fad7ab 100644 --- a/example/examples/data_list/basic/data_list_basic.gui +++ b/example/examples/data_list/basic/data_list_basic.gui @@ -8,7 +8,7 @@ textures { } nodes { type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "root" inherit_alpha: true size_mode: SIZE_MODE_AUTO @@ -28,7 +28,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "view" pivot: PIVOT_N parent: "root" @@ -41,7 +41,7 @@ nodes { y: 700.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "content" pivot: PIVOT_N parent: "view" @@ -73,7 +73,7 @@ nodes { z: 0.961 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "panel" parent: "prefab" inherit_alpha: true diff --git a/example/examples/data_list/basic/data_list_horizontal_basic.gui b/example/examples/data_list/basic/data_list_horizontal_basic.gui index 7113e09..e6e975b 100644 --- a/example/examples/data_list/basic/data_list_horizontal_basic.gui +++ b/example/examples/data_list/basic/data_list_horizontal_basic.gui @@ -8,7 +8,7 @@ textures { } nodes { type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "root" inherit_alpha: true size_mode: SIZE_MODE_AUTO @@ -28,7 +28,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "view" pivot: PIVOT_W parent: "root" @@ -41,7 +41,7 @@ nodes { y: 350.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "content" pivot: PIVOT_W parent: "view" @@ -73,7 +73,7 @@ nodes { z: 0.961 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "panel" parent: "prefab" inherit_alpha: true diff --git a/example/examples/data_list/cache_with_component/button_component.gui b/example/examples/data_list/cache_with_component/button_component.gui index 108be79..42d14cc 100644 --- a/example/examples/data_list/cache_with_component/button_component.gui +++ b/example/examples/data_list/cache_with_component/button_component.gui @@ -27,7 +27,7 @@ nodes { z: 0.961 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "panel" parent: "root" inherit_alpha: true diff --git a/example/examples/data_list/cache_with_component/cache_with_component.gui b/example/examples/data_list/cache_with_component/cache_with_component.gui index e5fed03..1be4909 100644 --- a/example/examples/data_list/cache_with_component/cache_with_component.gui +++ b/example/examples/data_list/cache_with_component/cache_with_component.gui @@ -8,7 +8,7 @@ textures { } nodes { type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "root" inherit_alpha: true size_mode: SIZE_MODE_AUTO @@ -28,7 +28,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "view" pivot: PIVOT_N parent: "root" @@ -41,7 +41,7 @@ nodes { y: 700.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "content" pivot: PIVOT_N parent: "view" @@ -58,23 +58,5 @@ nodes { inherit_alpha: true template: "/example/examples/data_list/cache_with_component/button_component.gui" } -nodes { - type: TYPE_BOX - id: "button_component/root" - parent: "button_component" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "button_component/panel" - parent: "button_component/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "button_component/text" - parent: "button_component/root" - template_node_child: true -} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/example/examples/druid_examples.lua b/example/examples/druid_examples.lua index 6303e80..62ec6d2 100644 --- a/example/examples/druid_examples.lua +++ b/example/examples/druid_examples.lua @@ -18,8 +18,9 @@ local M = {} ---@field root string ---@field template string|nil ---@field code_url string|nil @URL to the source code ----@field component_class druid.base_component ----@field on_create fun(instance: druid.base_component, output_list: output_list)|nil +---@field component_class druid.base_component|nil +---@field widget_class druid.widget|nil New way to create components +---@field on_create fun(instance: druid.base_component|druid.widget, output_list: output_list)|nil ---@field get_debug_info (fun(instance: druid.base_component):string)|nil ---@field properties_control (fun(instance: druid.base_component, properties_panel: properties_panel))|nil ---@field information_text_id string|nil diff --git a/example/examples/gamepad/gamepad_tester/gamepad_tester.gui b/example/examples/gamepad/gamepad_tester/gamepad_tester.gui index 993e543..4dbc25b 100644 --- a/example/examples/gamepad/gamepad_tester/gamepad_tester.gui +++ b/example/examples/gamepad/gamepad_tester/gamepad_tester.gui @@ -8,7 +8,7 @@ nodes { y: 1000.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "root" inherit_alpha: true visible: false @@ -19,7 +19,7 @@ nodes { y: 100.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "gamepad" parent: "root" inherit_alpha: true @@ -36,66 +36,6 @@ nodes { inherit_alpha: true template: "/example/examples/gamepad/gamepad_tester/templates/gamepad_stick.gui" } -nodes { - type: TYPE_BOX - id: "stick_left/root" - parent: "stick_left" - template_node_child: true -} -nodes { - type: TYPE_PIE - id: "stick_left/background_mask" - parent: "stick_left/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "stick_left/background" - parent: "stick_left/background_mask" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "stick_left/stick_root" - parent: "stick_left/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "stick_left/stick_shadow" - parent: "stick_left/stick_root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "stick_left/stick" - parent: "stick_left/stick_root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "stick_left/dot_1" - parent: "stick_left/stick" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "stick_left/dot_2" - parent: "stick_left/stick" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "stick_left/dot_3" - parent: "stick_left/stick" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "stick_left/dot_4" - parent: "stick_left/stick" - template_node_child: true -} nodes { position { x: 200.0 @@ -107,66 +47,6 @@ nodes { inherit_alpha: true template: "/example/examples/gamepad/gamepad_tester/templates/gamepad_stick.gui" } -nodes { - type: TYPE_BOX - id: "stick_right/root" - parent: "stick_right" - template_node_child: true -} -nodes { - type: TYPE_PIE - id: "stick_right/background_mask" - parent: "stick_right/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "stick_right/background" - parent: "stick_right/background_mask" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "stick_right/stick_root" - parent: "stick_right/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "stick_right/stick_shadow" - parent: "stick_right/stick_root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "stick_right/stick" - parent: "stick_right/stick_root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "stick_right/dot_1" - parent: "stick_right/stick" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "stick_right/dot_2" - parent: "stick_right/stick" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "stick_right/dot_3" - parent: "stick_right/stick" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "stick_right/dot_4" - parent: "stick_right/stick" - template_node_child: true -} nodes { position { x: -330.0 @@ -177,7 +57,7 @@ nodes { y: 290.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "dpad" parent: "gamepad" inherit_alpha: true @@ -193,32 +73,6 @@ nodes { inherit_alpha: true template: "/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui" } -nodes { - type: TYPE_BOX - id: "button_left/button" - parent: "button_left" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "button_left/text" - parent: "button_left/button" - overridden_fields: 45 - overridden_fields: 46 - template_node_child: true - enabled: false - visible: false -} -nodes { - rotation { - z: 180.0 - } - type: TYPE_BOX - id: "button_left/icon" - parent: "button_left/button" - overridden_fields: 2 - template_node_child: true -} nodes { position { y: 100.0 @@ -229,32 +83,6 @@ nodes { inherit_alpha: true template: "/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui" } -nodes { - type: TYPE_BOX - id: "button_up/button" - parent: "button_up" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "button_up/text" - parent: "button_up/button" - overridden_fields: 45 - overridden_fields: 46 - template_node_child: true - enabled: false - visible: false -} -nodes { - rotation { - z: 90.0 - } - type: TYPE_BOX - id: "button_up/icon" - parent: "button_up/button" - overridden_fields: 2 - template_node_child: true -} nodes { position { x: 100.0 @@ -265,28 +93,6 @@ nodes { inherit_alpha: true template: "/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui" } -nodes { - type: TYPE_BOX - id: "button_right/button" - parent: "button_right" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "button_right/text" - parent: "button_right/button" - overridden_fields: 45 - overridden_fields: 46 - template_node_child: true - enabled: false - visible: false -} -nodes { - type: TYPE_BOX - id: "button_right/icon" - parent: "button_right/button" - template_node_child: true -} nodes { position { y: -100.0 @@ -297,32 +103,6 @@ nodes { inherit_alpha: true template: "/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui" } -nodes { - type: TYPE_BOX - id: "button_down/button" - parent: "button_down" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "button_down/text" - parent: "button_down/button" - overridden_fields: 45 - overridden_fields: 46 - template_node_child: true - enabled: false - visible: false -} -nodes { - rotation { - z: -90.0 - } - type: TYPE_BOX - id: "button_down/icon" - parent: "button_down/button" - overridden_fields: 2 - template_node_child: true -} nodes { position { x: 330.0 @@ -333,7 +113,7 @@ nodes { y: 290.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "buttons" parent: "gamepad" inherit_alpha: true @@ -349,26 +129,6 @@ nodes { inherit_alpha: true template: "/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui" } -nodes { - type: TYPE_BOX - id: "button_x/button" - parent: "button_x" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "button_x/text" - parent: "button_x/button" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "button_x/icon" - parent: "button_x/button" - overridden_fields: 45 - template_node_child: true - enabled: false -} nodes { position { y: 100.0 @@ -379,28 +139,6 @@ nodes { inherit_alpha: true template: "/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui" } -nodes { - type: TYPE_BOX - id: "button_y/button" - parent: "button_y" - template_node_child: true -} -nodes { - type: TYPE_TEXT - text: "Y" - id: "button_y/text" - parent: "button_y/button" - overridden_fields: 8 - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "button_y/icon" - parent: "button_y/button" - overridden_fields: 45 - template_node_child: true - enabled: false -} nodes { position { x: 100.0 @@ -411,28 +149,6 @@ nodes { inherit_alpha: true template: "/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui" } -nodes { - type: TYPE_BOX - id: "button_b/button" - parent: "button_b" - template_node_child: true -} -nodes { - type: TYPE_TEXT - text: "B" - id: "button_b/text" - parent: "button_b/button" - overridden_fields: 8 - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "button_b/icon" - parent: "button_b/button" - overridden_fields: 45 - template_node_child: true - enabled: false -} nodes { position { y: -100.0 @@ -443,28 +159,6 @@ nodes { inherit_alpha: true template: "/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui" } -nodes { - type: TYPE_BOX - id: "button_a/button" - parent: "button_a" - template_node_child: true -} -nodes { - type: TYPE_TEXT - text: "A" - id: "button_a/text" - parent: "button_a/button" - overridden_fields: 8 - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "button_a/icon" - parent: "button_a/button" - overridden_fields: 45 - template_node_child: true - enabled: false -} nodes { position { y: 160.0 @@ -474,7 +168,7 @@ nodes { y: 290.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "buttons_system" parent: "gamepad" inherit_alpha: true @@ -490,33 +184,6 @@ nodes { inherit_alpha: true template: "/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui" } -nodes { - size { - x: 180.0 - y: 90.0 - } - type: TYPE_BOX - id: "button_back/button" - parent: "button_back" - overridden_fields: 4 - template_node_child: true -} -nodes { - type: TYPE_TEXT - text: "Back" - id: "button_back/text" - parent: "button_back/button" - overridden_fields: 8 - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "button_back/icon" - parent: "button_back/button" - overridden_fields: 45 - template_node_child: true - enabled: false -} nodes { position { x: 110.0 @@ -527,33 +194,6 @@ nodes { inherit_alpha: true template: "/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui" } -nodes { - size { - x: 180.0 - y: 90.0 - } - type: TYPE_BOX - id: "button_start/button" - parent: "button_start" - overridden_fields: 4 - template_node_child: true -} -nodes { - type: TYPE_TEXT - text: "Start" - id: "button_start/text" - parent: "button_start/button" - overridden_fields: 8 - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "button_start/icon" - parent: "button_start/button" - overridden_fields: 45 - template_node_child: true - enabled: false -} nodes { position { x: -330.0 @@ -564,7 +204,7 @@ nodes { y: 200.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "button_left_bump" parent: "gamepad" inherit_alpha: true @@ -581,33 +221,6 @@ nodes { inherit_alpha: true template: "/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui" } -nodes { - size { - x: 180.0 - y: 90.0 - } - type: TYPE_BOX - id: "button_l1/button" - parent: "button_l1" - overridden_fields: 4 - template_node_child: true -} -nodes { - type: TYPE_TEXT - text: "L1" - id: "button_l1/text" - parent: "button_l1/button" - overridden_fields: 8 - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "button_l1/icon" - parent: "button_l1/button" - overridden_fields: 45 - template_node_child: true - enabled: false -} nodes { position { y: 60.0 @@ -618,26 +231,6 @@ nodes { inherit_alpha: true template: "/example/examples/gamepad/gamepad_tester/templates/gamepad_trigger.gui" } -nodes { - type: TYPE_BOX - id: "button_l2/button" - parent: "button_l2" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "button_l2/fill" - parent: "button_l2/button" - template_node_child: true -} -nodes { - type: TYPE_TEXT - text: "L2" - id: "button_l2/text" - parent: "button_l2/button" - overridden_fields: 8 - template_node_child: true -} nodes { position { x: 330.0 @@ -648,7 +241,7 @@ nodes { y: 200.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "button_right_bump" parent: "gamepad" inherit_alpha: true @@ -664,33 +257,6 @@ nodes { inherit_alpha: true template: "/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui" } -nodes { - size { - x: 180.0 - y: 90.0 - } - type: TYPE_BOX - id: "button_r1/button" - parent: "button_r1" - overridden_fields: 4 - template_node_child: true -} -nodes { - type: TYPE_TEXT - text: "R1" - id: "button_r1/text" - parent: "button_r1/button" - overridden_fields: 8 - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "button_r1/icon" - parent: "button_r1/button" - overridden_fields: 45 - template_node_child: true - enabled: false -} nodes { position { y: 60.0 @@ -701,25 +267,5 @@ nodes { inherit_alpha: true template: "/example/examples/gamepad/gamepad_tester/templates/gamepad_trigger.gui" } -nodes { - type: TYPE_BOX - id: "button_r2/button" - parent: "button_r2" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "button_r2/fill" - parent: "button_r2/button" - template_node_child: true -} -nodes { - type: TYPE_TEXT - text: "R2" - id: "button_r2/text" - parent: "button_r2/button" - overridden_fields: 8 - template_node_child: true -} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui b/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui index 93d6581..b666dda 100644 --- a/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui +++ b/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui @@ -17,7 +17,7 @@ nodes { z: 0.322 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "button" inherit_alpha: true slice9 { @@ -65,7 +65,7 @@ nodes { y: 0.984 } type: TYPE_BOX - texture: "druid/icon_arrow" + texture: "druid_example/icon_arrow" id: "icon" parent: "button" inherit_alpha: true diff --git a/example/examples/gamepad/gamepad_tester/templates/gamepad_stick.gui b/example/examples/gamepad/gamepad_tester/templates/gamepad_stick.gui index 3505a94..215dc15 100644 --- a/example/examples/gamepad/gamepad_tester/templates/gamepad_stick.gui +++ b/example/examples/gamepad/gamepad_tester/templates/gamepad_stick.gui @@ -17,7 +17,7 @@ nodes { z: 0.322 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "root" inherit_alpha: true } @@ -46,7 +46,7 @@ nodes { z: 0.322 } type: TYPE_BOX - texture: "druid/pixel" + texture: "druid_example/pixel" id: "background" parent: "background_mask" inherit_alpha: true @@ -59,7 +59,7 @@ nodes { } nodes { type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "stick_root" parent: "root" inherit_alpha: true @@ -77,7 +77,7 @@ nodes { z: 0.0 } type: TYPE_BOX - texture: "druid/ui_circle_64_blur_8" + texture: "druid_example/ui_circle_64_blur_8" id: "stick_shadow" parent: "stick_root" inherit_alpha: true @@ -95,7 +95,7 @@ nodes { z: 0.49 } type: TYPE_BOX - texture: "druid/ui_circle_64" + texture: "druid_example/ui_circle_64" id: "stick" parent: "stick_root" inherit_alpha: true @@ -121,7 +121,7 @@ nodes { z: 0.322 } type: TYPE_BOX - texture: "druid/ui_circle_16" + texture: "druid_example/ui_circle_16" id: "dot_1" parent: "stick" inherit_alpha: true @@ -141,7 +141,7 @@ nodes { z: 0.322 } type: TYPE_BOX - texture: "druid/ui_circle_16" + texture: "druid_example/ui_circle_16" id: "dot_2" parent: "stick" inherit_alpha: true @@ -161,7 +161,7 @@ nodes { z: 0.322 } type: TYPE_BOX - texture: "druid/ui_circle_16" + texture: "druid_example/ui_circle_16" id: "dot_3" parent: "stick" inherit_alpha: true @@ -181,7 +181,7 @@ nodes { z: 0.322 } type: TYPE_BOX - texture: "druid/ui_circle_16" + texture: "druid_example/ui_circle_16" id: "dot_4" parent: "stick" inherit_alpha: true diff --git a/example/examples/gamepad/gamepad_tester/templates/gamepad_trigger.gui b/example/examples/gamepad/gamepad_tester/templates/gamepad_trigger.gui index e057ec9..3403f00 100644 --- a/example/examples/gamepad/gamepad_tester/templates/gamepad_trigger.gui +++ b/example/examples/gamepad/gamepad_tester/templates/gamepad_trigger.gui @@ -17,7 +17,7 @@ nodes { z: 0.322 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "button" inherit_alpha: true slice9 { @@ -41,7 +41,7 @@ nodes { z: 0.961 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "fill" pivot: PIVOT_W parent: "button" diff --git a/example/examples/gamepad/on_screen_control/on_screen_control.gui b/example/examples/gamepad/on_screen_control/on_screen_control.gui index 774696e..8fab1e3 100644 --- a/example/examples/gamepad/on_screen_control/on_screen_control.gui +++ b/example/examples/gamepad/on_screen_control/on_screen_control.gui @@ -13,7 +13,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/ui_circle_64" + texture: "druid_example/ui_circle_64" id: "root" inherit_alpha: true slice9 { @@ -34,7 +34,7 @@ nodes { z: 0.624 } type: TYPE_BOX - texture: "druid/ui_circle_64" + texture: "druid_example/ui_circle_64" id: "character" parent: "root" inherit_alpha: true @@ -56,7 +56,7 @@ nodes { z: 0.157 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "eye_left" parent: "character" inherit_alpha: true @@ -72,7 +72,7 @@ nodes { y: 0.984 } type: TYPE_BOX - texture: "druid/ui_circle_8" + texture: "druid_example/ui_circle_8" id: "eye_left_blick" parent: "eye_left" inherit_alpha: true @@ -89,7 +89,7 @@ nodes { z: 0.157 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "eye_right" parent: "character" inherit_alpha: true @@ -105,7 +105,7 @@ nodes { y: 0.984 } type: TYPE_BOX - texture: "druid/ui_circle_8" + texture: "druid_example/ui_circle_8" id: "eye_right_blick" parent: "eye_right" inherit_alpha: true @@ -133,66 +133,6 @@ nodes { parent: "on_screen_input/root" template_node_child: true } -nodes { - type: TYPE_BOX - id: "on_screen_input/on_screen_stick/root" - parent: "on_screen_input/on_screen_stick" - template_node_child: true -} -nodes { - type: TYPE_PIE - id: "on_screen_input/on_screen_stick/background_mask" - parent: "on_screen_input/on_screen_stick/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "on_screen_input/on_screen_stick/background" - parent: "on_screen_input/on_screen_stick/background_mask" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "on_screen_input/on_screen_stick/stick_root" - parent: "on_screen_input/on_screen_stick/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "on_screen_input/on_screen_stick/stick_shadow" - parent: "on_screen_input/on_screen_stick/stick_root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "on_screen_input/on_screen_stick/stick" - parent: "on_screen_input/on_screen_stick/stick_root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "on_screen_input/on_screen_stick/dot_1" - parent: "on_screen_input/on_screen_stick/stick" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "on_screen_input/on_screen_stick/dot_2" - parent: "on_screen_input/on_screen_stick/stick" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "on_screen_input/on_screen_stick/dot_3" - parent: "on_screen_input/on_screen_stick/stick" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "on_screen_input/on_screen_stick/dot_4" - parent: "on_screen_input/on_screen_stick/stick" - template_node_child: true -} nodes { type: TYPE_BOX id: "on_screen_input/on_screen_button" @@ -205,23 +145,5 @@ nodes { parent: "on_screen_input/on_screen_button" template_node_child: true } -nodes { - type: TYPE_BOX - id: "on_screen_input/button_action/button" - parent: "on_screen_input/button_action" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "on_screen_input/button_action/text" - parent: "on_screen_input/button_action/button" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "on_screen_input/button_action/icon" - parent: "on_screen_input/button_action/button" - template_node_child: true -} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/example/examples/gamepad/on_screen_control/on_screen_input.gui b/example/examples/gamepad/on_screen_control/on_screen_input.gui index f005c06..5a6dc92 100644 --- a/example/examples/gamepad/on_screen_control/on_screen_input.gui +++ b/example/examples/gamepad/on_screen_control/on_screen_input.gui @@ -22,71 +22,6 @@ nodes { inherit_alpha: true template: "/example/examples/gamepad/gamepad_tester/templates/gamepad_stick.gui" } -nodes { - size { - x: 400.0 - y: 400.0 - } - type: TYPE_BOX - id: "on_screen_stick/root" - parent: "on_screen_stick" - overridden_fields: 4 - template_node_child: true -} -nodes { - type: TYPE_PIE - id: "on_screen_stick/background_mask" - parent: "on_screen_stick/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "on_screen_stick/background" - parent: "on_screen_stick/background_mask" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "on_screen_stick/stick_root" - parent: "on_screen_stick/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "on_screen_stick/stick_shadow" - parent: "on_screen_stick/stick_root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "on_screen_stick/stick" - parent: "on_screen_stick/stick_root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "on_screen_stick/dot_1" - parent: "on_screen_stick/stick" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "on_screen_stick/dot_2" - parent: "on_screen_stick/stick" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "on_screen_stick/dot_3" - parent: "on_screen_stick/stick" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "on_screen_stick/dot_4" - parent: "on_screen_stick/stick" - template_node_child: true -} nodes { position { x: 300.0 @@ -108,25 +43,5 @@ nodes { inherit_alpha: true template: "/example/examples/gamepad/gamepad_tester/templates/gamepad_button.gui" } -nodes { - type: TYPE_BOX - id: "button_action/button" - parent: "button_action" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "button_action/text" - parent: "button_action/button" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "button_action/icon" - parent: "button_action/button" - overridden_fields: 45 - template_node_child: true - enabled: false -} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/example/examples/intro/intro/intro.gui b/example/examples/intro/intro/intro.gui index 61de634..78283a9 100644 --- a/example/examples/intro/intro/intro.gui +++ b/example/examples/intro/intro/intro.gui @@ -25,7 +25,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/ui_circle_64" + texture: "druid_example/ui_circle_64" id: "root" inherit_alpha: true slice9 { @@ -158,7 +158,7 @@ nodes { y: -364.0 } type: TYPE_BOX - texture: "druid/icon_heart" + texture: "druid_example/icon_heart" id: "icon_heart1" parent: "root" inherit_alpha: true @@ -170,7 +170,7 @@ nodes { y: -364.0 } type: TYPE_BOX - texture: "druid/icon_heart" + texture: "druid_example/icon_heart" id: "icon_heart2" parent: "root" inherit_alpha: true @@ -183,7 +183,7 @@ nodes { y: -364.0 } type: TYPE_BOX - texture: "druid/icon_heart" + texture: "druid_example/icon_heart" id: "icon_heart3" parent: "root" inherit_alpha: true diff --git a/example/examples/layout/basic/basic_layout.gui b/example/examples/layout/basic/basic_layout.gui index c411061..ed74c30 100644 --- a/example/examples/layout/basic/basic_layout.gui +++ b/example/examples/layout/basic/basic_layout.gui @@ -13,7 +13,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/ui_circle_64" + texture: "druid_example/ui_circle_64" id: "root" inherit_alpha: true slice9 { @@ -29,7 +29,7 @@ nodes { y: 500.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "layout" parent: "root" inherit_alpha: true @@ -46,7 +46,7 @@ nodes { z: 0.961 } type: TYPE_BOX - texture: "druid/ui_circle_16" + texture: "druid_example/ui_circle_16" id: "prefab" parent: "layout" inherit_alpha: true diff --git a/example/examples/panthera/animation_blend/animation_blend.gui b/example/examples/panthera/animation_blend/animation_blend.gui index ee5efc2..b6a0e2e 100644 --- a/example/examples/panthera/animation_blend/animation_blend.gui +++ b/example/examples/panthera/animation_blend/animation_blend.gui @@ -21,7 +21,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/ui_circle_64" + texture: "druid_example/ui_circle_64" id: "root" inherit_alpha: true slice9 { diff --git a/example/examples/panthera/basic_animation/basic_animation.gui b/example/examples/panthera/basic_animation/basic_animation.gui index 0dd7236..4eb714a 100644 --- a/example/examples/panthera/basic_animation/basic_animation.gui +++ b/example/examples/panthera/basic_animation/basic_animation.gui @@ -20,19 +20,5 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_blue.gui" } -nodes { - type: TYPE_BOX - id: "button/root" - parent: "button" - template_node_child: true -} -nodes { - type: TYPE_TEXT - text: "Hover Me!" - id: "button/text" - parent: "button/root" - overridden_fields: 8 - template_node_child: true -} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/example/examples/widgets/hover_hint/hover_hint.gui b/example/examples/widgets/hover_hint/hover_hint.gui index ce4b3c2..f620a93 100644 --- a/example/examples/widgets/hover_hint/hover_hint.gui +++ b/example/examples/widgets/hover_hint/hover_hint.gui @@ -27,7 +27,7 @@ nodes { z: 0.157 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "panel_hint" parent: "root" inherit_alpha: true diff --git a/example/examples/widgets/hover_hint/hover_hint_example.gui b/example/examples/widgets/hover_hint/hover_hint_example.gui index 61ca0d8..9c19b51 100644 --- a/example/examples/widgets/hover_hint/hover_hint_example.gui +++ b/example/examples/widgets/hover_hint/hover_hint_example.gui @@ -13,7 +13,7 @@ nodes { z: 0.204 } type: TYPE_BOX - texture: "druid/ui_circle_64" + texture: "druid_example/ui_circle_64" id: "root" inherit_alpha: true slice9 { @@ -33,24 +33,6 @@ nodes { inherit_alpha: true template: "/example/examples/widgets/hover_hint/hover_hint.gui" } -nodes { - type: TYPE_BOX - id: "hover_hint/root" - parent: "hover_hint" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "hover_hint/panel_hint" - parent: "hover_hint/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "hover_hint/text_hint" - parent: "hover_hint/panel_hint" - template_node_child: true -} nodes { position { y: 100.0 @@ -65,7 +47,7 @@ nodes { z: 0.624 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "node_yellow" parent: "root" inherit_alpha: true @@ -90,7 +72,7 @@ nodes { z: 0.608 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "node_red" parent: "root" inherit_alpha: true @@ -115,7 +97,7 @@ nodes { z: 0.961 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "node_blue" parent: "root" inherit_alpha: true @@ -140,7 +122,7 @@ nodes { z: 0.62 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "node_green" parent: "root" inherit_alpha: true diff --git a/example/examples/widgets/memory_panel/example_memory_panel.gui b/example/examples/widgets/memory_panel/example_memory_panel.gui index 2732694..44ee04a 100644 --- a/example/examples/widgets/memory_panel/example_memory_panel.gui +++ b/example/examples/widgets/memory_panel/example_memory_panel.gui @@ -1,6 +1,18 @@ +nodes { + size { + x: 200.0 + y: 100.0 + } + type: TYPE_BOX + id: "root" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO + visible: false +} nodes { type: TYPE_TEMPLATE id: "memory_panel" + parent: "root" inherit_alpha: true template: "/druid/widget/memory_panel/memory_panel.gui" } diff --git a/example/examples/windows/window_confirmation/window_confirmation.gui b/example/examples/windows/window_confirmation/window_confirmation.gui index 185880f..2c11af3 100644 --- a/example/examples/windows/window_confirmation/window_confirmation.gui +++ b/example/examples/windows/window_confirmation/window_confirmation.gui @@ -17,7 +17,7 @@ nodes { y: 500.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "root" adjust_mode: ADJUST_MODE_STRETCH inherit_alpha: true @@ -40,7 +40,7 @@ nodes { z: 0.322 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "window" parent: "root" inherit_alpha: true @@ -65,7 +65,7 @@ nodes { z: 0.624 } type: TYPE_BOX - texture: "druid/ui_rounded_top_32" + texture: "druid_example/ui_rounded_top_32" id: "panel_header" pivot: PIVOT_N parent: "window" @@ -135,7 +135,7 @@ nodes { z: 0.322 } type: TYPE_BOX - texture: "druid/icon_cross" + texture: "druid_example/icon_cross" id: "icon_close" parent: "button_close" inherit_alpha: true @@ -202,18 +202,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } -nodes { - type: TYPE_BOX - id: "button_accept/root" - parent: "button_accept" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "button_accept/text" - parent: "button_accept/root" - template_node_child: true -} nodes { position { x: 160.0 @@ -225,18 +213,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_red.gui" } -nodes { - type: TYPE_BOX - id: "button_decline/root" - parent: "button_decline" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "button_decline/text" - parent: "button_decline/root" - template_node_child: true -} layers { name: "druid" } diff --git a/example/examples/windows/window_info/window_info.gui b/example/examples/windows/window_info/window_info.gui index 3601b50..d216457 100644 --- a/example/examples/windows/window_info/window_info.gui +++ b/example/examples/windows/window_info/window_info.gui @@ -17,7 +17,7 @@ nodes { y: 500.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "root" adjust_mode: ADJUST_MODE_STRETCH inherit_alpha: true @@ -40,7 +40,7 @@ nodes { z: 0.322 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "window" parent: "root" inherit_alpha: true @@ -65,7 +65,7 @@ nodes { z: 0.961 } type: TYPE_BOX - texture: "druid/ui_rounded_top_32" + texture: "druid_example/ui_rounded_top_32" id: "panel_header" pivot: PIVOT_N parent: "window" @@ -135,7 +135,7 @@ nodes { z: 0.322 } type: TYPE_BOX - texture: "druid/icon_cross" + texture: "druid_example/icon_cross" id: "icon_close" parent: "button_close" inherit_alpha: true @@ -201,18 +201,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } -nodes { - type: TYPE_BOX - id: "button_accept/root" - parent: "button_accept" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "button_accept/text" - parent: "button_accept/root" - template_node_child: true -} layers { name: "druid" } diff --git a/example/examples/windows/window_language/window_language.gui b/example/examples/windows/window_language/window_language.gui index 4a5bd26..c3ba2cd 100644 --- a/example/examples/windows/window_language/window_language.gui +++ b/example/examples/windows/window_language/window_language.gui @@ -17,7 +17,7 @@ nodes { y: 580.0 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "root" adjust_mode: ADJUST_MODE_STRETCH inherit_alpha: true @@ -40,7 +40,7 @@ nodes { z: 0.322 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "window" parent: "root" inherit_alpha: true @@ -65,7 +65,7 @@ nodes { z: 0.961 } type: TYPE_BOX - texture: "druid/ui_rounded_top_32" + texture: "druid_example/ui_rounded_top_32" id: "panel_header" pivot: PIVOT_N parent: "window" @@ -135,7 +135,7 @@ nodes { z: 0.322 } type: TYPE_BOX - texture: "druid/icon_cross" + texture: "druid_example/icon_cross" id: "icon_close" parent: "button_close" inherit_alpha: true @@ -173,30 +173,6 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_white.gui" } -nodes { - size { - x: 240.0 - y: 70.0 - } - type: TYPE_BOX - id: "button/root" - parent: "button" - overridden_fields: 4 - template_node_child: true -} -nodes { - size { - x: 220.0 - y: 50.0 - } - type: TYPE_TEXT - text: "English" - id: "button/text" - parent: "button/root" - overridden_fields: 4 - overridden_fields: 8 - template_node_child: true -} layers { name: "druid" } diff --git a/example/templates/button_text_blue.gui b/example/templates/button_text_blue.gui index 1560d06..305913d 100644 --- a/example/templates/button_text_blue.gui +++ b/example/templates/button_text_blue.gui @@ -17,7 +17,7 @@ nodes { z: 0.961 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "root" layer: "druid" inherit_alpha: true diff --git a/example/templates/button_text_green.gui b/example/templates/button_text_green.gui index 543f4fa..81921b6 100644 --- a/example/templates/button_text_green.gui +++ b/example/templates/button_text_green.gui @@ -17,7 +17,7 @@ nodes { z: 0.62 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "root" layer: "druid" inherit_alpha: true diff --git a/example/templates/button_text_red.gui b/example/templates/button_text_red.gui index 07b46e0..1d8efd6 100644 --- a/example/templates/button_text_red.gui +++ b/example/templates/button_text_red.gui @@ -17,7 +17,7 @@ nodes { z: 0.608 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "root" layer: "druid" inherit_alpha: true diff --git a/example/templates/button_text_white.gui b/example/templates/button_text_white.gui index 8398f81..6925cc8 100644 --- a/example/templates/button_text_white.gui +++ b/example/templates/button_text_white.gui @@ -16,7 +16,7 @@ nodes { y: 0.984 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "root" layer: "druid" inherit_alpha: true diff --git a/example/templates/button_text_yellow.gui b/example/templates/button_text_yellow.gui index 2e06dc6..2bd7677 100644 --- a/example/templates/button_text_yellow.gui +++ b/example/templates/button_text_yellow.gui @@ -17,7 +17,7 @@ nodes { z: 0.624 } type: TYPE_BOX - texture: "druid/ui_circle_32" + texture: "druid_example/ui_circle_32" id: "root" layer: "druid" inherit_alpha: true diff --git a/example/templates/input.gui b/example/templates/input.gui index 4389038..508eb27 100644 --- a/example/templates/input.gui +++ b/example/templates/input.gui @@ -17,7 +17,7 @@ nodes { z: 0.49 } type: TYPE_BOX - texture: "druid/rect_round2_width1" + texture: "druid_example/rect_round2_width1" id: "root" inherit_alpha: true slice9 { diff --git a/example/templates/rich_input.gui b/example/templates/rich_input.gui index 0f109d7..89023bd 100644 --- a/example/templates/rich_input.gui +++ b/example/templates/rich_input.gui @@ -22,7 +22,7 @@ nodes { y: 80.0 } type: TYPE_BOX - texture: "druid/rect_round2_width1" + texture: "druid_example/rect_round2_width1" id: "button" parent: "root" inherit_alpha: true @@ -100,7 +100,7 @@ nodes { z: 0.961 } type: TYPE_BOX - texture: "druid/ui_circle_16" + texture: "druid_example/ui_circle_16" id: "cursor_node" parent: "button" inherit_alpha: true diff --git a/example/templates/slider.gui b/example/templates/slider.gui index a1f363a..ce3cb31 100644 --- a/example/templates/slider.gui +++ b/example/templates/slider.gui @@ -13,7 +13,7 @@ nodes { z: 0.157 } type: TYPE_BOX - texture: "druid/empty" + texture: "druid_example/empty" id: "root" inherit_alpha: true } @@ -28,7 +28,7 @@ nodes { z: 0.157 } type: TYPE_BOX - texture: "druid/ui_circle_8" + texture: "druid_example/ui_circle_8" id: "slider_back" parent: "root" inherit_alpha: true @@ -53,7 +53,7 @@ nodes { z: 0.761 } type: TYPE_BOX - texture: "druid/ui_circle_8" + texture: "druid_example/ui_circle_8" id: "slider_pin" parent: "root" inherit_alpha: true From c00fb3590cfb8f8526e7f2a9b852428eda013a7a Mon Sep 17 00:00:00 2001 From: Insality Date: Wed, 20 Nov 2024 23:52:48 +0200 Subject: [PATCH 25/50] Replace event with event library --- druid/base/back_handler.lua | 4 +- druid/base/button.lua | 67 +++---- druid/base/drag.lua | 32 ++-- druid/base/hover.lua | 14 +- druid/base/scroll.lua | 20 +-- druid/base/static_grid.lua | 32 ++-- druid/base/text.lua | 20 +-- druid/event.lua | 166 ------------------ druid/extended/container.lua | 6 +- druid/extended/data_list.lua | 20 +-- druid/extended/hotkey.lua | 14 +- druid/extended/input.lua | 44 ++--- druid/extended/lang_text.lua | 8 +- druid/extended/layout.lua | 8 +- druid/extended/progress.lua | 8 +- druid/extended/slider.lua | 8 +- druid/extended/swipe.lua | 8 +- druid/extended/timer.lua | 14 +- druid/system/druid_instance.lua | 2 +- .../property_left_right_selector.lua | 2 +- example/components/container/container.lua | 6 +- .../examples_list_view/examples_list_view.lua | 8 +- .../examples_list_view_item.lua | 2 +- .../panel_druid_profiler.lua | 2 +- example/examples/basic/checkbox/checkbox.lua | 2 +- .../basic/checkbox_group/checkbox_group.lua | 2 +- .../basic/radio_group/radio_group.lua | 2 +- .../basic/rich_text/rich_text_tags_custom.lua | 2 +- example/examples/basic/timer/basic_timer.lua | 2 +- .../data_list_add_remove_clear.lua | 4 +- .../data_list/basic/data_list_basic.lua | 4 +- .../cache_with_component.lua | 4 +- .../on_screen_control/on_screen_input.lua | 14 +- .../animation_blend/animation_blend.lua | 4 +- example/examples/widgets/examples_list.lua | 10 +- .../widgets/fps_panel/example_fps_panel.gui | 104 +++++++++++ .../widgets/fps_panel/example_fps_panel.lua | 12 ++ .../window_language/window_language.lua | 6 +- game.project | 1 + 39 files changed, 324 insertions(+), 364 deletions(-) delete mode 100644 druid/event.lua create mode 100644 example/examples/widgets/fps_panel/example_fps_panel.gui create mode 100644 example/examples/widgets/fps_panel/example_fps_panel.lua diff --git a/druid/base/back_handler.lua b/druid/base/back_handler.lua index 56e0c0c..534eae7 100644 --- a/druid/base/back_handler.lua +++ b/druid/base/back_handler.lua @@ -1,9 +1,9 @@ -local event = require("druid.event") +local event = require("event.event") local const = require("druid.const") local component = require("druid.component") ---@class druid.back_handler: druid.base_component ----@field on_back druid.event Trigger on back handler action, fun(self, params) +---@field on_back event Trigger on back handler action, fun(self, params) ---@field params any|nil Custom args to pass in the callback local M = component.create("back_handler") diff --git a/druid/base/button.lua b/druid/base/button.lua index e7a5011..e21e7d9 100755 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -35,16 +35,16 @@ -- @alias druid.button ---- The druid.event: Event on successful release action over button. +--- The event: Event on successful release action over button. -- @usage -- -- Custom args passed in Button constructor -- button.on_click:subscribe(function(self, custom_args, button_instance) -- print("On button click!") -- end) --- @tfield druid.event on_click druid.event +-- @tfield event on_click event ---- The druid.event: Event on repeated action over button. +--- The event: Event on repeated action over button. -- -- This callback will be triggered if user hold the button. The repeat rate pick from `input.repeat_interval` in game.project -- @usage @@ -52,10 +52,10 @@ -- button.on_repeated_click:subscribe(function(self, custom_args, button_instance, click_count) -- print("On repeated Button click!") -- end) --- @tfield druid.event on_repeated_click druid.event +-- @tfield event on_repeated_click event ---- The druid.event: Event on long tap action over button. +--- The event: Event on long tap action over button. -- -- This callback will be triggered if user pressed the button and hold the some amount of time. -- The amount of time picked from button style param: LONGTAP_TIME @@ -64,10 +64,10 @@ -- button.on_long_click:subscribe(function(self, custom_args, button_instance, hold_time) -- print("On long Button click!") -- end) --- @tfield druid.event on_long_click druid.event +-- @tfield event on_long_click event ---- The druid.event: Event on double tap action over button. +--- The event: Event on double tap action over button. -- -- If secondary click was too fast after previous one, the double -- click will be called instead usual click (if on_double_click subscriber exists) @@ -76,10 +76,10 @@ -- button.on_double_click:subscribe(function(self, custom_args, button_instance, click_amount) -- print("On double Button click!") -- end) --- @tfield druid.event on_double_click druid.event +-- @tfield event on_double_click event ---- The druid.event: Event calls every frame before on_long_click event. +--- The event: Event calls every frame before on_long_click event. -- -- If long_click subscriber exists, the on_hold_callback will be called before long_click trigger. -- @@ -89,10 +89,10 @@ -- button.on_double_click:subscribe(function(self, custom_args, button_instance, time) -- print("On hold Button callback!") -- end) --- @tfield druid.event on_hold_callback druid.event +-- @tfield event on_hold_callback event ---- The druid.event: Event calls if click event was outside of button. +--- The event: Event calls if click event was outside of button. -- -- This event will be triggered for each button what was not clicked on user click action -- @@ -102,16 +102,16 @@ -- button.on_click_outside:subscribe(function(self, custom_args, button_instance) -- print("On click Button outside!") -- end) --- @tfield druid.event on_click_outside druid.event +-- @tfield event on_click_outside event ---- The druid.event: Event triggered if button was pressed by user. +--- The event: Event triggered if button was pressed by user. -- @usage -- -- Custom args passed in Button constructor -- button.on_pressed:subscribe(function(self, custom_args, button_instance) -- print("On Button pressed!") -- end) --- @tfield druid.event on_pressed druid.event +-- @tfield event on_pressed event --- Button trigger node -- @tfield node node @@ -136,19 +136,19 @@ --- -local Event = require("druid.event") +local event = require("event.event") local const = require("druid.const") local helper = require("druid.helper") local component = require("druid.component") ---@class druid.button: druid.base_component ----@field on_click druid.event ----@field on_pressed druid.event ----@field on_repeated_click druid.event ----@field on_long_click druid.event ----@field on_double_click druid.event ----@field on_hold_callback druid.event ----@field on_click_outside druid.event +---@field on_click event +---@field on_pressed event +---@field on_repeated_click event +---@field on_long_click event +---@field on_double_click event +---@field on_hold_callback event +---@field on_click_outside event ---@field node node ---@field node_id hash ---@field anim_node node @@ -229,6 +229,7 @@ local function on_button_hold(self, press_time) end +---@param self druid.button local function on_button_release(self) if self.is_repeated_started then return false @@ -253,10 +254,10 @@ local function on_button_release(self) local time = socket.gettime() local is_long_click = (time - self.last_pressed_time) >= self.style.LONGTAP_TIME - is_long_click = is_long_click and self.on_long_click:is_exist() + is_long_click = is_long_click and not self.on_long_click:is_empty() local is_double_click = (time - self.last_released_time) < self.style.DOUBLETAP_TIME - is_double_click = is_double_click and self.on_double_click:is_exist() + is_double_click = is_double_click and not self.on_double_click:is_empty() if is_long_click then local is_hold_complete = (time - self.last_pressed_time) >= self.style.AUTOHOLD_TRIGGER @@ -335,13 +336,13 @@ function M:init(node_or_node_id, callback, custom_args, anim_node) self._is_html5_listener_set = false -- Events - self.on_click = Event(callback) - self.on_pressed = Event() - self.on_repeated_click = Event() - self.on_long_click = Event() - self.on_double_click = Event() - self.on_hold_callback = Event() - self.on_click_outside = Event() + self.on_click = event.create(callback) + self.on_pressed = event.create() + self.on_repeated_click = event.create() + self.on_long_click = event.create() + self.on_double_click = event.create() + self.on_hold_callback = event.create() + self.on_click_outside = event.create() end @@ -408,7 +409,7 @@ function M:on_input(action_id, action) -- 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 + if not self.on_repeated_click:is_empty() and self.can_action then on_button_repeated_click(self) return is_consume end @@ -418,7 +419,7 @@ function M:on_input(action_id, action) return on_button_release(self) and is_consume end - if self.can_action and self.on_long_click:is_exist() then + if self.can_action and not self.on_long_click:is_empty() then local press_time = socket.gettime() - self.last_pressed_time if self.style.AUTOHOLD_TRIGGER <= press_time then diff --git a/druid/base/drag.lua b/druid/base/drag.lua index 0b0b36f..de30165 100644 --- a/druid/base/drag.lua +++ b/druid/base/drag.lua @@ -14,19 +14,19 @@ -- @tfield node node --- Event on touch start callback(self) --- @tfield druid.event on_touch_start druid.event +-- @tfield event on_touch_start event --- Event on touch end callback(self) --- @tfield druid.event on_touch_end druid.event +-- @tfield event on_touch_end event --- Event on drag start callback(self, touch) --- @tfield druid.event on_drag_start druid.event +-- @tfield event on_drag_start event --- on drag progress callback(self, dx, dy, total_x, total_y, touch) --- @tfield druid.event on_drag Event druid.event +-- @tfield event on_drag Event event --- Event on drag end callback(self, total_x, total_y, touch) --- @tfield druid.event on_drag_end druid.event +-- @tfield event on_drag_end event --- Is component now touching -- @tfield boolean is_touch @@ -57,18 +57,18 @@ --- -local Event = require("druid.event") +local event = require("event.event") local const = require("druid.const") local helper = require("druid.helper") local component = require("druid.component") ---@class druid.drag: druid.base_component ---@field node node ----@field on_touch_start druid.event ----@field on_touch_end druid.event ----@field on_drag_start druid.event ----@field on_drag druid.event ----@field on_drag_end druid.event +---@field on_touch_start event +---@field on_touch_end event +---@field on_drag_start event +---@field on_drag event +---@field on_drag_end event ---@field style table ---@field click_zone node ---@field is_touch boolean @@ -234,11 +234,11 @@ function M:init(node_or_node_id, on_drag_callback) self._scene_scale = helper.get_scene_scale(self.node) self.click_zone = nil - self.on_touch_start = Event() - self.on_touch_end = Event() - self.on_drag_start = Event() - self.on_drag = Event(on_drag_callback) - self.on_drag_end = Event() + self.on_touch_start = event.create() + self.on_touch_end = event.create() + self.on_drag_start = event.create() + self.on_drag = event.create(on_drag_callback) + self.on_drag_end = event.create() self:on_window_resized() self:set_drag_cursors(true) diff --git a/druid/base/hover.lua b/druid/base/hover.lua index b157fbb..b3b3ed6 100644 --- a/druid/base/hover.lua +++ b/druid/base/hover.lua @@ -9,22 +9,22 @@ -- @tfield node node --- On hover callback(self, state, hover_instance) --- @tfield druid.event on_hover druid.event +-- @tfield event on_hover event --- On mouse hover callback(self, state, hover_instance) --- @tfield druid.event on_mouse_hover druid.event +-- @tfield event on_mouse_hover event --- -local Event = require("druid.event") +local event = require("event.event") local const = require("druid.const") local helper = require("druid.helper") local component = require("druid.component") ---@class druid.hover: druid.base_component ---@field node node ----@field on_hover druid.event ----@field on_mouse_hover druid.event +---@field on_hover event +---@field on_mouse_hover event ---@field style table ---@field click_zone node ---@field private _is_hovered boolean @@ -46,8 +46,8 @@ function M:init(node, on_hover_callback, on_mouse_hover) self._is_enabled = true self._is_mobile = helper.is_mobile() - self.on_hover = Event(on_hover_callback) - self.on_mouse_hover = Event(on_mouse_hover) + self.on_hover = event.create(on_hover_callback) + self.on_mouse_hover = event.create(on_mouse_hover) end diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index 077dc8f..22e3f4b 100755 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -39,13 +39,13 @@ --- On scroll move callback(self, position) --- @tfield druid.event on_scroll druid.event +-- @tfield event on_scroll event --- On scroll_to function callback(self, target, is_instant) --- @tfield druid.event on_scroll_to druid.event +-- @tfield event on_scroll_to event --- On scroll_to_index function callback(self, index, point) --- @tfield druid.event on_point_scroll druid.event +-- @tfield event on_point_scroll event --- Scroll view node -- @tfield node view_node @@ -85,15 +85,15 @@ --- -local Event = require("druid.event") +local event = require("event.event") local const = require("druid.const") local helper = require("druid.helper") local component = require("druid.component") ---@class druid.scroll: druid.base_component ----@field on_scroll druid.event ----@field on_scroll_to druid.event ----@field on_point_scroll druid.event +---@field on_scroll event +---@field on_scroll_to event +---@field on_point_scroll event ---@field view_node node ---@field view_border vector4 ---@field content_node node @@ -194,9 +194,9 @@ function M:init(view_node, content_node) self.hover.on_mouse_hover:subscribe(self._on_mouse_hover) self._is_mouse_hover = false - self.on_scroll = Event() - self.on_scroll_to = Event() - self.on_point_scroll = Event() + self.on_scroll = event.create() + self.on_scroll_to = event.create() + self.on_point_scroll = event.create() self.selected = nil self.is_animate = false diff --git a/druid/base/static_grid.lua b/druid/base/static_grid.lua index 48f0e7d..e815ffb 100644 --- a/druid/base/static_grid.lua +++ b/druid/base/static_grid.lua @@ -37,19 +37,19 @@ -- @alias druid.grid --- On item add callback(self, node, index) --- @tfield druid.event on_add_item druid.event +-- @tfield event on_add_item event --- On item remove callback(self, index) --- @tfield druid.event on_remove_item druid.event +-- @tfield event on_remove_item event --- On item add, remove or change in_row callback(self, index|nil) --- @tfield druid.event on_change_items druid.event +-- @tfield event on_change_items event --- On grid clear callback(self) --- @tfield druid.event on_clear druid.event +-- @tfield event on_clear event --- On update item positions callback(self) --- @tfield druid.event on_update_positions druid.event +-- @tfield event on_update_positions event --- Parent gui node -- @tfield node parent @@ -78,16 +78,16 @@ --- local const = require("druid.const") -local Event = require("druid.event") +local event = require("event.event") local helper = require("druid.helper") local component = require("druid.component") ---@class druid.grid: druid.base_component ----@field on_add_item druid.event ----@field on_remove_item druid.event ----@field on_change_items druid.event ----@field on_clear druid.event ----@field on_update_positions druid.event +---@field on_add_item event +---@field on_remove_item event +---@field on_change_items event +---@field on_clear event +---@field on_update_positions event ---@field parent node ---@field nodes node[] ---@field first_index number @@ -152,11 +152,11 @@ function M:init(parent, element, in_row) self.border = vmath.vector4(0) -- Current grid content size - self.on_add_item = Event() - self.on_remove_item = Event() - self.on_change_items = Event() - self.on_clear = Event() - self.on_update_positions = Event() + self.on_add_item = event.create() + self.on_remove_item = event.create() + self.on_change_items = event.create() + self.on_clear = event.create() + self.on_update_positions = event.create() self._set_position_function = gui.set_position end diff --git a/druid/base/text.lua b/druid/base/text.lua index 773f57d..7d394a8 100755 --- a/druid/base/text.lua +++ b/druid/base/text.lua @@ -36,13 +36,13 @@ -- @alias druid.text --- On set text callback(self, text) --- @tfield druid.event on_set_text druid.event +-- @tfield event on_set_text event --- On adjust text size callback(self, new_scale, text_metrics) --- @tfield druid.event on_update_text_scale druid.event +-- @tfield event on_update_text_scale event --- On change pivot callback(self, pivot) --- @tfield druid.event on_set_pivot druid.event +-- @tfield event on_set_pivot event --- Text node -- @tfield node node @@ -76,7 +76,7 @@ --- -local Event = require("druid.event") +local event = require("event.event") local const = require("druid.const") local helper = require("druid.helper") local utf8_lua = require("druid.system.utf8") @@ -85,9 +85,9 @@ local utf8 = utf8 or utf8_lua --[[@as utf8]] ---@class druid.text: druid.base_component ---@field node node ----@field on_set_text druid.event ----@field on_update_text_scale druid.event ----@field on_set_pivot druid.event +---@field on_set_text event +---@field on_update_text_scale event +---@field on_set_pivot event ---@field style table ---@field private start_pivot number ---@field private start_scale vector3 @@ -343,9 +343,9 @@ function M:init(node, value, adjust_type) self.adjust_type = adjust_type or self.style.DEFAULT_ADJUST self.color = gui.get_color(self.node) - self.on_set_text = Event() - self.on_set_pivot = Event() - self.on_update_text_scale = Event() + self.on_set_text = event.create() + self.on_set_pivot = event.create() + self.on_update_text_scale = event.create() self:set_text(value or gui.get_text(self.node)) return self diff --git a/druid/event.lua b/druid/event.lua deleted file mode 100644 index 7bac8dc..0000000 --- a/druid/event.lua +++ /dev/null @@ -1,166 +0,0 @@ ----Event system for Druid ----@class druid.event -local M = {} - -M.COUNTER = 0 - --- Forward declaration -local EVENT_METATABLE - --- Local versions -local pcall = pcall -local tinsert = table.insert -local tremove = table.remove - ---- Return new event instance ----@param callback function|nil Subscribe the callback on new event, if callback exist ----@param callback_context any|nil Additional context as first param to callback call ----@return druid.event ----@nodiscard -function M.create(callback, callback_context) - local instance = setmetatable({}, EVENT_METATABLE) - - if callback then - instance:subscribe(callback, callback_context) - end - - M.COUNTER = M.COUNTER + 1 - return instance -end - - ---- Check is event subscribed. ----@param callback function Callback itself ----@param callback_context any|nil Additional context as first param to callback call ----@return boolean, number|nil Is event subscribed, return index of callback in event as second param -function M:is_subscribed(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 ----@param callback function Callback itself ----@param callback_context any|nil Additional context as first param to callback call, usually it's self ----@return boolean -function M:subscribe(callback, callback_context) - assert(type(self) == "table", "You should subscribe to event with : syntax") - assert(callback, "A function must be passed to subscribe to an event") - - if self:is_subscribed(callback, callback_context) then - return false - end - - tinsert(self, { callback, callback_context }) - return true -end - - ----Unsubscribe callback on event ----@param callback function Callback itself ----@param callback_context any|nil Additional context as first param to callback call ----@return boolean -function M:unsubscribe(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 - - tremove(self, event_index) - return true -end - - ----Return true, if event have at lease one handler ----@return boolean -function M:is_exist() - return #self > 0 -end - - ----Return true, if event not have handler ----@return boolean True if event not have handlers -function M:is_empty() - return #self == 0 -end - - ----Clear the all event handlers -function M:clear() - for index = #self, 1, -1 do - self[index] = nil - end -end - - ---- Trigger the event and call all subscribed callbacks ----@param ... any All event params ----@return any result Last returned value from subscribers -function M:trigger(...) - if #self == 0 then - return - 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 - - ----@param callback table Callback data {function, context} ----@param ... any All event params ----@return any result Result of the callback -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, -}) diff --git a/druid/extended/container.lua b/druid/extended/container.lua index 317e2bb..c9f07c9 100644 --- a/druid/extended/container.lua +++ b/druid/extended/container.lua @@ -13,7 +13,7 @@ local const = require("druid.const") local helper = require("druid.helper") local component = require("druid.component") -local Event = require("druid.event") +local event = require("event.event") ---@class druid.container: druid.base_component ---@field node node @@ -29,7 +29,7 @@ local Event = require("druid.event") ---@field fit_size vector3 ---@field min_size_x number|nil ---@field min_size_y number|nil ----@field on_size_changed druid.event @function on_size_changed(size) +---@field on_size_changed event @function on_size_changed(size) ---@field _parent_container druid.container ---@field _containers table ---@field _draggable_corners table @@ -82,7 +82,7 @@ function M:init(node, mode, callback) gui.set_size_mode(self.node, gui.SIZE_MODE_MANUAL) gui.set_adjust_mode(self.node, gui.ADJUST_FIT) - self.on_size_changed = Event(callback) + self.on_size_changed = event.create(callback) self.pivot_offset = helper.get_pivot_offset(gui.get_pivot(self.node)) self.center_offset = -vmath.vector3(self.size.x * self.pivot_offset.x, self.size.y * self.pivot_offset.y, 0) diff --git a/druid/extended/data_list.lua b/druid/extended/data_list.lua index b6bb1a4..9eaaafd 100644 --- a/druid/extended/data_list.lua +++ b/druid/extended/data_list.lua @@ -25,27 +25,27 @@ -- @tfield number last_index --- Event triggered when scroll progress is changed; event(self, progress_value) --- @tfield druid.event on_scroll_progress_change druid.event +-- @tfield event on_scroll_progress_change event ---On DataList visual element created Event callback(self, index, node, instance) --- @tfield druid.event on_element_add druid.event +-- @tfield event on_element_add event ---On DataList visual element created Event callback(self, index) --- @tfield druid.event on_element_remove druid.event +-- @tfield event on_element_remove event --- local const = require("druid.const") local helper = require("druid.helper") local component = require("druid.component") -local Event = require("druid.event") +local event = require("event.event") ---@class druid.data_list: druid.base_component ---@field scroll druid.scroll ---@field grid druid.grid ----@field on_scroll_progress_change druid.event ----@field on_element_add druid.event ----@field on_element_remove druid.event +---@field on_scroll_progress_change event +---@field on_element_add event +---@field on_element_remove event ---@field private _create_function function ---@field private _is_use_cache boolean ---@field private _cache table @@ -79,9 +79,9 @@ function M:init(scroll, grid, create_function) 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.on_scroll_progress_change = event.create() + self.on_element_add = event.create() + self.on_element_remove = event.create() end diff --git a/druid/extended/hotkey.lua b/druid/extended/hotkey.lua index 8333c5e..b06f1fe 100644 --- a/druid/extended/hotkey.lua +++ b/druid/extended/hotkey.lua @@ -8,10 +8,10 @@ -- @alias druid.hotkey --- On hotkey released callback(self, argument) --- @tfield druid.event on_hotkey_pressed druid.event +-- @tfield event on_hotkey_pressed event --- On hotkey released callback(self, argument) --- @tfield druid.event on_hotkey_released druid.event +-- @tfield event on_hotkey_released event --- Visual node -- @tfield node node @@ -26,11 +26,11 @@ local helper = require("druid.helper") local component = require("druid.component") -local Event = require("druid.event") +local event = require("event.event") ---@class druid.hotkey: druid.base_component ----@field on_hotkey_pressed druid.event ----@field on_hotkey_released druid.event +---@field on_hotkey_pressed event +---@field on_hotkey_released event ---@field style table ---@field private _hotkeys table ---@field private _modificators table @@ -47,8 +47,8 @@ function M:init(keys, callback, callback_argument) self._hotkeys = {} self._modificators = {} - self.on_hotkey_pressed = Event() - self.on_hotkey_released = Event(callback) + self.on_hotkey_pressed = event.create() + self.on_hotkey_released = event.create(callback) if keys then self:add_hotkey(keys, callback_argument) diff --git a/druid/extended/input.lua b/druid/extended/input.lua index 2febd79..30de427 100755 --- a/druid/extended/input.lua +++ b/druid/extended/input.lua @@ -10,25 +10,25 @@ -- @alias druid.input --- On input field select callback(self, input_instance) --- @tfield druid.event on_input_select druid.event +-- @tfield event on_input_select event --- On input field unselect callback(self, input_text, input_instance) --- @tfield druid.event on_input_unselect druid.event +-- @tfield event on_input_unselect event --- On input field text change callback(self, input_text) --- @tfield druid.event on_input_text druid.event +-- @tfield event on_input_text event --- On input field text change to empty string callback(self, input_text) --- @tfield druid.event on_input_empty druid.event +-- @tfield event on_input_empty event --- On input field text change to max length string callback(self, input_text) --- @tfield druid.event on_input_full druid.event +-- @tfield event on_input_full event --- On trying user input with not allowed character callback(self, params, input_text) --- @tfield druid.event on_input_wrong druid.event +-- @tfield event on_input_wrong event --- On cursor position change callback(self, cursor_index, start_index, end_index) --- @tfield druid.event on_select_cursor_change druid.event +-- @tfield event on_select_cursor_change event --- The cursor index. The index of letter cursor after. Leftmost cursor - 0 -- @tfield number cursor_index @@ -80,7 +80,7 @@ --- -local Event = require("druid.event") +local event = require("event.event") local const = require("druid.const") local helper = require("druid.helper") local component = require("druid.component") @@ -88,13 +88,13 @@ local utf8_lua = require("druid.system.utf8") local utf8 = utf8 or utf8_lua ---@class druid.input: druid.base_component ----@field on_input_select druid.event ----@field on_input_unselect druid.event ----@field on_input_text druid.event ----@field on_input_empty druid.event ----@field on_input_full druid.event ----@field on_input_wrong druid.event ----@field on_select_cursor_change druid.event +---@field on_input_select event +---@field on_input_unselect event +---@field on_input_text event +---@field on_input_empty event +---@field on_input_full event +---@field on_input_wrong event +---@field on_select_cursor_change event ---@field style table ---@field text druid.text local M = component.create("input") @@ -200,13 +200,13 @@ function M:init(click_node, text_node, keyboard_type) self.button:set_web_user_interaction(true) end - self.on_input_select = Event() - self.on_input_unselect = Event() - self.on_input_text = Event() - self.on_input_empty = Event() - self.on_input_full = Event() - self.on_input_wrong = Event() - self.on_select_cursor_change = Event() + self.on_input_select = event.create() + self.on_input_unselect = event.create() + self.on_input_text = event.create() + self.on_input_empty = event.create() + self.on_input_full = event.create() + self.on_input_wrong = event.create() + self.on_select_cursor_change = event.create() end diff --git a/druid/extended/lang_text.lua b/druid/extended/lang_text.lua index fdcebee..df8a9e7 100755 --- a/druid/extended/lang_text.lua +++ b/druid/extended/lang_text.lua @@ -18,7 +18,7 @@ -- @alias druid.lang_text --- On change text callback --- @tfield druid.event on_change druid.event +-- @tfield event on_change event --- The text component -- @tfield Text text Text @@ -28,14 +28,14 @@ --- -local Event = require("druid.event") +local event = require("event.event") local settings = require("druid.system.settings") local component = require("druid.component") ---@class druid.lang_text: druid.base_component ---@field text druid.text ---@field node node ----@field on_change druid.event +---@field on_change event ---@field private last_locale_args table ---@field private last_locale string local M = component.create("lang_text") @@ -51,7 +51,7 @@ function M:init(node, locale_id, adjust_type) self.node = self.text.node self.last_locale_args = {} - self.on_change = Event() + self.on_change = event.create() self:translate(locale_id or gui.get_text(self.node)) self.text.on_set_text:subscribe(self.on_change.trigger, self.on_change) diff --git a/druid/extended/layout.lua b/druid/extended/layout.lua index c0d1db7..8c081e9 100644 --- a/druid/extended/layout.lua +++ b/druid/extended/layout.lua @@ -1,10 +1,10 @@ -local event = require("druid.event") +local event = require("event.event") local helper = require("druid.helper") local component = require("druid.component") ---@alias druid.layout.mode "horizontal"|"vertical"|"horizontal_wrap" ----@class druid.event.on_size_changed: druid.event +---@class event.on_size_changed: event ---@field subscribe fun(_, callback: fun(new_size: vector3), context: any|nil) ---@class druid.layout.row_data @@ -30,7 +30,7 @@ local component = require("druid.component") ---@field is_resize_width boolean ---@field is_resize_height boolean ---@field is_justify boolean ----@field on_size_changed druid.event.on_size_changed +---@field on_size_changed event.on_size_changed local M = component.create("layout") ---Layout component constructor @@ -54,7 +54,7 @@ function M:init(node_or_node_id, layout_type) self.is_resize_height = false self.is_justify = false - self.on_size_changed = event.create() --[[@as druid.event.on_size_changed]] + self.on_size_changed = event.create() --[[@as event.on_size_changed]] end diff --git a/druid/extended/progress.lua b/druid/extended/progress.lua index d524357..fb75ac7 100644 --- a/druid/extended/progress.lua +++ b/druid/extended/progress.lua @@ -20,7 +20,7 @@ -- @alias druid.progress --- On progress bar change callback(self, new_value) --- @tfield druid.event on_change druid.event +-- @tfield event on_change event --- Progress bar fill node -- @tfield node node @@ -44,14 +44,14 @@ --- -local Event = require("druid.event") +local event = require("event.event") local const = require("druid.const") local helper = require("druid.helper") local component = require("druid.component") ---@class druid.progress: druid.base_component ---@field node node ----@field on_change druid.event +---@field on_change event ---@field style table ---@field key string ---@field prop hash @@ -154,7 +154,7 @@ function M:init(node, key, init_value) 0 ) - self.on_change = Event() + self.on_change = event.create() self:set_to(self.last_value) end diff --git a/druid/extended/slider.lua b/druid/extended/slider.lua index 8f66f25..26a4bec 100644 --- a/druid/extended/slider.lua +++ b/druid/extended/slider.lua @@ -8,7 +8,7 @@ -- @alias druid.slider --- On change value callback(self, value) --- @tfield druid.event on_change_value druid.event +-- @tfield event on_change_value event --- Slider pin node -- @tfield node node @@ -37,14 +37,14 @@ --- -local Event = require("druid.event") +local event = require("event.event") local helper = require("druid.helper") local const = require("druid.const") local component = require("druid.component") ---@class druid.slider: druid.base_component ---@field node node ----@field on_change_value druid.event +---@field on_change_value event ---@field style table ---@field private start_pos vector3 ---@field private pos vector3 @@ -85,7 +85,7 @@ function M:init(node, end_pos, callback) self.is_drag = false self.value = 0 - self.on_change_value = Event(callback) + self.on_change_value = event.create(callback) self:on_window_resized() assert(self.dist.x == 0 or self.dist.y == 0, "Slider for now can be only vertical or horizontal") diff --git a/druid/extended/swipe.lua b/druid/extended/swipe.lua index 3f6a77d..ed95364 100644 --- a/druid/extended/swipe.lua +++ b/druid/extended/swipe.lua @@ -16,18 +16,18 @@ ---@param click_zone node|nil --- Trigger on swipe event(self, swipe_side, dist, delta_time) --- @tfield druid.event on_swipe) druid.event +-- @tfield event on_swipe) event --- -local Event = require("druid.event") +local event = require("event.event") local const = require("druid.const") local helper = require("druid.helper") local component = require("druid.component") ---@class druid.swipe: druid.base_component ---@field node node ----@field on_swipe druid.event +---@field on_swipe event ---@field style table ---@field click_zone node ---@field private _trigger_on_move boolean @@ -106,7 +106,7 @@ function M:init(node_or_node_id, on_swipe_callback) self._start_pos = vmath.vector3(0) self.click_zone = nil - self.on_swipe = Event(on_swipe_callback) + self.on_swipe = event.create(on_swipe_callback) end diff --git a/druid/extended/timer.lua b/druid/extended/timer.lua index b6eee00..e4e95c4 100644 --- a/druid/extended/timer.lua +++ b/druid/extended/timer.lua @@ -1,11 +1,11 @@ -local Event = require("druid.event") +local event = require("event.event") local helper = require("druid.helper") local component = require("druid.component") ---@class druid.timer: druid.base_component ----@field on_tick druid.event ----@field on_set_enabled druid.event ----@field on_timer_end druid.event +---@field on_tick event +---@field on_set_enabled event +---@field on_timer_end event ---@field style table ---@field node node ---@field from number @@ -31,9 +31,9 @@ function M:init(node, seconds_from, seconds_to, callback) self.node = self:get_node(node) seconds_to = math.max(seconds_to or 0, 0) - self.on_tick = Event() - self.on_set_enabled = Event() - self.on_timer_end = Event(callback) + self.on_tick = event.create() + self.on_set_enabled = event.create() + self.on_timer_end = event.create(callback) if seconds_from then seconds_from = math.max(seconds_from, 0) diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index 520e76b..bf6cfe7 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -3,7 +3,7 @@ -- -- Helper - A useful set of functions for working with GUI nodes, such as centering nodes, get GUI scale ratio, etc -- --- druid.event - The core event system in Druid. Learn how to subscribe to any event in every Druid component. +-- event - The core event system in Druid. Learn how to subscribe to any event in every Druid component. -- -- BaseComponent - The parent class of all Druid components. You can find all default component methods there. -- diff --git a/druid/widget/properties_panel/properties/property_left_right_selector.lua b/druid/widget/properties_panel/properties/property_left_right_selector.lua index 0cc16d9..deae880 100644 --- a/druid/widget/properties_panel/properties/property_left_right_selector.lua +++ b/druid/widget/properties_panel/properties/property_left_right_selector.lua @@ -1,4 +1,4 @@ -local event = require("druid.event") +local event = require("event.event") ---@class widget.property_left_right_selector: druid.widget ---@field root node diff --git a/example/components/container/container.lua b/example/components/container/container.lua index ba8753f..8e1bf1a 100644 --- a/example/components/container/container.lua +++ b/example/components/container/container.lua @@ -13,7 +13,7 @@ local const = require("druid.const") local helper = require("druid.helper") local component = require("druid.component") -local Event = require("druid.event") +local event = require("event.event") ---@class druid.container: druid.base_component ---@field node node @@ -29,7 +29,7 @@ local Event = require("druid.event") ---@field fit_size vector3 ---@field min_size_x number|nil ---@field min_size_y number|nil ----@field on_size_changed druid.event @function on_size_changed(size) +---@field on_size_changed event @function on_size_changed(size) ---@field _parent_container druid.container ---@field _containers table ---@field _draggable_corners table @@ -82,7 +82,7 @@ function M:init(node, mode, callback) gui.set_size_mode(self.node, gui.SIZE_MODE_MANUAL) gui.set_adjust_mode(self.node, gui.ADJUST_FIT) - self.on_size_changed = Event(callback) + self.on_size_changed = event.create(callback) self.pivot_offset = helper.get_pivot_offset(gui.get_pivot(self.node)) self.center_offset = -vmath.vector3(self.size.x * self.pivot_offset.x, self.size.y * self.pivot_offset.y, 0) diff --git a/example/components/examples_list_view/examples_list_view.lua b/example/components/examples_list_view/examples_list_view.lua index 7ceacb0..92ae178 100644 --- a/example/components/examples_list_view/examples_list_view.lua +++ b/example/components/examples_list_view/examples_list_view.lua @@ -1,4 +1,4 @@ -local event = require("druid.event") +local event = require("event.event") local component = require("druid.component") local container = require("example.components.container.container") local lang_text = require("druid.extended.lang_text") @@ -39,9 +39,9 @@ function M:init(template, nodes) self.selected_example = nil self.examples = {} - self.on_debug_info = event() - self.on_set_information = event() - self.add_log_text = event() + self.on_debug_info = event.create() + self.on_set_information = event.create() + self.add_log_text = event.create() timer.delay(0.1, true, function() self:update_debug_info() diff --git a/example/components/examples_list_view/examples_list_view_item.lua b/example/components/examples_list_view/examples_list_view_item.lua index 4793fb5..e87e27f 100644 --- a/example/components/examples_list_view/examples_list_view_item.lua +++ b/example/components/examples_list_view/examples_list_view_item.lua @@ -6,7 +6,7 @@ local lang_text = require("druid.extended.lang_text") ---@field root druid.container ---@field text druid.lang_text ---@field druid druid_instance ----@field on_click druid.event +---@field on_click event local M = component.create("examples_list_view_item") ---@param template string diff --git a/example/components/panel_druid_profiler/panel_druid_profiler.lua b/example/components/panel_druid_profiler/panel_druid_profiler.lua index 974aaf3..9899a91 100644 --- a/example/components/panel_druid_profiler/panel_druid_profiler.lua +++ b/example/components/panel_druid_profiler/panel_druid_profiler.lua @@ -1,4 +1,4 @@ -local event = require("druid.event") +local event = require("event.event") local helper = require("druid.helper") local component = require("druid.component") local container = require("example.components.container.container") diff --git a/example/examples/basic/checkbox/checkbox.lua b/example/examples/basic/checkbox/checkbox.lua index 32bee28..cd27d26 100644 --- a/example/examples/basic/checkbox/checkbox.lua +++ b/example/examples/basic/checkbox/checkbox.lua @@ -1,5 +1,5 @@ local component = require("druid.component") -local event = require("druid.event") +local event = require("event.event") ---@class checkbox: druid.base_component ---@field druid druid_instance diff --git a/example/examples/basic/checkbox_group/checkbox_group.lua b/example/examples/basic/checkbox_group/checkbox_group.lua index cff045f..2ef54ce 100644 --- a/example/examples/basic/checkbox_group/checkbox_group.lua +++ b/example/examples/basic/checkbox_group/checkbox_group.lua @@ -1,4 +1,4 @@ -local event = require("druid.event") +local event = require("event.event") local component = require("druid.component") -- Require checkbox component from checkbox example diff --git a/example/examples/basic/radio_group/radio_group.lua b/example/examples/basic/radio_group/radio_group.lua index 1b74273..b1ac9bb 100644 --- a/example/examples/basic/radio_group/radio_group.lua +++ b/example/examples/basic/radio_group/radio_group.lua @@ -1,5 +1,5 @@ local component = require("druid.component") -local event = require("druid.event") +local event = require("event.event") -- Require checkbox component from checkbox example local checkbox = require("example.examples.basic.checkbox.checkbox") diff --git a/example/examples/basic/rich_text/rich_text_tags_custom.lua b/example/examples/basic/rich_text/rich_text_tags_custom.lua index 14d92e2..e541012 100644 --- a/example/examples/basic/rich_text/rich_text_tags_custom.lua +++ b/example/examples/basic/rich_text/rich_text_tags_custom.lua @@ -1,7 +1,7 @@ local component = require("druid.component") local rich_text = require("druid.custom.rich_text.rich_text") local helper = require("druid.helper") -local event = require("druid.event") +local event = require("event.event") ---@class rich_text_tags_custom: druid.base_component ---@field druid druid_instance diff --git a/example/examples/basic/timer/basic_timer.lua b/example/examples/basic/timer/basic_timer.lua index 72fcca4..0cc2a04 100644 --- a/example/examples/basic/timer/basic_timer.lua +++ b/example/examples/basic/timer/basic_timer.lua @@ -1,4 +1,4 @@ -local event = require("druid.event") +local event = require("event.event") local timer = require("druid.extended.timer") local component = require("druid.component") diff --git a/example/examples/data_list/add_remove_clear/data_list_add_remove_clear.lua b/example/examples/data_list/add_remove_clear/data_list_add_remove_clear.lua index fb3d95e..e7f38d3 100644 --- a/example/examples/data_list/add_remove_clear/data_list_add_remove_clear.lua +++ b/example/examples/data_list/add_remove_clear/data_list_add_remove_clear.lua @@ -1,4 +1,4 @@ -local event = require("druid.event") +local event = require("event.event") local component = require("druid.component") local data_list = require("druid.extended.data_list") @@ -26,7 +26,7 @@ function M:init(template, nodes) end self.data_list:set_data(data) - self.on_item_click = event() + self.on_item_click = event.create() end diff --git a/example/examples/data_list/basic/data_list_basic.lua b/example/examples/data_list/basic/data_list_basic.lua index b520c1b..238e47a 100644 --- a/example/examples/data_list/basic/data_list_basic.lua +++ b/example/examples/data_list/basic/data_list_basic.lua @@ -1,4 +1,4 @@ -local event = require("druid.event") +local event = require("event.event") local component = require("druid.component") local data_list = require("druid.extended.data_list") @@ -25,7 +25,7 @@ function M:init(template, nodes) end self.data_list:set_data(data) - self.on_item_click = event() + self.on_item_click = event.create() end diff --git a/example/examples/data_list/cache_with_component/cache_with_component.lua b/example/examples/data_list/cache_with_component/cache_with_component.lua index f336a2d..ba89aba 100644 --- a/example/examples/data_list/cache_with_component/cache_with_component.lua +++ b/example/examples/data_list/cache_with_component/cache_with_component.lua @@ -1,4 +1,4 @@ -local event = require("druid.event") +local event = require("event.event") local component = require("druid.component") local data_list = require("druid.extended.data_list") @@ -30,7 +30,7 @@ function M:init(template, nodes) end self.data_list:set_data(data) - self.on_item_click = event() + self.on_item_click = event.create() end diff --git a/example/examples/gamepad/on_screen_control/on_screen_input.lua b/example/examples/gamepad/on_screen_control/on_screen_input.lua index 41d1d21..bb927a0 100644 --- a/example/examples/gamepad/on_screen_control/on_screen_input.lua +++ b/example/examples/gamepad/on_screen_control/on_screen_input.lua @@ -1,13 +1,13 @@ local const = require("druid.const") -local event = require("druid.event") +local event = require("event.event") local helper = require("druid.helper") local component = require("druid.component") ---@class on_screen_input: druid.base_component ---@field druid druid_instance ----@field on_action druid.event @() ----@field on_movement druid.event @(x: number, y: number, dt: number) X/Y values are in range -1..1 ----@field on_movement_stop druid.event @() +---@field on_action event @() +---@field on_movement event @(x: number, y: number, dt: number) X/Y values are in range -1..1 +---@field on_movement_stop event @() local M = component.create("on_screen_input") local STICK_DISTANCE = 80 @@ -23,9 +23,9 @@ function M:init(template, nodes) self.stick_root = self:get_node("on_screen_stick/stick_root") self.stick_position = gui.get_position(self.stick_root) - self.on_action = event() - self.on_movement = event() - self.on_movement_stop = event() + self.on_action = event.create() + self.on_movement = event.create() + self.on_movement_stop = event.create() self.is_multitouch = helper.is_multitouch_supported() end diff --git a/example/examples/panthera/animation_blend/animation_blend.lua b/example/examples/panthera/animation_blend/animation_blend.lua index cbd5ea6..b4c86d7 100644 --- a/example/examples/panthera/animation_blend/animation_blend.lua +++ b/example/examples/panthera/animation_blend/animation_blend.lua @@ -1,7 +1,7 @@ local panthera = require("panthera.panthera") local component = require("druid.component") local helper = require("druid.helper") -local event = require("druid.event") +local event = require("event.event") local lang_text = require("druid.extended.lang_text") local rich_text = require("druid.custom.rich_text.rich_text") @@ -31,7 +31,7 @@ function M:init(template, nodes) }) self:setup_rich_text() - self.on_update = event() + self.on_update = event.create() end diff --git a/example/examples/widgets/examples_list.lua b/example/examples/widgets/examples_list.lua index 5329bc2..257090a 100644 --- a/example/examples/widgets/examples_list.lua +++ b/example/examples/widgets/examples_list.lua @@ -59,7 +59,15 @@ function M.get_examples() template = "example_memory_panel", root = "example_memory_panel/root", code_url = "example/examples/widgets/memory_panel/example_memory_panel.lua", - component_class = require("example.examples.widgets.memory_panel.example_memory_panel"), + widget_class = require("example.examples.widgets.memory_panel.example_memory_panel"), + }, + { + name_id = "ui_example_widget_fps_panel", + information_text_id = "ui_example_widget_fps_panel_description", + template = "example_fps_panel", + root = "example_fps_panel/root", + code_url = "example/examples/widgets/fps_panel/example_fps_panel.lua", + widget_class = require("example.examples.widgets.fps_panel.example_fps_panel"), }, } end diff --git a/example/examples/widgets/fps_panel/example_fps_panel.gui b/example/examples/widgets/fps_panel/example_fps_panel.gui new file mode 100644 index 0000000..ffccb4f --- /dev/null +++ b/example/examples/widgets/fps_panel/example_fps_panel.gui @@ -0,0 +1,104 @@ +nodes { + size { + x: 200.0 + y: 100.0 + } + type: TYPE_BOX + id: "root" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO + visible: false +} +nodes { + type: TYPE_TEMPLATE + id: "memory_panel" + parent: "root" + inherit_alpha: true + template: "/druid/widget/fps_panel/fps_panel.gui" +} +nodes { + type: TYPE_BOX + id: "memory_panel/root" + parent: "memory_panel" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "memory_panel/mini_graph" + parent: "memory_panel/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "memory_panel/mini_graph/root" + parent: "memory_panel/mini_graph" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "memory_panel/mini_graph/header" + parent: "memory_panel/mini_graph/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "memory_panel/mini_graph/text_header" + parent: "memory_panel/mini_graph/header" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "memory_panel/mini_graph/icon_drag" + parent: "memory_panel/mini_graph/header" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "memory_panel/mini_graph/content" + parent: "memory_panel/mini_graph/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "memory_panel/mini_graph/prefab_line" + parent: "memory_panel/mini_graph/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "memory_panel/mini_graph/color_low" + parent: "memory_panel/mini_graph/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "memory_panel/content" + parent: "memory_panel/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "memory_panel/text_min_fps" + parent: "memory_panel/content" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "memory_panel/text_fps" + parent: "memory_panel/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "memory_panel/line_second_1" + parent: "memory_panel/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "memory_panel/line_second_2" + parent: "memory_panel/content" + template_node_child: true +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/example/examples/widgets/fps_panel/example_fps_panel.lua b/example/examples/widgets/fps_panel/example_fps_panel.lua new file mode 100644 index 0000000..50de100 --- /dev/null +++ b/example/examples/widgets/fps_panel/example_fps_panel.lua @@ -0,0 +1,12 @@ +local fps_panel = require("druid.widget.fps_panel.fps_panel") + +---@class widget.example_fps_panel: druid.widget +local M = {} + + +function M:init() + self.fps_panel = self.druid:new_widget(fps_panel, "fps_panel") +end + + +return M \ No newline at end of file diff --git a/example/examples/windows/window_language/window_language.lua b/example/examples/windows/window_language/window_language.lua index 8f899bc..55dc74a 100644 --- a/example/examples/windows/window_language/window_language.lua +++ b/example/examples/windows/window_language/window_language.lua @@ -1,6 +1,6 @@ local lang = require("lang.lang") local druid = require("druid.druid") -local event = require("druid.event") +local event = require("event.event") local component = require("druid.component") local lang_text = require("druid.extended.lang_text") local panthera = require("panthera.panthera") @@ -13,7 +13,7 @@ local window_animation_panthera = require("example.examples.windows.window_anima ---@field druid druid_instance ---@field lang_buttons table ---@field grid druid.grid ----@field on_language_change druid.event +---@field on_language_change event local M = component.create("window_language") ---Color: #F0FBFF @@ -44,7 +44,7 @@ function M:init(template, nodes) self:load_langs() - self.on_language_change = event() + self.on_language_change = event.create() end diff --git a/game.project b/game.project index a657a67..08b9317 100644 --- a/game.project +++ b/game.project @@ -22,6 +22,7 @@ dependencies#1 = https://github.com/Insality/defold-saver/archive/refs/tags/1.zi dependencies#2 = https://github.com/Insality/defold-tweener/archive/refs/tags/3.zip dependencies#3 = https://github.com/Insality/panthera/archive/refs/tags/runtime.4.zip dependencies#4 = https://github.com/Insality/defold-lang/archive/refs/tags/3.zip +dependencies#5 = https://github.com/Insality/defold-event/archive/refs/tags/10.zip [library] include_dirs = druid From c0abfd350e51908424639db6bcb4d37bc075f3a8 Mon Sep 17 00:00:00 2001 From: Insality Date: Thu, 21 Nov 2024 00:01:16 +0200 Subject: [PATCH 26/50] Update examples --- .../panel_information/panel_information.gui | 28 +++++ example/druid.gui | 103 ++++++++++++++++++ .../widgets/fps_panel/example_fps_panel.gui | 58 +++++----- game.project | 1 + 4 files changed, 161 insertions(+), 29 deletions(-) diff --git a/example/components/panel_information/panel_information.gui b/example/components/panel_information/panel_information.gui index 0c01d7f..5cf8924 100644 --- a/example/components/panel_information/panel_information.gui +++ b/example/components/panel_information/panel_information.gui @@ -91,6 +91,18 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_blue.gui" } +nodes { + type: TYPE_BOX + id: "button_view_code/root" + parent: "button_view_code" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "button_view_code/text" + parent: "button_view_code/root" + template_node_child: true +} nodes { position { x: 220.0 @@ -112,12 +124,28 @@ nodes { x: -85.0 y: -32.5 } + scale { + x: 0.5 + y: 0.5 + } type: TYPE_TEMPLATE id: "button_profiler" parent: "NE_Anchor" inherit_alpha: true template: "/example/templates/button_text_yellow.gui" } +nodes { + type: TYPE_BOX + id: "button_profiler/root" + parent: "button_profiler" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "button_profiler/text" + parent: "button_profiler/root" + template_node_child: true +} nodes { position { x: -200.0 diff --git a/example/druid.gui b/example/druid.gui index 0133cfd..fa7360f 100644 --- a/example/druid.gui +++ b/example/druid.gui @@ -4025,6 +4025,109 @@ nodes { parent: "example_memory_panel/memory_panel/content" template_node_child: true } +nodes { + type: TYPE_TEMPLATE + id: "example_fps_panel" + parent: "widgets" + inherit_alpha: true + template: "/example/examples/widgets/fps_panel/example_fps_panel.gui" +} +nodes { + type: TYPE_BOX + id: "example_fps_panel/root" + parent: "example_fps_panel" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "example_fps_panel/fps_panel" + parent: "example_fps_panel/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_fps_panel/fps_panel/root" + parent: "example_fps_panel/fps_panel" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "example_fps_panel/fps_panel/mini_graph" + parent: "example_fps_panel/fps_panel/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_fps_panel/fps_panel/mini_graph/root" + parent: "example_fps_panel/fps_panel/mini_graph" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_fps_panel/fps_panel/mini_graph/header" + parent: "example_fps_panel/fps_panel/mini_graph/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_fps_panel/fps_panel/mini_graph/text_header" + parent: "example_fps_panel/fps_panel/mini_graph/header" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_fps_panel/fps_panel/mini_graph/icon_drag" + parent: "example_fps_panel/fps_panel/mini_graph/header" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_fps_panel/fps_panel/mini_graph/content" + parent: "example_fps_panel/fps_panel/mini_graph/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_fps_panel/fps_panel/mini_graph/prefab_line" + parent: "example_fps_panel/fps_panel/mini_graph/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_fps_panel/fps_panel/mini_graph/color_low" + parent: "example_fps_panel/fps_panel/mini_graph/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_fps_panel/fps_panel/content" + parent: "example_fps_panel/fps_panel/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_fps_panel/fps_panel/text_min_fps" + parent: "example_fps_panel/fps_panel/content" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_fps_panel/fps_panel/text_fps" + parent: "example_fps_panel/fps_panel/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_fps_panel/fps_panel/line_second_1" + parent: "example_fps_panel/fps_panel/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_fps_panel/fps_panel/line_second_2" + parent: "example_fps_panel/fps_panel/content" + template_node_child: true +} nodes { position { x: -20.0 diff --git a/example/examples/widgets/fps_panel/example_fps_panel.gui b/example/examples/widgets/fps_panel/example_fps_panel.gui index ffccb4f..4f01f77 100644 --- a/example/examples/widgets/fps_panel/example_fps_panel.gui +++ b/example/examples/widgets/fps_panel/example_fps_panel.gui @@ -11,93 +11,93 @@ nodes { } nodes { type: TYPE_TEMPLATE - id: "memory_panel" + id: "fps_panel" parent: "root" inherit_alpha: true template: "/druid/widget/fps_panel/fps_panel.gui" } nodes { type: TYPE_BOX - id: "memory_panel/root" - parent: "memory_panel" + id: "fps_panel/root" + parent: "fps_panel" template_node_child: true } nodes { type: TYPE_TEMPLATE - id: "memory_panel/mini_graph" - parent: "memory_panel/root" + id: "fps_panel/mini_graph" + parent: "fps_panel/root" template_node_child: true } nodes { type: TYPE_BOX - id: "memory_panel/mini_graph/root" - parent: "memory_panel/mini_graph" + id: "fps_panel/mini_graph/root" + parent: "fps_panel/mini_graph" template_node_child: true } nodes { type: TYPE_BOX - id: "memory_panel/mini_graph/header" - parent: "memory_panel/mini_graph/root" + id: "fps_panel/mini_graph/header" + parent: "fps_panel/mini_graph/root" template_node_child: true } nodes { type: TYPE_TEXT - id: "memory_panel/mini_graph/text_header" - parent: "memory_panel/mini_graph/header" + id: "fps_panel/mini_graph/text_header" + parent: "fps_panel/mini_graph/header" template_node_child: true } nodes { type: TYPE_BOX - id: "memory_panel/mini_graph/icon_drag" - parent: "memory_panel/mini_graph/header" + id: "fps_panel/mini_graph/icon_drag" + parent: "fps_panel/mini_graph/header" template_node_child: true } nodes { type: TYPE_BOX - id: "memory_panel/mini_graph/content" - parent: "memory_panel/mini_graph/root" + id: "fps_panel/mini_graph/content" + parent: "fps_panel/mini_graph/root" template_node_child: true } nodes { type: TYPE_BOX - id: "memory_panel/mini_graph/prefab_line" - parent: "memory_panel/mini_graph/content" + id: "fps_panel/mini_graph/prefab_line" + parent: "fps_panel/mini_graph/content" template_node_child: true } nodes { type: TYPE_BOX - id: "memory_panel/mini_graph/color_low" - parent: "memory_panel/mini_graph/content" + id: "fps_panel/mini_graph/color_low" + parent: "fps_panel/mini_graph/content" template_node_child: true } nodes { type: TYPE_BOX - id: "memory_panel/content" - parent: "memory_panel/root" + id: "fps_panel/content" + parent: "fps_panel/root" template_node_child: true } nodes { type: TYPE_TEXT - id: "memory_panel/text_min_fps" - parent: "memory_panel/content" + id: "fps_panel/text_min_fps" + parent: "fps_panel/content" template_node_child: true } nodes { type: TYPE_TEXT - id: "memory_panel/text_fps" - parent: "memory_panel/content" + id: "fps_panel/text_fps" + parent: "fps_panel/content" template_node_child: true } nodes { type: TYPE_BOX - id: "memory_panel/line_second_1" - parent: "memory_panel/content" + id: "fps_panel/line_second_1" + parent: "fps_panel/content" template_node_child: true } nodes { type: TYPE_BOX - id: "memory_panel/line_second_2" - parent: "memory_panel/content" + id: "fps_panel/line_second_2" + parent: "fps_panel/content" template_node_child: true } material: "/builtins/materials/gui.material" diff --git a/game.project b/game.project index 08b9317..5aebe16 100644 --- a/game.project +++ b/game.project @@ -10,6 +10,7 @@ height = 1080 display_profiles = /builtins/render/default.display_profilesc dynamic_orientation = 1 high_dpi = 1 +update_frequency = 60 [project] title = druid From 4ef65579a638e2122cf513fe260db84cd140096a Mon Sep 17 00:00:00 2001 From: Insality Date: Thu, 21 Nov 2024 00:18:43 +0200 Subject: [PATCH 27/50] Update --- druid/widget/fps_panel/fps_panel.lua | 5 + druid/widget/memory_panel/memory_panel.lua | 5 + druid/widget/mini_graph/mini_graph.lua | 15 +- .../properties/property_button.gui | 4 +- .../properties/property_checkbox.gui | 2 +- .../property_left_right_selector.lua | 3 + .../properties_panel/properties_panel.lua | 5 + example/druid.gui | 369 +++++++++++++++++- example/examples/widgets/examples_list.lua | 8 + .../example_properties_panel.gui | 368 +++++++++++++++++ .../example_properties_panel.lua | 38 ++ game.project | 1 + 12 files changed, 817 insertions(+), 6 deletions(-) create mode 100644 example/examples/widgets/properties_panel/example_properties_panel.gui create mode 100644 example/examples/widgets/properties_panel/example_properties_panel.lua diff --git a/druid/widget/fps_panel/fps_panel.lua b/druid/widget/fps_panel/fps_panel.lua index 1b0edaa..33a2d99 100644 --- a/druid/widget/fps_panel/fps_panel.lua +++ b/druid/widget/fps_panel/fps_panel.lua @@ -33,6 +33,11 @@ function M:init() end +function M:on_remove() + timer.cancel(self.timer_id) +end + + function M:update(dt) if not self.previous_time then self.previous_time = socket.gettime() diff --git a/druid/widget/memory_panel/memory_panel.lua b/druid/widget/memory_panel/memory_panel.lua index 213a3e5..e90aeec 100644 --- a/druid/widget/memory_panel/memory_panel.lua +++ b/druid/widget/memory_panel/memory_panel.lua @@ -28,6 +28,11 @@ function M:init() end +function M:on_remove() + timer.cancel(self.timer_id) +end + + function M:set_low_memory_limit(limit) self.memory_limit = limit end diff --git a/druid/widget/mini_graph/mini_graph.lua b/druid/widget/mini_graph/mini_graph.lua index cf266fc..f8cff1e 100644 --- a/druid/widget/mini_graph/mini_graph.lua +++ b/druid/widget/mini_graph/mini_graph.lua @@ -39,13 +39,24 @@ function M:init() end -function M:set_samples(samples) - self.samples = samples +function M:on_remove() + self:clear() +end + + +function M:clear() self.layout:clear_layout() for index = 1, #self.lines do gui.delete_node(self.lines[index]) end + self.lines = {} +end + + +function M:set_samples(samples) + self.samples = samples + self:clear() local line_width = self.layout:get_size().x / self.samples for index = 1, self.samples do diff --git a/druid/widget/properties_panel/properties/property_button.gui b/druid/widget/properties_panel/properties/property_button.gui index 2175a1c..a7e55c8 100644 --- a/druid/widget/properties_panel/properties/property_button.gui +++ b/druid/widget/properties_panel/properties/property_button.gui @@ -37,7 +37,7 @@ nodes { } type: TYPE_TEXT text: "Button" - font: "text_bold" + font: "druid_text_bold" id: "text_name" pivot: PIVOT_W outline { @@ -134,7 +134,7 @@ nodes { } type: TYPE_TEXT text: "Button" - font: "text_bold" + font: "druid_text_bold" id: "text_button" outline { x: 1.0 diff --git a/druid/widget/properties_panel/properties/property_checkbox.gui b/druid/widget/properties_panel/properties/property_checkbox.gui index 80740ca..aeb1180 100644 --- a/druid/widget/properties_panel/properties/property_checkbox.gui +++ b/druid/widget/properties_panel/properties/property_checkbox.gui @@ -37,7 +37,7 @@ nodes { } type: TYPE_TEXT text: "Checkbox" - font: "text_bold" + font: "druid_text_bold" id: "text_name" pivot: PIVOT_W outline { diff --git a/druid/widget/properties_panel/properties/property_left_right_selector.lua b/druid/widget/properties_panel/properties/property_left_right_selector.lua index deae880..2065663 100644 --- a/druid/widget/properties_panel/properties/property_left_right_selector.lua +++ b/druid/widget/properties_panel/properties/property_left_right_selector.lua @@ -20,7 +20,10 @@ function M:init() self.text_value = self.druid:new_text("text_value") self.button_left = self.druid:new_button("button_left", self.on_button_left) + self.button_left.on_repeated_click:subscribe(self.on_button_left, self) + self.button_right = self.druid:new_button("button_right", self.on_button_right) + self.button_right.on_repeated_click:subscribe(self.on_button_right, self) self.on_change_value = event.create() diff --git a/druid/widget/properties_panel/properties_panel.lua b/druid/widget/properties_panel/properties_panel.lua index a8f9da2..93227c5 100644 --- a/druid/widget/properties_panel/properties_panel.lua +++ b/druid/widget/properties_panel/properties_panel.lua @@ -75,6 +75,11 @@ function M:init() end +function M:on_remove() + self:clear() +end + + function M:on_drag_widget(dx, dy) local position = self.container:get_position() self.container:set_position(position.x + dx, position.y + dy) diff --git a/example/druid.gui b/example/druid.gui index fa7360f..8e1b2ea 100644 --- a/example/druid.gui +++ b/example/druid.gui @@ -4128,6 +4128,373 @@ nodes { parent: "example_fps_panel/fps_panel/content" template_node_child: true } +nodes { + type: TYPE_TEMPLATE + id: "example_properties_panel" + parent: "widgets" + inherit_alpha: true + template: "/example/examples/widgets/properties_panel/example_properties_panel.gui" +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/root" + parent: "example_properties_panel" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "example_properties_panel/properties_panel" + parent: "example_properties_panel/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/root" + parent: "example_properties_panel/properties_panel" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/header" + parent: "example_properties_panel/properties_panel/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/text_header" + parent: "example_properties_panel/properties_panel/header" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/icon_drag" + parent: "example_properties_panel/properties_panel/header" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/content" + parent: "example_properties_panel/properties_panel/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/scroll_view" + parent: "example_properties_panel/properties_panel/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/scroll_content" + parent: "example_properties_panel/properties_panel/scroll_view" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/propeties" + parent: "example_properties_panel/properties_panel/content" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "example_properties_panel/properties_panel/property_slider" + parent: "example_properties_panel/properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_slider/root" + parent: "example_properties_panel/properties_panel/property_slider" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_slider/text_name" + parent: "example_properties_panel/properties_panel/property_slider/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_slider/E_Anchor" + parent: "example_properties_panel/properties_panel/property_slider/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_slider/slider" + parent: "example_properties_panel/properties_panel/property_slider/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_slider/slider_back" + parent: "example_properties_panel/properties_panel/property_slider/slider" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_slider/slider_pin" + parent: "example_properties_panel/properties_panel/property_slider/slider" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_slider/button" + parent: "example_properties_panel/properties_panel/property_slider/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_slider/selected" + parent: "example_properties_panel/properties_panel/property_slider/button" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_slider/text_value" + parent: "example_properties_panel/properties_panel/property_slider/button" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "example_properties_panel/properties_panel/property_checkbox" + parent: "example_properties_panel/properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_checkbox/root" + parent: "example_properties_panel/properties_panel/property_checkbox" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_checkbox/text_name" + parent: "example_properties_panel/properties_panel/property_checkbox/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_checkbox/E_Anchor" + parent: "example_properties_panel/properties_panel/property_checkbox/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_checkbox/button" + parent: "example_properties_panel/properties_panel/property_checkbox/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_checkbox/icon" + parent: "example_properties_panel/properties_panel/property_checkbox/button" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_checkbox/selected" + parent: "example_properties_panel/properties_panel/property_checkbox/button" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "example_properties_panel/properties_panel/property_button" + parent: "example_properties_panel/properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_button/root" + parent: "example_properties_panel/properties_panel/property_button" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_button/text_name" + parent: "example_properties_panel/properties_panel/property_button/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_button/E_Anchor" + parent: "example_properties_panel/properties_panel/property_button/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_button/button" + parent: "example_properties_panel/properties_panel/property_button/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_button/selected" + parent: "example_properties_panel/properties_panel/property_button/button" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_button/text_button" + parent: "example_properties_panel/properties_panel/property_button/button" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "example_properties_panel/properties_panel/property_input" + parent: "example_properties_panel/properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_input/root" + parent: "example_properties_panel/properties_panel/property_input" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_input/text_name" + parent: "example_properties_panel/properties_panel/property_input/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_input/E_Anchor" + parent: "example_properties_panel/properties_panel/property_input/root" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "example_properties_panel/properties_panel/property_input/rich_input" + parent: "example_properties_panel/properties_panel/property_input/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_input/rich_input/root" + parent: "example_properties_panel/properties_panel/property_input/rich_input" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_input/rich_input/button" + parent: "example_properties_panel/properties_panel/property_input/rich_input/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_input/rich_input/placeholder_text" + parent: "example_properties_panel/properties_panel/property_input/rich_input/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_input/rich_input/input_text" + parent: "example_properties_panel/properties_panel/property_input/rich_input/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_input/rich_input/cursor_node" + parent: "example_properties_panel/properties_panel/property_input/rich_input/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_input/rich_input/cursor_text" + parent: "example_properties_panel/properties_panel/property_input/rich_input/cursor_node" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_input/selected" + parent: "example_properties_panel/properties_panel/property_input/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "example_properties_panel/properties_panel/property_text" + parent: "example_properties_panel/properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_text/root" + parent: "example_properties_panel/properties_panel/property_text" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_text/text_name" + parent: "example_properties_panel/properties_panel/property_text/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_text/text_right" + parent: "example_properties_panel/properties_panel/property_text/root" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "example_properties_panel/properties_panel/property_left_right_selector" + parent: "example_properties_panel/properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_left_right_selector/root" + parent: "example_properties_panel/properties_panel/property_left_right_selector" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_left_right_selector/text_name" + parent: "example_properties_panel/properties_panel/property_left_right_selector/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_left_right_selector/E_Anchor" + parent: "example_properties_panel/properties_panel/property_left_right_selector/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_left_right_selector/button_left" + parent: "example_properties_panel/properties_panel/property_left_right_selector/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_left_right_selector/icon_left" + parent: "example_properties_panel/properties_panel/property_left_right_selector/button_left" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_left_right_selector/button_right" + parent: "example_properties_panel/properties_panel/property_left_right_selector/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_left_right_selector/icon_right" + parent: "example_properties_panel/properties_panel/property_left_right_selector/button_right" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_left_right_selector/selected" + parent: "example_properties_panel/properties_panel/property_left_right_selector/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_left_right_selector/text_value" + parent: "example_properties_panel/properties_panel/property_left_right_selector/E_Anchor" + template_node_child: true +} nodes { position { x: -20.0 @@ -4260,4 +4627,4 @@ layers { } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 2048 +max_nodes: 4096 diff --git a/example/examples/widgets/examples_list.lua b/example/examples/widgets/examples_list.lua index 257090a..14c7728 100644 --- a/example/examples/widgets/examples_list.lua +++ b/example/examples/widgets/examples_list.lua @@ -69,6 +69,14 @@ function M.get_examples() code_url = "example/examples/widgets/fps_panel/example_fps_panel.lua", widget_class = require("example.examples.widgets.fps_panel.example_fps_panel"), }, + { + name_id = "ui_example_widget_properties_panel", + information_text_id = "ui_example_widget_properties_panel_description", + template = "example_properties_panel", + root = "example_properties_panel/root", + code_url = "example/examples/widgets/properties_panel/example_properties_panel.lua", + widget_class = require("example.examples.widgets.properties_panel.example_properties_panel"), + }, } end diff --git a/example/examples/widgets/properties_panel/example_properties_panel.gui b/example/examples/widgets/properties_panel/example_properties_panel.gui new file mode 100644 index 0000000..b1889c7 --- /dev/null +++ b/example/examples/widgets/properties_panel/example_properties_panel.gui @@ -0,0 +1,368 @@ +nodes { + size { + x: 200.0 + y: 100.0 + } + type: TYPE_BOX + id: "root" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO + visible: false +} +nodes { + type: TYPE_TEMPLATE + id: "properties_panel" + parent: "root" + inherit_alpha: true + template: "/druid/widget/properties_panel/properties_panel.gui" +} +nodes { + type: TYPE_BOX + id: "properties_panel/root" + parent: "properties_panel" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/header" + parent: "properties_panel/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/text_header" + parent: "properties_panel/header" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/icon_drag" + parent: "properties_panel/header" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/content" + parent: "properties_panel/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/scroll_view" + parent: "properties_panel/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/scroll_content" + parent: "properties_panel/scroll_view" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/propeties" + parent: "properties_panel/content" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "properties_panel/property_slider" + parent: "properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_slider/root" + parent: "properties_panel/property_slider" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_slider/text_name" + parent: "properties_panel/property_slider/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_slider/E_Anchor" + parent: "properties_panel/property_slider/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_slider/slider" + parent: "properties_panel/property_slider/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_slider/slider_back" + parent: "properties_panel/property_slider/slider" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_slider/slider_pin" + parent: "properties_panel/property_slider/slider" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_slider/button" + parent: "properties_panel/property_slider/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_slider/selected" + parent: "properties_panel/property_slider/button" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_slider/text_value" + parent: "properties_panel/property_slider/button" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "properties_panel/property_checkbox" + parent: "properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_checkbox/root" + parent: "properties_panel/property_checkbox" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_checkbox/text_name" + parent: "properties_panel/property_checkbox/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_checkbox/E_Anchor" + parent: "properties_panel/property_checkbox/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_checkbox/button" + parent: "properties_panel/property_checkbox/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_checkbox/icon" + parent: "properties_panel/property_checkbox/button" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_checkbox/selected" + parent: "properties_panel/property_checkbox/button" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "properties_panel/property_button" + parent: "properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_button/root" + parent: "properties_panel/property_button" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_button/text_name" + parent: "properties_panel/property_button/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_button/E_Anchor" + parent: "properties_panel/property_button/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_button/button" + parent: "properties_panel/property_button/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_button/selected" + parent: "properties_panel/property_button/button" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_button/text_button" + parent: "properties_panel/property_button/button" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "properties_panel/property_input" + parent: "properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_input/root" + parent: "properties_panel/property_input" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_input/text_name" + parent: "properties_panel/property_input/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_input/E_Anchor" + parent: "properties_panel/property_input/root" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "properties_panel/property_input/rich_input" + parent: "properties_panel/property_input/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_input/rich_input/root" + parent: "properties_panel/property_input/rich_input" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_input/rich_input/button" + parent: "properties_panel/property_input/rich_input/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_input/rich_input/placeholder_text" + parent: "properties_panel/property_input/rich_input/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_input/rich_input/input_text" + parent: "properties_panel/property_input/rich_input/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_input/rich_input/cursor_node" + parent: "properties_panel/property_input/rich_input/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_input/rich_input/cursor_text" + parent: "properties_panel/property_input/rich_input/cursor_node" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_input/selected" + parent: "properties_panel/property_input/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "properties_panel/property_text" + parent: "properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_text/root" + parent: "properties_panel/property_text" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_text/text_name" + parent: "properties_panel/property_text/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_text/text_right" + parent: "properties_panel/property_text/root" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "properties_panel/property_left_right_selector" + parent: "properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_left_right_selector/root" + parent: "properties_panel/property_left_right_selector" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_left_right_selector/text_name" + parent: "properties_panel/property_left_right_selector/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_left_right_selector/E_Anchor" + parent: "properties_panel/property_left_right_selector/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_left_right_selector/button_left" + parent: "properties_panel/property_left_right_selector/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_left_right_selector/icon_left" + parent: "properties_panel/property_left_right_selector/button_left" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_left_right_selector/button_right" + parent: "properties_panel/property_left_right_selector/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_left_right_selector/icon_right" + parent: "properties_panel/property_left_right_selector/button_right" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_left_right_selector/selected" + parent: "properties_panel/property_left_right_selector/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_left_right_selector/text_value" + parent: "properties_panel/property_left_right_selector/E_Anchor" + template_node_child: true +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/example/examples/widgets/properties_panel/example_properties_panel.lua b/example/examples/widgets/properties_panel/example_properties_panel.lua new file mode 100644 index 0000000..f892909 --- /dev/null +++ b/example/examples/widgets/properties_panel/example_properties_panel.lua @@ -0,0 +1,38 @@ +local properties_panel = require("druid.widget.properties_panel.properties_panel") + +---@class widget.example_properties_panel: druid.widget +local M = {} + + +function M:init() + self.properties_panel = self.druid:new_widget(properties_panel, "properties_panel") + + self.properties_panel:add_button("Button", function() + print("Button clicked") + end) + + self.properties_panel:add_checkbox("Checkbox", false, function(value) + print("Checkbox clicked", value) + end) + + self.properties_panel:add_input("Input", "Initial", function(value) + print("Input value", value) + end) + + self.properties_panel:add_left_right_selector("Arrows Number", 0, function(value) + print("Left Right Number value", value) + end):set_number_type(0, 42, true, 1) + + self.properties_panel:add_left_right_selector("Arrows Array", "Zero", function(value) + print("Left Right Array value", value) + end):set_array_type({"Zero", "One", "Two", "Three", "Four", "Five"}, false, 1) + + self.properties_panel:add_slider("Slider", 0.5, function(value) + print("Slider value", value) + end) + + self.properties_panel:add_text("Text", "Some text") +end + + +return M \ No newline at end of file diff --git a/game.project b/game.project index 5aebe16..e233e1c 100644 --- a/game.project +++ b/game.project @@ -24,6 +24,7 @@ dependencies#2 = https://github.com/Insality/defold-tweener/archive/refs/tags/3. dependencies#3 = https://github.com/Insality/panthera/archive/refs/tags/runtime.4.zip dependencies#4 = https://github.com/Insality/defold-lang/archive/refs/tags/3.zip dependencies#5 = https://github.com/Insality/defold-event/archive/refs/tags/10.zip +dependencies#6 = https://github.com/subsoap/defos/archive/refs/tags/v2.8.0.zip [library] include_dirs = druid From bc0ada7098c91edf15fd17411339767f7c744cef Mon Sep 17 00:00:00 2001 From: Insality Date: Thu, 21 Nov 2024 00:28:53 +0200 Subject: [PATCH 28/50] Remove register and update examples --- README.md | 7 - druid/custom/rich_input/rich_input.lua | 4 +- druid/system/druid_instance.lua | 4 +- example/components/container/container.lua | 527 ------------------ example/components/druid_logo/druid_logo.lua | 3 +- .../example_scene/example_scene.lua | 3 +- .../examples_list_view/examples_list_view.lua | 6 +- .../examples_list_view_item.lua | 6 +- .../components/output_list/output_list.lua | 6 +- .../panel_druid_profiler.lua | 12 +- .../panel_information/panel_information.lua | 14 +- .../properties/property_button.lua | 3 +- .../properties/property_checkbox.lua | 6 +- .../properties/property_slider.lua | 9 +- .../properties_panel/properties_panel.lua | 8 +- example/druid.gui_script | 3 +- .../examples/basic/hotkey/basic_hotkey.lua | 4 +- example/examples/basic/input/basic_input.lua | 5 +- .../examples/basic/input/input_password.lua | 5 +- example/examples/basic/input/rich_input.lua | 5 +- .../basic/progress_bar/basic_progress_bar.lua | 3 +- .../basic_progress_bar_slice9.lua | 3 +- .../basic/rich_text/basic_rich_text.lua | 3 +- .../basic/rich_text/rich_text_tags.lua | 11 +- .../basic/rich_text/rich_text_tags_custom.lua | 7 +- .../basic/scroll_slider/scroll_slider.lua | 3 +- .../examples/basic/slider/basic_slider.lua | 3 +- .../basic/slider/basic_slider_stepped.lua | 3 +- .../basic/slider/basic_slider_vertical.lua | 3 +- example/examples/basic/swipe/basic_swipe.lua | 3 +- example/examples/basic/text/basic_text.lua | 4 +- .../examples/basic/text/multiline_text.lua | 3 +- example/examples/basic/timer/basic_timer.lua | 5 +- .../data_list_add_remove_clear.lua | 3 +- .../data_list/basic/data_list_basic.lua | 3 +- .../basic/data_list_horizontal_basic.lua | 3 +- .../cache_with_component.lua | 3 +- .../gamepad/gamepad_tester/gamepad_tester.lua | 5 +- example/examples/intro/intro/intro.lua | 6 +- .../animation_blend/animation_blend.lua | 6 +- .../widgets/hover_hint/hover_hint_example.lua | 2 +- .../window_confirmation.lua | 9 +- .../windows/window_info/window_info.lua | 7 +- .../window_language/window_language.lua | 5 +- 44 files changed, 78 insertions(+), 668 deletions(-) delete mode 100644 example/components/container/container.lua diff --git a/README.md b/README.md index 77a9bee..a3c100a 100644 --- a/README.md +++ b/README.md @@ -178,13 +178,6 @@ Here is full **Druid** components list. ### Extended components -> Extended components before usage should be registered in **Druid** with [`druid.register()`](https://insality.github.io/druid/modules/Druid.html#druid.register) function. -> On usage of unregistered **Druid** component the next log will be shown in the console. -``` -local data_list = require("druid.extended.data_list") -druid.register("data_list", data_list) -``` - | Name | Description | Example |
Preview
| |------|-------------|---------|---------| | **[Data List](https://insality.github.io/druid/modules/DataList.html)** | Logic over Scroll and Grid components. Create only visible GUI nodes or components to make "infinity" scroll befaviour | [Data List Example](https://insality.github.io/druid/druid/?example=ui_example_data_list_basic) | | diff --git a/druid/custom/rich_input/rich_input.lua b/druid/custom/rich_input/rich_input.lua index db14b7b..067fbc1 100644 --- a/druid/custom/rich_input/rich_input.lua +++ b/druid/custom/rich_input/rich_input.lua @@ -43,8 +43,6 @@ local const = require("druid.const") local utf8_lua = require("druid.system.utf8") local utf8 = utf8 or utf8_lua -local input = require("druid.extended.input") - ---@class druid.rich_input: druid.base_component ---@field root node ---@field input druid.input @@ -209,7 +207,7 @@ function M:init(template, nodes) self.is_lshift = false self.is_lctrl = false - self.input = self.druid:new(input, "button", "input_text") + self.input = self.druid:new_input("button", "input_text") self.is_button_input_enabled = gui.is_enabled(self.input.button.node) self.cursor = self:get_node("cursor_node") diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index bf6cfe7..2260516 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -667,7 +667,7 @@ end local timer_component = require("druid.extended.timer") ---Create Timer component ---@param node string|node Gui text node ----@param seconds_from number Start timer value in seconds +---@param seconds_from number|nil Start timer value in seconds ---@param seconds_to number|nil End timer value in seconds ---@param callback function|nil Function on timer end ---@return druid.timer Timer component @@ -690,7 +690,7 @@ end local layout = require("druid.extended.layout") ---Create Layout component ---@param node string|node The_node id or gui.get_node(node_id). ----@param mode string vertical|horizontal|horizontal_wrap +---@param mode string|nil vertical|horizontal|horizontal_wrap. Default: horizontal ---@return druid.layout Layout component function M:new_layout(node, mode) return self:new(layout, node, mode) diff --git a/example/components/container/container.lua b/example/components/container/container.lua deleted file mode 100644 index 8e1bf1a..0000000 --- a/example/components/container/container.lua +++ /dev/null @@ -1,527 +0,0 @@ ---- Container component --- Container setup in GUI --- parent container - container that contains this container. If not, then it's a window default container or parent node --- container pivot - the point of the parent container that will be used as a pivot point for positioning --- node_offset - position offset from parent container pivot point (vector4 - offset in pixels from each side) --- adjust mode FIT - container will keep it's size and will be positioned inside parent container --- adjust mode STRETCH - container will have percentage of parent container size --- adjust mode STRETCH_X - container will have percentage of parent container size (only x side) --- adjust mode STRETCH_Y - container will have percentage of parent container size (only y side) --- Adjust Stretch and x_anchor == None: container will be positioned by pivot point with one side fixed margin, stretched to pivot side by percentage --- Adjust stretch and x_anchor ~= None: container will be positioned by pivot point, stretched to pivot side by percentage, but with fixed margins - -local const = require("druid.const") -local helper = require("druid.helper") -local component = require("druid.component") -local event = require("event.event") - ----@class druid.container: druid.base_component ----@field node node ----@field druid druid_instance ----@field node_offset vector4 ----@field origin_size vector3 ----@field size vector3 ----@field origin_position vector3 ----@field position vector3 ----@field pivot_offset vector3 ----@field center_offset vector3 ----@field mode string ----@field fit_size vector3 ----@field min_size_x number|nil ----@field min_size_y number|nil ----@field on_size_changed event @function on_size_changed(size) ----@field _parent_container druid.container ----@field _containers table ----@field _draggable_corners table -local M = component.create("container") - -local abs = math.abs -local min = math.min -local max = math.max - -local CORNER_PIVOTS = { - gui.PIVOT_NE, - gui.PIVOT_NW, - gui.PIVOT_SE, - gui.PIVOT_SW, -} - - ---- The Container init ----@param node node Gui node ----@param mode string Layout mode ----@param callback fun(self: druid.container, size: vector3) Callback on size changed -function M:init(node, mode, callback) - self.node = self:get_node(node) - self.druid = self:get_druid() - - self.min_size_x = 0 - self.min_size_y = 0 - self._containers = {} - self._draggable_corners = {} - self.node_offset = vmath.vector4(0) - self.node_fill_x = nil - self.node_fill_y = nil - self._position = gui.get_position(self.node) - local x_koef, y_koef = helper.get_screen_aspect_koef() - self.x_koef = x_koef - self.y_koef = y_koef - - self.x_anchor = gui.get_xanchor(self.node) - self.y_anchor = gui.get_yanchor(self.node) - - -- Can be changed - self.origin_size = gui.get_size(self.node) - self.size = gui.get_size(self.node) - self.position = gui.get_position(self.node) - self.origin_position = gui.get_position(self.node) - - local adjust_mode = gui.get_adjust_mode(self.node) - self.mode = mode or (adjust_mode == gui.ADJUST_FIT) and const.LAYOUT_MODE.FIT or const.LAYOUT_MODE.STRETCH - - gui.set_size_mode(self.node, gui.SIZE_MODE_MANUAL) - gui.set_adjust_mode(self.node, gui.ADJUST_FIT) - - self.on_size_changed = event.create(callback) - - self.pivot_offset = helper.get_pivot_offset(gui.get_pivot(self.node)) - self.center_offset = -vmath.vector3(self.size.x * self.pivot_offset.x, self.size.y * self.pivot_offset.y, 0) - self:set_size(self.size.x, self.size.y) -end - - -function M:on_late_init() - if not gui.get_parent(self.node) then - -- TODO: Scale issue here, in fit into window! - self:fit_into_window() - end -end - - -function M:on_remove() - self:clear_draggable_corners() -end - - -function M:refresh_origins() - self.origin_size = gui.get_size(self.node) - self.origin_position = gui.get_position(self.node) - self:set_pivot(gui.get_pivot(self.node)) -end - - ----@param pivot constant -function M:set_pivot(pivot) - gui.set_pivot(self.node, pivot) - self.pivot_offset = helper.get_pivot_offset(pivot) - self.center_offset = -vmath.vector3(self.size.x * self.pivot_offset.x, self.size.y * self.pivot_offset.y, 0) -end - - ---- Component style params. --- You can override this component styles params in Druid styles table --- or create your own style --- @table style --- @tfield[opt=vector3(24, 24, 0)] vector3 DRAGGABLE_CORNER_SIZE Size of box node for debug draggable corners --- @tfield[opt=vector4(1)] vector4 DRAGGABLE_CORNER_COLOR Color of debug draggable corners -function M:on_style_change(style) - self.style = {} - self.style.DRAGGABLE_CORNER_SIZE = style.DRAGGABLE_CORNER_SIZE or vmath.vector3(24, 24, 0) - self.style.DRAGGABLE_CORNER_COLOR = style.DRAGGABLE_CORNER_COLOR or vmath.vector4(10) -end - - ---- Set new size of layout node ----@param width number|nil ----@param height number|nil ----@return druid.container Container -function M:set_size(width, height) - width = width or self.size.x - height = height or self.size.y - - if self.min_size_x then - width = max(width, self.min_size_x) - end - if self.min_size_y then - height = max(height, self.min_size_y) - end - - if (width and width ~= self.size.x) or (height and height ~= self.size.y) then - self.center_offset.x = -width * self.pivot_offset.x - self.center_offset.y = -height * self.pivot_offset.y - self.size.x = width - self.size.y = height - self.size.z = 0 - gui.set_size(self.node, self.size) - - self:update_child_containers() - self.on_size_changed:trigger(self:get_context(), self.size) - end - - return self -end - - ----@param pos_x number ----@param pos_y number -function M:set_position(pos_x, pos_y) - if self._position.x == pos_x and self._position.y == pos_y then - return - end - - self._position.x = pos_x - self._position.y = pos_y - gui.set_position(self.node, self._position) -end - - ----Get current size of layout node ----@return vector3 size -function M:get_size() - return self.size -end - - ----Get current scale of layout node ----@return vector3 scale -function M:get_scale() - return helper.get_scene_scale(self.node, true) --[[@as vector3]] -end - - ---- Set size for layout node to fit inside it ----@param target_size vector3 ----@return druid.container Container -function M:fit_into_size(target_size) - self.fit_size = target_size - self:refresh() - - return self -end - - ---- Set current size for layout node to fit inside it ----@return druid.container Container -function M:fit_into_window() - return self:fit_into_size(vmath.vector3(gui.get_width(), gui.get_height(), 0)) -end - - -function M:on_window_resized() - local x_koef, y_koef = helper.get_screen_aspect_koef() - self.x_koef = x_koef - self.y_koef = y_koef - - if not self._parent_container then - self:refresh() - end -end - - ----@param node_or_container node|string|druid.container|table ----@param mode string|nil stretch, fit, stretch_x, stretch_y. Default: Pick from node, "fit" or "stretch" ----@param on_resize_callback fun(self: userdata, size: vector3)|nil ----@return druid.container Container New created layout instance -function M:add_container(node_or_container, mode, on_resize_callback) - local container = nil - local node = node_or_container - - -- Check it's a container components instead of node - if type(node_or_container) == "table" and node_or_container._component then - node = node_or_container.node - container = node_or_container - mode = mode or container.mode - end - - -- Covert node_id to node if needed - node = self:get_node(node) - - container = container or self.druid:new(M, node, mode) - container:set_parent_container(self) - if on_resize_callback then - container.on_size_changed:subscribe(on_resize_callback) - end - table.insert(self._containers, container) - - return container -end - - ----@return druid.container|nil -function M:remove_container_by_node(node) - for index = 1, #self._containers do - local container = self._containers[index] - if container.node == node then - table.remove(self._containers, index) - self.druid:remove(container) - return container - end - end - - return nil -end - - ----@param parent_container druid.container|nil -function M:set_parent_container(parent_container) - if not parent_container then - self._parent_container = nil - gui.set_parent(self.node, nil) - self:refresh() - return - end - - -- TODO: Just check it's already parent - gui.set_parent(self.node, parent_container.node, true) - - -- Node offset - fixed distance from parent side to the child side - local parent_left = parent_container.center_offset.x - parent_container.origin_size.x * 0.5 - local parent_right = parent_container.center_offset.x + parent_container.origin_size.x * 0.5 - local parent_top = parent_container.center_offset.y + parent_container.origin_size.y * 0.5 - local parent_bottom = parent_container.center_offset.y - parent_container.origin_size.y * 0.5 - - local node_left = self.origin_position.x + self.center_offset.x - self.origin_size.x * 0.5 - local node_right = self.origin_position.x + self.center_offset.x + self.origin_size.x * 0.5 - local node_top = self.origin_position.y + self.center_offset.y + self.origin_size.y * 0.5 - local node_bottom = self.origin_position.y + self.center_offset.y - self.origin_size.y * 0.5 - - self.node_offset.x = node_left - parent_left - self.node_offset.y = node_top - parent_top - self.node_offset.z = node_right - parent_right - self.node_offset.w = node_bottom - parent_bottom - self._parent_container = parent_container - - local offset_x = (self.node_offset.x + self.node_offset.z)/2 - local offset_y = (self.node_offset.y + self.node_offset.w)/2 - - if self.pivot_offset.x < 0 then - offset_x = self.node_offset.x - end - if self.pivot_offset.x > 0 then - offset_x = self.node_offset.z - end - if self.pivot_offset.y < 0 then - offset_y = self.node_offset.w - end - if self.pivot_offset.y > 0 then - offset_y = self.node_offset.y - end - - local koef_x = (parent_container.origin_size.x - abs(offset_x)) - self.node_fill_x = koef_x ~= 0 and self.origin_size.x / koef_x or 1 - local x_anchor = gui.get_xanchor(self.node) - if x_anchor ~= gui.ANCHOR_NONE then - self.node_fill_x = 1 - end - - local koef_y = (parent_container.origin_size.y - abs(offset_y)) - self.node_fill_y = koef_y ~= 0 and self.origin_size.y / koef_y or 1 - local y_anchor = gui.get_yanchor(self.node) - if y_anchor ~= gui.ANCHOR_NONE then - self.node_fill_y = 1 - end - - self:refresh() -end - - --- Glossary --- Center Offset - vector from node position to visual center of node -function M:refresh() - local x_koef, y_koef = self.x_koef, self.y_koef - self:refresh_scale() - - if self._parent_container then - local parent = self._parent_container - local offset_x = (self.node_offset.x + self.node_offset.z) / 2 - local offset_y = (self.node_offset.y + self.node_offset.w) / 2 - - if self.pivot_offset.x < 0 then - offset_x = self.node_offset.x - end - if self.pivot_offset.x > 0 then - offset_x = self.node_offset.z - end - if self.pivot_offset.y < 0 then - offset_y = self.node_offset.w - end - if self.pivot_offset.y > 0 then - offset_y = self.node_offset.y - end - - local stretch_side_x = parent.size.x - abs(offset_x) - local stretch_side_y = parent.size.y - abs(offset_y) - - do - local parent_pivot_x = parent.center_offset.x + (parent.size.x * self.pivot_offset.x) - local parent_pivot_y = parent.center_offset.y + (parent.size.y * self.pivot_offset.y) - local pos_x = parent_pivot_x + offset_x - local pos_y = parent_pivot_y + offset_y - self:set_position(pos_x, pos_y) - end - - do - if self.x_anchor ~= gui.ANCHOR_NONE then - stretch_side_x = parent.size.x - (abs(self.node_offset.x) + abs(self.node_offset.z)) - end - - if self.y_anchor ~= gui.ANCHOR_NONE then - stretch_side_y = parent.size.y - (abs(self.node_offset.y) + abs(self.node_offset.w)) - end - - ---- Size Update (for stretch) - if self.mode == const.LAYOUT_MODE.STRETCH then - self:set_size( - abs(stretch_side_x * self.node_fill_x), - abs(stretch_side_y * self.node_fill_y)) - end - - if self.mode == const.LAYOUT_MODE.STRETCH_X then - self:set_size(abs(stretch_side_x * self.node_fill_x), nil) - end - - if self.mode == const.LAYOUT_MODE.STRETCH_Y then - self:set_size(nil, abs(stretch_side_y * self.node_fill_y)) - end - end - else - if self.fit_size then - x_koef = self.fit_size.x / self.origin_size.x * x_koef - y_koef = self.fit_size.y / self.origin_size.y * y_koef - - if self.mode == const.LAYOUT_MODE.STRETCH then - self:set_size(self.origin_size.x * x_koef, self.origin_size.y * y_koef) - end - end - end - - self:update_child_containers() -end - - -function M:refresh_scale() - if self._fit_node then - local fit_node_size = gui.get_size(self._fit_node) - - local scale = vmath.vector3(1) - scale.x = min(fit_node_size.x / self.size.x, 1) - scale.y = min(fit_node_size.y / self.size.y, 1) - - scale.x = min(scale.x, scale.y) - scale.y = min(scale.x, scale.y) - - gui.set_scale(self.node, scale) - end -end - - -function M:update_child_containers() - for index = 1, #self._containers do - self._containers[index]:refresh() - end -end - - ----@return druid.container Container -function M:create_draggable_corners() - self:clear_draggable_corners() - - for _, corner_pivot in pairs(CORNER_PIVOTS) do - local corner_offset = helper.get_pivot_offset(corner_pivot) - local anchor_position = vmath.vector3( - self.center_offset.x + (self.size.x) * corner_offset.x, - self.center_offset.y + (self.size.y) * corner_offset.y, - 0) - - local new_draggable_node = gui.new_box_node(anchor_position, self.style.DRAGGABLE_CORNER_SIZE) - gui.set_color(new_draggable_node, self.style.DRAGGABLE_CORNER_COLOR) - gui.set_pivot(new_draggable_node, corner_pivot) - gui.set_parent(new_draggable_node, self.node) - self:add_container(new_draggable_node) - - ---@type druid.drag - local drag = self.druid:new_drag(new_draggable_node, function(_, x, y) - self:_on_corner_drag(x, y, corner_offset) - end) - table.insert(self._draggable_corners, drag) - - drag.style.DRAG_DEADZONE = 0 - end - - return self -end - - ----@return druid.container Container -function M:clear_draggable_corners() - for index = 1, #self._draggable_corners do - local drag_component = self._draggable_corners[index] - self.druid:remove(drag_component) - self:remove_container_by_node(drag_component.node) - gui.delete_node(drag_component.node) - end - - self._draggable_corners = {} - - return self -end - - -function M:_on_corner_drag(x, y, corner_offset) - x = corner_offset.x >= 0 and x or -x - y = corner_offset.y >= 0 and y or -y - - local size = self:get_size() - if self.min_size_x and size.x + x < self.min_size_x then - x = self.min_size_x - size.x - end - if self.min_size_y and size.y + y < self.min_size_y then - y = self.min_size_y - size.y - end - - if corner_offset.x < 0 then - self.node_offset.x = self.node_offset.x - x - end - if corner_offset.x > 0 then - self.node_offset.z = self.node_offset.z - x - end - if corner_offset.y < 0 then - self.node_offset.w = self.node_offset.w - y - end - if corner_offset.y > 0 then - self.node_offset.y = self.node_offset.y - y - end - - local pivot = gui.get_pivot(self.node) - local pivot_offset = helper.get_pivot_offset(pivot) - - local center_pos_x = self._position.x + (x * (pivot_offset.x + corner_offset.x)) - local center_pos_y = self._position.y + (y * (pivot_offset.y + corner_offset.y)) - - self:set_position(center_pos_x, center_pos_y) - self:set_size(size.x + x, size.y + y) -end - - ---- Set node for layout node to fit inside it. Pass nil to reset ----@param node string|node The node_id or gui.get_node(node_id) ----@return druid.container Layout -function M:fit_into_node(node) - self._fit_node = self:get_node(node) - self:refresh_scale() - return self -end - - ----@param min_size_x number|nil ----@param min_size_y number|nil -function M:set_min_size(min_size_x, min_size_y) - self.min_size_x = min_size_x or self.min_size_x - self.min_size_y = min_size_y or self.min_size_y - self:refresh() - - return self -end - - -return M diff --git a/example/components/druid_logo/druid_logo.lua b/example/components/druid_logo/druid_logo.lua index 4784a80..c2eb7d2 100644 --- a/example/components/druid_logo/druid_logo.lua +++ b/example/components/druid_logo/druid_logo.lua @@ -2,7 +2,6 @@ local panthera = require("panthera.panthera") local component = require("druid.component") local druid_logo_panthera = require("example.components.druid_logo.druid_logo_panthera") -local container = require("example.components.container.container") ---@class druid_logo: druid.base_component ---@field root druid.container @@ -16,7 +15,7 @@ local DruidLogo = component.create("druid_logo") function DruidLogo:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.root = self.druid:new(container, "root") --[[@as druid.container]] + self.root = self.druid:new_container("root") --[[@as druid.container]] self.root:add_container("E_Anchor") self.root:add_container("W_Anchor") diff --git a/example/components/example_scene/example_scene.lua b/example/components/example_scene/example_scene.lua index a237456..24ddb50 100644 --- a/example/components/example_scene/example_scene.lua +++ b/example/components/example_scene/example_scene.lua @@ -1,5 +1,4 @@ local component = require("druid.component") -local container = require("example.components.container.container") ---@class example_scene: druid.base_component ---@field root druid.container @@ -14,7 +13,7 @@ local M = component.create("example_scene") function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.root = self.druid:new(container, "root") --[[@as druid.container]] + self.root = self.druid:new_container("root") --[[@as druid.container]] self.root:add_container("text_debug_info") self.root:add_container("text_gui_path") diff --git a/example/components/examples_list_view/examples_list_view.lua b/example/components/examples_list_view/examples_list_view.lua index 92ae178..d5f98d2 100644 --- a/example/components/examples_list_view/examples_list_view.lua +++ b/example/components/examples_list_view/examples_list_view.lua @@ -1,7 +1,5 @@ local event = require("event.event") local component = require("druid.component") -local container = require("example.components.container.container") -local lang_text = require("druid.extended.lang_text") local storage = require("saver.storage") local examples_list_view_item = require("example.components.examples_list_view.examples_list_view_item") @@ -19,10 +17,10 @@ local M = component.create("examples_list_view") function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.root = self.druid:new(container, "root") --[[@as druid.container]] + self.root = self.druid:new_container("root") --[[@as druid.container]] self.root:add_container("text_header") - self.druid:new(lang_text, "text_header", "ui_examples") + self.druid:new_lang_text("text_header", "ui_examples") self.druid:new(examples_list_view_item, "examples_list_view_item") self.prefab = self:get_node("examples_list_view_item/root") diff --git a/example/components/examples_list_view/examples_list_view_item.lua b/example/components/examples_list_view/examples_list_view_item.lua index e87e27f..1b4edc1 100644 --- a/example/components/examples_list_view/examples_list_view_item.lua +++ b/example/components/examples_list_view/examples_list_view_item.lua @@ -1,6 +1,4 @@ local component = require("druid.component") -local container = require("example.components.container.container") -local lang_text = require("druid.extended.lang_text") ---@class examples_list_view_item: druid.base_component ---@field root druid.container @@ -14,8 +12,8 @@ local M = component.create("examples_list_view_item") function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.root = self.druid:new(container, "root") --[[@as druid.container]] - self.text = self.druid:new(lang_text, "text") --[[ @as druid.lang_text]] + self.root = self.druid:new_container("root") --[[@as druid.container]] + self.text = self.druid:new_lang_text("text") --[[ @as druid.lang_text]] self.icon = self:get_node("icon") self.selected = self:get_node("panel_selected") self.highlight = self:get_node("panel_highlight") diff --git a/example/components/output_list/output_list.lua b/example/components/output_list/output_list.lua index 39d3323..c7e0802 100644 --- a/example/components/output_list/output_list.lua +++ b/example/components/output_list/output_list.lua @@ -1,6 +1,4 @@ local component = require("druid.component") -local container = require("example.components.container.container") -local lang_text = require("druid.extended.lang_text") ---@class output_list: druid.base_component ---@field root druid.container @@ -14,7 +12,7 @@ local M = component.create("output_list") function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.root = self.druid:new(container, "root") --[[@as druid.container]] + self.root = self.druid:new_container("root") --[[@as druid.container]] self.root:add_container("text_header") self.root:add_container("separator") @@ -27,7 +25,7 @@ function M:init(template, nodes) self.scroll:bind_grid(self.grid) self.scroll:set_horizontal_scroll(false) - self.druid:new(lang_text, "text_header", "ui_output") + self.druid:new_lang_text("text_header", "ui_output") local defold_version = sys.get_engine_info().version gui.set_text(self:get_node("text_version_defold"), "Defold v" .. defold_version) diff --git a/example/components/panel_druid_profiler/panel_druid_profiler.lua b/example/components/panel_druid_profiler/panel_druid_profiler.lua index 9899a91..47804a4 100644 --- a/example/components/panel_druid_profiler/panel_druid_profiler.lua +++ b/example/components/panel_druid_profiler/panel_druid_profiler.lua @@ -1,8 +1,6 @@ local event = require("event.event") local helper = require("druid.helper") local component = require("druid.component") -local container = require("example.components.container.container") -local lang_text = require("druid.extended.lang_text") ---@class panel_druid_profiler: druid.base_component @@ -16,7 +14,7 @@ local FPS_SAMPLES = 60 function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.root = self.druid:new(container, "root") --[[@as druid.container]] + self.root = self.druid:new_container("root") --[[@as druid.container]] self.group_memory = self.root:add_container("group_memory") self.group_fps = self.root:add_container("group_fps") self.group_components = self.root:add_container("group_components") @@ -35,10 +33,10 @@ function M:init(template, nodes) self.text_components_amount = self.druid:new_text("text_components_amount") self.text_events_amount = self.druid:new_text("text_events_amount") - self.druid:new(lang_text, "text_memory", "ui_profiler_memory") - self.druid:new(lang_text, "text_fps", "ui_profiler_fps") - self.druid:new(lang_text, "text_components", "ui_profiler_components") - self.druid:new(lang_text, "text_events", "ui_profiler_events") + self.druid:new_lang_text("text_memory", "ui_profiler_memory") + self.druid:new_lang_text("text_fps", "ui_profiler_fps") + self.druid:new_lang_text("text_components", "ui_profiler_components") + self.druid:new_lang_text("text_events", "ui_profiler_events") self.previous_time = nil self.fps_samples = {} diff --git a/example/components/panel_information/panel_information.lua b/example/components/panel_information/panel_information.lua index fd0a35e..cd799dd 100644 --- a/example/components/panel_information/panel_information.lua +++ b/example/components/panel_information/panel_information.lua @@ -1,10 +1,6 @@ local lang = require("lang.lang") local component = require("druid.component") -local container = require("example.components.container.container") -local lang_text = require("druid.extended.lang_text") -local rich_text = require("druid.custom.rich_text.rich_text") - ---@class panel_information: druid.base_component ---@field root druid.container ---@field text_header druid.lang_text @@ -17,17 +13,17 @@ local PanelInformation = component.create("panel_information") function PanelInformation:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.root = self.druid:new(container, "root") --[[@as druid.container]] + self.root = self.druid:new_container("root") --[[@as druid.container]] self.root:add_container("text_header") self.root:add_container("scroll_view") self.root:add_container("S_Anchor") self.root:add_container("NE_Anchor") - self.druid:new(lang_text, "text_header", "ui_information") - self.druid:new(lang_text, "button_profiler/text", "ui_profiler") + self.druid:new_lang_text("text_header", "ui_information") + self.druid:new_lang_text("button_profiler/text", "ui_profiler") - --self.text_description = self.druid:new(lang_text, "text_description", "") --[[@as druid.lang_text]] - self.rich_text = self.druid:new(rich_text, "text_description") + --self.text_description = self.druid:new_lang_text("text_description", "") --[[@as druid.lang_text]] + self.rich_text = self.druid:new_rich_text("text_description") self.button_profiler = self.druid:new_button("button_profiler/root", self.on_profiler_click) self.button_profiler:set_key_trigger("key_p") self.button_view_code = self.druid:new_button("button_view_code/root") diff --git a/example/components/properties_panel/properties/property_button.lua b/example/components/properties_panel/properties/property_button.lua index 9ffa273..6dcc2ab 100644 --- a/example/components/properties_panel/properties/property_button.lua +++ b/example/components/properties_panel/properties/property_button.lua @@ -1,5 +1,4 @@ local component = require("druid.component") -local lang_text = require("druid.extended.lang_text") ---@class property_button: druid.base_component ---@field root node @@ -15,7 +14,7 @@ function M:init(template, nodes) self.druid = self:get_druid(template, nodes) self.root = self:get_node("root") - self.text_name = self.druid:new(lang_text, "text_name") --[[@as druid.lang_text]] + self.text_name = self.druid:new_lang_text("text_name") --[[@as druid.lang_text]] self.selected = self:get_node("selected") gui.set_alpha(self.selected, 0) diff --git a/example/components/properties_panel/properties/property_checkbox.lua b/example/components/properties_panel/properties/property_checkbox.lua index fbe92c5..d3e9ce8 100644 --- a/example/components/properties_panel/properties/property_checkbox.lua +++ b/example/components/properties_panel/properties/property_checkbox.lua @@ -1,6 +1,4 @@ local component = require("druid.component") -local container = require("example.components.container.container") -local lang_text = require("druid.extended.lang_text") ---@class property_checkbox: druid.base_component ---@field druid druid_instance @@ -15,7 +13,7 @@ local M = component.create("property_checkbox") ---@param nodes table function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.root = self.druid:new(container, "root") --[[@as druid.container]] + self.root = self.druid:new_container("root") --[[@as druid.container]] self.icon = self:get_node("icon") gui.set_enabled(self.icon, false) @@ -23,7 +21,7 @@ function M:init(template, nodes) self.selected = self:get_node("selected") gui.set_alpha(self.selected, 0) - self.text_name = self.druid:new(lang_text, "text_name") --[[@as druid.lang_text]] + self.text_name = self.druid:new_lang_text("text_name") --[[@as druid.lang_text]] self.button = self.druid:new_button("button", self.on_click) end diff --git a/example/components/properties_panel/properties/property_slider.lua b/example/components/properties_panel/properties/property_slider.lua index d5ada5f..82fd16b 100644 --- a/example/components/properties_panel/properties/property_slider.lua +++ b/example/components/properties_panel/properties/property_slider.lua @@ -1,7 +1,4 @@ local component = require("druid.component") -local container = require("example.components.container.container") -local lang_text = require("druid.extended.lang_text") -local slider = require("druid.extended.slider") ---@class property_slider: druid.base_component ---@field druid druid_instance @@ -17,14 +14,14 @@ local M = component.create("property_slider") function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.root = self.druid:new(container, "root") --[[@as druid.container]] + self.root = self.druid:new_container("root") --[[@as druid.container]] self.selected = self:get_node("selected") gui.set_alpha(self.selected, 0) self._value = 0 - self.text_name = self.druid:new(lang_text, "text_name") --[[@as druid.lang_text]] + self.text_name = self.druid:new_lang_text("text_name") --[[@as druid.lang_text]] self.text_value = self.druid:new_text("text_value") - self.slider = self.druid:new(slider, "slider_pin", vmath.vector3(68, 0, 0), self._on_slider_change_by_user) --[[@as druid.slider]] + self.slider = self.druid:new_slider("slider_pin", vmath.vector3(68, 0, 0), self._on_slider_change_by_user) --[[@as druid.slider]] self.slider:set_input_node("slider") self:set_text_function(function(value) diff --git a/example/components/properties_panel/properties_panel.lua b/example/components/properties_panel/properties_panel.lua index 667aa93..2d370d1 100644 --- a/example/components/properties_panel/properties_panel.lua +++ b/example/components/properties_panel/properties_panel.lua @@ -1,6 +1,4 @@ local component = require("druid.component") -local container = require("example.components.container.container") -local lang_text = require("druid.extended.lang_text") local property_checkbox = require("example.components.properties_panel.properties.property_checkbox") local property_slider = require("example.components.properties_panel.properties.property_slider") @@ -18,7 +16,7 @@ local M = component.create("properties_panel") function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.root = self.druid:new(container, "root") --[[@as druid.container]] + self.root = self.druid:new_container("root") --[[@as druid.container]] self.root:add_container("text_header") self.root:add_container("separator") --self.root:add_container("scroll_view", nil, function() @@ -27,8 +25,8 @@ function M:init(template, nodes) self.properties = {} - self.druid:new(lang_text, "text_header", "ui_properties_panel") - self.text_no_properties = self.druid:new(lang_text, "text_no_properties", "ui_no_properties") --[[@as druid.lang_text]] + self.druid:new_lang_text("text_header", "ui_properties_panel") + self.text_no_properties = self.druid:new_lang_text("text_no_properties", "ui_no_properties") --[[@as druid.lang_text]] self.scroll = self.druid:new_scroll("scroll_view", "scroll_content") self.grid = self.druid:new_grid("scroll_content", "item_size", 1) diff --git a/example/druid.gui_script b/example/druid.gui_script index ff90b43..1a7eb7c 100644 --- a/example/druid.gui_script +++ b/example/druid.gui_script @@ -3,7 +3,6 @@ local saver = require("saver.saver") local storage = require("saver.storage") local druid = require("druid.druid") -local container = require("example.components.container.container") local druid_logo = require("example.components.druid_logo.druid_logo") local panel_information = require("example.components.panel_information.panel_information") local example_scene = require("example.components.example_scene.example_scene") @@ -56,7 +55,7 @@ end --- This allow easily move components in the GUI scene and change the size of each section ---@param self druid.example local function setup_layout(self) - self.container_root = self.druid:new(container, "root") --[[@as druid.container]] + self.container_root = self.druid:new_container("root") --[[@as druid.container]] self.container_left = self.container_root:add_container("container_left", "stretch_y") self.container_logo = self.container_left:add_container("container_logo") self.container_examples = self.container_left:add_container("container_examples") diff --git a/example/examples/basic/hotkey/basic_hotkey.lua b/example/examples/basic/hotkey/basic_hotkey.lua index d003699..fec96aa 100644 --- a/example/examples/basic/hotkey/basic_hotkey.lua +++ b/example/examples/basic/hotkey/basic_hotkey.lua @@ -1,5 +1,3 @@ -local hotkey = require("druid.extended.hotkey") - local component = require("druid.component") ---@class basic_hotkey: druid.base_component @@ -15,7 +13,7 @@ function M:init(template, nodes) self.druid = self:get_druid(template, nodes) self.root = self:get_node("root") - self.hotkey = self.druid:new(hotkey, { "key_lshift", "key_x" }, self.on_hotkey) + self.hotkey = self.druid:new_hotkey({ "key_lshift", "key_x" }, self.on_hotkey) end diff --git a/example/examples/basic/input/basic_input.lua b/example/examples/basic/input/basic_input.lua index 3648191..7be4813 100644 --- a/example/examples/basic/input/basic_input.lua +++ b/example/examples/basic/input/basic_input.lua @@ -1,5 +1,4 @@ local component = require("druid.component") -local input = require("druid.extended.input") ---@class basic_input: druid.base_component ---@field druid druid_instance @@ -12,9 +11,9 @@ local M = component.create("basic_input") function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.input = self.druid:new(input, "input/root", "input/text") + self.input = self.druid:new_input("input/root", "input/text") - self.input_2 = self.druid:new(input, "input_2/root", "input_2/text") --[[@as druid.input]] + self.input_2 = self.druid:new_input("input_2/root", "input_2/text") --[[@as druid.input]] -- you can set custom style for input and their components -- Check in the example, how long tap on bottom input will erase text diff --git a/example/examples/basic/input/input_password.lua b/example/examples/basic/input/input_password.lua index d56760a..014f1d7 100644 --- a/example/examples/basic/input/input_password.lua +++ b/example/examples/basic/input/input_password.lua @@ -1,7 +1,6 @@ local component = require("druid.component") -local input = require("druid.extended.input") ----@class input_password: druid.component +---@class input_password: druid.base_component ---@field druid druid_instance ---@field root node local M = component.create("input_password") @@ -13,7 +12,7 @@ function M:init(template, nodes) self.druid = self:get_druid(template, nodes) self.root = self:get_node("root") - self.input = self.druid:new(input, "input/root", "input/text", gui.KEYBOARD_TYPE_PASSWORD) + self.input = self.druid:new_input("input/root", "input/text", gui.KEYBOARD_TYPE_PASSWORD) self.input:set_text("") self.input.on_input_unselect:subscribe(function(_, text) diff --git a/example/examples/basic/input/rich_input.lua b/example/examples/basic/input/rich_input.lua index cef718c..a7e04ab 100644 --- a/example/examples/basic/input/rich_input.lua +++ b/example/examples/basic/input/rich_input.lua @@ -1,5 +1,4 @@ local component = require("druid.component") -local rich_input = require("druid.custom.rich_input.rich_input") ---@class rich_input: druid.base_component ---@field druid druid_instance @@ -11,10 +10,10 @@ local M = component.create("rich_input") function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.rich_input = self.druid:new(rich_input, "rich_input") --[[@as druid.rich_input]] + self.rich_input = self.druid:new_rich_input("rich_input") --[[@as druid.rich_input]] self.rich_input:set_placeholder("Enter text") - self.rich_input_2 = self.druid:new(rich_input, "rich_input_2") --[[@as druid.rich_input]] + self.rich_input_2 = self.druid:new_rich_input("rich_input_2") --[[@as druid.rich_input]] self.rich_input_2:set_placeholder("Enter text") end diff --git a/example/examples/basic/progress_bar/basic_progress_bar.lua b/example/examples/basic/progress_bar/basic_progress_bar.lua index 6681d01..fe85f93 100644 --- a/example/examples/basic/progress_bar/basic_progress_bar.lua +++ b/example/examples/basic/progress_bar/basic_progress_bar.lua @@ -1,5 +1,4 @@ local component = require("druid.component") -local progress = require("druid.extended.progress") ---@class basic_progress_bar: druid.base_component ---@field druid druid_instance @@ -12,7 +11,7 @@ local M = component.create("basic_progress_bar") function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.progress = self.druid:new(progress, "progress_bar_fill", "x") + self.progress = self.druid:new_progress("progress_bar_fill", "x") self.text_value = self:get_node("progress_value") self:set_value(self.progress:get()) diff --git a/example/examples/basic/progress_bar/basic_progress_bar_slice9.lua b/example/examples/basic/progress_bar/basic_progress_bar_slice9.lua index 9a73c0d..2640001 100644 --- a/example/examples/basic/progress_bar/basic_progress_bar_slice9.lua +++ b/example/examples/basic/progress_bar/basic_progress_bar_slice9.lua @@ -1,5 +1,4 @@ local component = require("druid.component") -local progress = require("druid.extended.progress") ---@class basic_progress_bar_slice9: druid.base_component ---@field druid druid_instance @@ -12,7 +11,7 @@ local M = component.create("basic_progress_bar_slice9") function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.progress = self.druid:new(progress, "progress_bar_fill", "x") + self.progress = self.druid:new_progress("progress_bar_fill", "x") self.text_value = self:get_node("progress_value") self:set_value(self.progress:get()) diff --git a/example/examples/basic/rich_text/basic_rich_text.lua b/example/examples/basic/rich_text/basic_rich_text.lua index 3abb632..e61226b 100644 --- a/example/examples/basic/rich_text/basic_rich_text.lua +++ b/example/examples/basic/rich_text/basic_rich_text.lua @@ -1,5 +1,4 @@ local component = require("druid.component") -local rich_text = require("druid.custom.rich_text.rich_text") ---@class basic_rich_text: druid.base_component ---@field druid druid_instance @@ -11,7 +10,7 @@ local M = component.create("basic_rich_text") ---@param nodes table function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.druid:new(rich_text, "text", "Hello, I'm a Rich Text!") + self.druid:new_rich_text("text", "Hello, I'm a Rich Text!") end diff --git a/example/examples/basic/rich_text/rich_text_tags.lua b/example/examples/basic/rich_text/rich_text_tags.lua index 69f65cb..dc8f6c7 100644 --- a/example/examples/basic/rich_text/rich_text_tags.lua +++ b/example/examples/basic/rich_text/rich_text_tags.lua @@ -1,5 +1,4 @@ local component = require("druid.component") -local rich_text = require("druid.custom.rich_text.rich_text") local helper = require("druid.helper") ---@class rich_text_tags: druid.base_component @@ -13,19 +12,19 @@ local M = component.create("rich_text_tags") function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.rich_text_color = self.druid:new(rich_text, "rich_text_color") --[[@as druid.rich_text]] + self.rich_text_color = self.druid:new_rich_text("rich_text_color") --[[@as druid.rich_text]] self.rich_text_color:set_text("Hello, I'm a Rich Text and it's nested color tag") - self.rich_text_font = self.druid:new(rich_text, "rich_text_font") --[[@as druid.rich_text]] + self.rich_text_font = self.druid:new_rich_text("rich_text_font") --[[@as druid.rich_text]] self.rich_text_font:set_text("Hello, I'm a Rich Text and this is bold text") - self.rich_text_size = self.druid:new(rich_text, "rich_text_size") --[[@as druid.rich_text]] + self.rich_text_size = self.druid:new_rich_text("rich_text_size") --[[@as druid.rich_text]] self.rich_text_size:set_text("Hello, I'm have East Pivot and different text scale") - self.rich_text_breaks = self.druid:new(rich_text, "rich_text_breaks") --[[@as druid.rich_text]] + self.rich_text_breaks = self.druid:new_rich_text("rich_text_breaks") --[[@as druid.rich_text]] self.rich_text_breaks:set_text("Hello, I'm Rich Text
With \"Line Breaks\"\nEnabled in GUI") - self.rich_text_image = self.druid:new(rich_text, "rich_text_image") --[[@as druid.rich_text]] + self.rich_text_image = self.druid:new_rich_text("rich_text_image") --[[@as druid.rich_text]] self.rich_text_image:set_text("Hello, I'mRich Text ") self.position = { diff --git a/example/examples/basic/rich_text/rich_text_tags_custom.lua b/example/examples/basic/rich_text/rich_text_tags_custom.lua index e541012..38adf14 100644 --- a/example/examples/basic/rich_text/rich_text_tags_custom.lua +++ b/example/examples/basic/rich_text/rich_text_tags_custom.lua @@ -1,5 +1,4 @@ local component = require("druid.component") -local rich_text = require("druid.custom.rich_text.rich_text") local helper = require("druid.helper") local event = require("event.event") @@ -15,7 +14,7 @@ function M:init(template, nodes) self.druid = self:get_druid(template, nodes) do -- Init rich text with links example - self.rich_text_link = self.druid:new(rich_text, "rich_text_link") --[[@as druid.rich_text]] + self.rich_text_link = self.druid:new_rich_text("rich_text_link") --[[@as druid.rich_text]] self.rich_text_link:set_text("Hello, I'm a Custom Link") local tagged = self.rich_text_link:tagged("custom_link") @@ -27,10 +26,10 @@ function M:init(template, nodes) end end - self.rich_text_characters = self.druid:new(rich_text, "rich_text_characters") --[[@as druid.rich_text]] + self.rich_text_characters = self.druid:new_rich_text("rich_text_characters") --[[@as druid.rich_text]] self.rich_text_characters:set_text("Hello, I'm a have a splitted characters") - self.rich_text_custom = self.druid:new(rich_text, "rich_text_custom") --[[@as druid.rich_text]] + self.rich_text_custom = self.druid:new_rich_text("rich_text_custom") --[[@as druid.rich_text]] self.rich_text_custom:set_text("Hello, I'm have South Text Pivot to adjust different text scale") self.position = { diff --git a/example/examples/basic/scroll_slider/scroll_slider.lua b/example/examples/basic/scroll_slider/scroll_slider.lua index 79723ef..0627f82 100644 --- a/example/examples/basic/scroll_slider/scroll_slider.lua +++ b/example/examples/basic/scroll_slider/scroll_slider.lua @@ -1,5 +1,4 @@ local component = require("druid.component") -local slider = require("druid.extended.slider") ---@class scroll_slider: druid.base_component ---@field root node @@ -16,7 +15,7 @@ function M:init(template, nodes) self.scroll = self.druid:new_scroll("scroll_view", "scroll_content") self.scroll.on_scroll:subscribe(self.on_scroll) - self.slider = self.druid:new(slider, "slider_pin", vmath.vector3(-8, -976, 0), self.on_slider) --[[@as druid.slider]] + self.slider = self.druid:new_slider("slider_pin", vmath.vector3(-8, -976, 0), self.on_slider) --[[@as druid.slider]] self.slider:set_input_node("slider_back") self.druid:new_hover("slider_back", nil, self.on_slider_back_hover) diff --git a/example/examples/basic/slider/basic_slider.lua b/example/examples/basic/slider/basic_slider.lua index 05fcabc..73fe031 100644 --- a/example/examples/basic/slider/basic_slider.lua +++ b/example/examples/basic/slider/basic_slider.lua @@ -1,5 +1,4 @@ local component = require("druid.component") -local slider = require("druid.extended.slider") ---@class basic_slider: druid.base_component ---@field druid druid_instance @@ -13,7 +12,7 @@ local M = component.create("basic_slider") function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.slider = self.druid:new(slider, "slider/slider_pin", vmath.vector3(118, 0, 0), self.on_slider_change) --[[@as druid.slider]] + self.slider = self.druid:new_slider("slider/slider_pin", vmath.vector3(118, 0, 0), self.on_slider_change) --[[@as druid.slider]] -- To add input across all slider widget add a root node to acquire additional input self.slider:set_input_node("slider/root") diff --git a/example/examples/basic/slider/basic_slider_stepped.lua b/example/examples/basic/slider/basic_slider_stepped.lua index 02becaf..8a22642 100644 --- a/example/examples/basic/slider/basic_slider_stepped.lua +++ b/example/examples/basic/slider/basic_slider_stepped.lua @@ -1,5 +1,4 @@ local component = require("druid.component") -local slider = require("druid.extended.slider") ---@class basic_slider_stepped: druid.base_component ---@field druid druid_instance @@ -13,7 +12,7 @@ local M = component.create("basic_slider_stepped") function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.slider = self.druid:new(slider, "slider/slider_pin", vmath.vector3(118, 0, 0), self.on_slider_change) --[[@as druid.slider]] + self.slider = self.druid:new_slider("slider/slider_pin", vmath.vector3(118, 0, 0), self.on_slider_change) --[[@as druid.slider]] -- To add input across all slider widget add a root node to acquire additional input self.slider:set_input_node("slider/root") diff --git a/example/examples/basic/slider/basic_slider_vertical.lua b/example/examples/basic/slider/basic_slider_vertical.lua index ba3eff7..bbeb019 100644 --- a/example/examples/basic/slider/basic_slider_vertical.lua +++ b/example/examples/basic/slider/basic_slider_vertical.lua @@ -1,5 +1,4 @@ local component = require("druid.component") -local slider = require("druid.extended.slider") ---@class basic_slider_vertical: druid.base_component ---@field druid druid_instance @@ -13,7 +12,7 @@ local M = component.create("basic_slider_vertical") function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.slider = self.druid:new(slider, "slider/slider_pin", vmath.vector3(0, -118, 0), self.on_slider_change) --[[@as druid.slider]] + self.slider = self.druid:new_slider("slider/slider_pin", vmath.vector3(0, -118, 0), self.on_slider_change) --[[@as druid.slider]] -- To add input across all slider widget add a root node to acquire additional input self.slider:set_input_node("slider/root") diff --git a/example/examples/basic/swipe/basic_swipe.lua b/example/examples/basic/swipe/basic_swipe.lua index e8d768a..ca56596 100644 --- a/example/examples/basic/swipe/basic_swipe.lua +++ b/example/examples/basic/swipe/basic_swipe.lua @@ -1,5 +1,4 @@ local component = require("druid.component") -local swipe = require("druid.extended.swipe") ---@class basic_swipe: druid.base_component ---@field druid druid_instance @@ -10,7 +9,7 @@ local M = component.create("basic_swipe") function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.swipe = self.druid:new(swipe, "root", self.on_swipe) --[[@as druid.swipe]] + self.swipe = self.druid:new_swipe("root", self.on_swipe) --[[@as druid.swipe]] self.text_hint = self:get_node("swipe_hint") end diff --git a/example/examples/basic/text/basic_text.lua b/example/examples/basic/text/basic_text.lua index 63889c5..dca1682 100644 --- a/example/examples/basic/text/basic_text.lua +++ b/example/examples/basic/text/basic_text.lua @@ -1,7 +1,5 @@ local helper = require("druid.helper") local component = require("druid.component") -local container = require("example.components.container.container") -local lang_text = require("druid.extended.lang_text") ---@class basic_text: druid.base_component ---@field druid druid_instance @@ -16,7 +14,7 @@ function M:init(template, nodes) self.text = self.druid:new_text("text") -- This code is for adjustable text area with mouse - self.container = self.druid:new(container, "text_area", nil, function(_, size) + self.container = self.druid:new_container("text_area", nil, function(_, size) self.text:set_size(size) self:refresh_text_position() end) --[[@as druid.container]] diff --git a/example/examples/basic/text/multiline_text.lua b/example/examples/basic/text/multiline_text.lua index 56f78c8..d50de10 100644 --- a/example/examples/basic/text/multiline_text.lua +++ b/example/examples/basic/text/multiline_text.lua @@ -1,6 +1,5 @@ local helper = require("druid.helper") local component = require("druid.component") -local container = require("example.components.container.container") ---@class multiline_text: druid.base_component ---@field root node @@ -16,7 +15,7 @@ function M:init(template, nodes) self.text = self.druid:new_text("text") -- This code is for adjustable text area with mouse - self.container = self.druid:new(container, "text_area", nil, function(_, size) + self.container = self.druid:new_container("text_area", nil, function(_, size) self.text:set_size(size) self:refresh_text_position() end) --[[@as druid.container]] diff --git a/example/examples/basic/timer/basic_timer.lua b/example/examples/basic/timer/basic_timer.lua index 0cc2a04..1687628 100644 --- a/example/examples/basic/timer/basic_timer.lua +++ b/example/examples/basic/timer/basic_timer.lua @@ -1,9 +1,8 @@ local event = require("event.event") -local timer = require("druid.extended.timer") local component = require("druid.component") ----@class basic_timer: druid.component +---@class basic_timer: druid.base_component ---@field druid druid_instance ---@field root node ---@field text druid.text @@ -16,7 +15,7 @@ function M:init(template, nodes) self.druid = self:get_druid(template, nodes) self.root = self:get_node("root") - self.timer = self.druid:new(timer, "text") + self.timer = self.druid:new_timer("text") local time = 5 self.timer:set_interval(time, 0) diff --git a/example/examples/data_list/add_remove_clear/data_list_add_remove_clear.lua b/example/examples/data_list/add_remove_clear/data_list_add_remove_clear.lua index e7f38d3..b4ab3f6 100644 --- a/example/examples/data_list/add_remove_clear/data_list_add_remove_clear.lua +++ b/example/examples/data_list/add_remove_clear/data_list_add_remove_clear.lua @@ -1,6 +1,5 @@ local event = require("event.event") local component = require("druid.component") -local data_list = require("druid.extended.data_list") ---@class data_list_add_remove_clear: druid.base_component ---@field druid druid_instance @@ -18,7 +17,7 @@ function M:init(template, nodes) self.scroll = self.druid:new_scroll("view", "content") self.grid = self.druid:new_grid("content", self.prefab, 1) - self.data_list = self.druid:new(data_list, self.scroll, self.grid, self.create_item_callback) --[[@as druid.data_list]] + self.data_list = self.druid:new_data_list(self.scroll, self.grid, self.create_item_callback) --[[@as druid.data_list]] local data = {} for index = 1, 20 do diff --git a/example/examples/data_list/basic/data_list_basic.lua b/example/examples/data_list/basic/data_list_basic.lua index 238e47a..f950b73 100644 --- a/example/examples/data_list/basic/data_list_basic.lua +++ b/example/examples/data_list/basic/data_list_basic.lua @@ -1,6 +1,5 @@ local event = require("event.event") local component = require("druid.component") -local data_list = require("druid.extended.data_list") ---@class data_list_basic: druid.base_component ---@field druid druid_instance @@ -17,7 +16,7 @@ function M:init(template, nodes) self.scroll = self.druid:new_scroll("view", "content") self.grid = self.druid:new_grid("content", self.prefab, 1) - self.data_list = self.druid:new(data_list, self.scroll, self.grid, self.create_item_callback) --[[@as druid.data_list]] + self.data_list = self.druid:new_data_list(self.scroll, self.grid, self.create_item_callback) --[[@as druid.data_list]] local data = {} for index = 1, 1000 do diff --git a/example/examples/data_list/basic/data_list_horizontal_basic.lua b/example/examples/data_list/basic/data_list_horizontal_basic.lua index 2bc5aff..262bea1 100644 --- a/example/examples/data_list/basic/data_list_horizontal_basic.lua +++ b/example/examples/data_list/basic/data_list_horizontal_basic.lua @@ -1,5 +1,4 @@ local component = require("druid.component") -local data_list = require("druid.extended.data_list") ---@class data_list_horizontal_basic: druid.base_component ---@field druid druid_instance @@ -16,7 +15,7 @@ function M:init(template, nodes) self.scroll = self.druid:new_scroll("view", "content") self.grid = self.druid:new_grid("content", self.prefab, 1000) - self.data_list = self.druid:new(data_list, self.scroll, self.grid, self.create_item_callback) --[[@as druid.data_list]] + self.data_list = self.druid:new_data_list(self.scroll, self.grid, self.create_item_callback) --[[@as druid.data_list]] local data = {} for index = 1, 100 do diff --git a/example/examples/data_list/cache_with_component/cache_with_component.lua b/example/examples/data_list/cache_with_component/cache_with_component.lua index ba89aba..ffd8622 100644 --- a/example/examples/data_list/cache_with_component/cache_with_component.lua +++ b/example/examples/data_list/cache_with_component/cache_with_component.lua @@ -1,6 +1,5 @@ local event = require("event.event") local component = require("druid.component") -local data_list = require("druid.extended.data_list") local button_component = require("example.examples.data_list.cache_with_component.button_component") @@ -19,7 +18,7 @@ function M:init(template, nodes) self.scroll = self.druid:new_scroll("view", "content") self.grid = self.druid:new_grid("content", self.prefab, 1) - self.data_list = self.druid:new(data_list, self.scroll, self.grid, self.create_item_callback) --[[@as druid.data_list]] + self.data_list = self.druid:new_data_list(self.scroll, self.grid, self.create_item_callback) --[[@as druid.data_list]] self.data_list:set_use_cache(true) self.data_list.on_element_add:subscribe(self.on_element_add) self.data_list.on_element_remove:subscribe(self.on_element_remove) diff --git a/example/examples/gamepad/gamepad_tester/gamepad_tester.lua b/example/examples/gamepad/gamepad_tester/gamepad_tester.lua index af59cab..4b807d4 100644 --- a/example/examples/gamepad/gamepad_tester/gamepad_tester.lua +++ b/example/examples/gamepad/gamepad_tester/gamepad_tester.lua @@ -1,5 +1,4 @@ local component = require("druid.component") -local progress = require("druid.extended.progress") ---@class gamepad_tester: druid.base_component ---@field root node @@ -38,8 +37,8 @@ function M:init(template, nodes) self.button_start = self.druid:new_button("button_start/button"):set_key_trigger("gamepad_start") self.button_back = self.druid:new_button("button_back/button"):set_key_trigger("gamepad_back") - self.trigger_l2 = self.druid:new(progress, "button_l2/fill", "x", 0) --[[@as druid.progress]] - self.trigger_r2 = self.druid:new(progress, "button_r2/fill", "x", 0) --[[@as druid.progress]] + self.trigger_l2 = self.druid:new_progress("button_l2/fill", "x", 0) --[[@as druid.progress]] + self.trigger_r2 = self.druid:new_progress("button_r2/fill", "x", 0) --[[@as druid.progress]] self.stick_left = self:get_node("stick_left/stick_root") self.stick_right = self:get_node("stick_right/stick_root") diff --git a/example/examples/intro/intro/intro.lua b/example/examples/intro/intro/intro.lua index 4473ba1..abeee0e 100644 --- a/example/examples/intro/intro/intro.lua +++ b/example/examples/intro/intro/intro.lua @@ -1,6 +1,4 @@ local component = require("druid.component") -local rich_text = require("druid.custom.rich_text.rich_text") -local layout = require("druid.extended.layout") local panthera = require("panthera.panthera") local intro_panthera = require("example.examples.intro.intro.intro_panthera") @@ -15,13 +13,13 @@ function M:init(template, nodes) self.druid = self:get_druid(template, nodes) self.root = self:get_node("root") - self.druid:new(rich_text, "text_hello", "Hello!") + self.druid:new_rich_text("text_hello", "Hello!") self.druid:new_button("sponsor_github", self.open_link, "https://github.com/sponsors/insality") self.druid:new_button("sponsor_coffee", self.open_link, "https://www.buymeacoffee.com/insality") self.druid:new_button("sponsor_kofi", self.open_link, "https://ko-fi.com/insality") - self.druid:new(layout, "sponsor") + self.druid:new_layout("sponsor") :add("sponsor_github") :add("sponsor_coffee") :add("sponsor_kofi") diff --git a/example/examples/panthera/animation_blend/animation_blend.lua b/example/examples/panthera/animation_blend/animation_blend.lua index b4c86d7..2192db2 100644 --- a/example/examples/panthera/animation_blend/animation_blend.lua +++ b/example/examples/panthera/animation_blend/animation_blend.lua @@ -2,8 +2,6 @@ local panthera = require("panthera.panthera") local component = require("druid.component") local helper = require("druid.helper") local event = require("event.event") -local lang_text = require("druid.extended.lang_text") -local rich_text = require("druid.custom.rich_text.rich_text") local character_animation_blend = require("example.examples.panthera.animation_blend.character_animation_blend") @@ -20,7 +18,7 @@ function M:init(template, nodes) self.root = self:get_node("root") self.root_size = gui.get_size(self.root) - self.druid:new(lang_text, "text_hint", "ui_example_panthera_animation_blend_hint") + self.druid:new_lang_text("text_hint", "ui_example_panthera_animation_blend_hint") self.animation_idle = panthera.create_gui(character_animation_blend, self:get_template(), nodes) self.animation_vertical = panthera.create_gui(character_animation_blend, self:get_template(), nodes) @@ -59,7 +57,7 @@ end function M:setup_rich_text() - self.rich_text = self.druid:new(rich_text, "rich_text_kenney", "Character assets by Kenney") + self.rich_text = self.druid:new_rich_text("rich_text_kenney", "Character assets by Kenney") local tagged = self.rich_text:tagged("link") for index = 1, #tagged do diff --git a/example/examples/widgets/hover_hint/hover_hint_example.lua b/example/examples/widgets/hover_hint/hover_hint_example.lua index 53633c1..28cf278 100644 --- a/example/examples/widgets/hover_hint/hover_hint_example.lua +++ b/example/examples/widgets/hover_hint/hover_hint_example.lua @@ -2,7 +2,7 @@ local hover_hint = require("example.examples.widgets.hover_hint.hover_hint") local component = require("druid.component") ----@class hover_hint_example: druid.component +---@class hover_hint_example: druid.base_component ---@field druid druid_instance local M = component.create("hover_hint_example") diff --git a/example/examples/windows/window_confirmation/window_confirmation.lua b/example/examples/windows/window_confirmation/window_confirmation.lua index a59bcd9..f91b7a5 100644 --- a/example/examples/windows/window_confirmation/window_confirmation.lua +++ b/example/examples/windows/window_confirmation/window_confirmation.lua @@ -1,5 +1,4 @@ local component = require("druid.component") -local lang_text = require("druid.extended.lang_text") local panthera = require("panthera.panthera") local window_animation_panthera = require("example.examples.windows.window_animation_panthera") @@ -19,10 +18,10 @@ local M = component.create("window_confirmation") function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.text_header = self.druid:new(lang_text, "text_header", "ui_confirmation") --[[@as druid.lang_text]] - self.text_button_accept = self.druid:new(lang_text, "button_accept/text", "ui_accept") --[[@as druid.lang_text]] - self.text_button_decline = self.druid:new(lang_text, "button_decline/text", "ui_decline") --[[@as druid.lang_text]] - self.text_description = self.druid:new(lang_text, "text") --[[@as druid.lang_text]] + self.text_header = self.druid:new_lang_text("text_header", "ui_confirmation") --[[@as druid.lang_text]] + self.text_button_accept = self.druid:new_lang_text("button_accept/text", "ui_accept") --[[@as druid.lang_text]] + self.text_button_decline = self.druid:new_lang_text("button_decline/text", "ui_decline") --[[@as druid.lang_text]] + self.text_description = self.druid:new_lang_text("text") --[[@as druid.lang_text]] self.button_close = self.druid:new_button("button_close", self.on_button_close) self.button_accept = self.druid:new_button("button_accept/root") diff --git a/example/examples/windows/window_info/window_info.lua b/example/examples/windows/window_info/window_info.lua index 26c36c1..3385176 100644 --- a/example/examples/windows/window_info/window_info.lua +++ b/example/examples/windows/window_info/window_info.lua @@ -1,6 +1,5 @@ local component = require("druid.component") local panthera = require("panthera.panthera") -local lang_text = require("druid.extended.lang_text") local window_animation_panthera = require("example.examples.windows.window_animation_panthera") @@ -18,9 +17,9 @@ local M = component.create("window_info") function M:init(template, nodes) self.druid = self:get_druid(template, nodes) - self.text_header = self.druid:new(lang_text, "text_header", "ui_information") --[[@as druid.lang_text]] - self.text_button_accept = self.druid:new(lang_text, "button_accept/text", "ui_accept") --[[@as druid.lang_text]] - self.text_description = self.druid:new(lang_text, "text") --[[@as druid.lang_text]] + self.text_header = self.druid:new_lang_text("text_header", "ui_information") --[[@as druid.lang_text]] + self.text_button_accept = self.druid:new_lang_text("button_accept/text", "ui_accept") --[[@as druid.lang_text]] + self.text_description = self.druid:new_lang_text("text") --[[@as druid.lang_text]] self.button_close = self.druid:new_button("button_close", self.on_button_close) self.button_accept = self.druid:new_button("button_accept/root") diff --git a/example/examples/windows/window_language/window_language.lua b/example/examples/windows/window_language/window_language.lua index 55dc74a..f572d64 100644 --- a/example/examples/windows/window_language/window_language.lua +++ b/example/examples/windows/window_language/window_language.lua @@ -2,7 +2,6 @@ local lang = require("lang.lang") local druid = require("druid.druid") local event = require("event.event") local component = require("druid.component") -local lang_text = require("druid.extended.lang_text") local panthera = require("panthera.panthera") local window_animation_panthera = require("example.examples.windows.window_animation_panthera") @@ -35,7 +34,7 @@ function M:init(template, nodes) self.button_close = self.druid:new_button("button_close", self.on_button_close) - self.druid:new(lang_text, "text_header", "ui_language") + self.druid:new_lang_text("text_header", "ui_language") self.grid = self.druid:new_grid("content", self.prefab, 2) self.grid.style.IS_DYNAMIC_NODE_POSES = true @@ -73,7 +72,7 @@ function M:load_langs() local text = prefab_nodes[template .. "button/text"] local button = self.druid:new_button(button_node, self.on_language_button, lang_id) - self.druid:new(lang_text, text, "ui_language_" .. lang_id) + self.druid:new_lang_text(text, "ui_language_" .. lang_id) gui.set_enabled(root, true) self.grid:add(root) From 9c03c950ad47efcb8b0b08ac5db863f361c56123 Mon Sep 17 00:00:00 2001 From: Insality Date: Thu, 21 Nov 2024 00:51:35 +0200 Subject: [PATCH 29/50] Remove on_message_input functional --- druid/base/button.lua | 25 ------------------------- druid/base/text.lua | 11 ----------- druid/component.lua | 3 --- druid/const.lua | 1 - druid/system/druid_instance.lua | 13 +------------ 5 files changed, 1 insertion(+), 52 deletions(-) diff --git a/druid/base/button.lua b/druid/base/button.lua index e21e7d9..ce93c85 100755 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -444,31 +444,6 @@ function M:on_input_interrupt() end -function M:on_message_input(node_id, message) - if node_id ~= self.node_id or self.disabled or not gui.is_enabled(self.node) then - return false - end - - if message.action == const.MESSAGE_INPUT.BUTTON_CLICK then - on_button_click(self) - end - - if message.action == const.MESSAGE_INPUT.BUTTON_LONG_CLICK then - on_button_long_click(self) - end - - if message.action == const.MESSAGE_INPUT.BUTTON_DOUBLE_CLICK then - on_button_double_click(self) - end - - if message.action == const.MESSAGE_INPUT.BUTTON_REPEATED_CLICK then - on_button_repeated_click(self) - self.is_repeated_started = false - self.last_pressed_time = socket.gettime() - end -end - - --- Set button enabled state. -- The style.on_set_enabled will be triggered. -- Disabled button is not clickable. diff --git a/druid/base/text.lua b/druid/base/text.lua index 7d394a8..ee05801 100755 --- a/druid/base/text.lua +++ b/druid/base/text.lua @@ -357,17 +357,6 @@ function M:on_layout_change() end -function M:on_message_input(node_id, message) - if node_id ~= self.node_id then - return false - end - - if message.action == const.MESSAGE_INPUT.TEXT_SET then - M.set_text(self, message.value) - end -end - - --- Calculate text width with font with respect to trailing space ---@param text string|nil ---@return number Width diff --git a/druid/component.lua b/druid/component.lua index 37e12ce..31890d4 100644 --- a/druid/component.lua +++ b/druid/component.lua @@ -50,7 +50,6 @@ M.ON_LATE_INIT = const.ON_LATE_INIT M.ON_FOCUS_LOST = const.ON_FOCUS_LOST M.ON_FOCUS_GAINED = const.ON_FOCUS_GAINED M.ON_LAYOUT_CHANGE = const.ON_LAYOUT_CHANGE -M.ON_MESSAGE_INPUT = const.ON_MESSAGE_INPUT M.ON_WINDOW_RESIZED = const.ON_WINDOW_RESIZED M.ON_LANGUAGE_CHANGE = const.ON_LANGUAGE_CHANGE @@ -62,7 +61,6 @@ M.ALL_INTERESTS = { M.ON_FOCUS_LOST, M.ON_FOCUS_GAINED, M.ON_LAYOUT_CHANGE, - M.ON_MESSAGE_INPUT, M.ON_WINDOW_RESIZED, M.ON_LANGUAGE_CHANGE, } @@ -73,7 +71,6 @@ M.SPECIFIC_UI_MESSAGES = { [hash(M.ON_FOCUS_LOST)] = M.ON_FOCUS_LOST, [hash(M.ON_FOCUS_GAINED)] = M.ON_FOCUS_GAINED, [hash(M.ON_WINDOW_RESIZED)] = M.ON_WINDOW_RESIZED, - [hash(M.ON_MESSAGE_INPUT)] = M.ON_MESSAGE_INPUT, [hash(M.ON_LANGUAGE_CHANGE)] = M.ON_LANGUAGE_CHANGE, } diff --git a/druid/const.lua b/druid/const.lua index 8bfd3d1..25d6b88 100755 --- a/druid/const.lua +++ b/druid/const.lua @@ -26,7 +26,6 @@ M.ON_LATE_INIT = "on_late_init" M.ON_FOCUS_LOST = "on_focus_lost" M.ON_FOCUS_GAINED = "on_focus_gained" M.ON_LAYOUT_CHANGE = "on_layout_change" -M.ON_MESSAGE_INPUT = "on_message_input" M.ON_WINDOW_RESIZED = "on_window_resized" M.ON_LANGUAGE_CHANGE = "on_language_change" diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index 2260516..0e2d9b7 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -386,18 +386,7 @@ end function M:on_message(message_id, message, sender) local specific_ui_message = base_component.SPECIFIC_UI_MESSAGES[message_id] - if specific_ui_message == base_component.ON_MESSAGE_INPUT then - -- ON_MESSAGE_INPUT is special message, need to perform additional logic - local components = self.components_interest[base_component.ON_MESSAGE_INPUT] - if components then - for i = 1, #components do - local component = components[i] - if can_use_input_component(self, component) then - component[specific_ui_message](component, hash(message.node_id), message) - end - end - end - elseif specific_ui_message then + if specific_ui_message then -- Resend special message to all components with the related interest local components = self.components_interest[specific_ui_message] if components then From 69ebb252e1c9d216a395a60cd5aadeb8447444b6 Mon Sep 17 00:00:00 2001 From: Insality Date: Thu, 21 Nov 2024 00:53:06 +0200 Subject: [PATCH 30/50] Remove no_auto_template and no_stencil_check settings --- docs_md/advanced-setup.md | 23 ----------------------- druid/base/button.lua | 2 +- druid/base/drag.lua | 2 +- druid/base/hover.lua | 2 +- druid/base/scroll.lua | 2 +- druid/component.lua | 3 +-- druid/const.lua | 2 -- druid/extended/swipe.lua | 2 +- 8 files changed, 6 insertions(+), 32 deletions(-) diff --git a/docs_md/advanced-setup.md b/docs_md/advanced-setup.md index ef95336..cf369d1 100644 --- a/docs_md/advanced-setup.md +++ b/docs_md/advanced-setup.md @@ -61,29 +61,6 @@ no_auto_input = 1 ``` -## Template Name Check - -By default, **Druid** automatically checks the parent component's template name to construct the full template name for the component. It's used in user custom components. - -If, for some reason, you want to pass the full template name manually, you can disable this feature by setting the `druid.no_auto_template` field in the _game.project_ file: - -``` -[druid] -no_auto_template = 1 -``` - - -## Stencil Check - -When creating input components inside stencil nodes, **Druid** automatically sets up `component:set_click_zone()` during the _late_init_ component step to restrict input clicks outside of the stencil zone. This is particularly useful for buttons inside scroll stencil nodes. - -To disable this feature, add the following field to your _game.project_ file: -``` -[druid] -no_stencil_check = 1 -``` - - ## Code Bindings Adjust **Druid** settings as needed: diff --git a/druid/base/button.lua b/druid/base/button.lua index ce93c85..d57a193 100755 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -347,7 +347,7 @@ end function M:on_late_init() - if not self.click_zone and const.IS_STENCIL_CHECK then + if not self.click_zone then local stencil_node = helper.get_closest_stencil_node(self.node) if stencil_node then self:set_click_zone(stencil_node) diff --git a/druid/base/drag.lua b/druid/base/drag.lua index de30165..da275d3 100644 --- a/druid/base/drag.lua +++ b/druid/base/drag.lua @@ -259,7 +259,7 @@ end function M:on_late_init() - if not self.click_zone and const.IS_STENCIL_CHECK then + if not self.click_zone then local stencil_node = helper.get_closest_stencil_node(self.node) if stencil_node then self:set_click_zone(stencil_node) diff --git a/druid/base/hover.lua b/druid/base/hover.lua index b3b3ed6..b1713b4 100644 --- a/druid/base/hover.lua +++ b/druid/base/hover.lua @@ -52,7 +52,7 @@ end function M:on_late_init() - if not self.click_zone and const.IS_STENCIL_CHECK then + if not self.click_zone then local stencil_node = helper.get_closest_stencil_node(self.node) if stencil_node then self:set_click_zone(stencil_node) diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index 22e3f4b..fd9d8ab 100755 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -212,7 +212,7 @@ end function M:on_late_init() - if not self.click_zone and const.IS_STENCIL_CHECK then + if not self.click_zone then local stencil_node = helper.get_closest_stencil_node(self.node) if stencil_node then self:set_click_zone(stencil_node) diff --git a/druid/component.lua b/druid/component.lua index 31890d4..000df35 100644 --- a/druid/component.lua +++ b/druid/component.lua @@ -40,7 +40,6 @@ local helper = require("druid.helper") local M = {} local INTERESTS = {} -- Cache interests per component class in runtime -local IS_AUTO_TEMPLATE = not (sys.get_config_int("druid.no_auto_template", 0) == 1) -- Component Interests M.ON_INPUT = const.ON_INPUT @@ -114,7 +113,7 @@ function M:set_template(template) template = template or "" local parent = self:get_parent_component() - if parent and IS_AUTO_TEMPLATE then + if parent then local parent_template = parent:get_template() if #parent_template > 0 then if #template > 0 then diff --git a/druid/const.lua b/druid/const.lua index 25d6b88..b1e5ea4 100755 --- a/druid/const.lua +++ b/druid/const.lua @@ -17,8 +17,6 @@ M.ACTION_LSHIFT = hash(sys.get_config_string("druid.input_key_lshift", "key_lshi 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.ON_INPUT = "on_input" M.ON_UPDATE = "update" M.ON_MESSAGE = "on_message" diff --git a/druid/extended/swipe.lua b/druid/extended/swipe.lua index ed95364..ae2b2ee 100644 --- a/druid/extended/swipe.lua +++ b/druid/extended/swipe.lua @@ -111,7 +111,7 @@ end function M:on_late_init() - if not self.click_zone and const.IS_STENCIL_CHECK then + if not self.click_zone then local stencil_node = helper.get_closest_stencil_node(self.node) if stencil_node then self:set_click_zone(stencil_node) From 5a1668a8af2a799202cb5f61f1c7654e6fc427f5 Mon Sep 17 00:00:00 2001 From: Insality Date: Thu, 21 Nov 2024 22:00:05 +0200 Subject: [PATCH 31/50] Update --- .gitignore | 3 +- druid/base/button.lua | 4 +- druid/base/drag.lua | 8 +- druid/base/static_grid.lua | 2 +- druid/component.lua | 39 +++--- druid/const.lua | 25 +--- druid/custom/rich_input/rich_input.lua | 6 +- druid/druid.lua | 74 +++-------- druid/extended/lang_text.lua | 6 +- druid/extended/layout.lua | 1 + druid/extended/progress.lua | 2 +- druid/extended/slider.lua | 9 +- druid/extended/swipe.lua | 22 +-- druid/helper.lua | 9 +- druid/materials/gui_world/gui_world.fp | 10 ++ druid/materials/gui_world/gui_world.material | 8 ++ druid/materials/gui_world/gui_world.vp | 16 +++ druid/system/druid_instance.lua | 125 ++++++++---------- druid/widget/mini_graph/mini_graph.lua | 1 - .../property_left_right_selector.gui | 4 +- .../properties_panel/properties_panel.lua | 3 +- settings_deployer | 2 +- 22 files changed, 174 insertions(+), 205 deletions(-) create mode 100644 druid/materials/gui_world/gui_world.fp create mode 100644 druid/materials/gui_world/gui_world.material create mode 100644 druid/materials/gui_world/gui_world.vp diff --git a/.gitignore b/.gitignore index 690997a..b8e9de9 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ deployer_version_settings.txt .deployer_cache bob*.jar manifest.private.der -manifest.public.der \ No newline at end of file +manifest.public.der +/.editor_settings \ No newline at end of file diff --git a/druid/base/button.lua b/druid/base/button.lua index d57a193..a8a6707 100755 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -154,7 +154,7 @@ local component = require("druid.component") ---@field anim_node node ---@field params any ---@field hover druid.hover ----@field click_zone node +---@field click_zone node|nil ---@field start_scale vector3 ---@field start_pos vector3 ---@field disabled boolean @@ -474,7 +474,7 @@ end ---@param zone node|string|nil Gui node ---@return druid.button self function M:set_click_zone(zone) - self.click_zone = self:get_node(zone) + self.click_zone = zone and self:get_node(zone) or nil self.hover:set_click_zone(zone) return self diff --git a/druid/base/drag.lua b/druid/base/drag.lua index da275d3..87f5be5 100644 --- a/druid/base/drag.lua +++ b/druid/base/drag.lua @@ -70,7 +70,7 @@ local component = require("druid.component") ---@field on_drag event ---@field on_drag_end event ---@field style table ----@field click_zone node +---@field click_zone node|nil ---@field is_touch boolean ---@field is_drag boolean ---@field can_x boolean @@ -365,9 +365,9 @@ end ---Set Drag click zone ---@param node node|string|nil ----@return druid.drag self +---@return druid.drag self Current instance function M:set_click_zone(node) - self.click_zone = self:get_node(node) + self.click_zone = node and self:get_node(node) or nil return self end @@ -375,7 +375,7 @@ end ---Set Drag component enabled state. ---@param is_enabled boolean ----@return druid.drag self +---@return druid.drag self Current instance function M:set_enabled(is_enabled) self._is_enabled = is_enabled diff --git a/druid/base/static_grid.lua b/druid/base/static_grid.lua index e815ffb..7788d99 100644 --- a/druid/base/static_grid.lua +++ b/druid/base/static_grid.lua @@ -541,7 +541,7 @@ end ---@private function M:_get_zero_offset() if not self.style.IS_DYNAMIC_NODE_POSES then - return const.VECTOR_ZERO + return vmath.vector3(0) end -- zero offset: center pos - border size * anchor diff --git a/druid/component.lua b/druid/component.lua index 000df35..350ebcb 100644 --- a/druid/component.lua +++ b/druid/component.lua @@ -1,17 +1,15 @@ ----Base component class for all Druid components. - local const = require("druid.const") local helper = require("druid.helper") ---@class druid.base_component.meta ---@field template string ---@field context table ----@field nodes table ----@field style table +---@field nodes table|nil +---@field style table|nil ---@field druid druid_instance ---@field input_enabled boolean ---@field children table ----@field parent druid.base_component +---@field parent druid.base_component|nil ---@field instance_class table ---@class druid.base_component.component @@ -64,15 +62,6 @@ M.ALL_INTERESTS = { M.ON_LANGUAGE_CHANGE, } --- Mapping from on_message method to specific method name -M.SPECIFIC_UI_MESSAGES = { - [hash("layout_changed")] = M.ON_LAYOUT_CHANGE, -- The message_id from Defold - [hash(M.ON_FOCUS_LOST)] = M.ON_FOCUS_LOST, - [hash(M.ON_FOCUS_GAINED)] = M.ON_FOCUS_GAINED, - [hash(M.ON_WINDOW_RESIZED)] = M.ON_WINDOW_RESIZED, - [hash(M.ON_LANGUAGE_CHANGE)] = M.ON_LANGUAGE_CHANGE, -} - local uid = 0 function M.create_uid() @@ -136,7 +125,7 @@ end ---Set current component nodes, returned from `gui.clone_tree` function. ----@param nodes table +---@param nodes table ---@return druid.base_component function M:set_nodes(nodes) self._meta.nodes = nodes @@ -271,7 +260,7 @@ end ---@param context table Druid context. Usually it is self of script ---@param style table Druid style module ---@param instance_class table The component instance class ----@return component BaseComponent itself +---@return druid.base_component BaseComponent itself ---@private function M:setup_component(druid_instance, context, style, instance_class) self._meta = { @@ -282,7 +271,7 @@ function M:setup_component(druid_instance, context, style, instance_class) druid = druid_instance, input_enabled = true, children = {}, - parent = type(context) ~= "userdata" and context, + parent = type(context) ~= "userdata" and context --[[@as druid.base_component]], instance_class = instance_class } @@ -341,20 +330,28 @@ function M:get_nodes() if parent then nodes = nodes or parent:get_nodes() end + return nodes end ---Add child to component children list ----@param child druid.base_component The druid component instance +---@generic T: druid.base_component +---@param child T The druid component instance +---@return T self The component itself for chaining ---@private function M:__add_child(child) table.insert(self._meta.children, child) + + return self end ---- Remove child from component children list ----@param child component The druid component instance + +---Remove child from component children list +---@generic T: druid.base_component +---@param child T The druid component instance +---@return boolean true if child was removed ---@private function M:__remove_child(child) for i = #self._meta.children, 1, -1 do @@ -363,6 +360,8 @@ function M:__remove_child(child) return true end end + + return false end diff --git a/druid/const.lua b/druid/const.lua index b1e5ea4..3ebb4d5 100755 --- a/druid/const.lua +++ b/druid/const.lua @@ -27,19 +27,13 @@ M.ON_LAYOUT_CHANGE = "on_layout_change" M.ON_WINDOW_RESIZED = "on_window_resized" M.ON_LANGUAGE_CHANGE = "on_language_change" +M.MSG_LAYOUT_CHANGED = hash("layout_changed") + -- Components with higher priority value processed first M.PRIORITY_INPUT = 10 M.PRIORITY_INPUT_HIGH = 20 M.PRIORITY_INPUT_MAX = 100 -M.MESSAGE_INPUT = { - BUTTON_CLICK = "button_click", - BUTTON_LONG_CLICK = "button_long_click", - BUTTON_DOUBLE_CLICK = "button_double_click", - BUTTON_REPEATED_CLICK = "button_repeated_click", - TEXT_SET = "text_set", -} - M.PIVOTS = { [gui.PIVOT_CENTER] = vmath.vector3(0), [gui.PIVOT_N] = vmath.vector3(0, 0.5, 0), @@ -73,7 +67,6 @@ M.LAYOUT_MODE = { STRETCH = gui.ADJUST_STRETCH, } -M.VECTOR_ZERO = vmath.vector3(0) M.SYS_INFO = sys.get_sys_info() M.CURRENT_SYSTEM_NAME = M.SYS_INFO.system_name @@ -94,13 +87,13 @@ M.SHIFT = { M.TEXT_ADJUST = { DOWNSCALE = "downscale", + NO_ADJUST = "no_adjust", + DOWNSCALE_LIMITED = "downscale_limited", + SCROLL = "scroll", TRIM = "trim", TRIM_LEFT = "trim_left", SCALE_THEN_TRIM = "scale_then_trim", SCALE_THEN_TRIM_LEFT = "scale_then_trim_left", - NO_ADJUST = "no_adjust", - DOWNSCALE_LIMITED = "downscale_limited", - SCROLL = "scroll", SCALE_THEN_SCROLL = "scale_then_scroll", } @@ -109,13 +102,5 @@ M.SIDE = { Y = "y" } -M.SWIPE = { - UP = "up", - DOWN = "down", - LEFT = "left", - RIGHT = "right", -} - -M.EMPTY_FUNCTION = function() end return M diff --git a/druid/custom/rich_input/rich_input.lua b/druid/custom/rich_input/rich_input.lua index 067fbc1..fdc5f10 100644 --- a/druid/custom/rich_input/rich_input.lua +++ b/druid/custom/rich_input/rich_input.lua @@ -279,8 +279,8 @@ end --- Set input field text ----@return druid.input Current input instance ---@param text string The input text +---@return druid.rich_input self Current instance function M:set_text(text) self.input:set_text(text) gui.set_enabled(self.placeholder.node, true and #self.input:get_text() == 0) @@ -291,7 +291,7 @@ end --- Set input field font ---@param font hash The font hash ----@return druid.input Current input instance +---@return druid.rich_input self Current instance function M:set_font(font) gui.set_font(self.input.text.node, font) gui.set_font(self.placeholder.node, font) @@ -310,7 +310,7 @@ end -- See: https://defold.com/ref/stable/string/ -- ex: [%a%d] for alpha and numeric ---@param characters string Regulax exp. for validate user input ----@return RichInput Current instance +---@return druid.rich_input Current instance function M:set_allowed_characters(characters) self.input:set_allowed_characters(characters) diff --git a/druid/druid.lua b/druid/druid.lua index 6fb3d68..ce3f034 100644 --- a/druid/druid.lua +++ b/druid/druid.lua @@ -1,27 +1,26 @@ -local const = require("druid.const") +local events = require("event.events") local settings = require("druid.system.settings") -local base_component = require("druid.component") local druid_instance = require("druid.system.druid_instance") local default_style = require("druid.styles.default.style") ---@class druid local M = {} -local druid_instances = {} -local function clean_deleted_druid_instances() - for i = #druid_instances, 1, -1 do - if druid_instances[i]._deleted then - table.remove(druid_instances, i) - end +---Create a new Druid instance for creating GUI components. +---@param context table The Druid context. Usually, this is the self of the gui_script. It is passed into all Druid callbacks. +---@param style table|nil The Druid style table to override style parameters for this Druid instance. +---@return druid_instance druid_instance The new Druid instance +function M.new(context, style) + if settings.default_style == nil then + M.set_default_style(default_style) end -end + local new_instance = setmetatable({}, { __index = druid_instance }) + new_instance:initialize(context, style) -local function get_druid_instances() - clean_deleted_druid_instances() - return druid_instances + return new_instance end @@ -39,25 +38,6 @@ function M.register(name, module) end ----Create a new Druid instance for creating GUI components. ----@param context table The Druid context. Usually, this is the self of the gui_script. It is passed into all Druid callbacks. ----@param style table|nil The Druid style table to override style parameters for this Druid instance. ----@return druid_instance druid_instance The new Druid instance -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 = setmetatable({}, { __index = druid_instance }) - new_instance:initialize(context, style) - - table.insert(druid_instances, new_instance) - return new_instance -end - - ---Set the default style for all Druid instances. ---@param style table Default style function M.set_default_style(style) @@ -68,7 +48,7 @@ end ---Set the text function for the LangText component. ---@param callback fun(text_id: string): string Get localized text function function M.set_text_function(callback) - settings.get_text = callback or const.EMPTY_FUNCTION + settings.get_text = callback or function() end M.on_language_change() end @@ -76,7 +56,7 @@ end ---Set the sound function to able components to play sounds. ---@param callback fun(sound_id: string) Sound play callback function M.set_sound_function(callback) - settings.play_sound = callback or const.EMPTY_FUNCTION + settings.play_sound = callback or function() end end @@ -84,40 +64,22 @@ end ---window listener, so if you have one, you should call M.on_window_callback manually. function M.init_window_listener() window.set_listener(function(_, window_event) - M.on_window_callback(window_event) + events.trigger("druid.window_event", window_event) end) end ---Set the window callback to enable Druid window events. ----@param event constant Event param from window listener -function M.on_window_callback(event) - local instances = get_druid_instances() - - if event == window.WINDOW_EVENT_FOCUS_LOST then - for i = 1, #instances do - msg.post(instances[i].url, base_component.ON_FOCUS_LOST) - end - elseif event == window.WINDOW_EVENT_FOCUS_GAINED then - for i = 1, #instances do - msg.post(instances[i].url, base_component.ON_FOCUS_GAINED) - end - elseif event == window.WINDOW_EVENT_RESIZED then - for i = 1, #instances do - msg.post(instances[i].url, base_component.ON_WINDOW_RESIZED) - end - end +---@param window_event constant Event param from window listener +function M.on_window_callback(window_event) + events.trigger("druid.window_event", window_event) end ---Call this function when the game language changes. ---It will notify all Druid instances to update the lang text components. function M.on_language_change() - local instances = get_druid_instances() - - for i = 1, #instances do - msg.post(instances[i].url, base_component.ON_LANGUAGE_CHANGE) - end + events.trigger("druid.language_change") end diff --git a/druid/extended/lang_text.lua b/druid/extended/lang_text.lua index df8a9e7..a2ee5f3 100755 --- a/druid/extended/lang_text.lua +++ b/druid/extended/lang_text.lua @@ -69,7 +69,7 @@ end --- Setup raw text to lang_text component ---@param text string Text for text node ----@return LangText Current instance +---@return druid.lang_text Current instance function M:set_to(text) self.last_locale = false self.text:set_to(text) @@ -88,7 +88,7 @@ end ---@param e string|nil Optional param to string.format ---@param f string|nil Optional param to string.format ---@param g string|nil Optional param to string.format ----@return LangText Current instance +---@return druid.lang_text Current instance function M:translate(locale_id, a, b, c, d, e, f, g) self.last_locale_args = { a, b, c, d, e, f, g } self.last_locale = locale_id or self.last_locale @@ -106,7 +106,7 @@ end ---@param e string|nil Optional param to string.format ---@param f string|nil Optional param to string.format ---@param g string|nil Optional param to string.format ----@return LangText Current instance +---@return druid.lang_text Current instance function M:format(a, b, c, d, e, f, g) self.last_locale_args = { a, b, c, d, e, f, g } self.text:set_to(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "") diff --git a/druid/extended/layout.lua b/druid/extended/layout.lua index 8c081e9..3bee2bd 100644 --- a/druid/extended/layout.lua +++ b/druid/extended/layout.lua @@ -221,6 +221,7 @@ function M:refresh_layout() 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() + self.rows_data = rows_data local rows = rows_data.rows local row_index = 1 local row = rows[row_index] diff --git a/druid/extended/progress.lua b/druid/extended/progress.lua index fb75ac7..bac6d3c 100644 --- a/druid/extended/progress.lua +++ b/druid/extended/progress.lua @@ -247,7 +247,7 @@ end --- Set progress bar max node size ---@param max_size vector3 The new node maximum (full) size ----@return Progress Progress +---@return druid.progress Progress function M:set_max_size(max_size) self.max_size[self.key] = max_size[self.key] self:set_to(self.last_value) diff --git a/druid/extended/slider.lua b/druid/extended/slider.lua index 26a4bec..197d57f 100644 --- a/druid/extended/slider.lua +++ b/druid/extended/slider.lua @@ -212,7 +212,7 @@ end -- apply closest step position ---@param steps number[] Array of steps -- @usage slider:set_steps({0, 0.2, 0.6, 1}) ----@return Slider Slider +---@return druid.slider Slider function M:set_steps(steps) self.steps = steps return self @@ -224,8 +224,13 @@ end -- move at this position and node drag will start. -- This function require the Defold version 1.3.0+ ---@param input_node node|string|nil ----@return Slider Slider +---@return druid.slider Slider function M:set_input_node(input_node) + if not input_node then + self._input_node = nil + return self + end + self._input_node = self:get_node(input_node) return self end diff --git a/druid/extended/swipe.lua b/druid/extended/swipe.lua index ae2b2ee..d40e63d 100644 --- a/druid/extended/swipe.lua +++ b/druid/extended/swipe.lua @@ -16,7 +16,7 @@ ---@param click_zone node|nil --- Trigger on swipe event(self, swipe_side, dist, delta_time) --- @tfield event on_swipe) event +---@param event event on_swipe --- @@ -27,7 +27,7 @@ local component = require("druid.component") ---@class druid.swipe: druid.base_component ---@field node node ----@field on_swipe event +---@field on_swipe event function(side, dist, dt), side - "left", "right", "up", "down" ---@field style table ---@field click_zone node ---@field private _trigger_on_move boolean @@ -62,16 +62,16 @@ local function check_swipe(self, action) local swipe_side = false if is_x_swipe and dx > 0 then - swipe_side = const.SWIPE.RIGHT + swipe_side = "right" end if is_x_swipe and dx < 0 then - swipe_side = const.SWIPE.LEFT + swipe_side = "left" end if not is_x_swipe and dy > 0 then - swipe_side = const.SWIPE.UP + swipe_side = "up" end if not is_x_swipe and dy < 0 then - swipe_side = const.SWIPE.DOWN + swipe_side = "down" end self.on_swipe:trigger(self:get_context(), swipe_side, dist, delta_time) @@ -83,10 +83,12 @@ end --- Component style params. -- You can override this component styles params in druid styles table -- or create your own style --- @table style --- @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 +---@class druid.swipe.style +---@field SWIPE_TIME number|nil Maximum time for swipe trigger. Default: 0.4 +---@field SWIPE_THRESHOLD number|nil Minimum distance for swipe trigger. Default: 50 +---@field SWIPE_TRIGGER_ON_MOVE boolean|nil If true, trigger on swipe moving, not only release action. Default: false + +---@param style druid.swipe.style function M:on_style_change(style) self.style = {} self.style.SWIPE_TIME = style.SWIPE_TIME or 0.4 diff --git a/druid/helper.lua b/druid/helper.lua index 14a89b2..f24ca56 100644 --- a/druid/helper.lua +++ b/druid/helper.lua @@ -1,7 +1,6 @@ ---- Druid Helper module - local const = require("druid.const") +-- Localize functions for better performance local gui_get_node = gui.get_node local gui_get = gui.get local gui_pick_node = gui.pick_node @@ -153,8 +152,7 @@ end ---@return number scale_x function M.get_gui_scale() local window_x, window_y = window.get_size() - return math.min(window_x / gui.get_width(), - window_y / gui.get_height()) + return math.min(window_x / gui.get_width(), window_y / gui.get_height()) end @@ -462,7 +460,7 @@ end ---Add value to array with shift policy --- Shift policy can be: left, right, no_shift +---Shift policy can be: left, right, no_shift ---@param array table Array ---@param item any Item to insert ---@param index number|nil Index to insert. If nil, item will be inserted at the end of array @@ -492,7 +490,6 @@ end ---Remove value from array with shift policy --- -- Shift policy can be: left, right, no_shift ---@param array any[] Array ---@param index number|nil Index to remove. If nil, item will be removed from the end of array diff --git a/druid/materials/gui_world/gui_world.fp b/druid/materials/gui_world/gui_world.fp new file mode 100644 index 0000000..aeddd5d --- /dev/null +++ b/druid/materials/gui_world/gui_world.fp @@ -0,0 +1,10 @@ +varying mediump vec2 var_texcoord0; +varying lowp vec4 var_color; + +uniform lowp sampler2D texture_sampler; + +void main() +{ + lowp vec4 tex = texture2D(texture_sampler, var_texcoord0.xy); + gl_FragColor = tex * var_color; +} diff --git a/druid/materials/gui_world/gui_world.material b/druid/materials/gui_world/gui_world.material new file mode 100644 index 0000000..f609d2e --- /dev/null +++ b/druid/materials/gui_world/gui_world.material @@ -0,0 +1,8 @@ +name: "gui_world" +tags: "tile" +vertex_program: "/druid/materials/gui_world/gui_world.vp" +fragment_program: "/druid/materials/gui_world/gui_world.fp" +vertex_constants { + name: "view_proj" + type: CONSTANT_TYPE_VIEWPROJ +} diff --git a/druid/materials/gui_world/gui_world.vp b/druid/materials/gui_world/gui_world.vp new file mode 100644 index 0000000..5e71498 --- /dev/null +++ b/druid/materials/gui_world/gui_world.vp @@ -0,0 +1,16 @@ +uniform highp mat4 view_proj; + +// positions are in world space +attribute highp vec3 position; +attribute mediump vec2 texcoord0; +attribute lowp vec4 color; + +varying mediump vec2 var_texcoord0; +varying lowp vec4 var_color; + +void main() +{ + var_texcoord0 = texcoord0; + var_color = vec4(color.rgb * color.a, color.a); + gl_Position = view_proj * vec4(position.xyz, 1.0); +} diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index 0e2d9b7..1a4547e 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -1,20 +1,4 @@ - --- Please review the following API pages: --- --- Helper - A useful set of functions for working with GUI nodes, such as centering nodes, get GUI scale ratio, etc --- --- event - The core event system in Druid. Learn how to subscribe to any event in every Druid component. --- --- BaseComponent - The parent class of all Druid components. You can find all default component methods there. --- --- # Tech Info # --- --- • To use Druid, you need to create a Druid instance first. This instance is used to spawn components. --- --- • When using Druid components, provide the node name as a string argument directly. Avoid calling gui.get_node() before passing it to the component. Because Druid can get nodes from template and cloned gui nodes. --- --- • All Druid and component methods are called using the colon operator (e.g., self.druid:new_button()). - +local events = require("event.events") local const = require("druid.const") local helper = require("druid.helper") local settings = require("druid.system.settings") @@ -162,7 +146,10 @@ local function check_sort_input_stack(self, components) end ---- Check whitelists and blacklists for input components +---Check whitelists and blacklists for input components +---@param self druid_instance +---@param component druid.base_component +---@return boolean local function can_use_input_component(self, component) local can_by_whitelist = true local can_by_blacklist = true @@ -222,7 +209,6 @@ function M:initialize(context, style) self._deleted = false self._is_late_remove_enabled = false self._late_remove = {} - self.url = msg.url() self._input_blacklist = nil self._input_whitelist = nil @@ -232,6 +218,9 @@ function M:initialize(context, style) for i = 1, #base_component.ALL_INTERESTS do self.components_interest[base_component.ALL_INTERESTS[i]] = {} end + + events.subscribe("druid.window_event", self.on_window_event, self) + events.subscribe("druid.language_change", self.on_language_change, self) end @@ -267,6 +256,9 @@ function M:final() self._deleted = true set_input_state(self, false) + + events.unsubscribe("druid.window_event", self.on_window_event, self) + events.unsubscribe("druid.language_change", self.on_language_change, self) end @@ -340,9 +332,7 @@ function M:late_init() end ---- Call this in gui_script update function. --- --- Used for: scroll, progress, timer components +---Call this in gui_script update function. ---@param dt number Delta time function M:update(dt) self._is_late_remove_enabled = true @@ -357,9 +347,7 @@ function M:update(dt) end ---- Call this in gui_script on_input function. --- --- Used for almost all components +---Call this in gui_script on_input function. ---@param action_id hash Action_id from on_input ---@param action table Action from on_input ---@return boolean The boolean value is input was consumed @@ -378,22 +366,15 @@ end --- Call this in gui_script on_message function. --- --- Used for special actions. See SPECIFIC_UI_MESSAGES table ---@param message_id hash Message_id from on_message ---@param message table Message from on_message ---@param sender url Sender from on_message function M:on_message(message_id, message, sender) - local specific_ui_message = base_component.SPECIFIC_UI_MESSAGES[message_id] - - if specific_ui_message then + if message_id == const.MSG_LAYOUT_CHANGED then -- Resend special message to all components with the related interest - local components = self.components_interest[specific_ui_message] - if components then - for i = 1, #components do - local component = components[i] - component[specific_ui_message](component, message, sender) - end + local components = self.components_interest[base_component.ON_LAYOUT_CHANGE] + for i = 1, #components do + components[i]:on_layout_change() end else -- Resend message to all components with on_message interest @@ -405,24 +386,22 @@ function M:on_message(message_id, message, sender) end ---- Calls the on_focus_lost function in all related components --- This one called by on_window_callback by global window listener ----@private -function M:on_focus_lost() - local components = self.components_interest[base_component.ON_FOCUS_LOST] - for i = 1, #components do - components[i]:on_focus_lost() - end -end - - ---- Calls the on_focus_gained function in all related components --- This one called by on_window_callback by global window listener ----@private -function M:on_focus_gained() - local components = self.components_interest[base_component.ON_FOCUS_GAINED] - for i = 1, #components do - components[i]:on_focus_gained() +function M:on_window_event(window_event) + if window_event == window.WINDOW_EVENT_FOCUS_LOST then + local components = self.components_interest[base_component.ON_FOCUS_LOST] + for i = 1, #components do + components[i]:on_focus_lost() + end + elseif window_event == window.WINDOW_EVENT_FOCUS_GAINED then + local components = self.components_interest[base_component.ON_FOCUS_GAINED] + for i = 1, #components do + components[i]:on_focus_gained() + end + elseif window_event == window.WINDOW_EVENT_RESIZED then + local components = self.components_interest[base_component.ON_WINDOW_RESIZED] + for i = 1, #components do + components[i]:on_window_resized() + end end end @@ -439,9 +418,9 @@ function M:on_language_change() end ---- Set whitelist components for input processing. --- If whitelist is not empty and component not contains in this list, --- component will be not processed on input step +---Set whitelist components for input processing. +---If whitelist is not empty and component not contains in this list, +---component will be not processed on input step ---@param whitelist_components table|druid.base_component[]|nil The array of component to whitelist ---@return druid_instance function M:set_whitelist(whitelist_components) @@ -459,9 +438,9 @@ function M:set_whitelist(whitelist_components) end ---- Set blacklist components for input processing. --- If blacklist is not empty and component contains in this list, --- component will be not processed on input step DruidInstance +---Set blacklist components for input processing. +---If blacklist is not empty and component contains in this list, +---component will be not processed on input step DruidInstance ---@param blacklist_components table|druid.base_component[]|nil The array of component to blacklist ---@return druid_instance function M:set_blacklist(blacklist_components) @@ -497,11 +476,17 @@ end ---@generic T: druid.base_component ---@param widget T ---@param template string|nil The template name used by widget ----@param nodes table|nil The nodes table from gui.clone_tree +---@param nodes table|node|nil The nodes table from gui.clone_tree or prefab node to use for clone ---@vararg any ---@return T function M:new_widget(widget, template, nodes, ...) local instance = create_widget(self, widget) + + if type(nodes) == "userdata" then + -- It's a node, we will use it as a root node to make nodes + nodes = gui.clone_tree(nodes) + end + instance.druid = instance:get_druid(template, nodes) if instance.init then @@ -614,7 +599,7 @@ local lang_text = require("druid.extended.lang_text") ---@param node string|node The_node id or gui.get_node(node_id) ---@param locale_id string|nil Default locale id or text from node as default ---@param adjust_type string|nil Adjust type for text node. Default: const.TEXT_ADJUST.DOWNSCALE ----@return druid.lang_text LangText component +---@return druid.lang_text lang_text component function M:new_lang_text(node, locale_id, adjust_type) return self:new(lang_text, node, locale_id, adjust_type) end @@ -625,7 +610,7 @@ local slider = require("druid.extended.slider") ---@param pin_node string|node The_node id or gui.get_node(node_id). ---@param end_pos vector3 The end position of slider ---@param callback function|nil On slider change callback ----@return druid.slider Slider component +---@return druid.slider slider component function M:new_slider(pin_node, end_pos, callback) return self:new(slider, pin_node, end_pos, callback) end @@ -636,7 +621,7 @@ local input = require("druid.extended.input") ---@param click_node string|node Button node to enabled input component ---@param text_node string|node|druid.text Text node what will be changed on user input ---@param keyboard_type number|nil Gui keyboard type for input field ----@return druid.input Input component +---@return druid.input input component function M:new_input(click_node, text_node, keyboard_type) return self:new(input, click_node, text_node, keyboard_type) end @@ -647,7 +632,7 @@ local data_list = require("druid.extended.data_list") ---@param druid_scroll druid.scroll The Scroll instance for Data List component ---@param druid_grid druid.grid The StaticGrid} or @{DynamicGrid instance for Data List component ---@param create_function function The create function callback(self, data, index, data_list). Function should return (node, [component]) ----@return druid.data_list DataList component +---@return druid.data_list data_list component function M:new_data_list(druid_scroll, druid_grid, create_function) return self:new(data_list, druid_scroll, druid_grid, create_function) end @@ -659,7 +644,7 @@ local timer_component = require("druid.extended.timer") ---@param seconds_from number|nil Start timer value in seconds ---@param seconds_to number|nil End timer value in seconds ---@param callback function|nil Function on timer end ----@return druid.timer Timer component +---@return druid.timer timer component function M:new_timer(node, seconds_from, seconds_to, callback) return self:new(timer_component, node, seconds_from, seconds_to, callback) end @@ -670,7 +655,7 @@ local progress = require("druid.extended.progress") ---@param node string|node Progress bar fill node or node name ---@param key string Progress bar direction: const.SIDE.X or const.SIDE.Y ---@param init_value number|nil Initial value of progress bar. Default: 1 ----@return druid.progress Progress component +---@return druid.progress progress component function M:new_progress(node, key, init_value) return self:new(progress, node, key, init_value) end @@ -680,7 +665,7 @@ local layout = require("druid.extended.layout") ---Create Layout component ---@param node string|node The_node id or gui.get_node(node_id). ---@param mode string|nil vertical|horizontal|horizontal_wrap. Default: horizontal ----@return druid.layout Layout component +---@return druid.layout layout component function M:new_layout(node, mode) return self:new(layout, node, mode) end @@ -691,7 +676,7 @@ local container = require("druid.extended.container") ---@param node string|node The_node id or gui.get_node(node_id). ---@param mode string|nil Layout mode ---@param callback fun(self: druid.container, size: vector3)|nil Callback on size changed ----@return druid.container Container component +---@return druid.container container component function M:new_container(node, mode, callback) return self:new(container, node, mode, callback) end @@ -702,7 +687,7 @@ local hotkey = require("druid.extended.hotkey") ---@param keys_array string|string[] Keys for trigger action. Should contains one action key and any amount of modificator keys ---@param callback function|nil The callback function ---@param callback_argument any|nil The argument to pass into the callback function ----@return druid.hotkey Hotkey component +---@return druid.hotkey hotkey component function M:new_hotkey(keys_array, callback, callback_argument) return self:new(hotkey, keys_array, callback, callback_argument) end diff --git a/druid/widget/mini_graph/mini_graph.lua b/druid/widget/mini_graph/mini_graph.lua index f8cff1e..3236850 100644 --- a/druid/widget/mini_graph/mini_graph.lua +++ b/druid/widget/mini_graph/mini_graph.lua @@ -8,7 +8,6 @@ local SIZE_Y = hash("size.y") function M:init() self.root = self:get_node("root") - self.container = self.druid:new_container(self.root) self.text_header = self.druid:new_text("text_header") self.druid:new_drag("header", self.on_drag_widget) diff --git a/druid/widget/properties_panel/properties/property_left_right_selector.gui b/druid/widget/properties_panel/properties/property_left_right_selector.gui index e959dd5..69f8b73 100644 --- a/druid/widget/properties_panel/properties/property_left_right_selector.gui +++ b/druid/widget/properties_panel/properties/property_left_right_selector.gui @@ -37,7 +37,7 @@ nodes { } type: TYPE_TEXT text: "Left Right Selector" - font: "text_bold" + font: "druid_text_bold" id: "text_name" pivot: PIVOT_W outline { @@ -191,7 +191,7 @@ nodes { } type: TYPE_TEXT text: "42" - font: "text_bold" + font: "druid_text_bold" id: "text_value" outline { x: 1.0 diff --git a/druid/widget/properties_panel/properties_panel.lua b/druid/widget/properties_panel/properties_panel.lua index 93227c5..a23f5c8 100644 --- a/druid/widget/properties_panel/properties_panel.lua +++ b/druid/widget/properties_panel/properties_panel.lua @@ -214,8 +214,7 @@ end ---@private function M:create_from_prefab(widget_class, widget_name, prefab) - local nodes = gui.clone_tree(prefab) - local instance = self.druid:new_widget(widget_class, widget_name, nodes) + local instance = self.druid:new_widget(widget_class, widget_name, prefab) self:add_property(instance) return instance end diff --git a/settings_deployer b/settings_deployer index 448e40d..e2a6722 100644 --- a/settings_deployer +++ b/settings_deployer @@ -2,7 +2,7 @@ bob_folder=./ # You can point bob version for project in format "filename:sha" -bob_sha="193:e4aaff11f49c941fde1dd93883cf69c6b8abebe4" +bob_sha="195:87b6907759f7b8dff830d54b2250b8d721bde291" # Select Defold channel. Values: stable, beta, alpha bob_channel="stable" From af44d0d26e067a1b9a56e3f096804ad185b5c2e5 Mon Sep 17 00:00:00 2001 From: Insality Date: Thu, 21 Nov 2024 22:38:40 +0200 Subject: [PATCH 32/50] Update components interests link --- druid/component.lua | 27 ++----------------- druid/const.lua | 12 +++++++++ druid/system/druid_instance.lua | 26 +++++++++--------- .../properties_panel/properties_panel.lua | 7 +++++ 4 files changed, 34 insertions(+), 38 deletions(-) diff --git a/druid/component.lua b/druid/component.lua index 350ebcb..e7deb30 100644 --- a/druid/component.lua +++ b/druid/component.lua @@ -39,29 +39,6 @@ local M = {} local INTERESTS = {} -- Cache interests per component class in runtime --- Component Interests -M.ON_INPUT = const.ON_INPUT -M.ON_UPDATE = const.ON_UPDATE -M.ON_MESSAGE = const.ON_MESSAGE -M.ON_LATE_INIT = const.ON_LATE_INIT -M.ON_FOCUS_LOST = const.ON_FOCUS_LOST -M.ON_FOCUS_GAINED = const.ON_FOCUS_GAINED -M.ON_LAYOUT_CHANGE = const.ON_LAYOUT_CHANGE -M.ON_WINDOW_RESIZED = const.ON_WINDOW_RESIZED -M.ON_LANGUAGE_CHANGE = const.ON_LANGUAGE_CHANGE - -M.ALL_INTERESTS = { - M.ON_INPUT, - M.ON_UPDATE, - M.ON_MESSAGE, - M.ON_LATE_INIT, - M.ON_FOCUS_LOST, - M.ON_FOCUS_GAINED, - M.ON_LAYOUT_CHANGE, - M.ON_WINDOW_RESIZED, - M.ON_LANGUAGE_CHANGE, -} - local uid = 0 function M.create_uid() @@ -310,8 +287,8 @@ function M:__get_interests() end local interests = {} - for index = 1, #M.ALL_INTERESTS do - local interest = M.ALL_INTERESTS[index] + for index = 1, #const.ALL_INTERESTS do + local interest = const.ALL_INTERESTS[index] if self[interest] and type(self[interest]) == "function" then table.insert(interests, interest) end diff --git a/druid/const.lua b/druid/const.lua index 3ebb4d5..46ac38c 100755 --- a/druid/const.lua +++ b/druid/const.lua @@ -27,6 +27,18 @@ M.ON_LAYOUT_CHANGE = "on_layout_change" M.ON_WINDOW_RESIZED = "on_window_resized" M.ON_LANGUAGE_CHANGE = "on_language_change" +M.ALL_INTERESTS = { + M.ON_INPUT, + M.ON_UPDATE, + M.ON_MESSAGE, + M.ON_LATE_INIT, + M.ON_FOCUS_LOST, + M.ON_FOCUS_GAINED, + M.ON_LAYOUT_CHANGE, + M.ON_WINDOW_RESIZED, + M.ON_LANGUAGE_CHANGE, +} + M.MSG_LAYOUT_CHANGED = hash("layout_changed") -- Components with higher priority value processed first diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index 1a4547e..e39fad1 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -49,7 +49,7 @@ end local function sort_input_stack(self) - local input_components = self.components_interest[base_component.ON_INPUT] + local input_components = self.components_interest[const.ON_INPUT] if not input_components then return end @@ -215,8 +215,8 @@ function M:initialize(context, style) self.components_all = {} self.components_interest = {} - for i = 1, #base_component.ALL_INTERESTS do - self.components_interest[base_component.ALL_INTERESTS[i]] = {} + for i = 1, #const.ALL_INTERESTS do + self.components_interest[const.ALL_INTERESTS[i]] = {} end events.subscribe("druid.window_event", self.on_window_event, self) @@ -319,13 +319,13 @@ end -- An example use case is performing an auto stencil check in the GUI hierarchy for input components. ---@private function M:late_init() - local late_init_components = self.components_interest[base_component.ON_LATE_INIT] + local late_init_components = self.components_interest[const.ON_LATE_INIT] while late_init_components[1] do late_init_components[1]:on_late_init() table.remove(late_init_components, 1) end - if not self.input_inited and #self.components_interest[base_component.ON_INPUT] > 0 then + if not self.input_inited and #self.components_interest[const.ON_INPUT] > 0 then -- Input init on late init step, to be sure it goes after user go acquire input set_input_state(self, true) end @@ -337,7 +337,7 @@ end function M:update(dt) self._is_late_remove_enabled = true - local components = self.components_interest[base_component.ON_UPDATE] + local components = self.components_interest[const.ON_UPDATE] for i = 1, #components do components[i]:update(dt) end @@ -354,7 +354,7 @@ end function M:on_input(action_id, action) self._is_late_remove_enabled = true - local components = self.components_interest[base_component.ON_INPUT] + local components = self.components_interest[const.ON_INPUT] check_sort_input_stack(self, components) local is_input_consumed = process_input(self, action_id, action, components) @@ -372,13 +372,13 @@ end function M:on_message(message_id, message, sender) if message_id == const.MSG_LAYOUT_CHANGED then -- Resend special message to all components with the related interest - local components = self.components_interest[base_component.ON_LAYOUT_CHANGE] + local components = self.components_interest[const.ON_LAYOUT_CHANGE] for i = 1, #components do components[i]:on_layout_change() end else -- Resend message to all components with on_message interest - local components = self.components_interest[base_component.ON_MESSAGE] + local components = self.components_interest[const.ON_MESSAGE] for i = 1, #components do components[i]:on_message(message_id, message, sender) end @@ -388,17 +388,17 @@ end function M:on_window_event(window_event) if window_event == window.WINDOW_EVENT_FOCUS_LOST then - local components = self.components_interest[base_component.ON_FOCUS_LOST] + local components = self.components_interest[const.ON_FOCUS_LOST] for i = 1, #components do components[i]:on_focus_lost() end elseif window_event == window.WINDOW_EVENT_FOCUS_GAINED then - local components = self.components_interest[base_component.ON_FOCUS_GAINED] + local components = self.components_interest[const.ON_FOCUS_GAINED] for i = 1, #components do components[i]:on_focus_gained() end elseif window_event == window.WINDOW_EVENT_RESIZED then - local components = self.components_interest[base_component.ON_WINDOW_RESIZED] + local components = self.components_interest[const.ON_WINDOW_RESIZED] for i = 1, #components do components[i]:on_window_resized() end @@ -411,7 +411,7 @@ end -- call manualy to update all translations ---@private function M:on_language_change() - local components = self.components_interest[base_component.ON_LANGUAGE_CHANGE] + local components = self.components_interest[const.ON_LANGUAGE_CHANGE] for i = 1, #components do components[i]:on_language_change() end diff --git a/druid/widget/properties_panel/properties_panel.lua b/druid/widget/properties_panel/properties_panel.lua index a23f5c8..6934dda 100644 --- a/druid/widget/properties_panel/properties_panel.lua +++ b/druid/widget/properties_panel/properties_panel.lua @@ -212,6 +212,13 @@ function M:add_left_right_selector(text, value, on_change_callback) end + +---@param widget druid.widget +function M:add_widget(widget) + self:add_property(widget) +end + + ---@private function M:create_from_prefab(widget_class, widget_name, prefab) local instance = self.druid:new_widget(widget_class, widget_name, prefab) From 28bd165cee3e76b65b38dc1d9b8ab5ea691c3060 Mon Sep 17 00:00:00 2001 From: Insality Date: Fri, 22 Nov 2024 02:22:21 +0200 Subject: [PATCH 33/50] Update --- druid/custom/rich_input/rich_input.gui | 6 +++--- druid/helper.lua | 17 +++++++++++++++++ druid/widget/fps_panel/fps_panel.lua | 9 ++++++++- druid/widget/memory_panel/memory_panel.lua | 14 +++++++++++++- .../properties/property_input.gui | 2 +- .../properties/property_text.gui | 4 ++-- 6 files changed, 44 insertions(+), 8 deletions(-) diff --git a/druid/custom/rich_input/rich_input.gui b/druid/custom/rich_input/rich_input.gui index ad0bb1d..c179f20 100644 --- a/druid/custom/rich_input/rich_input.gui +++ b/druid/custom/rich_input/rich_input.gui @@ -54,7 +54,7 @@ nodes { } type: TYPE_TEXT text: "Placeholder" - font: "text_bold" + font: "druid_text_bold" id: "placeholder_text" outline { x: 0.4 @@ -87,7 +87,7 @@ nodes { } type: TYPE_TEXT text: "User input" - font: "text_bold" + font: "druid_text_bold" id: "input_text" shadow { x: 1.0 @@ -145,7 +145,7 @@ nodes { } type: TYPE_TEXT text: "|" - font: "text_bold" + font: "druid_text_bold" id: "cursor_text" shadow { x: 1.0 diff --git a/druid/helper.lua b/druid/helper.lua index f24ca56..ac49d43 100644 --- a/druid/helper.lua +++ b/druid/helper.lua @@ -519,4 +519,21 @@ function M.remove_with_shift(array, index, shift_policy) end +---Get full position of node in the GUI tree +---@param node node GUI node +---@param root node|nil GUI root node to stop search +function M.get_full_position(node, root) + local position = gui.get_position(node) + local parent = gui.get_parent(node) + while parent and parent ~= root do + local parent_position = gui.get_position(parent) + position.x = position.x + parent_position.x + position.y = position.y + parent_position.y + parent = gui.get_parent(parent) + end + + return position +end + + return M diff --git a/druid/widget/fps_panel/fps_panel.lua b/druid/widget/fps_panel/fps_panel.lua index 33a2d99..58d9ed5 100644 --- a/druid/widget/fps_panel/fps_panel.lua +++ b/druid/widget/fps_panel/fps_panel.lua @@ -1,3 +1,4 @@ +local helper = require("druid.helper") local mini_graph = require("druid.widget.mini_graph.mini_graph") ---@class widget.fps_panel: druid.widget @@ -22,7 +23,13 @@ function M:init() self.mini_graph:set_samples(self.graph_samples) -- show last 30 seconds self.mini_graph:set_max_value(TARGET_FPS) - gui.set_parent(self:get_node("content"), self.mini_graph.content, true) + do -- Set parent manually + local parent_node = self.mini_graph.content + local position = helper.get_full_position(parent_node, self.mini_graph.root) + local content = self:get_node("content") + gui.set_parent(content, self.mini_graph.content) + gui.set_position(content, -position) + end self.text_min_fps = self.druid:new_text("text_min_fps") self.text_fps = self.druid:new_text("text_fps") diff --git a/druid/widget/memory_panel/memory_panel.lua b/druid/widget/memory_panel/memory_panel.lua index e90aeec..fad517c 100644 --- a/druid/widget/memory_panel/memory_panel.lua +++ b/druid/widget/memory_panel/memory_panel.lua @@ -1,3 +1,4 @@ +local helper = require("druid.helper") local mini_graph = require("druid.widget.mini_graph.mini_graph") ---@class widget.memory_panel: druid.widget @@ -5,13 +6,24 @@ local mini_graph = require("druid.widget.mini_graph.mini_graph") local M = {} function M:init() + self.root = self:get_node("root") self.delta_time = 0.1 self.samples_count = 30 self.memory_limit = 100 self.mini_graph = self.druid:new_widget(mini_graph, "mini_graph") self.mini_graph:set_samples(self.samples_count) - gui.set_parent(self:get_node("content"), self.mini_graph.content, true) + + -- This one is not works with scaled root + --gui.set_parent(self:get_node("content"), self.mini_graph.content, true) + + do -- Set parent manually + local parent_node = self.mini_graph.content + local position = helper.get_full_position(parent_node, self.mini_graph.root) + local content = self:get_node("content") + gui.set_parent(content, self.mini_graph.content) + gui.set_position(content, -position) + end self.max_value = self.druid:new_text("text_max_value") self.text_per_second = self.druid:new_text("text_per_second") diff --git a/druid/widget/properties_panel/properties/property_input.gui b/druid/widget/properties_panel/properties/property_input.gui index e82aaf3..c204d30 100644 --- a/druid/widget/properties_panel/properties/property_input.gui +++ b/druid/widget/properties_panel/properties/property_input.gui @@ -37,7 +37,7 @@ nodes { } type: TYPE_TEXT text: "Input" - font: "text_bold" + font: "druid_text_bold" id: "text_name" pivot: PIVOT_W outline { diff --git a/druid/widget/properties_panel/properties/property_text.gui b/druid/widget/properties_panel/properties/property_text.gui index 3ebf171..1f1af0a 100644 --- a/druid/widget/properties_panel/properties/property_text.gui +++ b/druid/widget/properties_panel/properties/property_text.gui @@ -37,7 +37,7 @@ nodes { } type: TYPE_TEXT text: "Text" - font: "text_bold" + font: "druid_text_bold" id: "text_name" pivot: PIVOT_W outline { @@ -74,7 +74,7 @@ nodes { } type: TYPE_TEXT text: "Text" - font: "text_bold" + font: "druid_text_bold" id: "text_right" pivot: PIVOT_E outline { From 06f682e8e4d290b634ff21cbb7daad21b956a837 Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 23 Nov 2024 12:39:55 +0200 Subject: [PATCH 34/50] Update --- druid/helper.lua | 28 ++++++---- druid/widget/mini_graph/mini_graph.lua | 5 +- .../properties/property_slider.lua | 55 ++++++++++++++++--- .../properties_panel/properties_panel.lua | 2 +- 4 files changed, 66 insertions(+), 24 deletions(-) diff --git a/druid/helper.lua b/druid/helper.lua index ac49d43..163a75c 100644 --- a/druid/helper.lua +++ b/druid/helper.lua @@ -171,22 +171,26 @@ end ---Clamp value between min and max ----@param a number Value ----@param min number Min value ----@param max number Max value +---@param value number Value +---@param v1 number|nil Min value. If nil, value will be clamped to positive infinity +---@param v2 number|nil Max value If nil, value will be clamped to negative infinity ---@return number value Clamped value -function M.clamp(a, min, max) - if min > max then - min, max = max, min +function M.clamp(value, v1, v2) + if v1 and v2 then + if v1 > v2 then + v1, v2 = v2, v1 + end end - if a >= min and a <= max then - return a - elseif a < min then - return min - else - return max + if v1 and value < v1 then + return v1 end + + if v2 and value > v2 then + return v2 + end + + return value end diff --git a/druid/widget/mini_graph/mini_graph.lua b/druid/widget/mini_graph/mini_graph.lua index 3236850..eb4a37b 100644 --- a/druid/widget/mini_graph/mini_graph.lua +++ b/druid/widget/mini_graph/mini_graph.lua @@ -1,4 +1,5 @@ local color = require("druid.color") +local helper = require("druid.helper") ---@class widget.mini_graph: druid.widget local M = {} @@ -78,7 +79,7 @@ function M:set_line_value(index, value) self.values[index] = value - local normalized = vmath.clamp(value/self.max_value, 0, 1) + local normalized = helper.clamp(value/self.max_value, 0, 1) local target_color = color.lerp(normalized, self.color_zero, self.color_one) gui.set_color(line, target_color) self:set_line_height(index) @@ -115,7 +116,7 @@ end function M:set_line_height(index) local value = self.values[index] or 0 - local normalized = vmath.clamp(value / self.max_value, 0, 1) + local normalized = helper.clamp(value / self.max_value, 0, 1) local size_y = normalized * 70 gui.set(self.lines[index], SIZE_Y, size_y) end diff --git a/druid/widget/properties_panel/properties/property_slider.lua b/druid/widget/properties_panel/properties/property_slider.lua index 91b975c..805a183 100644 --- a/druid/widget/properties_panel/properties/property_slider.lua +++ b/druid/widget/properties_panel/properties/property_slider.lua @@ -1,3 +1,6 @@ +local event = require("event.event") +local helper = require("druid.helper") + ---@class widget.property_slider: druid.widget ---@field root node ---@field container druid.container @@ -14,11 +17,14 @@ function M:init() gui.set_alpha(self.selected, 0) self._value = 0 + self.min = 0 + self.max = 1 + self.text_name = self.druid:new_text("text_name") :set_text_adjust("scale_then_trim_left", 0.3) self.text_value = self.druid:new_text("text_value") - self.slider = self.druid:new_slider("slider_pin", vmath.vector3(55, 0, 0), self._on_slider_change_by_user) --[[@as druid.slider]] + self.slider = self.druid:new_slider("slider_pin", vmath.vector3(55, 0, 0), self.update_value) --[[@as druid.slider]] self.slider:set_input_node("slider") self:set_text_function(function(value) @@ -28,6 +34,8 @@ function M:init() self.container = self.druid:new_container(self.root) self.container:add_container("text_name") self.container:add_container("E_Anchor") + + self.on_change_value = event.create() end @@ -40,13 +48,17 @@ end ---@param value number function M:set_value(value, is_instant) - if self._value == value then + local diff = math.abs(self.max - self.min) + self.slider:set(value / diff, true) + + local is_changed = self._value ~= value + if not is_changed then return end self._value = value - self.slider:set(value, true) - self.text_value:set_to(self._text_function(value)) + self.text_value:set_text(self._text_function(value)) + self.on_change_value:trigger(value) if not is_instant then gui.set_alpha(self.selected, 1) @@ -61,12 +73,37 @@ function M:get_value() end -function M:_on_slider_change_by_user(value) - self._value = value - self.text_value:set_to(self._text_function(value)) +function M:update_value(value) + local current_value = self._value - gui.set_alpha(self.selected, 1) - gui.animate(self.selected, "color.w", 0, gui.EASING_INSINE, 0.16) + local diff = math.abs(self.max - self.min) + -- [0..1] To range + value = value * diff + self.min + + -- Round to steps value (0.1, or 5. Should be divided on this value) + value = math.floor(value / self.step + 0.5) * self.step + + value = helper.clamp(value, self.min, self.max) + + self:set_value(value) +end + + +function M:set_number_type(min, max, step) + self.min = min or 0 + self.max = max or 1 + self.step = step + + self:set_text_function(function(value) + return tostring(value) + end) + + self:set_value(self._value, true) +end + + +function M:_on_slider_change_by_user(value) + self:set_value(value) end diff --git a/druid/widget/properties_panel/properties_panel.lua b/druid/widget/properties_panel/properties_panel.lua index 6934dda..1569870 100644 --- a/druid/widget/properties_panel/properties_panel.lua +++ b/druid/widget/properties_panel/properties_panel.lua @@ -142,7 +142,7 @@ function M:add_slider(text, initial_value, on_change_callback) instance.text_name:set_text(text) instance:set_value(initial_value, true) - instance.slider.on_change_value:subscribe(function(_, value) + instance.on_change_value:subscribe(function(value) on_change_callback(value) end) From 434dce55ce04dc02efd907388178ccf24a4b4097 Mon Sep 17 00:00:00 2001 From: Insality Date: Wed, 27 Nov 2024 23:34:50 +0200 Subject: [PATCH 35/50] Update --- druid/base/drag.lua | 6 +- druid/bindings.lua | 2 +- druid/component.lua | 11 +- druid/custom/rich_text/rich_text.lua | 38 ++- druid/extended/input.lua | 2 +- druid/extended/lang_text.lua | 14 +- druid/extended/layout.lua | 9 +- druid/system/druid_instance.lua | 3 +- .../properties/property_button.lua | 10 +- .../properties/property_checkbox.lua | 21 +- .../properties/property_input.lua | 21 +- .../property_left_right_selector.lua | 3 +- .../properties/property_slider.gui | 2 +- .../properties/property_slider.lua | 16 +- .../properties/property_text.lua | 4 +- .../properties_panel/properties_panel.lua | 247 +++++++++--------- 16 files changed, 252 insertions(+), 157 deletions(-) diff --git a/druid/base/drag.lua b/druid/base/drag.lua index 87f5be5..bcc6f78 100644 --- a/druid/base/drag.lua +++ b/druid/base/drag.lua @@ -62,6 +62,10 @@ local const = require("druid.const") local helper = require("druid.helper") local component = require("druid.component") +---@class druid.drag.style +---@field DRAG_DEADZONE number Distance in pixels to start dragging. Default: 10 +---@field NO_USE_SCREEN_KOEF boolean If screen aspect ratio affects on drag values. Default: false + ---@class druid.drag: druid.base_component ---@field node node ---@field on_touch_start event @@ -69,7 +73,7 @@ local component = require("druid.component") ---@field on_drag_start event ---@field on_drag event ---@field on_drag_end event ----@field style table +---@field style druid.drag.style ---@field click_zone node|nil ---@field is_touch boolean ---@field is_drag boolean diff --git a/druid/bindings.lua b/druid/bindings.lua index 15f87a4..e63a11e 100644 --- a/druid/bindings.lua +++ b/druid/bindings.lua @@ -4,7 +4,7 @@ local M = {} local WRAPPED_WIDGETS = {} ---Set a widget to the current game object. The game object can acquire the widget by calling `bindings.get_widget` ----It wraps only top level functions, so no access to nested widgets +---It wraps with events only top level functions cross-context, so no access to nested widgets functions ---@param widget druid.widget function M.set_widget(widget) local object = msg.url() diff --git a/druid/component.lua b/druid/component.lua index e7deb30..6ea5918 100644 --- a/druid/component.lua +++ b/druid/component.lua @@ -81,7 +81,7 @@ function M:set_template(template) local parent = self:get_parent_component() if parent then local parent_template = parent:get_template() - if #parent_template > 0 then + if parent_template and #parent_template > 0 then if #template > 0 then template = "/" .. template end @@ -89,7 +89,12 @@ function M:set_template(template) end end - self._meta.template = template + if template ~= "" then + self._meta.template = template + else + self._meta.template = nil + end + return self end @@ -127,7 +132,7 @@ end ---Get Druid instance for inner component creation. ---@param template string|nil ----@param nodes table|nil +---@param nodes table|nil ---@return druid_instance function M:get_druid(template, nodes) local context = { _context = self } diff --git a/druid/custom/rich_text/rich_text.lua b/druid/custom/rich_text/rich_text.lua index e36b67a..a8ad888 100644 --- a/druid/custom/rich_text/rich_text.lua +++ b/druid/custom/rich_text/rich_text.lua @@ -76,6 +76,42 @@ local component = require("druid.component") local rich_text = require("druid.custom.rich_text.module.rt") +---@class druid.rich_text.word +---@field node node +---@field relative_scale number +---@field color vector4 +---@field position vector3 +---@field offset vector3 +---@field scale vector3 +---@field size vector3 +---@field metrics druid.rich_text.metrics +---@field pivot userdata +---@field text string +---@field shadow vector4 +---@field outline vector4 +---@field font string +---@field image druid.rich_text.word.image +---@field br boolean +---@field nobr boolean + +---@class druid.rich_text.word.image +---@field texture string +---@field anim string +---@field width number +---@field height number + +---@class druid.rich_text.lines_metrics +---@field text_width number +---@field text_height number +---@field lines table + +---@class druid.rich_text.metrics +---@field width number +---@field height number +---@field offset_x number|nil +---@field offset_y number|nil +---@field node_size vector3|nil + ---@class druid.rich_text: druid.base_component ---@field root node ---@field text_prefab node @@ -231,7 +267,7 @@ end --- Get all current words. ----@return table druid.rich_text.word[] +---@return druid.rich_text.word[] function M:get_words() return self._words end diff --git a/druid/extended/input.lua b/druid/extended/input.lua index 30de427..89492f6 100755 --- a/druid/extended/input.lua +++ b/druid/extended/input.lua @@ -373,7 +373,7 @@ function M:set_text(input_text) self.is_empty = #value == 0 and #marked_value == 0 local final_text = value .. marked_value - self.text:set_to(final_text) + self.text:set_text(final_text) -- measure it self.text_width = self.text:get_text_size(value) diff --git a/druid/extended/lang_text.lua b/druid/extended/lang_text.lua index a2ee5f3..8c8c276 100755 --- a/druid/extended/lang_text.lua +++ b/druid/extended/lang_text.lua @@ -72,13 +72,21 @@ end ---@return druid.lang_text Current instance function M:set_to(text) self.last_locale = false - self.text:set_to(text) + self.text:set_text(text) self.on_change:trigger() return self end +--- Setup raw text to lang_text component +---@param text string Text for text node +---@return druid.lang_text Current instance +function M:set_text(text) + return self:set_to(text) +end + + --- Translate the text by locale_id ---@param locale_id string Locale id ---@param a string|nil Optional param to string.format @@ -92,7 +100,7 @@ end function M:translate(locale_id, a, b, c, d, e, f, g) self.last_locale_args = { a, b, c, d, e, f, g } self.last_locale = locale_id or self.last_locale - self.text:set_to(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "") + self.text:set_text(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "") return self end @@ -109,7 +117,7 @@ end ---@return druid.lang_text Current instance function M:format(a, b, c, d, e, f, g) self.last_locale_args = { a, b, c, d, e, f, g } - self.text:set_to(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "") + self.text:set_text(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "") return self end diff --git a/druid/extended/layout.lua b/druid/extended/layout.lua index 3bee2bd..33d023d 100644 --- a/druid/extended/layout.lua +++ b/druid/extended/layout.lua @@ -45,7 +45,9 @@ function M:init(node_or_node_id, layout_type) self.size = gui.get_size(self.node) self.padding = gui.get_slice9(self.node) + -- Grab default margins from slice9 z/w values self.margin = { x = self.padding.z, y = self.padding.w } + -- Use symmetrical padding from x/z self.padding.z = self.padding.x self.padding.w = self.padding.y @@ -199,10 +201,11 @@ function M:get_size() end ----@return vector3 +---@return number, number function M:get_content_size() - local rows_data = self:calculate_rows_data() - return vmath.vector3(rows_data.total_width, rows_data.total_height, 0) + local width = self.size.x - self.padding.x - self.padding.z + local height = self.size.y - self.padding.y - self.padding.w + return width, height end diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index e39fad1..0c3fb69 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -476,14 +476,13 @@ end ---@generic T: druid.base_component ---@param widget T ---@param template string|nil The template name used by widget ----@param nodes table|node|nil The nodes table from gui.clone_tree or prefab node to use for clone +---@param nodes table|node|nil The nodes table from gui.clone_tree or prefab node to use for clone ---@vararg any ---@return T function M:new_widget(widget, template, nodes, ...) local instance = create_widget(self, widget) if type(nodes) == "userdata" then - -- It's a node, we will use it as a root node to make nodes nodes = gui.clone_tree(nodes) end diff --git a/druid/widget/properties_panel/properties/property_button.lua b/druid/widget/properties_panel/properties/property_button.lua index d7fa92f..eefa866 100644 --- a/druid/widget/properties_panel/properties/property_button.lua +++ b/druid/widget/properties_panel/properties/property_button.lua @@ -12,7 +12,7 @@ local M = {} function M:init() self.root = self:get_node("root") self.text_name = self.druid:new_text("text_name") - :set_text_adjust("scale_then_trim_left", 0.3) + :set_text_adjust("scale_then_trim", 0.3) self.selected = self:get_node("selected") gui.set_alpha(self.selected, 0) @@ -34,6 +34,14 @@ function M:on_click() end +---@param text string +---@return widget.property_button +function M:set_text_property(text) + self.text_name:set_text(text) + return self +end + + ---@param text string ---@return widget.property_button function M:set_text_button(text) diff --git a/druid/widget/properties_panel/properties/property_checkbox.lua b/druid/widget/properties_panel/properties/property_checkbox.lua index bf4c2dc..a0fc7ea 100644 --- a/druid/widget/properties_panel/properties/property_checkbox.lua +++ b/druid/widget/properties_panel/properties/property_checkbox.lua @@ -1,3 +1,5 @@ +local event = require("event.event") + ---@class widget.property_checkbox: druid.widget ---@field root node ---@field druid druid_instance @@ -17,13 +19,15 @@ function M:init() gui.set_alpha(self.selected, 0) self.text_name = self.druid:new_text("text_name") - :set_text_adjust("scale_then_trim_left", 0.3) + :set_text_adjust("scale_then_trim", 0.3) self.button = self.druid:new_button("button", self.on_click) self.container = self.druid:new_container(self.root) self.container:add_container("text_name") self.container:add_container("E_Anchor") + + self.on_change_value = event.create() end @@ -35,6 +39,7 @@ function M:set_value(value, is_instant) self._value = value gui.set_enabled(self.icon, value) + self.on_change_value:trigger(value) if not is_instant then gui.set_alpha(self.selected, 1) @@ -54,4 +59,18 @@ function M:on_click() end +--- Set the text property of the checkbox +---@param text string +function M:set_text_property(text) + self.text_name:set_text(text) +end + + +--- Set the callback function for when the checkbox value changes +---@param callback function +function M:on_change(callback) + self.on_change_value:subscribe(callback) +end + + return M diff --git a/druid/widget/properties_panel/properties/property_input.lua b/druid/widget/properties_panel/properties/property_input.lua index 7f18847..7fa5712 100644 --- a/druid/widget/properties_panel/properties/property_input.lua +++ b/druid/widget/properties_panel/properties/property_input.lua @@ -3,14 +3,13 @@ ---@field container druid.container ---@field text_name druid.text ---@field button druid.button ----@field text_button druid.text ---@field druid druid_instance local M = {} function M:init() self.root = self:get_node("root") self.text_name = self.druid:new_text("text_name") - :set_text_adjust("scale_then_trim_left", 0.3) + :set_text_adjust("scale_then_trim", 0.3) self.selected = self:get_node("selected") gui.set_alpha(self.selected, 0) @@ -30,11 +29,23 @@ end ---@param text string ----@return property_input -function M:set_text_button(text) - self.text_button:set_text(text) +---@return widget.property_input +function M:set_text_property(text) + self.text_name:set_text(text) + return self +end + +---@param text string +---@return widget.property_input +function M:set_text_value(text) + self.rich_input:set_text(text) return self end +function M:on_change(callback, callback_context) + self.rich_input.input.on_input_unselect:subscribe(callback, callback_context) +end + + return M diff --git a/druid/widget/properties_panel/properties/property_left_right_selector.lua b/druid/widget/properties_panel/properties/property_left_right_selector.lua index 2065663..6cb79b5 100644 --- a/druid/widget/properties_panel/properties/property_left_right_selector.lua +++ b/druid/widget/properties_panel/properties/property_left_right_selector.lua @@ -7,6 +7,7 @@ local event = require("event.event") ---@field button druid.button ---@field selected node ---@field value string|number +---@field on_change_value event fun(value: string|number) local M = {} @@ -16,7 +17,7 @@ function M:init() gui.set_alpha(self.selected, 0) self.text_name = self.druid:new_text("text_name") - :set_text_adjust("scale_then_trim_left", 0.3) + :set_text_adjust("scale_then_trim", 0.3) self.text_value = self.druid:new_text("text_value") self.button_left = self.druid:new_button("button_left", self.on_button_left) diff --git a/druid/widget/properties_panel/properties/property_slider.gui b/druid/widget/properties_panel/properties/property_slider.gui index c0a9564..4a2f739 100644 --- a/druid/widget/properties_panel/properties/property_slider.gui +++ b/druid/widget/properties_panel/properties/property_slider.gui @@ -149,7 +149,7 @@ nodes { z: 0.49 } type: TYPE_BOX - texture: "druid/rect_round2_width1" + texture: "druid/rect_round2_width2" id: "button" pivot: PIVOT_E parent: "E_Anchor" diff --git a/druid/widget/properties_panel/properties/property_slider.lua b/druid/widget/properties_panel/properties/property_slider.lua index 805a183..d025989 100644 --- a/druid/widget/properties_panel/properties/property_slider.lua +++ b/druid/widget/properties_panel/properties/property_slider.lua @@ -21,7 +21,7 @@ function M:init() self.max = 1 self.text_name = self.druid:new_text("text_name") - :set_text_adjust("scale_then_trim_left", 0.3) + :set_text_adjust("scale_then_trim", 0.3) self.text_value = self.druid:new_text("text_value") self.slider = self.druid:new_slider("slider_pin", vmath.vector3(55, 0, 0), self.update_value) --[[@as druid.slider]] @@ -46,6 +46,20 @@ function M:set_text_function(callback) end +--- Sets the text property of the slider +---@param text string +function M:set_text_property(text) + self.text_name:set_text(text) +end + + +--- Sets the callback function for when the slider value changes +---@param callback fun(value:number) +function M:on_change(callback) + self.on_change_value:subscribe(callback) +end + + ---@param value number function M:set_value(value, is_instant) local diff = math.abs(self.max - self.min) diff --git a/druid/widget/properties_panel/properties/property_text.lua b/druid/widget/properties_panel/properties/property_text.lua index 20c0e81..cb73678 100644 --- a/druid/widget/properties_panel/properties/property_text.lua +++ b/druid/widget/properties_panel/properties/property_text.lua @@ -25,7 +25,7 @@ end ---@param text string ---@return widget.property_text -function M:set_text(text) +function M:set_text_property(text) self.text_name:set_text(text) return self end @@ -33,7 +33,7 @@ end ---@param text string|nil ---@return widget.property_text -function M:set_right_text(text) +function M:set_text_value(text) self.text_right:set_text(text or "") return self end diff --git a/druid/widget/properties_panel/properties_panel.lua b/druid/widget/properties_panel/properties_panel.lua index 1569870..e960ace 100644 --- a/druid/widget/properties_panel/properties_panel.lua +++ b/druid/widget/properties_panel/properties_panel.lua @@ -8,7 +8,15 @@ local property_left_right_selector = require("druid.widget.properties_panel.prop ---@class widget.properties_panel: druid.widget ---@field root node ---@field scroll druid.scroll ----@field druid druid_instance +---@field layout druid.layout +---@field container druid.container +---@field container_content druid.container +---@field container_scroll_view druid.container +---@field contaienr_scroll_content druid.container +---@field text_header druid.text +---@field paginator widget.property_left_right_selector +---@field properties druid.widget[] List of created properties +---@field properties_constructors fun()[] List of properties functions to create a new widget. Used to not spawn non-visible widgets but keep the reference local M = {} @@ -59,19 +67,18 @@ function M:init() self.property_left_right_selector_prefab = self:get_node("property_left_right_selector/root") gui.set_enabled(self.property_left_right_selector_prefab, false) - self.paginator = self:add_left_right_selector("Page", self.current_page, function(value) - self.current_page = value - self:refresh_page() - end):set_number_type(1, 1, true) - gui.set_enabled(self.paginator.root, false) + -- We not using as a part of properties, since it handled in a way to be paginable + self.paginator = self.druid:new_widget(property_left_right_selector, "property_left_right_selector", self.property_left_right_selector_prefab) + self.paginator:set_text("Page") + self.paginator:set_number_type(1, 1, true) + self.paginator:set_value(self.current_page) + self.paginator.on_change_value:subscribe(function(value) + self:set_page(value) + end) + local width = self.layout:get_content_size() + self.paginator.container:set_size(width) - -- Remove paginator from properties - for index = 1, #self.properties do - if self.properties[index] == self.paginator then - table.remove(self.properties, index) - break - end - end + gui.set_enabled(self.paginator.root, false) end @@ -86,18 +93,23 @@ function M:on_drag_widget(dx, dy) end -function M:clear() +function M:clear_created_properties() for index = 1, #self.properties do gui.delete_node(self.properties[index].root) self.druid:remove(self.properties[index]) end - self.layout:clear_layout() - self.layout:add(self.paginator.root) - self.properties = {} - self.properties_constructors = {} - self:refresh_page() + self.layout:clear_layout() + + -- Use paginator as "pinned" widget + self.layout:add(self.paginator.root) +end + + +function M:clear() + self:clear_created_properties() + self.properties_constructors = {} end @@ -113,117 +125,114 @@ function M:on_size_changed(new_size) for index = 1, #self.properties do self.properties[index].container:set_size(width) end + self.paginator.container:set_size(width) end ----@param text string ----@param initial_value boolean ----@param on_change_callback function ----@return widget.property_checkbox -function M:add_checkbox(text, initial_value, on_change_callback) - local instance = self:create_from_prefab(property_checkbox, "property_checkbox", self.property_checkbox_prefab) +function M:update(dt) + if self.is_dirty then + self.is_dirty = false - instance.text_name:set_text(text) - instance:set_value(initial_value, true) - instance.button.on_click:subscribe(function() - on_change_callback(instance:get_value()) - end) + self:clear_created_properties() - return instance -end + local properties_count = #self.properties_constructors + -- Render all current properties + local start_index = (self.current_page - 1) * self.properties_per_page + 1 + local end_index = start_index + self.properties_per_page - 1 + end_index = math.min(end_index, properties_count) ----@param text string ----@param initial_value number ----@param on_change_callback function ----@return widget.property_slider -function M:add_slider(text, initial_value, on_change_callback) - local instance = self:create_from_prefab(property_slider, "property_slider", self.property_slider_prefab) + local is_paginator_visible = properties_count > self.properties_per_page + gui.set_enabled(self.paginator.root, is_paginator_visible) + self.paginator:set_number_type(1, math.ceil(properties_count / self.properties_per_page), true) + self.paginator.text_value:set_text(self.current_page .. " / " .. math.ceil(properties_count / self.properties_per_page)) - instance.text_name:set_text(text) - instance:set_value(initial_value, true) - instance.on_change_value:subscribe(function(value) - on_change_callback(value) - end) - - return instance -end - - ----@param text string ----@param on_click_callback function|nil ----@param callback_context any|nil ----@return widget.property_button -function M:add_button(text, on_click_callback, callback_context) - local instance = self:create_from_prefab(property_button, "property_button", self.property_button_prefab) - - instance.text_name:set_text(text) - if on_click_callback then - instance.button.on_click:subscribe(on_click_callback, callback_context) + for index = start_index, end_index do + self.properties_constructors[index]() + end end - - return instance end ----@param text string ----@param initial_value string ----@param on_change_callback function ----@return widget.property_input -function M:add_input(text, initial_value, on_change_callback) - local instance = self:create_from_prefab(property_input, "property_input", self.property_input_prefab) +---@param on_create fun(checkbox: widget.property_checkbox)|nil +---@return widget.properties_panel +function M:add_checkbox(on_create) + return self:add_inner_widget(property_checkbox, "property_checkbox", self.property_checkbox_prefab, on_create) +end - instance.text_name:set_text(text) - instance.rich_input:set_text(initial_value) - instance.rich_input:set_placeholder("") - instance.rich_input.input.on_input_unselect:subscribe(function(_, value) - on_change_callback(value) + +---@param on_create fun(slider: widget.property_slider)|nil +---@return widget.properties_panel +function M:add_slider(on_create) + return self:add_inner_widget(property_slider, "property_slider", self.property_slider_prefab, on_create) +end + + +---@param on_create fun(button: widget.property_button)|nil +---@return widget.properties_panel +function M:add_button(on_create) + return self:add_inner_widget(property_button, "property_button", self.property_button_prefab, on_create) +end + + +---@param on_create fun(input: widget.property_input)|nil +---@return widget.properties_panel +function M:add_input(on_create) + return self:add_inner_widget(property_input, "property_input", self.property_input_prefab, on_create) +end + + +---@param on_create fun(text: widget.property_text)|nil +function M:add_text(on_create) + return self:add_inner_widget(property_text, "property_text", self.property_text_prefab, on_create) +end + + +---@param on_create fun(selector: widget.property_left_right_selector)|nil +function M:add_left_right_selector(on_create) + return self:add_inner_widget(property_left_right_selector, "property_left_right_selector", self.property_left_right_selector_prefab, on_create) +end + + +---@generic T: druid.widget +---@param widget_class T +---@param template string|nil +---@param nodes table|node|nil +---@param on_create fun(widget: T)|nil +---@return widget.properties_panel +function M:add_inner_widget(widget_class, template, nodes, on_create) + table.insert(self.properties_constructors, function() + local widget = self.druid:new_widget(widget_class, template, nodes) + + self:add_property(widget) + if on_create then + on_create(widget) + end end) - return instance + self.is_dirty = true + + return self end ----@param text string ----@param right_text string|nil ----@return widget.property_text -function M:add_text(text, right_text) - local instance = self:create_from_prefab(property_text, "property_text", self.property_text_prefab) +---@param create_widget_callback fun(): druid.widget +---@return widget.properties_panel +function M:add_widget(create_widget_callback) + table.insert(self.properties_constructors, function() + local widget = create_widget_callback() + self:add_property(widget) + end) - instance:set_text(text) - instance:set_right_text(right_text) + self.is_dirty = true - return instance -end - - ----@param text string ----@param value string|number|nil ----@param on_change_callback fun(value: string|number) ----@return widget.property_left_right_selector -function M:add_left_right_selector(text, value, on_change_callback) - local instance = self:create_from_prefab(property_left_right_selector, "property_left_right_selector", self.property_left_right_selector_prefab) - - instance:set_text(text) - instance:set_value(value or 0, true) - instance.on_change_value:subscribe(on_change_callback) - - return instance -end - - - ----@param widget druid.widget -function M:add_widget(widget) - self:add_property(widget) + return self end ---@private -function M:create_from_prefab(widget_class, widget_name, prefab) - local instance = self.druid:new_widget(widget_class, widget_name, prefab) - self:add_property(instance) - return instance +function M:create_from_prefab(widget_class, template, nodes) + return self:add_property(self.druid:new_widget(widget_class, template, nodes)) end @@ -233,34 +242,13 @@ function M:add_property(widget) self.layout:add(widget.root) table.insert(self.properties, widget) - local width = self.layout:get_size().x - self.layout.padding.x - self.layout.padding.z + local width = self.layout:get_content_size() widget.container:set_size(width) - if #self.properties > self.properties_per_page then - self:refresh_page() - end - return widget end -function M:refresh_page() - local start_index = (self.current_page - 1) * self.properties_per_page + 1 - local end_index = start_index + self.properties_per_page - 1 - - for index = 1, #self.properties do - local is_visible = index >= start_index and index <= end_index - gui.set_enabled(self.properties[index].root, is_visible) - end - - gui.set_enabled(self.paginator.root, #self.properties > self.properties_per_page) - self.paginator:set_number_type(1, math.ceil(#self.properties / self.properties_per_page), true) - self.paginator.text_value:set_text(self.current_page .. " / " .. math.ceil(#self.properties / self.properties_per_page)) - - self.layout:set_dirty() -end - - function M:remove(widget) for index = 1, #self.properties do if self.properties[index] == widget then @@ -294,8 +282,7 @@ end function M:set_page(page) self.current_page = page - self.paginator:set_value(self.current_page, true) - self:refresh_page() + self.is_dirty = true end From cb3662583637617ba021e71ec109556703ec29d7 Mon Sep 17 00:00:00 2001 From: Insality Date: Fri, 29 Nov 2024 00:49:56 +0200 Subject: [PATCH 36/50] Add vector3 property --- .../properties/property_input.lua | 7 +- .../properties/property_vector3.gui | 490 ++++++++++++++++++ .../properties/property_vector3.lua | 75 +++ .../properties_panel/properties_panel.gui | 208 ++++++++ .../properties_panel/properties_panel.lua | 10 + 5 files changed, 784 insertions(+), 6 deletions(-) create mode 100644 druid/widget/properties_panel/properties/property_vector3.gui create mode 100644 druid/widget/properties_panel/properties/property_vector3.lua diff --git a/druid/widget/properties_panel/properties/property_input.lua b/druid/widget/properties_panel/properties/property_input.lua index 7fa5712..e09b1f0 100644 --- a/druid/widget/properties_panel/properties/property_input.lua +++ b/druid/widget/properties_panel/properties/property_input.lua @@ -22,12 +22,6 @@ function M:init() end -function M:on_click() - gui.set_alpha(self.selected, 1) - gui.animate(self.selected, "color.w", 0, gui.EASING_INSINE, 0.16) -end - - ---@param text string ---@return widget.property_input function M:set_text_property(text) @@ -35,6 +29,7 @@ function M:set_text_property(text) return self end + ---@param text string ---@return widget.property_input function M:set_text_value(text) diff --git a/druid/widget/properties_panel/properties/property_vector3.gui b/druid/widget/properties_panel/properties/property_vector3.gui new file mode 100644 index 0000000..71b30f2 --- /dev/null +++ b/druid/widget/properties_panel/properties/property_vector3.gui @@ -0,0 +1,490 @@ +fonts { + name: "druid_text_bold" + font: "/druid/fonts/druid_text_bold.font" +} +fonts { + name: "druid_text_regular" + font: "/druid/fonts/druid_text_regular.font" +} +textures { + name: "druid" + texture: "/druid/druid.atlas" +} +nodes { + size { + x: 400.0 + y: 40.0 + } + type: TYPE_BOX + texture: "druid/empty" + id: "root" + adjust_mode: ADJUST_MODE_STRETCH + inherit_alpha: true + visible: false +} +nodes { + position { + x: -200.0 + } + scale { + x: 0.5 + y: 0.5 + } + size { + x: 350.0 + y: 50.0 + } + color { + x: 0.463 + y: 0.475 + z: 0.49 + } + type: TYPE_TEXT + text: "Vector3" + font: "druid_text_bold" + id: "text_name" + pivot: PIVOT_W + outline { + x: 1.0 + y: 1.0 + z: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + } + parent: "root" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} +nodes { + position { + x: 200.0 + } + size { + x: 200.0 + y: 40.0 + } + type: TYPE_BOX + id: "E_Anchor" + pivot: PIVOT_E + parent: "root" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO + visible: false +} +nodes { + position { + x: -200.0 + } + size { + x: 66.0 + y: 40.0 + } + type: TYPE_BOX + id: "field_x" + pivot: PIVOT_W + parent: "E_Anchor" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO + visible: false +} +nodes { + position { + x: 7.0 + } + scale { + x: 0.5 + y: 0.5 + } + size { + x: 30.0 + y: 40.0 + } + color { + x: 0.31 + y: 0.318 + z: 0.322 + } + type: TYPE_TEXT + text: "X" + font: "druid_text_regular" + id: "text_x" + parent: "field_x" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} +nodes { + position { + x: 40.0 + } + type: TYPE_TEMPLATE + id: "rich_input_x" + parent: "field_x" + inherit_alpha: true + template: "/druid/custom/rich_input/rich_input.gui" +} +nodes { + size { + x: 50.0 + y: 40.0 + } + type: TYPE_BOX + id: "rich_input_x/root" + parent: "rich_input_x" + overridden_fields: 4 + template_node_child: true +} +nodes { + size { + x: 50.0 + y: 40.0 + } + type: TYPE_BOX + id: "rich_input_x/button" + parent: "rich_input_x/root" + overridden_fields: 4 + template_node_child: true +} +nodes { + size { + x: 70.0 + y: 50.0 + } + type: TYPE_TEXT + id: "rich_input_x/placeholder_text" + parent: "rich_input_x/root" + overridden_fields: 4 + overridden_fields: 8 + template_node_child: true +} +nodes { + size { + x: 70.0 + y: 50.0 + } + type: TYPE_TEXT + text: "20.0" + id: "rich_input_x/input_text" + parent: "rich_input_x/root" + overridden_fields: 4 + overridden_fields: 8 + template_node_child: true +} +nodes { + position { + x: 18.0 + } + type: TYPE_BOX + id: "rich_input_x/cursor_node" + parent: "rich_input_x/root" + overridden_fields: 1 + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "rich_input_x/cursor_text" + parent: "rich_input_x/cursor_node" + template_node_child: true +} +nodes { + position { + x: 40.0 + y: -20.0 + } + size { + x: 50.0 + y: 4.0 + } + color { + x: 0.894 + y: 0.506 + z: 0.333 + } + type: TYPE_BOX + texture: "druid/pixel" + id: "selected_x" + pivot: PIVOT_S + adjust_mode: ADJUST_MODE_STRETCH + parent: "field_x" + inherit_alpha: true +} +nodes { + position { + x: -132.0 + } + size { + x: 66.0 + y: 40.0 + } + type: TYPE_BOX + id: "field_y" + pivot: PIVOT_W + parent: "E_Anchor" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO + visible: false +} +nodes { + position { + x: 7.0 + } + scale { + x: 0.5 + y: 0.5 + } + size { + x: 30.0 + y: 40.0 + } + color { + x: 0.31 + y: 0.318 + z: 0.322 + } + type: TYPE_TEXT + text: "Y" + font: "druid_text_regular" + id: "text_y" + parent: "field_y" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} +nodes { + position { + x: 40.0 + } + type: TYPE_TEMPLATE + id: "rich_input_y" + parent: "field_y" + inherit_alpha: true + template: "/druid/custom/rich_input/rich_input.gui" +} +nodes { + size { + x: 50.0 + y: 40.0 + } + type: TYPE_BOX + id: "rich_input_y/root" + parent: "rich_input_y" + overridden_fields: 4 + template_node_child: true +} +nodes { + size { + x: 50.0 + y: 40.0 + } + type: TYPE_BOX + id: "rich_input_y/button" + parent: "rich_input_y/root" + overridden_fields: 4 + template_node_child: true +} +nodes { + size { + x: 70.0 + y: 50.0 + } + type: TYPE_TEXT + id: "rich_input_y/placeholder_text" + parent: "rich_input_y/root" + overridden_fields: 4 + overridden_fields: 8 + template_node_child: true +} +nodes { + size { + x: 70.0 + y: 50.0 + } + type: TYPE_TEXT + text: "20.0" + id: "rich_input_y/input_text" + parent: "rich_input_y/root" + overridden_fields: 4 + overridden_fields: 8 + template_node_child: true +} +nodes { + position { + x: 18.0 + } + type: TYPE_BOX + id: "rich_input_y/cursor_node" + parent: "rich_input_y/root" + overridden_fields: 1 + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "rich_input_y/cursor_text" + parent: "rich_input_y/cursor_node" + template_node_child: true +} +nodes { + position { + x: 40.0 + y: -20.0 + } + size { + x: 50.0 + y: 4.0 + } + color { + x: 0.894 + y: 0.506 + z: 0.333 + } + type: TYPE_BOX + texture: "druid/pixel" + id: "selected_y" + pivot: PIVOT_S + adjust_mode: ADJUST_MODE_STRETCH + parent: "field_y" + inherit_alpha: true +} +nodes { + position { + x: -66.0 + } + size { + x: 66.0 + y: 40.0 + } + type: TYPE_BOX + id: "field_z" + pivot: PIVOT_W + parent: "E_Anchor" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO + visible: false +} +nodes { + position { + x: 7.0 + } + scale { + x: 0.5 + y: 0.5 + } + size { + x: 30.0 + y: 40.0 + } + color { + x: 0.31 + y: 0.318 + z: 0.322 + } + type: TYPE_TEXT + text: "Z" + font: "druid_text_regular" + id: "text_z" + parent: "field_z" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} +nodes { + position { + x: 40.0 + } + type: TYPE_TEMPLATE + id: "rich_input_z" + parent: "field_z" + inherit_alpha: true + template: "/druid/custom/rich_input/rich_input.gui" +} +nodes { + size { + x: 50.0 + y: 40.0 + } + type: TYPE_BOX + id: "rich_input_z/root" + parent: "rich_input_z" + overridden_fields: 4 + template_node_child: true +} +nodes { + size { + x: 50.0 + y: 40.0 + } + type: TYPE_BOX + id: "rich_input_z/button" + parent: "rich_input_z/root" + overridden_fields: 4 + template_node_child: true +} +nodes { + size { + x: 70.0 + y: 50.0 + } + type: TYPE_TEXT + id: "rich_input_z/placeholder_text" + parent: "rich_input_z/root" + overridden_fields: 4 + overridden_fields: 8 + template_node_child: true +} +nodes { + size { + x: 70.0 + y: 50.0 + } + type: TYPE_TEXT + text: "20.0" + id: "rich_input_z/input_text" + parent: "rich_input_z/root" + overridden_fields: 4 + overridden_fields: 8 + template_node_child: true +} +nodes { + position { + x: 18.0 + } + type: TYPE_BOX + id: "rich_input_z/cursor_node" + parent: "rich_input_z/root" + overridden_fields: 1 + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "rich_input_z/cursor_text" + parent: "rich_input_z/cursor_node" + template_node_child: true +} +nodes { + position { + x: 40.0 + y: -20.0 + } + size { + x: 50.0 + y: 4.0 + } + color { + x: 0.894 + y: 0.506 + z: 0.333 + } + type: TYPE_BOX + texture: "druid/pixel" + id: "selected_z" + pivot: PIVOT_S + adjust_mode: ADJUST_MODE_STRETCH + parent: "field_z" + inherit_alpha: true +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties/property_vector3.lua b/druid/widget/properties_panel/properties/property_vector3.lua new file mode 100644 index 0000000..56ccf9d --- /dev/null +++ b/druid/widget/properties_panel/properties/property_vector3.lua @@ -0,0 +1,75 @@ +local event = require("event.event") + + +---@class widget.property_vector3: druid.widget +---@field root node +---@field container druid.container +---@field text_name druid.text +---@field button druid.button +---@field druid druid_instance +local M = {} + +function M:init() + self.root = self:get_node("root") + self.text_name = self.druid:new_text("text_name") + :set_text_adjust("scale_then_trim", 0.3) + + self.selected_x = self:get_node("selected_x") + gui.set_alpha(self.selected_x, 0) + + self.selected_y = self:get_node("selected_y") + gui.set_alpha(self.selected_y, 0) + + self.selected_z = self:get_node("selected_z") + gui.set_alpha(self.selected_z, 0) + + self.rich_input_x = self.druid:new_rich_input("rich_input_x") + self.rich_input_y = self.druid:new_rich_input("rich_input_y") + self.rich_input_z = self.druid:new_rich_input("rich_input_z") + + self.value = vmath.vector3(0) + + self.rich_input_x.input.on_input_unselect:subscribe(function() + self.value.x = tonumber(self.rich_input_x.input:get_text()) or 0 + self.on_change:trigger(self.value) + end) + + self.rich_input_y.input.on_input_unselect:subscribe(function() + self.value.y = tonumber(self.rich_input_y.input:get_text()) or 0 + self.on_change:trigger(self.value) + end) + + self.rich_input_z.input.on_input_unselect:subscribe(function() + self.value.z = tonumber(self.rich_input_z.input:get_text()) or 0 + self.on_change:trigger(self.value) + end) + + self.container = self.druid:new_container(self.root) + self.container:add_container("text_name") + self.container:add_container("E_Anchor") + + self.on_change = event.create() +end + + +---@param text string +---@return widget.property_vector3 +function M:set_text_property(text) + self.text_name:set_text(text) + return self +end + + +---@param x number +---@param y number +---@param z number +---@return widget.property_vector3 +function M:set_value(x, y, z) + self.rich_input_x:set_text(tostring(x)) + self.rich_input_y:set_text(tostring(y)) + self.rich_input_z:set_text(tostring(z)) + return self +end + + +return M diff --git a/druid/widget/properties_panel/properties_panel.gui b/druid/widget/properties_panel/properties_panel.gui index 70f6db0..7ba5a5c 100644 --- a/druid/widget/properties_panel/properties_panel.gui +++ b/druid/widget/properties_panel/properties_panel.gui @@ -490,5 +490,213 @@ nodes { parent: "property_left_right_selector/E_Anchor" template_node_child: true } +nodes { + position { + y: -300.0 + } + type: TYPE_TEMPLATE + id: "property_vector3" + parent: "propeties" + inherit_alpha: true + template: "/druid/widget/properties_panel/properties/property_vector3.gui" +} +nodes { + type: TYPE_BOX + id: "property_vector3/root" + parent: "property_vector3" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_vector3/text_name" + parent: "property_vector3/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_vector3/E_Anchor" + parent: "property_vector3/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_vector3/field_x" + parent: "property_vector3/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_vector3/text_x" + parent: "property_vector3/field_x" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "property_vector3/rich_input_x" + parent: "property_vector3/field_x" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_vector3/rich_input_x/root" + parent: "property_vector3/rich_input_x" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_vector3/rich_input_x/button" + parent: "property_vector3/rich_input_x/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_vector3/rich_input_x/placeholder_text" + parent: "property_vector3/rich_input_x/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_vector3/rich_input_x/input_text" + parent: "property_vector3/rich_input_x/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_vector3/rich_input_x/cursor_node" + parent: "property_vector3/rich_input_x/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_vector3/rich_input_x/cursor_text" + parent: "property_vector3/rich_input_x/cursor_node" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_vector3/selected_x" + parent: "property_vector3/field_x" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_vector3/field_y" + parent: "property_vector3/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_vector3/text_y" + parent: "property_vector3/field_y" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "property_vector3/rich_input_y" + parent: "property_vector3/field_y" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_vector3/rich_input_y/root" + parent: "property_vector3/rich_input_y" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_vector3/rich_input_y/button" + parent: "property_vector3/rich_input_y/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_vector3/rich_input_y/placeholder_text" + parent: "property_vector3/rich_input_y/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_vector3/rich_input_y/input_text" + parent: "property_vector3/rich_input_y/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_vector3/rich_input_y/cursor_node" + parent: "property_vector3/rich_input_y/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_vector3/rich_input_y/cursor_text" + parent: "property_vector3/rich_input_y/cursor_node" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_vector3/selected_y" + parent: "property_vector3/field_y" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_vector3/field_z" + parent: "property_vector3/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_vector3/text_z" + parent: "property_vector3/field_z" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "property_vector3/rich_input_z" + parent: "property_vector3/field_z" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_vector3/rich_input_z/root" + parent: "property_vector3/rich_input_z" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_vector3/rich_input_z/button" + parent: "property_vector3/rich_input_z/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_vector3/rich_input_z/placeholder_text" + parent: "property_vector3/rich_input_z/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_vector3/rich_input_z/input_text" + parent: "property_vector3/rich_input_z/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_vector3/rich_input_z/cursor_node" + parent: "property_vector3/rich_input_z/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "property_vector3/rich_input_z/cursor_text" + parent: "property_vector3/rich_input_z/cursor_node" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_vector3/selected_z" + parent: "property_vector3/field_z" + template_node_child: true +} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties_panel.lua b/druid/widget/properties_panel/properties_panel.lua index e960ace..a0e185a 100644 --- a/druid/widget/properties_panel/properties_panel.lua +++ b/druid/widget/properties_panel/properties_panel.lua @@ -4,6 +4,7 @@ local property_button = require("druid.widget.properties_panel.properties.proper local property_input = require("druid.widget.properties_panel.properties.property_input") local property_text = require("druid.widget.properties_panel.properties.property_text") local property_left_right_selector = require("druid.widget.properties_panel.properties.property_left_right_selector") +local property_vector3 = require("druid.widget.properties_panel.properties.property_vector3") ---@class widget.properties_panel: druid.widget ---@field root node @@ -67,6 +68,9 @@ function M:init() self.property_left_right_selector_prefab = self:get_node("property_left_right_selector/root") gui.set_enabled(self.property_left_right_selector_prefab, false) + self.property_vector3_prefab = self:get_node("property_vector3/root") + gui.set_enabled(self.property_vector3_prefab, false) + -- We not using as a part of properties, since it handled in a way to be paginable self.paginator = self.druid:new_widget(property_left_right_selector, "property_left_right_selector", self.property_left_right_selector_prefab) self.paginator:set_text("Page") @@ -194,6 +198,12 @@ function M:add_left_right_selector(on_create) end +---@param on_create fun(vector3: widget.property_vector3)|nil +function M:add_vector3(on_create) + return self:add_inner_widget(property_vector3, "property_vector3", self.property_vector3_prefab, on_create) +end + + ---@generic T: druid.widget ---@param widget_class T ---@param template string|nil From e59a2b0bcbc4a4a26beb04d70d45093a1d3dffa6 Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 30 Nov 2024 15:04:05 +0200 Subject: [PATCH 37/50] Update --- druid/widget/fps_panel/fps_panel.gui | 2 +- druid/widget/fps_panel/fps_panel.lua | 5 +++++ druid/widget/memory_panel/memory_panel.gui | 2 +- druid/widget/memory_panel/memory_panel.lua | 3 +++ druid/widget/properties_panel/properties_panel.lua | 4 ++-- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/druid/widget/fps_panel/fps_panel.gui b/druid/widget/fps_panel/fps_panel.gui index bf8b20b..5b85967 100644 --- a/druid/widget/fps_panel/fps_panel.gui +++ b/druid/widget/fps_panel/fps_panel.gui @@ -13,7 +13,7 @@ textures { nodes { size { x: 200.0 - y: 100.0 + y: 140.0 } type: TYPE_BOX id: "root" diff --git a/druid/widget/fps_panel/fps_panel.lua b/druid/widget/fps_panel/fps_panel.lua index 58d9ed5..c86c66b 100644 --- a/druid/widget/fps_panel/fps_panel.lua +++ b/druid/widget/fps_panel/fps_panel.lua @@ -11,6 +11,8 @@ if TARGET_FPS == 0 then end function M:init() + self.root = self:get_node("root") + self.delta_time = 0.1 -- in seconds self.collect_time = 3 -- in seconds self.collect_time_counter = 0 @@ -37,6 +39,9 @@ function M:init() self.timer_id = timer.delay(self.delta_time, true, function() self:push_fps_value() end) + + self.container = self.druid:new_container(self.root) + self.container:add_container(self.mini_graph.container) end diff --git a/druid/widget/memory_panel/memory_panel.gui b/druid/widget/memory_panel/memory_panel.gui index 99e8cf2..80b3b4a 100644 --- a/druid/widget/memory_panel/memory_panel.gui +++ b/druid/widget/memory_panel/memory_panel.gui @@ -13,7 +13,7 @@ textures { nodes { size { x: 200.0 - y: 100.0 + y: 140.0 } type: TYPE_BOX id: "root" diff --git a/druid/widget/memory_panel/memory_panel.lua b/druid/widget/memory_panel/memory_panel.lua index fad517c..3a72ae0 100644 --- a/druid/widget/memory_panel/memory_panel.lua +++ b/druid/widget/memory_panel/memory_panel.lua @@ -37,6 +37,9 @@ function M:init() self.timer_id = timer.delay(self.delta_time, true, function() self:push_next_value() end) + + self.container = self.druid:new_container(self.root) + self.container:add_container(self.mini_graph.container) end diff --git a/druid/widget/properties_panel/properties_panel.lua b/druid/widget/properties_panel/properties_panel.lua index a0e185a..b9c6563 100644 --- a/druid/widget/properties_panel/properties_panel.lua +++ b/druid/widget/properties_panel/properties_panel.lua @@ -249,12 +249,12 @@ end ---@private function M:add_property(widget) gui.set_enabled(widget.root, true) - self.layout:add(widget.root) - table.insert(self.properties, widget) local width = self.layout:get_content_size() widget.container:set_size(width) + self.layout:add(widget.root) + return widget end From 917a84fc94631cd42d26975036e2fd9a46b88718 Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 30 Nov 2024 22:52:27 +0200 Subject: [PATCH 38/50] Update --- druid/widget/mini_graph/mini_graph.gui | 2 +- .../properties_panel/properties_panel.lua | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/druid/widget/mini_graph/mini_graph.gui b/druid/widget/mini_graph/mini_graph.gui index 161f0df..11ad730 100644 --- a/druid/widget/mini_graph/mini_graph.gui +++ b/druid/widget/mini_graph/mini_graph.gui @@ -67,7 +67,7 @@ nodes { } type: TYPE_TEXT text: "Mini Graph" - font: "druid_text_regular" + font: "druid_text_bold" id: "text_header" pivot: PIVOT_NW outline { diff --git a/druid/widget/properties_panel/properties_panel.lua b/druid/widget/properties_panel/properties_panel.lua index b9c6563..f19af12 100644 --- a/druid/widget/properties_panel/properties_panel.lua +++ b/druid/widget/properties_panel/properties_panel.lua @@ -99,7 +99,16 @@ end function M:clear_created_properties() for index = 1, #self.properties do - gui.delete_node(self.properties[index].root) + local property = self.properties[index] + + -- If prefab used clone nodes we can remove it + if property:get_nodes() then + gui.delete_node(property.root) + else + -- Probably we have component placed on scene directly + gui.set_enabled(property.root, false) + end + self.druid:remove(self.properties[index]) end self.properties = {} @@ -264,7 +273,15 @@ function M:remove(widget) if self.properties[index] == widget then self.druid:remove(widget) self.layout:remove(widget.root) - gui.delete_node(widget.root) + + -- If prefab used clone nodes we can remove it + if widget:get_nodes() then + gui.delete_node(widget.root) + else + -- Probably we have component placed on scene directly + gui.set_enabled(widget.root, false) + end + table.remove(self.properties, index) break end From 9a1cd795b86e74c5d89345a9bdd2b7c95f9da741 Mon Sep 17 00:00:00 2001 From: Insality Date: Tue, 3 Dec 2024 20:42:33 +0200 Subject: [PATCH 39/50] Test shaders --- druid/druid.script | 37 ++++ druid/event_queue.lua | 84 ++++++++ druid/helper.lua | 122 +++++++++++ druid/materials/gui_repeat/gui_repeat.fp | 84 ++++++++ .../materials/gui_repeat/gui_repeat.material | 43 ++++ druid/materials/gui_repeat/gui_repeat.vp | 55 +++++ druid/materials/skew/gui_skew.fp | 18 ++ druid/materials/skew/gui_skew.material | 8 + druid/materials/skew/gui_skew.vp | 20 ++ druid/widget/node_repeat/node_repeat.lua | 195 ++++++++++++++++++ .../properties/property_slider.lua | 3 +- 11 files changed, 668 insertions(+), 1 deletion(-) create mode 100644 druid/druid.script create mode 100644 druid/event_queue.lua create mode 100644 druid/materials/gui_repeat/gui_repeat.fp create mode 100644 druid/materials/gui_repeat/gui_repeat.material create mode 100644 druid/materials/gui_repeat/gui_repeat.vp create mode 100644 druid/materials/skew/gui_skew.fp create mode 100644 druid/materials/skew/gui_skew.material create mode 100644 druid/materials/skew/gui_skew.vp create mode 100644 druid/widget/node_repeat/node_repeat.lua diff --git a/druid/druid.script b/druid/druid.script new file mode 100644 index 0000000..209ba74 --- /dev/null +++ b/druid/druid.script @@ -0,0 +1,37 @@ +-- Place this script nearby with the gui component to able make requests +-- To the go namespace from GUI with events systems (cross context) + +local event_queue = require("druid.event_queue") + +---Usage: event_queue.request("druid.get_atlas_path", callback, gui.get_texture(self.node), msg.url()) +---Pass texture name to get atlas info and sender url to check if the request is valid +local MESSAGE_GET_ATLAS_PATH = "druid.get_atlas_path" + + +---@param texture_name hash The name from gui.get_texture(node) +---@param sender hash Just msg.url from the caller +local function get_atlas_path(texture_name, sender) + local my_url = msg.url() + my_url.fragment = nil + + local copy_url = msg.url(sender) + copy_url.fragment = nil + + -- This check should works well + local is_my_url = my_url == copy_url + if not is_my_url then + return nil + end + + return go.get(sender, "textures", { key = texture_name }) +end + + +function init(self) + event_queue.subscribe(MESSAGE_GET_ATLAS_PATH, get_atlas_path) +end + + +function final(self) + event_queue.unsubscribe(MESSAGE_GET_ATLAS_PATH, get_atlas_path) +end \ No newline at end of file diff --git a/druid/event_queue.lua b/druid/event_queue.lua new file mode 100644 index 0000000..cdeb7c2 --- /dev/null +++ b/druid/event_queue.lua @@ -0,0 +1,84 @@ +local event = require("event.event") + +---@class event.queue +local M = {} + +local event_handlers = {} +local pending_callbacks = {} + + +---Request to handle a specified event and processes the queue of callbacks associated with it. +---If event has already been triggered, the callback will be executed immediately. +---If event not triggered yet, callback will be executed when event will be triggered. +---It triggered only once and then removed from the queue. +---@param event_name string The name of the event to trigger. +---@param callback fun() The callback function to execute upon triggering. +---@param ... any Additional arguments for the callback. +function M.request(event_name, callback, ...) + pending_callbacks[event_name] = pending_callbacks[event_name] or {} + table.insert(pending_callbacks[event_name], { event.create(callback), ... }) + + M.process_pending_callbacks(event_name) +end + + +---Subscribes to a specified event and executes a callback when the event is triggered. +-- If the event has already been triggered, the callback will be executed immediately. +---@param event_name string The name of the event to subscribe to. +---@param callback fun() The function to call when the event is triggered. +function M.subscribe(event_name, callback) + event_handlers[event_name] = event_handlers[event_name] or event.create() + + if event_handlers[event_name] then + event_handlers[event_name]:subscribe(callback) + end + + M.process_pending_callbacks(event_name) +end + + +---Unsubscribes a callback function from a specified event. +---@param event_name string The name of the event to unsubscribe from. +---@param callback fun() The function to remove from the event's subscription list. +function M.unsubscribe(event_name, callback) + if event_handlers[event_name] then + event_handlers[event_name]:unsubscribe(callback) + end +end + + +---Processes the queue for a given event name, executing callbacks and handling results. +---Processed callbacks are removed from the queue. +---@param event_name string The name of the event for which to process the queue. +function M.process_pending_callbacks(event_name) + local callbacks_to_process = pending_callbacks[event_name] + local event_handler = event_handlers[event_name] + + if not callbacks_to_process or not event_handler then + return + end + + -- Loop through the queue in reverse to prevent index errors during removal + for i = #callbacks_to_process, 1, -1 do + local callback_entry = callbacks_to_process[i] + -- Better to figure out how to make it without 2 unpacks, but ok for all our cases now + local args = { unpack(callback_entry, 2) } + + -- Safely call the event handler and handle errors + local success, result = pcall(event_handler.trigger, event_handler, unpack(args)) + + if success and result then + local callback_function = callback_entry[1] + pcall(callback_function, result) -- Safely invoke the callback, catching any errors + table.remove(callbacks_to_process, i) -- Remove the processed callback from the queue + end + end + + -- Clean up if the callback queue is empty + if #callbacks_to_process == 0 then + pending_callbacks[event_name] = nil + end +end + + +return M diff --git a/druid/helper.lua b/druid/helper.lua index 163a75c..214d14b 100644 --- a/druid/helper.lua +++ b/druid/helper.lua @@ -12,6 +12,11 @@ local POSITION_X = hash("position.x") local SCALE_X = hash("scale.x") local SIZE_X = hash("size.x") +M.PROP_SIZE_X = hash("size.x") +M.PROP_SIZE_Y = hash("size.y") +M.PROP_SCALE_X = hash("scale.x") +M.PROP_SCALE_Y = hash("scale.y") + local function get_text_width(text_node) if text_node then local text_metrics = M.get_text_metrics_from_node(text_node) @@ -540,4 +545,121 @@ function M.get_full_position(node, root) end +---@class druid.animation_data +---@field frames table> @List of frames with uv coordinates and size +---@field width number @Width of the animation +---@field height number @Height of the animation +---@field fps number @Frames per second +---@field current_frame number @Current frame +---@field node node @Node with flipbook animation +---@field v vector4 @Vector with UV coordinates and size + +---@param node node +---@param atlas_path string @Path to the atlas +---@return druid.animation_data +function M.get_animation_data_from_node(node, atlas_path) + local atlas_data = resource.get_atlas(atlas_path) + local tex_info = resource.get_texture_info(atlas_data.texture) + local tex_w = tex_info.width + local tex_h = tex_info.height + + local animation_data + + local sprite_image_id = gui.get_flipbook(node) + for _, animation in ipairs(atlas_data.animations) do + if hash(animation.id) == sprite_image_id then + animation_data = animation + break + end + end + assert(animation_data, "Unable to find image " .. sprite_image_id) + + local frames = {} + for index = animation_data.frame_start, animation_data.frame_end - 1 do + local uvs = atlas_data.geometries[index].uvs + assert(#uvs == 8, "Sprite trim mode should be disabled for the images.") + + -- UV texture coordinates + -- 1 + -- ^ V + -- | + -- | + -- | U + -- 0-------> 1 + + -- uvs = { + -- 0, 0, + -- 0, height, + -- width, height, + -- width, 0 + -- }, + -- Point indeces (Point number {uv_index_x, uv_index_y}) + -- geometries.indices = {0 (1,2), 1(3,4), 2(5,6), 0(1,2), 2(5,6), 3(7,8)} + -- 1------2 + -- | / | + -- | A / | + -- | / B | + -- | / | + -- 0------3 + + local width = uvs[5] - uvs[1] -- Width of sprite region + local height = uvs[2] - uvs[4] -- Height of sprite region + local is_rotated = height < 0 -- In case of rotated sprite + + local x_left = uvs[1] + local y_bottom = uvs[2] + local x_right = uvs[5] + local y_top = uvs[6] + + -- Okay now it's correct for non rotated + local uv_coord = vmath.vector4( + x_left / tex_w, + (tex_h - y_bottom) / tex_h, + x_right / tex_w, + (tex_h - y_top) / tex_h + ) + + if is_rotated then + -- In case the atlas has clockwise rotated sprite. + -- 0---------------1 + -- | \ A | + -- | \ | + -- | \ | + -- | B \ | + -- 3---------------2 + height = -height + + uv_coord.x, uv_coord.y, uv_coord.z, uv_coord.w = uv_coord.y, uv_coord.z, uv_coord.w, uv_coord.x + + -- Update uv_coord + --uv_coord = vmath.vector4( + -- u1 / tex_w, + -- (tex_h - v2) / tex_h, + -- u2 / tex_w, + -- (tex_h - v1) / tex_h + --) + end + + local frame = { + uv_coord = uv_coord, + w = width, + h = height, + uv_rotated = is_rotated and vmath.vector4(0, 1, 0, 0) or vmath.vector4(1, 0, 0, 0) + } + + table.insert(frames, frame) + end + + return { + frames = frames, + width = animation_data.width, + height = animation_data.height, + fps = animation_data.fps, + v = vmath.vector4(1, 1, animation_data.width, animation_data.height), + current_frame = 1, + node = node, + } +end + + return M diff --git a/druid/materials/gui_repeat/gui_repeat.fp b/druid/materials/gui_repeat/gui_repeat.fp new file mode 100644 index 0000000..fb355aa --- /dev/null +++ b/druid/materials/gui_repeat/gui_repeat.fp @@ -0,0 +1,84 @@ +#version 140 + +uniform sampler2D texture_sampler; + +in vec2 var_texcoord0; +in vec4 var_color; +in vec4 var_uv; +in vec4 var_repeat; // [repeat_x, repeat_y, anchor_x, anchor_y] +in vec4 var_params; // [margin_x, margin_y, offset_x, offset_y] +in vec4 var_perspective; +in vec4 var_uv_rotated; + +out vec4 color_out; + +void main() { + vec2 pivot = var_repeat.zw; + // Margin is a value between 0 and 1 that means offset/padding from the one image to another + vec2 margin = var_params.xy; + vec2 offset = var_params.zw; + vec2 repeat = var_repeat.xy; + + // Atlas UV to local UV [0, 1] + float u = (var_texcoord0.x - var_uv.x) / (var_uv.z - var_uv.x); + float v = (var_texcoord0.y - var_uv.y) / (var_uv.w - var_uv.y); + + // Adjust local UV by the pivot point. So 0:0 will be at the pivot point of node + u = u - (0.5 + pivot.x); + v = v - (0.5 - pivot.y); + + // If rotated, swap UV + if (var_uv_rotated.y < 0.5) { + float temp = u; + u = v; + v = temp; + } + + // Adjust repeat by the margin + repeat.x = repeat.x / (1.0 + margin.x); + repeat.y = repeat.y / (1.0 + margin.y); + + // Repeat is a value between 0 and 1 that represents the number of times the texture is repeated in the atlas. + float tile_u = fract(u * repeat.x); + float tile_v = fract(v * repeat.y); + + float tile_width = 1.0 / repeat.x; + float tile_height = 1.0 / repeat.y; + + // Adjust tile UV by the pivot point. + // Not center is left top corner, need to adjust it to pivot point + tile_u = fract(tile_u + pivot.x + 0.5); + tile_v = fract(tile_v - pivot.y + 0.5); + + // Apply offset + tile_u = fract(tile_u + offset.x); + tile_v = fract(tile_v + offset.y); + + // Extend margins + margin = margin * 0.5; + tile_u = mix(0.0 - margin.x, 1.0 + margin.x, tile_u); + tile_v = mix(0.0 - margin.y, 1.0 + margin.y, tile_v); + float alpha = 0.0; + // If the tile is outside the margins, make it transparent, without IF + alpha = step(0.0, tile_u) * step(tile_u, 1.0) * step(0.0, tile_v) * step(tile_v, 1.0); + + tile_u = clamp(tile_u, 0.0, 1.0); // Keep borders in the range 0-1 + tile_v = clamp(tile_v, 0.0, 1.0); // Keep borders in the range 0-1 + + if (var_uv_rotated.y < 0.5) { + float temp = tile_u; + tile_u = tile_v; + tile_v = temp; + } + + // Remap local UV to the atlas UV + vec2 uv = vec2( + mix(var_uv.x, var_uv.z, tile_u), // Get texture coordinate from the atlas + mix(var_uv.y, var_uv.w, tile_v) // Get texture coordinate from the atlas + //mix(var_uv.x, var_uv.z, tile_u * var_uv_rotated.x + tile_v * var_uv_rotated.z), + //mix(var_uv.y, var_uv.w, 1.0 - (tile_u * var_uv_rotated.y + tile_v * var_uv_rotated.x)) + ); + + lowp vec4 tex = texture(texture_sampler, uv); + color_out = tex * var_color; +} \ No newline at end of file diff --git a/druid/materials/gui_repeat/gui_repeat.material b/druid/materials/gui_repeat/gui_repeat.material new file mode 100644 index 0000000..213467e --- /dev/null +++ b/druid/materials/gui_repeat/gui_repeat.material @@ -0,0 +1,43 @@ +name: "repeat" +tags: "gui" +vertex_program: "/druid/materials/gui_repeat/gui_repeat.vp" +fragment_program: "/druid/materials/gui_repeat/gui_repeat.fp" +vertex_constants { + name: "view_proj" + type: CONSTANT_TYPE_VIEWPROJ +} +vertex_constants { + name: "uv_coord" + type: CONSTANT_TYPE_USER + value { + z: 1.0 + w: 1.0 + } +} +vertex_constants { + name: "uv_repeat" + type: CONSTANT_TYPE_USER + value { + x: 1.0 + y: 1.0 + } +} +vertex_constants { + name: "params" + type: CONSTANT_TYPE_USER + value { + } +} +vertex_constants { + name: "perspective" + type: CONSTANT_TYPE_USER + value { + } +} +vertex_constants { + name: "uv_rotated" + type: CONSTANT_TYPE_USER + value { + x: 1.0 + } +} diff --git a/druid/materials/gui_repeat/gui_repeat.vp b/druid/materials/gui_repeat/gui_repeat.vp new file mode 100644 index 0000000..f50808b --- /dev/null +++ b/druid/materials/gui_repeat/gui_repeat.vp @@ -0,0 +1,55 @@ +#version 140 + +in mediump vec3 position; +in mediump vec2 texcoord0; +in lowp vec4 color; + +uniform vertex_inputs +{ + highp mat4 view_proj; + highp vec4 uv_coord; + highp vec4 uv_repeat; // [repeat_x, repeat_y, pivot_x, pivot_y] + vec4 uv_rotated; + vec4 params; // [margin_x, margin_y, offset_x, offset_y] + vec4 perspective; // [perspective_x, perspective_y, zoom, offset_y] +}; + +out mediump vec2 var_texcoord0; +out lowp vec4 var_color; +out highp vec4 var_uv; +out highp vec4 var_repeat; +out vec4 var_params; +out vec4 var_perspective; +out vec4 var_uv_rotated; + +void main() +{ + var_texcoord0 = texcoord0; + var_color = vec4(color.rgb * color.a, color.a); + var_uv = uv_coord; + var_repeat = uv_repeat; + var_params = params; + var_perspective = perspective; + var_uv_rotated = uv_rotated; + + float perspective_y = position.z; + + float scale_x = 1.0 - abs(perspective.x); + float scale_y = 1.0 - abs(perspective_y); + + mat4 transform = mat4( + scale_x, 0, 0, perspective.z, + 0, scale_y, 0, perspective.w, + 0, 0, 1, 0, + perspective.x, perspective_y, 0, 1.0 + ); + + // Matrix Info = mat4( + // scale_x, skew_x, 0, offset_x, + // skew_y, scale_y, 0, offset_y, + // 0, 0, scale_z, offset_z, + // perspective_x, perspective_y, perspective_z, zoom + //) + + gl_Position = view_proj * vec4(position.xyz, 1.0) * transform; +} diff --git a/druid/materials/skew/gui_skew.fp b/druid/materials/skew/gui_skew.fp new file mode 100644 index 0000000..c3d593d --- /dev/null +++ b/druid/materials/skew/gui_skew.fp @@ -0,0 +1,18 @@ +#version 140 + +uniform sampler2D texture_sampler; + +in vec2 var_texcoord0; +in vec4 var_color; + +out vec4 color_out; + +void main() { + lowp vec4 tex = texture(texture_sampler, var_texcoord0.xy); + if (tex.a < 0.5) { + discard; + } + + // Final color of stencil texture + color_out = tex * var_color; +} \ No newline at end of file diff --git a/druid/materials/skew/gui_skew.material b/druid/materials/skew/gui_skew.material new file mode 100644 index 0000000..5575ae1 --- /dev/null +++ b/druid/materials/skew/gui_skew.material @@ -0,0 +1,8 @@ +name: "repeat" +tags: "gui" +vertex_program: "/druid/materials/stencil/gui_stencil.vp" +fragment_program: "/druid/materials/stencil/gui_stencil.fp" +vertex_constants { + name: "view_proj" + type: CONSTANT_TYPE_VIEWPROJ +} diff --git a/druid/materials/skew/gui_skew.vp b/druid/materials/skew/gui_skew.vp new file mode 100644 index 0000000..382c88b --- /dev/null +++ b/druid/materials/skew/gui_skew.vp @@ -0,0 +1,20 @@ +#version 140 + +uniform vertex_inputs { + highp mat4 view_proj; +}; + +// positions are in world space +in mediump vec3 position; +in mediump vec2 texcoord0; +in lowp vec4 color; + +out mediump vec2 var_texcoord0; +out lowp vec4 var_color; + +void main() +{ + var_texcoord0 = texcoord0; + var_color = vec4(color.rgb * color.a, color.a); + gl_Position = view_proj * vec4(position.xyz, 1.0); +} diff --git a/druid/widget/node_repeat/node_repeat.lua b/druid/widget/node_repeat/node_repeat.lua new file mode 100644 index 0000000..353517d --- /dev/null +++ b/druid/widget/node_repeat/node_repeat.lua @@ -0,0 +1,195 @@ +local helper = require("druid.helper") +local event_queue = require("druid.event_queue") + +---@class druid.node_repeat: druid.widget +---@field animation table +---@field node node +---@field params vector4 +---@field time number +local M = {} + +function M:init(node) + self.node = self:get_node(node) + self.animation = nil + gui.set_material(self.node, hash("gui_repeat")) + self.time = 0 + self.margin = 0 + + self.params = gui.get(self.node, "params") --[[@as vector4]] + self:get_atlas_path(function(atlas_path) + self.is_inited = self:init_tiling_animation(atlas_path) + local repeat_x, repeat_y = self:get_repeat() + self:animate(repeat_x, repeat_y) + end) + + --self.druid.events.on_node_property_changed:subscribe(self.on_node_property_changed, self) +end + + +function M:on_node_property_changed(node, property) + if not self.is_inited or node ~= self.node then + return + end + + if property == "size" or property == "scale" then + local repeat_x, repeat_y = self:get_repeat() + self:set_repeat(repeat_x, repeat_y) + end +end + + +function M:get_repeat() + if not self.is_inited then + return 1, 1 + end + local size_x = gui.get(self.node, helper.PROP_SIZE_X) + local size_y = gui.get(self.node, helper.PROP_SIZE_Y) + local scale_x = gui.get(self.node, helper.PROP_SCALE_X) + local scale_y = gui.get(self.node, helper.PROP_SCALE_Y) + + local repeat_x = (size_x / self.animation.width) / scale_x + local repeat_y = (size_y / self.animation.height) / scale_y + + return repeat_x, repeat_y +end + + +function M:get_atlas_path(callback) + event_queue.request("druid.get_atlas_path", callback, gui.get_texture(self.node), msg.url()) +end + + +---@return boolean +function M:init_tiling_animation(atlas_path) + if not atlas_path then + print("No atlas path found for node", gui.get_id(self.node), gui.get_texture(self.node)) + print("Probably you should add druid.script at window collection to access resources") + return false + end + + self.animation = helper.get_animation_data_from_node(self.node, atlas_path) + return true +end + +-- Start our repeat shader work +-- @param repeat_x -- X factor +-- @param repeat_y -- Y factor +function M:animate(repeat_x, repeat_y) + if not self.is_inited then + return + end + + local node = self.node + local animation = self.animation + + local frame = animation.frames[1] + gui.set(node, "uv_coord", frame.uv_coord) + self:set_repeat(repeat_x, repeat_y) + + if #animation.frames > 1 and animation.fps > 0 then + animation.handle = + timer.delay(1/animation.fps, true, function(self, handle, time_elapsed) + local next_rame = animation.frames[animation.current_frame] + gui.set(node, "uv_coord", next_rame.uv_coord) + + animation.current_frame = animation.current_frame + 1 + if animation.current_frame > #animation.frames then + animation.current_frame = 1 + end + end) + end +end + + +function M:final() + local animation = self.animation + if animation.handle then + timer.cancel(animation.handle) + animation.handle = nil + end +end + + +-- Update repeat factor values +-- @param repeat_x +-- @param repeat_y +function M:set_repeat(repeat_x, repeat_y) + local animation = self.animation + animation.v.x = repeat_x or animation.v.x + animation.v.y = repeat_y or animation.v.y + + local anchor = helper.get_pivot_offset(gui.get_pivot(self.node)) + animation.v.z = anchor.x + animation.v.w = anchor.y + + gui.set(self.node, "uv_repeat", animation.v) +end + + +function M:set_perpective(perspective_x, perspective_y) + if perspective_x then + gui.set(self.node, "perspective.x", perspective_x) + end + + if perspective_y then + gui.set(self.node, "perspective.y", perspective_y) + end + + return self +end + + +function M:set_perpective_offset(offset_x, offset_y) + if offset_x then + gui.set(self.node, "perspective.z", offset_x) + end + + if offset_y then + gui.set(self.node, "perspective.w", offset_y) + end + + return self +end + + +function M:set_offset(offset_perc_x, offset_perc_y) + self.params.z = offset_perc_x or self.params.z + self.params.w = offset_perc_y or self.params.w + gui.set(self.node, "params", self.params) + return self +end + + +function M:set_margin(margin_x, margin_y) + self.params.x = margin_x or self.params.x + self.params.y = margin_y or self.params.y + gui.set(self.node, "params", self.params) + return self +end + + +---@param scale number +function M:set_scale(scale) + local current_scale_x = gui.get(self.node, helper.PROP_SCALE_X) + local current_scale_y = gui.get(self.node, helper.PROP_SCALE_Y) + local current_size_x = gui.get(self.node, helper.PROP_SIZE_X) + local current_size_y = gui.get(self.node, helper.PROP_SIZE_Y) + + local delta_scale_x = scale / current_scale_x + local delta_scale_y = scale / current_scale_y + gui.set(self.node, helper.PROP_SCALE_X, scale) + gui.set(self.node, helper.PROP_SCALE_Y, scale) + gui.set(self.node, helper.PROP_SIZE_X, current_size_x / delta_scale_x) + gui.set(self.node, helper.PROP_SIZE_Y, current_size_y / delta_scale_y) + + --self.druid:on_node_property_changed(self.node, "scale") + --self.druid:on_node_property_changed(self.node, "size") + + --local repeat_x, repeat_y = self:get_repeat() + --self:set_repeat(repeat_x, repeat_y) + + return self +end + + +return M diff --git a/druid/widget/properties_panel/properties/property_slider.lua b/druid/widget/properties_panel/properties/property_slider.lua index d025989..844cb94 100644 --- a/druid/widget/properties_panel/properties/property_slider.lua +++ b/druid/widget/properties_panel/properties/property_slider.lua @@ -19,6 +19,7 @@ function M:init() self.min = 0 self.max = 1 + self.step = 0.01 self.text_name = self.druid:new_text("text_name") :set_text_adjust("scale_then_trim", 0.3) @@ -63,7 +64,7 @@ end ---@param value number function M:set_value(value, is_instant) local diff = math.abs(self.max - self.min) - self.slider:set(value / diff, true) + self.slider:set((value - self.min) / diff, true) local is_changed = self._value ~= value if not is_changed then From 6b8bbe1970b7ae7d1cbe98e63ec1ea838b4e927b Mon Sep 17 00:00:00 2001 From: Insality Date: Sun, 8 Dec 2024 13:35:41 +0200 Subject: [PATCH 40/50] Refactor text setting methods and remove ldoc files --- .vscode/settings.json | 2 +- config.ld | 18 - druid/base/button.lua | 22 +- druid/base/drag.lua | 7 +- druid/base/hover.lua | 11 +- druid/base/text.lua | 8 +- druid/component.lua | 24 +- druid/custom/rich_text/module/rt.lua | 2 +- druid/custom/rich_text/rich_text.lua | 21 ++ druid/extended/data_list.lua | 6 +- druid/extended/input.lua | 2 +- druid/extended/swipe.lua | 13 +- druid/helper.lua | 4 +- druid/materials/gui_repeat/gui_repeat.vp | 11 +- druid/system/druid_annotations.lua | 55 +++- druid/system/druid_instance.lua | 13 +- .../example_scene/example_scene.lua | 4 +- .../panel_druid_profiler.lua | 10 +- .../properties/property_slider.lua | 6 +- .../cache_with_component.lua | 2 +- .../widgets/hover_hint/hover_hint.lua | 2 +- test/helper/test_helper.lua | 3 +- test/test.gui_script | 2 +- update_docs.sh | 17 - utils/annotations_manual.lua | 126 ------- utils/ldoc_fixed.css | 311 ------------------ 26 files changed, 158 insertions(+), 544 deletions(-) delete mode 100644 config.ld delete mode 100755 update_docs.sh delete mode 100644 utils/annotations_manual.lua delete mode 100644 utils/ldoc_fixed.css diff --git a/.vscode/settings.json b/.vscode/settings.json index 28a4386..4c7b95d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -29,7 +29,7 @@ "utils/annotations_manual.lua" ], "Lua.runtime.pathStrict": true, - "Lua.diagnostics.libraryFiles": "Enable", + "Lua.diagnostics.libraryFiles": "Disable", "Lua.runtime.version": "Lua 5.1", "Lua.workspace.library": [ "~/Library/Application Support/Code/User/globalStorage/astronachos.defold", diff --git a/config.ld b/config.ld deleted file mode 100644 index a487ec9..0000000 --- a/config.ld +++ /dev/null @@ -1,18 +0,0 @@ -project='Druid' -title='Defold Druid UI Framework' -description='Documentation for Druid Framework' -file={"./druid", - exclude = { - "./druid/styles/", - "./druid/templates/", - "./druid/annotations.lua", - "./druid/custom/rich_text/module", - } -} -package='druid' -sort=true -dir='./docs' -style='!fixed' -topics={} -use_markdown_titles=true -no_space_before_args=true diff --git a/druid/base/button.lua b/druid/base/button.lua index a8a6707..345e00e 100755 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -485,7 +485,11 @@ end ---@param key hash|string The action_id of the input key. Example: "key_space" ---@return druid.button self function M:set_key_trigger(key) - self.key_trigger = hash(key) + if type(key) == "string" then + self.key_trigger = hash(key) + else + self.key_trigger = key + end return self end @@ -498,22 +502,24 @@ function M:get_key_trigger() end ---- Set function for additional check for button click availability +---Set function for additional check for button click availability ---@param check_function function|nil Should return true or false. If true - button can be pressed. ---@param failure_callback function|nil Function will be called on button click, if check function return false ---@return druid.button self function M:set_check_function(check_function, failure_callback) self._check_function = check_function self._failure_callback = failure_callback + + return self end ---- Set Button mode to work inside user HTML5 interaction event. --- --- It's required to make protected things like copy & paste text, show mobile keyboard, etc --- The HTML5 button's doesn't call any events except on_click event. --- --- If the game is not HTML, html mode will be not enabled +---Set Button mode to work inside user HTML5 interaction event. +--- +---It's required to make protected things like copy & paste text, show mobile keyboard, etc +---The HTML5 button's doesn't call any events except on_click event. +--- +---If the game is not HTML, html mode will be not enabled ---@param is_web_mode boolean|nil If true - button will be called inside html5 callback ---@return druid.button self function M:set_web_user_interaction(is_web_mode) diff --git a/druid/base/drag.lua b/druid/base/drag.lua index bcc6f78..ee5a3dc 100644 --- a/druid/base/drag.lua +++ b/druid/base/drag.lua @@ -206,9 +206,10 @@ end -- @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 M:on_style_change(style) - self.style = {} - self.style.DRAG_DEADZONE = style.DRAG_DEADZONE or 10 - self.style.NO_USE_SCREEN_KOEF = style.NO_USE_SCREEN_KOEF or false + self.style = { + DRAG_DEADZONE = style.DRAG_DEADZONE or 10, + NO_USE_SCREEN_KOEF = style.NO_USE_SCREEN_KOEF or false, + } end diff --git a/druid/base/hover.lua b/druid/base/hover.lua index b1713b4..4ca0849 100644 --- a/druid/base/hover.lua +++ b/druid/base/hover.lua @@ -27,9 +27,9 @@ local component = require("druid.component") ---@field on_mouse_hover event ---@field style table ---@field click_zone node ----@field private _is_hovered boolean ----@field private _is_mouse_hovered boolean ----@field private _is_enabled boolean +---@field private _is_hovered boolean|nil +---@field private _is_mouse_hovered boolean|nil +---@field private _is_enabled boolean|nil ---@field private _is_mobile boolean local M = component.create("hover") @@ -163,6 +163,11 @@ end -- no click events outside stencil node ---@param zone node|string|nil Gui node function M:set_click_zone(zone) + if not zone then + self.click_zone = nil + return + end + self.click_zone = self:get_node(zone) end diff --git a/druid/base/text.lua b/druid/base/text.lua index ee05801..461299f 100755 --- a/druid/base/text.lua +++ b/druid/base/text.lua @@ -515,22 +515,22 @@ function M:set_pivot(pivot) end ---- Return true, if text with line break +---Return true, if text with line break ---@return boolean Is text node with line break function M:is_multiline() return gui.get_line_break(self.node) end ---- Set text adjust, refresh the current text visuals, if needed +---Set text adjust, refresh the current text visuals, if needed ---Values are: "downscale", "trim", "no_adjust", "downscale_limited", ---"scroll", "scale_then_scroll", "trim_left", "scale_then_trim", "scale_then_trim_left" ---@param adjust_type string|nil See const.TEXT_ADJUST. If pass nil - use current adjust type ----@param minimal_scale number|nil If pass nil - not use minimal scale +---@param minimal_scale number|nil To remove minimal scale, use `text:set_minimal_scale(nil)`, if pass nil - not change minimal scale ---@return druid.text self Current text instance function M:set_text_adjust(adjust_type, minimal_scale) self.adjust_type = adjust_type - self._minimal_scale = minimal_scale + self._minimal_scale = minimal_scale or self._minimal_scale self:set_text(self.last_value) return self diff --git a/druid/component.lua b/druid/component.lua index 6ea5918..df216eb 100644 --- a/druid/component.lua +++ b/druid/component.lua @@ -21,18 +21,18 @@ local helper = require("druid.helper") ---@class druid.base_component ---@field druid druid_instance Druid instance to create inner components ----@field protected init fun(self:druid.base_component, ...)|nil ----@field protected update fun(self:druid.base_component, dt:number)|nil ----@field protected on_remove fun(self:druid.base_component)|nil ----@field protected on_input fun(self:druid.base_component, action_id:number, action:table)|nil ----@field protected on_message fun(self:druid.base_component, message_id:hash, message:table, sender:userdata)|nil ----@field protected on_late_init fun(self:druid.base_component)|nil ----@field protected on_focus_lost fun(self:druid.base_component)|nil ----@field protected on_focus_gained fun(self:druid.base_component)|nil ----@field protected on_style_change fun(self:druid.base_component, style: table)|nil ----@field protected on_layout_change fun(self:druid.base_component)|nil ----@field protected on_window_resized fun(self:druid.base_component, width:number, height:number)|nil ----@field protected on_language_change fun(self:druid.base_component, language:string)|nil +---@field init fun(self:druid.base_component, ...)|nil +---@field update fun(self:druid.base_component, dt:number)|nil +---@field on_remove fun(self:druid.base_component)|nil +---@field on_input fun(self:druid.base_component, action_id:number, action:table)|nil +---@field on_message fun(self:druid.base_component, message_id:hash, message:table, sender:userdata)|nil +---@field on_late_init fun(self:druid.base_component)|nil +---@field on_focus_lost fun(self:druid.base_component)|nil +---@field on_focus_gained fun(self:druid.base_component)|nil +---@field on_style_change fun(self:druid.base_component, style: table)|nil +---@field on_layout_change fun(self:druid.base_component)|nil +---@field on_window_resized fun(self:druid.base_component)|nil +---@field on_language_change fun(self:druid.base_component)|nil ---@field private _component druid.base_component.component ---@field private _meta druid.base_component.meta local M = {} diff --git a/druid/custom/rich_text/module/rt.lua b/druid/custom/rich_text/module/rt.lua index 4ae501f..83d1b85 100755 --- a/druid/custom/rich_text/module/rt.lua +++ b/druid/custom/rich_text/module/rt.lua @@ -181,7 +181,7 @@ function M.create(text, settings, style) outline = settings.outline, font = gui.get_font(settings.text_prefab), -- Image params - ---@type druid.rich_text.image + ---@type druid.rich_text.word.image image = nil, -- Tags br = nil, diff --git a/druid/custom/rich_text/rich_text.lua b/druid/custom/rich_text/rich_text.lua index a8ad888..91f9da2 100644 --- a/druid/custom/rich_text/rich_text.lua +++ b/druid/custom/rich_text/rich_text.lua @@ -76,6 +76,27 @@ local component = require("druid.component") local rich_text = require("druid.custom.rich_text.module.rt") +---@class druid.rich_text.settings +---@field parent node +---@field size number +---@field fonts table +---@field scale vector3 +---@field color vector4 +---@field shadow vector4 +---@field outline vector4 +---@field position vector3 +---@field image_pixel_grid_snap boolean +---@field combine_words boolean +---@field default_animation string +---@field text_prefab node +---@field adjust_scale number +---@field default_texture string +---@field is_multiline boolean +---@field text_leading number +---@field font hash +---@field width number +---@field height number + ---@class druid.rich_text.word ---@field node node ---@field relative_scale number diff --git a/druid/extended/data_list.lua b/druid/extended/data_list.lua index 9eaaafd..c7ece01 100644 --- a/druid/extended/data_list.lua +++ b/druid/extended/data_list.lua @@ -51,13 +51,13 @@ local event = require("event.event") ---@field private _cache table ---@field private _data table ---@field private _data_visual table ----@field private top_index number +---@field top_index number local M = component.create("data_list") --- The DataList constructor ----@param scroll Scroll The Scroll instance for Data List component ----@param grid StaticGrid The StaticGrid} or @{DynamicGrid instance for Data List component +---@param scroll druid.scroll The Scroll instance for Data List component +---@param grid druid.grid The StaticGrid} or @{DynamicGrid instance for Data List component ---@param create_function function The create function callback(self, data, index, data_list). Function should return (node, [component]) function M:init(scroll, grid, create_function) self.scroll = scroll diff --git a/druid/extended/input.lua b/druid/extended/input.lua index 89492f6..ae243a2 100755 --- a/druid/extended/input.lua +++ b/druid/extended/input.lua @@ -157,7 +157,7 @@ end --- The Input constructor ---@param click_node node Node to enabled input component ----@param text_node node|Text Text node what will be changed on user input. You can pass text component instead of text node name Text +---@param text_node node|druid.text Text node what will be changed on user input. You can pass text component instead of text node name Text ---@param keyboard_type number|nil Gui keyboard type for input field function M:init(click_node, text_node, keyboard_type) self.druid = self:get_druid() diff --git a/druid/extended/swipe.lua b/druid/extended/swipe.lua index d40e63d..fb65293 100644 --- a/druid/extended/swipe.lua +++ b/druid/extended/swipe.lua @@ -10,13 +10,13 @@ -- @alias druid.swipe --- Swipe node ----@param node node +--@param node node --- Restriction zone ----@param click_zone node|nil +--@param click_zone node|nil --- Trigger on swipe event(self, swipe_side, dist, delta_time) ----@param event event on_swipe +--@param event event on_swipe --- @@ -59,7 +59,7 @@ local function check_swipe(self, action) if is_swipe then local is_x_swipe = math.abs(dx) >= math.abs(dy) - local swipe_side = false + local swipe_side = "undefined" if is_x_swipe and dx > 0 then swipe_side = "right" @@ -164,6 +164,11 @@ end -- restrict events outside stencil node ---@param zone node|string|nil Gui node function M:set_click_zone(zone) + if not zone then + self.click_zone = nil + return + end + self.click_zone = self:get_node(zone) end diff --git a/druid/helper.lua b/druid/helper.lua index 214d14b..9f5c5c2 100644 --- a/druid/helper.lua +++ b/druid/helper.lua @@ -311,9 +311,9 @@ end ---Get size of node with scale multiplier ---@param node node GUI node ----@treturn vector3 Scaled size +---@return vector3 scaled_size function M.get_scaled_size(node) - return vmath.mul_per_elem(gui.get_size(node), gui.get_scale(node)) + return vmath.mul_per_elem(gui.get_size(node), gui.get_scale(node)) --[[@as vector3]] end diff --git a/druid/materials/gui_repeat/gui_repeat.vp b/druid/materials/gui_repeat/gui_repeat.vp index f50808b..12c1460 100644 --- a/druid/materials/gui_repeat/gui_repeat.vp +++ b/druid/materials/gui_repeat/gui_repeat.vp @@ -32,16 +32,11 @@ void main() var_perspective = perspective; var_uv_rotated = uv_rotated; - float perspective_y = position.z; - - float scale_x = 1.0 - abs(perspective.x); - float scale_y = 1.0 - abs(perspective_y); - mat4 transform = mat4( - scale_x, 0, 0, perspective.z, - 0, scale_y, 0, perspective.w, + 1.0, 0, 0, 0.0, + 0, 1.0, 0, 0.0, 0, 0, 1, 0, - perspective.x, perspective_y, 0, 1.0 + 0.0, position.z, 0, 1.0 ); // Matrix Info = mat4( diff --git a/druid/system/druid_annotations.lua b/druid/system/druid_annotations.lua index b31130a..60f45ae 100644 --- a/druid/system/druid_annotations.lua +++ b/druid/system/druid_annotations.lua @@ -1,2 +1,55 @@ ---@class druid.widget: druid.base_component ----@field druid druid_instance \ No newline at end of file +---@field druid druid_instance + +---@class GUITextMetrics +---@field width number +---@field height number +---@field max_ascent number +---@field max_descent number + +---@class utf8 +---@field len fun(s: string):number +---@field sub fun(s: string, start_index: number, length: number) +---@field reverse fun() +---@field char fun() +---@field unicode fun() +---@field gensub fun() +---@field byte fun() +---@field find fun() +---@field match fun(s: string, m: string) +---@field gmatch fun(s: string, m: string) +---@field gsub fun() +---@field dump fun() +---@field format fun() +---@field lower fun() +---@field upper fun() +---@field rep fun() + +---@class action +---@field value number The amount of input given by the user. This is usually 1 for buttons and 0-1 for analogue inputs. This is not present for mouse movement. +---@field pressed boolean If the input was pressed this frame. This is not present for mouse movement. +---@field released boolean If the input was released this frame. This is not present for mouse movement. +---@field repeated boolean If the input was repeated this frame. This is similar to how a key on a keyboard is repeated when you hold it down. This is not present for mouse movement. +---@field x number The x value of a pointer device, if present. +---@field y number The y value of a pointer device, if present. +---@field screen_x number The screen space x value of a pointer device, if present. +---@field screen_y number The screen space y value of a pointer device, if present. +---@field dx number The change in x value of a pointer device, if present. +---@field dy number The change in y value of a pointer device, if present. +---@field screen_dx number The change in screen space x value of a pointer device, if present. +---@field screen_dy number The change in screen space y value of a pointer device, if present. +---@field gamepad number The index of the gamepad device that provided the input. +---@field touch touch[] List of touch input, one element per finger, if present. See table below about touch input + +---@class touch +---@field id number A number identifying the touch input during its duration. +---@field pressed boolean True if the finger was pressed this frame. +---@field released boolean True if the finger was released this frame. +---@field tap_count number Number of taps, one for single, two for double-tap, etc +---@field x number The x touch location. +---@field y number The y touch location. +---@field dx number The change in x value. +---@field dy number The change in y value. +---@field acc_x number|nil Accelerometer x value (if present). +---@field acc_y number|nil Accelerometer y value (if present). +---@field acc_z number|nil Accelerometer z value (if present). diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index 0c3fb69..afdecb5 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -147,10 +147,9 @@ end ---Check whitelists and blacklists for input components ----@param self druid_instance ---@param component druid.base_component ---@return boolean -local function can_use_input_component(self, component) +function M:_can_use_input_component(component) local can_by_whitelist = true local can_by_blacklist = true @@ -166,13 +165,13 @@ local function can_use_input_component(self, component) end -local function process_input(self, action_id, action, components) +function M:_process_input(action_id, action, components) local is_input_consumed = false for i = #components, 1, -1 do local component = components[i] local meta = component._meta - if meta.input_enabled and can_use_input_component(self, component) then + if meta.input_enabled and self:_can_use_input_component(component) then if not is_input_consumed then is_input_consumed = component:on_input(action_id, action) or false else @@ -356,7 +355,7 @@ function M:on_input(action_id, action) local components = self.components_interest[const.ON_INPUT] check_sort_input_stack(self, components) - local is_input_consumed = process_input(self, action_id, action, components) + local is_input_consumed = self:_process_input(action_id, action, components) self._is_late_remove_enabled = false self:_clear_late_remove() @@ -421,7 +420,7 @@ end ---Set whitelist components for input processing. ---If whitelist is not empty and component not contains in this list, ---component will be not processed on input step ----@param whitelist_components table|druid.base_component[]|nil The array of component to whitelist +---@param whitelist_components table|druid.base_component[] The array of component to whitelist ---@return druid_instance function M:set_whitelist(whitelist_components) if whitelist_components and whitelist_components._component then @@ -441,7 +440,7 @@ end ---Set blacklist components for input processing. ---If blacklist is not empty and component contains in this list, ---component will be not processed on input step DruidInstance ----@param blacklist_components table|druid.base_component[]|nil The array of component to blacklist +---@param blacklist_components table|druid.base_component[] The array of component to blacklist ---@return druid_instance function M:set_blacklist(blacklist_components) if blacklist_components and blacklist_components._component then diff --git a/example/components/example_scene/example_scene.lua b/example/components/example_scene/example_scene.lua index 24ddb50..394ccc1 100644 --- a/example/components/example_scene/example_scene.lua +++ b/example/components/example_scene/example_scene.lua @@ -24,7 +24,7 @@ end ---@param info string function M:set_debug_info(info) - self.text_debug_info:set_to(info) + self.text_debug_info:set_text(info) end @@ -34,7 +34,7 @@ function M:set_gui_path(path) -- We need add "/" before path and replace .lua to .gui path = "/" .. path:gsub(".lua", ".gui") - self.text_gui_path:set_to(path) + self.text_gui_path:set_text(path) end diff --git a/example/components/panel_druid_profiler/panel_druid_profiler.lua b/example/components/panel_druid_profiler/panel_druid_profiler.lua index 47804a4..f300711 100644 --- a/example/components/panel_druid_profiler/panel_druid_profiler.lua +++ b/example/components/panel_druid_profiler/panel_druid_profiler.lua @@ -81,7 +81,7 @@ end function M:update_memory() local memory = collectgarbage("count") - self.text_memory_amount:set_to(tostring(math.ceil(memory))) + self.text_memory_amount:set_text(tostring(math.ceil(memory))) local width = helper.centrate_nodes(2, unpack(self.nodes_memory)) for index = 1, #self.nodes_memory do @@ -102,8 +102,8 @@ function M:update_fps() end average_frame_time = average_frame_time / #self.fps_samples - self.text_fps_amount:set_to(tostring(math.ceil(1 / average_frame_time))) - self.text_fps_min:set_to("/ " .. tostring(math.ceil(1 / max_frame_time))) + self.text_fps_amount:set_text(tostring(math.ceil(1 / average_frame_time))) + self.text_fps_min:set_text("/ " .. tostring(math.ceil(1 / max_frame_time))) local width = helper.centrate_nodes(2, unpack(self.nodes_fps)) self.group_fps:set_size(width, nil) @@ -114,14 +114,14 @@ function M:update_components() ---@diagnostic disable-next-line: undefined-field local components = #self.druid.components_all - self.text_components_amount:set_to(tostring(components)) + self.text_components_amount:set_text(tostring(components)) local width = helper.centrate_nodes(2, unpack(self.nodes_components)) self.group_components:set_size(width, nil) end function M:update_events() - self.text_events_amount:set_to(tostring(event.COUNTER)) + self.text_events_amount:set_text("unsupported") local width = helper.centrate_nodes(2, unpack(self.nodes_events)) for index = 1, #self.nodes_events do diff --git a/example/components/properties_panel/properties/property_slider.lua b/example/components/properties_panel/properties/property_slider.lua index 82fd16b..9784d24 100644 --- a/example/components/properties_panel/properties/property_slider.lua +++ b/example/components/properties_panel/properties/property_slider.lua @@ -33,7 +33,7 @@ end ---@param callback fun(value:number):string function M:set_text_function(callback) self._text_function = callback - self.text_value:set_to(self._text_function(self._value)) + self.text_value:set_text(self._text_function(self._value)) end @@ -45,7 +45,7 @@ function M:set_value(value, is_instant) self._value = value self.slider:set(value, true) - self.text_value:set_to(self._text_function(value)) + self.text_value:set_text(self._text_function(value)) if not is_instant then gui.set_alpha(self.selected, 1) @@ -62,7 +62,7 @@ end function M:_on_slider_change_by_user(value) self._value = value - self.text_value:set_to(self._text_function(value)) + self.text_value:set_text(self._text_function(value)) gui.set_alpha(self.selected, 1) gui.animate(self.selected, "color.w", 0, gui.EASING_INSINE, 0.16) diff --git a/example/examples/data_list/cache_with_component/cache_with_component.lua b/example/examples/data_list/cache_with_component/cache_with_component.lua index ffd8622..1c2a0ac 100644 --- a/example/examples/data_list/cache_with_component/cache_with_component.lua +++ b/example/examples/data_list/cache_with_component/cache_with_component.lua @@ -51,7 +51,7 @@ end ---@param instance button_component ---@param data table function M:on_element_add(index, node, instance, data) - instance.text:set_to("Data Item " .. index) + instance.text:set_text("Data Item " .. index) instance.button.on_click:subscribe(self.on_button_click, self) instance:set_data(index) end diff --git a/example/examples/widgets/hover_hint/hover_hint.lua b/example/examples/widgets/hover_hint/hover_hint.lua index 1578106..2cf4537 100644 --- a/example/examples/widgets/hover_hint/hover_hint.lua +++ b/example/examples/widgets/hover_hint/hover_hint.lua @@ -88,7 +88,7 @@ end ---@private function M:refresh_content(node, hint_text, pivot_point, content_pivot) - self.text_hint:set_to(hint_text) + self.text_hint:set_text(hint_text) local text_width, text_height = self.text_hint:get_text_size() local panel_width = math.max(text_width, MIN_PANEL_WIDTH) + PANEL_MARGIN diff --git a/test/helper/test_helper.lua b/test/helper/test_helper.lua index a728a0d..a451959 100644 --- a/test/helper/test_helper.lua +++ b/test/helper/test_helper.lua @@ -3,8 +3,9 @@ local mock = require("deftest.mock.mock") local M = {} -- Userdata type instead of script self +---@return vector3|vector4 function M.get_context() - return vmath.vector() + return vmath.vector({}) end diff --git a/test/test.gui_script b/test/test.gui_script index 54dcb74..59f6c21 100644 --- a/test/test.gui_script +++ b/test/test.gui_script @@ -17,6 +17,6 @@ function init(self) deftest.add(tests[i]) end - local is_report = (sys.get_config("test.report") == "1") + local is_report = (sys.get_config_int("test.report", 0) == 1) deftest.run({ coverage = { enabled = is_report } }) end diff --git a/update_docs.sh b/update_docs.sh deleted file mode 100755 index e469afb..0000000 --- a/update_docs.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -## I am using Ldoc and my own Ldoc -> emmylua generator: -## https://github.com/Insality/emmylua-from-ldoc-annotations - -emmylua_generator_path=~/code/lua/emmylua-from-ldoc-annotations - -echo "Update Ldoc" -ldoc . --testing - -echo "" -echo "Update EmmyLua annotations" -original_path=$(pwd) -bash $emmylua_generator_path/export.sh $original_path -mv $emmylua_generator_path/annotations.lua $original_path/druid/annotations.lua -cat ./utils/annotations_manual.lua >> $original_path/druid/annotations.lua -cp $original_path/utils/ldoc_fixed.css $original_path/docs/ldoc_fixed.css diff --git a/utils/annotations_manual.lua b/utils/annotations_manual.lua deleted file mode 100644 index ee86713..0000000 --- a/utils/annotations_manual.lua +++ /dev/null @@ -1,126 +0,0 @@ --- Manual Annotations -- - ----@class druid.component: druid.base_component - ----@class druid.rich_text.metrics ----@field width number ----@field height number ----@field offset_x number|nil ----@field offset_y number|nil ----@field max_ascent number ----@field max_descent number ----@field node_size vector3|nil @For images only - ----@class druid.rich_text.lines_metrics ----@field text_width number ----@field text_height number ----@field lines table - ----@class druid.rich_text.word ----@field node node ----@field relative_scale number ----@field color vector4 ----@field position vector3 ----@field offset vector3 ----@field scale vector3 ----@field size vector3 ----@field metrics druid.rich_text.metrics ----@field pivot userdata @ The gui.PIVOT_* constant ----@field text string ----@field shadow vector4 ----@field outline vector4 ----@field font string ----@field image druid.rich_text.image ----@field default_animation string ----@field anchor number ----@field br boolean ----@field nobr boolean ----@field source_text string ----@field image_color vector4 ----@field text_color vector4 - ----@class druid.rich_text.image ----@field texture string ----@field anim string ----@field width number ----@field height number - ----@class druid.rich_text.settings ----@field parent node ----@field size number ----@field fonts table ----@field scale vector3 ----@field color vector4 ----@field shadow vector4 ----@field outline vector4 ----@field position vector3 ----@field image_pixel_grid_snap boolean ----@field combine_words boolean ----@field default_animation string ----@field text_prefab node ----@field adjust_scale number ----@field default_texture string ----@field is_multiline boolean ----@field text_leading number ----@field font hash ----@field width number ----@field height number - ----@class GUITextMetrics ----@field width number ----@field height number ----@field max_ascent number ----@field max_descent number - ----@class utf8 ----@field len fun(s: string):number ----@field sub fun(s: string, start_index: number, length: number) ----@field reverse fun() ----@field char fun() ----@field unicode fun() ----@field gensub fun() ----@field byte fun() ----@field find fun() ----@field match fun(s: string, m: string) ----@field gmatch fun(s: string, m: string) ----@field gsub fun() ----@field dump fun() ----@field format fun() ----@field lower fun() ----@field upper fun() ----@field rep fun() - - ----Add generics to some functions. - ----Create new component. ----@generic T: druid.base_component ----@param self druid_instance ----@param component T Component module ----@param ... any Other component params to pass it to component:init function ----@return T Component instance -function druid_instance.new(self, component, ...) end - ---- Set current component style table. ---- Invoke `on_style_change` on component, if exist. Component should handle their style changing and store all style params ----@generic T: druid.base_component ----@param self T BaseComponent ----@param druid_style table|nil Druid style module ----@return T BaseComponent -function druid__base_component.set_style(self, druid_style) end - ---- Set component template name. ---- 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() ----@generic T: druid.base_component ----@param self T BaseComponent ----@param template string BaseComponent template name ----@return T BaseComponent -function druid__base_component.set_template(self, template) end - ---- Set current component nodes. ---- Use if your component nodes was cloned with `gui.clone_tree` and you got the node tree. ----@generic T: druid.base_component ----@param self T BaseComponent ----@param nodes table BaseComponent nodes table ----@return T BaseComponent -function druid__base_component.set_nodes(self, nodes) end diff --git a/utils/ldoc_fixed.css b/utils/ldoc_fixed.css deleted file mode 100644 index e63d191..0000000 --- a/utils/ldoc_fixed.css +++ /dev/null @@ -1,311 +0,0 @@ -/* BEGIN RESET - -Copyright (c) 2010, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.com/yui/license.html -version: 2.8.2r1 -*/ -html { - color: #000; - background: #FFF; -} -body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td { - margin: 0; - padding: 0; -} -table { - border-collapse: collapse; - border-spacing: 0; -} -fieldset,img { - border: 0; -} -address,caption,cite,code,dfn,em,strong,th,var,optgroup { - font-style: inherit; - font-weight: inherit; -} -del,ins { - text-decoration: none; -} -li { - margin-left: 20px; -} -caption,th { - text-align: left; -} -h1,h2,h3,h4,h5,h6 { - font-size: 100%; - font-weight: bold; -} -q:before,q:after { - content: ''; -} -abbr,acronym { - border: 0; - font-variant: normal; -} -sup { - vertical-align: baseline; -} -sub { - vertical-align: baseline; -} -legend { - color: #000; -} -input,button,textarea,select,optgroup,option { - font-family: inherit; - font-size: inherit; - font-style: inherit; - font-weight: inherit; -} -input,button,textarea,select {*font-size:100%; -} -/* END RESET */ - -body { - margin-left: 1em; - margin-right: 1em; - font-family: arial, helvetica, geneva, sans-serif; - background-color: #ffffff; margin: 0px; -} - -code, tt { font-family: monospace; font-size: 1.1em; } -span.parameter { font-family:monospace; } -span.parameter:after { content:":"; } -span.types:before { content:"("; } -span.types:after { content:")"; } -.type { font-weight: bold; font-style:italic } - -body, p, td, th { font-size: .95em; line-height: 1.2em;} - -p, ul { margin: 10px 0 0 0px;} - -strong { font-weight: bold;} - -em { font-style: italic;} - -h1 { - font-size: 1.5em; - margin: 0 0 20px 0; -} -h2, h3, h4 { margin: 15px 0 10px 0; } -h2 { font-size: 1.25em; } -h3 { font-size: 1.15em; } -h4 { font-size: 1.06em; } - -a:link { font-weight: bold; color: #004080; text-decoration: none; } -a:visited { font-weight: bold; color: #006699; text-decoration: none; } -a:link:hover { text-decoration: underline; } - -hr { - color:#cccccc; - background: #00007f; - height: 1px; -} - -blockquote { margin-left: 3em; } - -ul { list-style-type: disc; } - -p.name { - font-family: "Andale Mono", monospace; - padding-top: 1em; -} - -pre { - background-color: rgb(245, 245, 245); - border: 1px solid #C0C0C0; /* silver */ - padding: 10px; - margin: 10px 0 10px 0; - overflow: auto; - font-family: "Andale Mono", monospace; -} - -pre.example { - font-size: .85em; -} - -table.index { border: 1px #00007f; } -table.index td { text-align: left; vertical-align: top; } - -#container { - margin-left: 1em; - margin-right: 1em; - background-color: #ffffff; -} - -#product { - text-align: center; - border-bottom: 1px solid #cccccc; - background-color: #ffffff; -} - -#product big { - font-size: 2em; -} - -#main { - background-color:#FFFFFF; // #f0f0f0; - border-left: 1px solid #cccccc; -} - -#navigation { - position: fixed; - top: 0; - left: 0; - float: left; - width: 14em; - vertical-align: top; - background-color:#FFFFFF; // #f0f0f0; - border-right: 2px solid #cccccc; - overflow: visible; - overflow-y: scroll; - height: 100%; - padding-left: 1em; -} - -#navigation h2 { - background-color:#FFFFFF;//:#e7e7e7; - font-size:1.1em; - color:#000000; - text-align: left; - padding:0.2em; - border-bottom:1px solid #dddddd; -} - -#navigation ul -{ - font-size:1em; - list-style-type: none; - margin: 1px 1px 10px 1px; -} - -#navigation li { - text-indent: -1em; - display: block; - margin: 3px 0px 0px 22px; -} - -#navigation li li a { - margin: 0px 3px 0px -1em; -} - -#content { - margin-left: 14em; - padding: 1em; - padding-left: 2em; - width: 900px; - border-left: 2px solid #cccccc; - // border-right: 2px solid #cccccc; - background-color: #ffffff; -} - -#about { - clear: both; - padding-left: 1em; - margin-left: 14em; // avoid the damn sidebar! - border-top: 2px solid #cccccc; - border-left: 2px solid #cccccc; - background-color: #ffffff; -} - -@media print { - body { - font: 12pt "Times New Roman", "TimeNR", Times, serif; - } - a { font-weight: bold; color: #004080; text-decoration: underline; } - - #main { - background-color: #ffffff; - border-left: 0px; - } - - #container { - margin-left: 2%; - margin-right: 2%; - background-color: #ffffff; - } - - #content { - padding: 1em; - background-color: #ffffff; - } - - #navigation { - display: none; - } - pre.example { - font-family: "Andale Mono", monospace; - font-size: 10pt; - page-break-inside: avoid; - } -} - -table.module_list { - border-width: 1px; - border-style: solid; - border-color: #cccccc; - border-collapse: collapse; -} -table.module_list td { - border-width: 1px; - padding: 3px; - border-style: solid; - border-color: #cccccc; -} -table.module_list td.name { background-color: #f0f0f0; ; min-width: 200px; } -table.module_list td.summary { width: 100%; } - -table.function_list { - border-width: 1px; - border-style: solid; - border-color: #cccccc; - border-collapse: collapse; -} -table.function_list td { - border-width: 1px; - padding: 3px; - border-style: solid; - border-color: #cccccc; -} -table.function_list td.name { background-color: #f6f6ff; ; min-width: 200px; } -table.function_list td.summary { width: 100%; } - -dl.table dt, dl.function dt {border-top: 1px solid #ccc; padding-top: 1em;} -dl.table dd, dl.function dd {padding-bottom: 1em; margin: 10px 0 0 20px;} -dl.table h3, dl.function h3 {font-size: .95em;} - -ul.nowrap { - overflow:auto; - whitespace:nowrap; -} - -/* stop sublists from having initial vertical space */ -ul ul { margin-top: 0px; } -ol ul { margin-top: 0px; } -ol ol { margin-top: 0px; } -ul ol { margin-top: 0px; } - -/* make the target distinct; helps when we're navigating to a function */ -a:target + * { - background-color: #FF9; -} - - -/* styles for prettification of source */ -pre .comment { color: #558817; } -pre .constant { color: #a8660d; } -pre .escape { color: #844631; } -pre .keyword { color: #aa5050; font-weight: bold; } -pre .library { color: #0e7c6b; } -pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; } -pre .string { color: #8080ff; } -pre .number { color: #f8660d; } -pre .operator { color: #2239a8; font-weight: bold; } -pre .preprocessor, pre .prepro { color: #a33243; } -pre .global { color: #800080; } -pre .user-keyword { color: #800080; } -pre .prompt { color: #558817; } -pre .url { color: #272fc2; text-decoration: underline; } - From ae33b08a6b9a3fd9709ef4985965bb2e6b56f495 Mon Sep 17 00:00:00 2001 From: Insality Date: Tue, 24 Dec 2024 01:23:20 +0200 Subject: [PATCH 41/50] Decrease default drag dead zone to 4 pixels --- druid/styles/default/style.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/druid/styles/default/style.lua b/druid/styles/default/style.lua index 0f74a66..7398c74 100644 --- a/druid/styles/default/style.lua +++ b/druid/styles/default/style.lua @@ -61,7 +61,7 @@ M["hover"] = { } M["drag"] = { - DRAG_DEADZONE = 10, -- Size in pixels of drag deadzone + DRAG_DEADZONE = 4, -- Size in pixels of drag deadzone NO_USE_SCREEN_KOEF = false, } From db0c4c8ee560c97d5e9e4a16d41824e721c011d9 Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 11 Jan 2025 15:32:36 +0100 Subject: [PATCH 42/50] Fix components inner table typo --- druid/system/druid_instance.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index afdecb5..3749c79 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -86,7 +86,7 @@ local function create_widget(self, widget_class) }) local uid = base_component.create_uid() - instance._components = { + instance._component = { _uid = uid, name = "Druid Widget #" .. uid, input_priority = const.PRIORITY_INPUT, From da5c6b9a54967e52b130ae7bb686150c6a728857 Mon Sep 17 00:00:00 2001 From: Insality Date: Wed, 29 Jan 2025 23:13:09 +0200 Subject: [PATCH 43/50] Fix for examples --- README.md | 6 +- druid/editor_scripts/setup_layers.py | 2 +- example/druid.gui | 204 ++++++++++++++++++ .../example_properties_panel.lua | 63 ++++-- .../window_confirmation.gui | 28 ++- .../windows/window_info/window_info.gui | 16 +- .../window_language/window_language.gui | 21 +- .../window_language/window_language.lua | 2 +- example/locales/en.json | 9 + 9 files changed, 319 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index a3c100a..c79373d 100644 --- a/README.md +++ b/README.md @@ -131,8 +131,12 @@ Create a new lua file to create a new widget class. This widget can be created w local M = {} function M:init() - self.druid = self:get_druid() self.root = self:get_node("root") + self.button = self.druid:new_button("button", self.on_click) +end + +function M:on_click() + print("Button clicked!") end return M diff --git a/druid/editor_scripts/setup_layers.py b/druid/editor_scripts/setup_layers.py index dd0d580..4af9cff 100644 --- a/druid/editor_scripts/setup_layers.py +++ b/druid/editor_scripts/setup_layers.py @@ -31,7 +31,7 @@ def main(): texture = node.get_attribute("texture") font = node.get_attribute("font") - if texture: + if texture and texture.value: layer = texture.value.split("/")[0] node.set_attribute("layer", layer) diff --git a/example/druid.gui b/example/druid.gui index 8e1b2ea..3f325af 100644 --- a/example/druid.gui +++ b/example/druid.gui @@ -4495,6 +4495,210 @@ nodes { parent: "example_properties_panel/properties_panel/property_left_right_selector/E_Anchor" template_node_child: true } +nodes { + type: TYPE_TEMPLATE + id: "example_properties_panel/properties_panel/property_vector3" + parent: "example_properties_panel/properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_vector3/root" + parent: "example_properties_panel/properties_panel/property_vector3" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_vector3/text_name" + parent: "example_properties_panel/properties_panel/property_vector3/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_vector3/E_Anchor" + parent: "example_properties_panel/properties_panel/property_vector3/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_vector3/field_x" + parent: "example_properties_panel/properties_panel/property_vector3/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_vector3/text_x" + parent: "example_properties_panel/properties_panel/property_vector3/field_x" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "example_properties_panel/properties_panel/property_vector3/rich_input_x" + parent: "example_properties_panel/properties_panel/property_vector3/field_x" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_vector3/rich_input_x/root" + parent: "example_properties_panel/properties_panel/property_vector3/rich_input_x" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_vector3/rich_input_x/button" + parent: "example_properties_panel/properties_panel/property_vector3/rich_input_x/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_vector3/rich_input_x/placeholder_text" + parent: "example_properties_panel/properties_panel/property_vector3/rich_input_x/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_vector3/rich_input_x/input_text" + parent: "example_properties_panel/properties_panel/property_vector3/rich_input_x/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_vector3/rich_input_x/cursor_node" + parent: "example_properties_panel/properties_panel/property_vector3/rich_input_x/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_vector3/rich_input_x/cursor_text" + parent: "example_properties_panel/properties_panel/property_vector3/rich_input_x/cursor_node" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_vector3/selected_x" + parent: "example_properties_panel/properties_panel/property_vector3/field_x" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_vector3/field_y" + parent: "example_properties_panel/properties_panel/property_vector3/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_vector3/text_y" + parent: "example_properties_panel/properties_panel/property_vector3/field_y" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "example_properties_panel/properties_panel/property_vector3/rich_input_y" + parent: "example_properties_panel/properties_panel/property_vector3/field_y" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_vector3/rich_input_y/root" + parent: "example_properties_panel/properties_panel/property_vector3/rich_input_y" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_vector3/rich_input_y/button" + parent: "example_properties_panel/properties_panel/property_vector3/rich_input_y/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_vector3/rich_input_y/placeholder_text" + parent: "example_properties_panel/properties_panel/property_vector3/rich_input_y/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_vector3/rich_input_y/input_text" + parent: "example_properties_panel/properties_panel/property_vector3/rich_input_y/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_vector3/rich_input_y/cursor_node" + parent: "example_properties_panel/properties_panel/property_vector3/rich_input_y/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_vector3/rich_input_y/cursor_text" + parent: "example_properties_panel/properties_panel/property_vector3/rich_input_y/cursor_node" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_vector3/selected_y" + parent: "example_properties_panel/properties_panel/property_vector3/field_y" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_vector3/field_z" + parent: "example_properties_panel/properties_panel/property_vector3/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_vector3/text_z" + parent: "example_properties_panel/properties_panel/property_vector3/field_z" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "example_properties_panel/properties_panel/property_vector3/rich_input_z" + parent: "example_properties_panel/properties_panel/property_vector3/field_z" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_vector3/rich_input_z/root" + parent: "example_properties_panel/properties_panel/property_vector3/rich_input_z" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_vector3/rich_input_z/button" + parent: "example_properties_panel/properties_panel/property_vector3/rich_input_z/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_vector3/rich_input_z/placeholder_text" + parent: "example_properties_panel/properties_panel/property_vector3/rich_input_z/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_vector3/rich_input_z/input_text" + parent: "example_properties_panel/properties_panel/property_vector3/rich_input_z/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_vector3/rich_input_z/cursor_node" + parent: "example_properties_panel/properties_panel/property_vector3/rich_input_z/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "example_properties_panel/properties_panel/property_vector3/rich_input_z/cursor_text" + parent: "example_properties_panel/properties_panel/property_vector3/rich_input_z/cursor_node" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "example_properties_panel/properties_panel/property_vector3/selected_z" + parent: "example_properties_panel/properties_panel/property_vector3/field_z" + template_node_child: true +} nodes { position { x: -20.0 diff --git a/example/examples/widgets/properties_panel/example_properties_panel.lua b/example/examples/widgets/properties_panel/example_properties_panel.lua index f892909..887950d 100644 --- a/example/examples/widgets/properties_panel/example_properties_panel.lua +++ b/example/examples/widgets/properties_panel/example_properties_panel.lua @@ -7,31 +7,60 @@ local M = {} function M:init() self.properties_panel = self.druid:new_widget(properties_panel, "properties_panel") - self.properties_panel:add_button("Button", function() - print("Button clicked") + self.properties_panel:add_button(function(button) + button:set_text_button("Button") + button.button.on_click:subscribe(function() + print("Button clicked") + end) end) - self.properties_panel:add_checkbox("Checkbox", false, function(value) - print("Checkbox clicked", value) + self.properties_panel:add_checkbox(function(checkbox) + --print("Checkbox clicked", value) + checkbox:set_text_property("Checkbox") + checkbox.on_change_value:subscribe(function(value) + print("Checkbox clicked", value) + end) + checkbox:set_value(false) end) - self.properties_panel:add_input("Input", "Initial", function(value) - print("Input value", value) + self.properties_panel:add_input(function(input) + input:set_text_property("Input") + input:set_text_value("Initial") + input:on_change(function(text) + print("Input changed", text) + end) end) - self.properties_panel:add_left_right_selector("Arrows Number", 0, function(value) - print("Left Right Number value", value) - end):set_number_type(0, 42, true, 1) - - self.properties_panel:add_left_right_selector("Arrows Array", "Zero", function(value) - print("Left Right Array value", value) - end):set_array_type({"Zero", "One", "Two", "Three", "Four", "Five"}, false, 1) - - self.properties_panel:add_slider("Slider", 0.5, function(value) - print("Slider value", value) + self.properties_panel:add_left_right_selector(function(selector) + selector:set_template("Arrows Number") + selector.on_change_value:subscribe(function(value) + print("Left Right Selector changed", value) + end) + selector:set_number_type(0, 42, true, 1) + selector:set_value(0) end) - self.properties_panel:add_text("Text", "Some text") + self.properties_panel:add_left_right_selector(function(selector) + selector:set_template("Arrows Array") + selector.on_change_value:subscribe(function(value) + print("Left Right Array value", value) + end) + selector:set_array_type({"Zero", "One", "Two", "Three", "Four", "Five"}, false, 1) + selector:set_value("Zero") + end) + + self.properties_panel:add_slider(function(slider) + slider:set_text_property("Slider") + slider:set_value(0.5) + slider:on_change(function(value) + print("Slider changed", value) + end) + end) + + self.properties_panel:add_text(function(text) + text:set_text_property("Text") + text:set_text_value("Hello, World!") + end) end diff --git a/example/examples/windows/window_confirmation/window_confirmation.gui b/example/examples/windows/window_confirmation/window_confirmation.gui index 2c11af3..2c60a9e 100644 --- a/example/examples/windows/window_confirmation/window_confirmation.gui +++ b/example/examples/windows/window_confirmation/window_confirmation.gui @@ -8,10 +8,6 @@ textures { texture: "/example/assets/druid_example.atlas" } nodes { - position { - x: 960.0 - y: 540.0 - } size { x: 700.0 y: 500.0 @@ -202,6 +198,18 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } +nodes { + type: TYPE_BOX + id: "button_accept/root" + parent: "button_accept" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "button_accept/text" + parent: "button_accept/root" + template_node_child: true +} nodes { position { x: 160.0 @@ -213,6 +221,18 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_red.gui" } +nodes { + type: TYPE_BOX + id: "button_decline/root" + parent: "button_decline" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "button_decline/text" + parent: "button_decline/root" + template_node_child: true +} layers { name: "druid" } diff --git a/example/examples/windows/window_info/window_info.gui b/example/examples/windows/window_info/window_info.gui index d216457..869dd30 100644 --- a/example/examples/windows/window_info/window_info.gui +++ b/example/examples/windows/window_info/window_info.gui @@ -8,10 +8,6 @@ textures { texture: "/example/assets/druid_example.atlas" } nodes { - position { - x: 960.0 - y: 540.0 - } size { x: 700.0 y: 500.0 @@ -201,6 +197,18 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_green.gui" } +nodes { + type: TYPE_BOX + id: "button_accept/root" + parent: "button_accept" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "button_accept/text" + parent: "button_accept/root" + template_node_child: true +} layers { name: "druid" } diff --git a/example/examples/windows/window_language/window_language.gui b/example/examples/windows/window_language/window_language.gui index c3ba2cd..29c6763 100644 --- a/example/examples/windows/window_language/window_language.gui +++ b/example/examples/windows/window_language/window_language.gui @@ -8,10 +8,6 @@ textures { texture: "/example/assets/druid_example.atlas" } nodes { - position { - x: 960.0 - y: 540.0 - } size { x: 600.0 y: 580.0 @@ -173,6 +169,23 @@ nodes { inherit_alpha: true template: "/example/templates/button_text_white.gui" } +nodes { + size { + x: 245.0 + y: 75.0 + } + type: TYPE_BOX + id: "button/root" + parent: "button" + overridden_fields: 4 + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "button/text" + parent: "button/root" + template_node_child: true +} layers { name: "druid" } diff --git a/example/examples/windows/window_language/window_language.lua b/example/examples/windows/window_language/window_language.lua index f572d64..25c9bf4 100644 --- a/example/examples/windows/window_language/window_language.lua +++ b/example/examples/windows/window_language/window_language.lua @@ -38,7 +38,7 @@ function M:init(template, nodes) self.grid = self.druid:new_grid("content", self.prefab, 2) self.grid.style.IS_DYNAMIC_NODE_POSES = true - self.animation = panthera.create_gui(window_animation_panthera, self:get_template(), nodes) + self.animation = panthera.create_gui(window_animation_panthera, self:get_template(), self:get_nodes()) panthera.play(self.animation, "open") self:load_langs() diff --git a/example/locales/en.json b/example/locales/en.json index c05a651..dcf64ea 100644 --- a/example/locales/en.json +++ b/example/locales/en.json @@ -177,6 +177,15 @@ "ui_example_widget_property_checkbox": "Property Checkbox", "ui_example_widget_property_checkbox_description": "Here is a widget used in Properties panel", + "ui_example_widget_memory_panel": "Memory Panel", + "ui_example_widget_memory_panel_description": "Here is a example of memory panel usage", + + "ui_example_widget_fps_panel": "FPS Panel", + "ui_example_widget_fps_panel_description": "Here is a example of FPS panel usage", + + "ui_example_widget_properties_panel": "Properties Panel", + "ui_example_widget_properties_panel_description": "Here is a example of properties panel usage", + "ui_example_gamepad_tester": "Gamepad Tester", "ui_example_gamepad_tester_description": "Test your gamepad here to bind buttons and axes", From c51a00ad806d5e0b3f813406bbf55903c0ab1eab Mon Sep 17 00:00:00 2001 From: Insality Date: Wed, 29 Jan 2025 23:35:46 +0200 Subject: [PATCH 44/50] Revert "Remove HTML API from this branch" This reverts commit 0972c53c700caf32354463a0734798891aa20635. --- docs/index.html | 186 ++++ docs/ldoc_fixed.css | 311 ++++++ docs/modules/BackHandler.html | 172 ++++ docs/modules/BaseComponent.html | 549 ++++++++++ docs/modules/Blocker.html | 233 +++++ docs/modules/Button.html | 880 ++++++++++++++++ docs/modules/Checkbox.html | 350 +++++++ docs/modules/CheckboxGroup.html | 259 +++++ docs/modules/DataList.html | 712 +++++++++++++ docs/modules/Drag.html | 633 ++++++++++++ docs/modules/Druid.html | 374 +++++++ docs/modules/DruidEvent.html | 399 ++++++++ docs/modules/DruidInstance.html | 1223 +++++++++++++++++++++++ docs/modules/DynamicGrid.html | 788 +++++++++++++++ docs/modules/Helper.html | 927 +++++++++++++++++ docs/modules/Hotkey.html | 373 +++++++ docs/modules/Hover.html | 469 +++++++++ docs/modules/Input.html | 1086 ++++++++++++++++++++ docs/modules/LangText.html | 380 +++++++ docs/modules/Layout.html | 147 +++ docs/modules/PinKnob.html | 299 ++++++ docs/modules/Progress.html | 569 +++++++++++ docs/modules/RadioGroup.html | 259 +++++ docs/modules/RichInput.html | 567 +++++++++++ docs/modules/RichText.html | 560 +++++++++++ docs/modules/Scroll.html | 1183 ++++++++++++++++++++++ docs/modules/Slider.html | 531 ++++++++++ docs/modules/StaticGrid.html | 1094 ++++++++++++++++++++ docs/modules/Swipe.html | 288 ++++++ docs/modules/Text.html | 942 +++++++++++++++++ docs/modules/Timer.html | 409 ++++++++ docs/modules/druid.extended.layout.html | 95 ++ docs/modules/druid.system.utf8.html | 93 ++ 33 files changed, 17340 insertions(+) create mode 100644 docs/index.html create mode 100644 docs/ldoc_fixed.css create mode 100644 docs/modules/BackHandler.html create mode 100644 docs/modules/BaseComponent.html create mode 100644 docs/modules/Blocker.html create mode 100644 docs/modules/Button.html create mode 100644 docs/modules/Checkbox.html create mode 100644 docs/modules/CheckboxGroup.html create mode 100644 docs/modules/DataList.html create mode 100644 docs/modules/Drag.html create mode 100644 docs/modules/Druid.html create mode 100644 docs/modules/DruidEvent.html create mode 100644 docs/modules/DruidInstance.html create mode 100644 docs/modules/DynamicGrid.html create mode 100644 docs/modules/Helper.html create mode 100644 docs/modules/Hotkey.html create mode 100644 docs/modules/Hover.html create mode 100644 docs/modules/Input.html create mode 100644 docs/modules/LangText.html create mode 100644 docs/modules/Layout.html create mode 100644 docs/modules/PinKnob.html create mode 100644 docs/modules/Progress.html create mode 100644 docs/modules/RadioGroup.html create mode 100644 docs/modules/RichInput.html create mode 100644 docs/modules/RichText.html create mode 100644 docs/modules/Scroll.html create mode 100644 docs/modules/Slider.html create mode 100644 docs/modules/StaticGrid.html create mode 100644 docs/modules/Swipe.html create mode 100644 docs/modules/Text.html create mode 100644 docs/modules/Timer.html create mode 100644 docs/modules/druid.extended.layout.html create mode 100644 docs/modules/druid.system.utf8.html diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..192ca28 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,186 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ + +

Documentation for Druid Framework

+ +

Modules

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

## Overview ## +

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

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

The Event module provides a simple class for handling callbacks.

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

# Overview # +

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

LayoutLayout management on node
ProgressDruid component to handle the progress bars.
SliderDruid slider component
SwipeComponent to handle swipe gestures on node.
TimerComponent to handle GUI timers.
HelperHelper module with various usefull GUI functions.
DruidInstanceDruid Instance which you use for component creation.
+ +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/ldoc_fixed.css b/docs/ldoc_fixed.css new file mode 100644 index 0000000..e63d191 --- /dev/null +++ b/docs/ldoc_fixed.css @@ -0,0 +1,311 @@ +/* BEGIN RESET + +Copyright (c) 2010, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.com/yui/license.html +version: 2.8.2r1 +*/ +html { + color: #000; + background: #FFF; +} +body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td { + margin: 0; + padding: 0; +} +table { + border-collapse: collapse; + border-spacing: 0; +} +fieldset,img { + border: 0; +} +address,caption,cite,code,dfn,em,strong,th,var,optgroup { + font-style: inherit; + font-weight: inherit; +} +del,ins { + text-decoration: none; +} +li { + margin-left: 20px; +} +caption,th { + text-align: left; +} +h1,h2,h3,h4,h5,h6 { + font-size: 100%; + font-weight: bold; +} +q:before,q:after { + content: ''; +} +abbr,acronym { + border: 0; + font-variant: normal; +} +sup { + vertical-align: baseline; +} +sub { + vertical-align: baseline; +} +legend { + color: #000; +} +input,button,textarea,select,optgroup,option { + font-family: inherit; + font-size: inherit; + font-style: inherit; + font-weight: inherit; +} +input,button,textarea,select {*font-size:100%; +} +/* END RESET */ + +body { + margin-left: 1em; + margin-right: 1em; + font-family: arial, helvetica, geneva, sans-serif; + background-color: #ffffff; margin: 0px; +} + +code, tt { font-family: monospace; font-size: 1.1em; } +span.parameter { font-family:monospace; } +span.parameter:after { content:":"; } +span.types:before { content:"("; } +span.types:after { content:")"; } +.type { font-weight: bold; font-style:italic } + +body, p, td, th { font-size: .95em; line-height: 1.2em;} + +p, ul { margin: 10px 0 0 0px;} + +strong { font-weight: bold;} + +em { font-style: italic;} + +h1 { + font-size: 1.5em; + margin: 0 0 20px 0; +} +h2, h3, h4 { margin: 15px 0 10px 0; } +h2 { font-size: 1.25em; } +h3 { font-size: 1.15em; } +h4 { font-size: 1.06em; } + +a:link { font-weight: bold; color: #004080; text-decoration: none; } +a:visited { font-weight: bold; color: #006699; text-decoration: none; } +a:link:hover { text-decoration: underline; } + +hr { + color:#cccccc; + background: #00007f; + height: 1px; +} + +blockquote { margin-left: 3em; } + +ul { list-style-type: disc; } + +p.name { + font-family: "Andale Mono", monospace; + padding-top: 1em; +} + +pre { + background-color: rgb(245, 245, 245); + border: 1px solid #C0C0C0; /* silver */ + padding: 10px; + margin: 10px 0 10px 0; + overflow: auto; + font-family: "Andale Mono", monospace; +} + +pre.example { + font-size: .85em; +} + +table.index { border: 1px #00007f; } +table.index td { text-align: left; vertical-align: top; } + +#container { + margin-left: 1em; + margin-right: 1em; + background-color: #ffffff; +} + +#product { + text-align: center; + border-bottom: 1px solid #cccccc; + background-color: #ffffff; +} + +#product big { + font-size: 2em; +} + +#main { + background-color:#FFFFFF; // #f0f0f0; + border-left: 1px solid #cccccc; +} + +#navigation { + position: fixed; + top: 0; + left: 0; + float: left; + width: 14em; + vertical-align: top; + background-color:#FFFFFF; // #f0f0f0; + border-right: 2px solid #cccccc; + overflow: visible; + overflow-y: scroll; + height: 100%; + padding-left: 1em; +} + +#navigation h2 { + background-color:#FFFFFF;//:#e7e7e7; + font-size:1.1em; + color:#000000; + text-align: left; + padding:0.2em; + border-bottom:1px solid #dddddd; +} + +#navigation ul +{ + font-size:1em; + list-style-type: none; + margin: 1px 1px 10px 1px; +} + +#navigation li { + text-indent: -1em; + display: block; + margin: 3px 0px 0px 22px; +} + +#navigation li li a { + margin: 0px 3px 0px -1em; +} + +#content { + margin-left: 14em; + padding: 1em; + padding-left: 2em; + width: 900px; + border-left: 2px solid #cccccc; + // border-right: 2px solid #cccccc; + background-color: #ffffff; +} + +#about { + clear: both; + padding-left: 1em; + margin-left: 14em; // avoid the damn sidebar! + border-top: 2px solid #cccccc; + border-left: 2px solid #cccccc; + background-color: #ffffff; +} + +@media print { + body { + font: 12pt "Times New Roman", "TimeNR", Times, serif; + } + a { font-weight: bold; color: #004080; text-decoration: underline; } + + #main { + background-color: #ffffff; + border-left: 0px; + } + + #container { + margin-left: 2%; + margin-right: 2%; + background-color: #ffffff; + } + + #content { + padding: 1em; + background-color: #ffffff; + } + + #navigation { + display: none; + } + pre.example { + font-family: "Andale Mono", monospace; + font-size: 10pt; + page-break-inside: avoid; + } +} + +table.module_list { + border-width: 1px; + border-style: solid; + border-color: #cccccc; + border-collapse: collapse; +} +table.module_list td { + border-width: 1px; + padding: 3px; + border-style: solid; + border-color: #cccccc; +} +table.module_list td.name { background-color: #f0f0f0; ; min-width: 200px; } +table.module_list td.summary { width: 100%; } + +table.function_list { + border-width: 1px; + border-style: solid; + border-color: #cccccc; + border-collapse: collapse; +} +table.function_list td { + border-width: 1px; + padding: 3px; + border-style: solid; + border-color: #cccccc; +} +table.function_list td.name { background-color: #f6f6ff; ; min-width: 200px; } +table.function_list td.summary { width: 100%; } + +dl.table dt, dl.function dt {border-top: 1px solid #ccc; padding-top: 1em;} +dl.table dd, dl.function dd {padding-bottom: 1em; margin: 10px 0 0 20px;} +dl.table h3, dl.function h3 {font-size: .95em;} + +ul.nowrap { + overflow:auto; + whitespace:nowrap; +} + +/* stop sublists from having initial vertical space */ +ul ul { margin-top: 0px; } +ol ul { margin-top: 0px; } +ol ol { margin-top: 0px; } +ul ol { margin-top: 0px; } + +/* make the target distinct; helps when we're navigating to a function */ +a:target + * { + background-color: #FF9; +} + + +/* styles for prettification of source */ +pre .comment { color: #558817; } +pre .constant { color: #a8660d; } +pre .escape { color: #844631; } +pre .keyword { color: #aa5050; font-weight: bold; } +pre .library { color: #0e7c6b; } +pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; } +pre .string { color: #8080ff; } +pre .number { color: #f8660d; } +pre .operator { color: #2239a8; font-weight: bold; } +pre .preprocessor, pre .prepro { color: #a33243; } +pre .global { color: #800080; } +pre .user-keyword { color: #800080; } +pre .prompt { color: #558817; } +pre .url { color: #272fc2; text-decoration: underline; } + diff --git a/docs/modules/BackHandler.html b/docs/modules/BackHandler.html new file mode 100644 index 0000000..e8f7dc7 --- /dev/null +++ b/docs/modules/BackHandler.html @@ -0,0 +1,172 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module BackHandler

+

Component with event on back and backspace button.

+

+ # Overview # +

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

# Notes # +

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

• Back Handler react on release action ACTION_BACK or ACTION_BACKSPACE

+

Usage:

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

Fields

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

Fields

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

Trigger on input action ACTION_BACK or ACTION_BACKSPACE + + +

+ + + + +

Usage:

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

Usage:

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

Module BaseComponent

+

Basic class for all Druid components.

+

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

+

Usage:

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

Functions

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

Functions

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

Parameters:

+ + +

Returns:

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

Parameters:

+ + +

Returns:

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

Parameters:

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

Returns:

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

Parameters:

+ + +

Returns:

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

Parameters:

+ + +

Returns:

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

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

Parameters:

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

Returns:

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

Parameters:

+ + +

Returns:

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

Parameters:

+ + +

Returns:

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

Parameters:

+ + +

Returns:

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

UID generated in component creation order. + + +

Parameters:

+ + +

Returns:

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

Parameters:

+ + +

Returns:

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

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

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

Module Blocker

+

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

+

+ # Overview # +

# Notes # +

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

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

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

• The Blocker node should be enabled to capture the input

+

Usage:

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

Functions

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

Fields

+ + + + + +
nodeBlocker node
+ +
+
+ + +

Functions

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

Parameters:

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

Parameters:

+ + +

Returns:

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

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

Parameters:

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

Fields

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

Module Button

+

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

+

+

# Overview # +

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

# Notes # +

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

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

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

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

Example Link

+

Usage:

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

Functions

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

Tables

+ + + + + +
styleComponent style params.
+

Fields

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

Functions

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

Parameters:

+
    +
  • self + Button + +
  • +
+ +

Returns:

+
    + + hash + The action_id of the input key +
+ + + +

Usage:

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

Parameters:

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

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

Parameters:

+
    +
  • self + Button + Button +
  • +
+ +

Returns:

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

Usage:

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

Parameters:

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

Returns:

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

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

Parameters:

+ + +

Returns:

+
    + + Button + Current button instance +
+ + + +

Usage:

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

Parameters:

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

Returns:

+
    + + Button + Current button instance +
+ + + +

Usage:

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

Parameters:

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

Returns:

+
    + + Button + Current button instance +
+ + + +

Usage:

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

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

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

Parameters:

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

Returns:

+
    + + Button + Current button instance +
+ + + +

Usage:

+
    +
    button:set_web_user_interaction(true)
    +
+ +
+
+

Tables

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

Fields:

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

Fields

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

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

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

Usage:

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

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

Usecase: Hide the popup when click outside + + +

    +
  • on_click_outside + DruidEvent + DruidEvent +
  • +
+ + + + +

Usage:

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

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

+ + + + +

Usage:

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

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

Usecase: Animate button progress of long tap + + +

    +
  • on_hold_callback + DruidEvent + DruidEvent +
  • +
+ + + + +

Usage:

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

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

+ + + + +

Usage:

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

Usage:

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

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

    +
  • on_repeated_click + DruidEvent + DruidEvent +
  • +
+ + + + +

Usage:

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

Module Checkbox

+

Druid checkbox component

+

Example Link

+ + +

Functions

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

Tables

+ + + + + +
styleComponent style params.
+

Fields

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

Functions

+ +
+
+ + get_state(self) +
+
+ Return checkbox state + + +

Parameters:

+ + +

Returns:

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

Parameters:

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

Parameters:

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

Tables

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

Fields:

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

Fields

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

Module CheckboxGroup

+

Checkbox group module

+

Example Link

+ + +

Functions

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

Fields

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

Functions

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

Parameters:

+ + +

Returns:

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

Parameters:

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

Parameters:

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

Fields

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

Module DataList

+

Component to manage data for huge dataset in scroll.

+

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

Example Link

+ + +

Functions

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

Fields

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

Functions

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

Parameters:

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

Parameters:

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

Parameters:

+ + +

Returns:

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

Parameters:

+ + +

Returns:

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

Parameters:

+ + +

Returns:

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

Parameters:

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

Parameters:

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

Parameters:

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

Parameters:

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

Parameters:

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

Parameters:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

+
    + + druid.data_list + Current DataList instance +
+ + + + +
+
+

Fields

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

Module Drag

+

Component to handle drag action on node.

+

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

Example Link

+ + +

Functions

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

Tables

+ + + + + +
styleComponent style params.
+

Fields

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

Functions

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

Parameters:

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

Parameters:

+
    +
  • self + Drag + Drag +
  • +
+ +

Returns:

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

Parameters:

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

Parameters:

+
    +
  • self + Drag + Drag +
  • +
  • is_enabled + boolean or nil + +
  • +
+ + + + + +
+
+

Tables

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

Fields:

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

Fields

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

Module Druid

+

Druid UI Component Framework.

+

+ # Overview # +

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

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

# Notes # +

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

See next: DruidInstance +

+

Usage:

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

Functions

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

Functions

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

Parameters:

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

Returns:

+
    + + druid_instance + The Druid instance DruidInstance. +
+ + + +

Usage:

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

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

Usage:

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

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

Parameters:

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

Usage:

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

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

Parameters:

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

Usage:

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

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

Parameters:

+
    +
  • style + table + Druid style module +
  • +
+ + + + +

Usage:

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

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

Parameters:

+
    +
  • callback + function + Sound play callback +
  • +
+ + + + +

Usage:

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

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

Parameters:

+
    +
  • callback + function + Get localized text function +
  • +
+ + + + +

Usage:

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

Module DruidEvent

+

Druid Event Module +

The Event module provides a simple class for handling callbacks.

+

It is used in many Druid components. +

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

+ + +

Functions

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

Functions

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

Parameters:

+ + + + + +

Usage:

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

Parameters:

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

Usage:

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

Parameters:

+ + +

Returns:

+
    + + boolean + True if event not have handlers +
+ + + +

Usage:

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

Parameters:

+ + +

Returns:

+
    + + boolean + True if event have handlers +
+ + + +

Usage:

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

Parameters:

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

Returns:

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

Parameters:

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

Returns:

+
    + + boolean + True if callback was subscribed +
+ + + +

Usage:

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

Parameters:

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

Usage:

+
    +
    local Event = require("druid.event")
    +...
    +local event = Event()
    +event:trigger("Param1", "Param2")
    +
+ +
+
+ + unsubscribe(self, callback, callback_context) +
+
+ Unsubscribe callback on event + + +

Parameters:

+
    +
  • self + DruidEvent + DruidEvent +
  • +
  • callback + function + Callback itself +
  • +
  • callback_context + any or nil + Additional context as first param to callback call +
  • +
+ + + + +

Usage:

+
    +
    local function on_long_callback(self)
    +    print("Long click!")
    +end
    +...
    +button.on_long_click:unsubscribe(on_long_callback, self)
    +
+ +
+
+ + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/DruidInstance.html b/docs/modules/DruidInstance.html new file mode 100644 index 0000000..afa2ecb --- /dev/null +++ b/docs/modules/DruidInstance.html @@ -0,0 +1,1223 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module DruidInstance

+

Druid Instance which you use for component creation.

+

+

# Component List # +

For a list of all available components, please refer to the "See Also" section. +

# Notes # +

Please review the following API pages: +

Helper - A useful set of functions for working with GUI nodes, such as centering nodes, get GUI scale ratio, etc +

DruidEvent - The core event system in Druid. Learn how to subscribe to any event in every Druid component. +

BaseComponent - The parent class of all Druid components. You can find all default component methods there. +

# Tech Info # +

• To use Druid, you need to create a Druid instance first. This instance is used to spawn components. +

• When using Druid components, provide the node name as a string argument directly. Avoid calling gui.get_node() before passing it to the component. Because Druid can get nodes from template and cloned gui nodes. +

• All Druid and component methods are called using the colon operator (e.g., self.druid:new_button()).

+

See also:

+ +

Usage:

+
    +
    local druid = require("druid.druid")
    +
    +local function close_window(self)
    +    print("Yeah! You closed the game!")
    +end
    +
    +function init(self)
    +    self.druid = druid.new(self)
    +
    +    -- Call all druid instance function with ":" syntax:
    +    local text = self.druid:new_text("text_header", "Hello Druid!")
    +    local button = self.druid:new_button("button_close", close_window)
    +
    +    -- You not need to save component reference if not need it
    +    self.druid:new_back_handler(close_window)
    +end
    +
    +
+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
final(self)Call this in gui_script final function.
new_back_handler(self, callback, params)Create BackHandler component
new_blocker(self, node)Create Blocker component
new_button(self, node, callback, params, anim_node)Create Button component
new_data_list(self, druid_scroll, druid_grid, create_function)Create DataList component
new_drag(self, node, on_drag_callback)Create Drag component
new_dynamic_grid(self, parent_node)Create DynamicGrid component + Deprecated
new_hotkey(self, keys_array, callback, callback_argument)Create Hotkey component
new_hover(self, node, on_hover_callback, on_mouse_hover_callback)Create Hover component
new_input(self, click_node, text_node, keyboard_type)Create Input component
new_lang_text(self, node, locale_id, adjust_type)Create LangText component
new_layout(self, node, mode)Create Layout component
new_progress(self, node, key, init_value)Create Progress component
new_rich_input(self, template, nodes)Create RichInput component.
new_rich_text(self, text_node, value)Create RichText component.
new_scroll(self, view_node, content_node)Create Scroll component
new_slider(self, pin_node, end_pos, callback)Create Slider component
new_static_grid(self, parent_node, item, in_row)Create StaticGrid component
new_swipe(self, node, on_swipe_callback)Create Swipe component
new_text(self, node, value, no_adjust)Create Text component
new_timer(self, node, seconds_from, seconds_to, callback)Create Timer component
on_input(self, action_id, action)Call this in gui_script on_input function.
on_message(self, message_id, message, sender)Call this in gui_script on_message function.
remove(self, component)Remove created component from Druid instance.
set_blacklist(self, blacklist_components)Set blacklist components for input processing.
set_whitelist(self, whitelist_components)Set whitelist components for input processing.
update(self, dt)Call this in gui_script update function.
+ +
+
+ + +

Functions

+ +
+
+ + final(self) +
+
+ Call this in gui_script final function. + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
+ + + + + +
+
+ + new_back_handler(self, callback, params) +
+
+ Create BackHandler component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • callback + function or nil + @The callback(self, custom_args) to call on back event +
  • +
  • params + any or nil + Callback argument +
  • +
+ +

Returns:

+
    + + BackHandler + BackHandler component +
+ + + + +
+
+ + new_blocker(self, node) +
+
+ Create Blocker component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • node + string or node + The node_id or gui.get_node(node_id) +
  • +
+ +

Returns:

+
    + + Blocker + Blocker component +
+ + + + +
+
+ + new_button(self, node, callback, params, anim_node) +
+
+ Create Button component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • node + string or node + The node_id or gui.get_node(node_id) +
  • +
  • callback + function or nil + Button callback +
  • +
  • params + any or nil + Button callback params +
  • +
  • anim_node + node, string or nil + Button anim node (node, if not provided) +
  • +
+ +

Returns:

+
    + + Button + Button component +
+ + + + +
+
+ + new_data_list(self, druid_scroll, druid_grid, create_function) +
+
+ Create DataList component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • druid_scroll + Scroll + The Scroll instance for Data List component +
  • +
  • druid_grid + StaticGrid + The StaticGrid or DynamicGrid instance for Data List component +
  • +
  • create_function + function + The create function callback(self, data, index, data_list). Function should return (node, [component]) +
  • +
+ +

Returns:

+
    + + DataList + DataList component +
+ + + + +
+
+ + new_drag(self, node, on_drag_callback) +
+
+ Create Drag component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • node + string or node + The node_id or gui.get_node(node_id). Will used as user input node. +
  • +
  • on_drag_callback + function or nil + Callback for on_drag_event(self, dx, dy) +
  • +
+ +

Returns:

+
    + + Drag + Drag component +
+ + + + +
+
+ + new_dynamic_grid(self, parent_node) +
+
+ Create DynamicGrid component + Deprecated + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • parent_node + string or node + The node_id or gui.get_node(node_id). Parent of all Grid items. +
  • +
+ +

Returns:

+
    + + DynamicGrid + DynamicGrid component +
+ + + + +
+
+ + new_hotkey(self, keys_array, callback, callback_argument) +
+
+ Create Hotkey component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • keys_array + string or string[] + Keys for trigger action. Should contains one action key and any amount of modificator keys +
  • +
  • callback + function + The callback function +
  • +
  • callback_argument + any or nil + The argument to pass into the callback function +
  • +
+ +

Returns:

+
    + + Hotkey + Hotkey component +
+ + + + +
+
+ + new_hover(self, node, on_hover_callback, on_mouse_hover_callback) +
+
+ Create Hover component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • node + string or node + The node_id or gui.get_node(node_id) +
  • +
  • on_hover_callback + function or nil + Hover callback +
  • +
  • on_mouse_hover_callback + function or nil + Mouse hover callback +
  • +
+ +

Returns:

+
    + + Hover + Hover component +
+ + + + +
+
+ + new_input(self, click_node, text_node, keyboard_type) +
+
+ Create Input component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • click_node + string or node + Button node to enabled input component +
  • +
  • text_node + string, node or druid.text + Text node what will be changed on user input +
  • +
  • keyboard_type + number or nil + Gui keyboard type for input field +
  • +
+ +

Returns:

+
    + + Input + Input component +
+ + + + +
+
+ + new_lang_text(self, node, locale_id, adjust_type) +
+
+ Create LangText component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • node + string or node + The_node id or gui.get_node(node_id) +
  • +
  • locale_id + string or nil + Default locale id or text from node as default +
  • +
  • adjust_type + string or nil + Adjust type for text node. Default: const.TEXT_ADJUST.DOWNSCALE +
  • +
+ +

Returns:

+
    + + LangText + LangText component +
+ + + + +
+
+ + new_layout(self, node, mode) +
+
+ Create Layout component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • node + string or node + The_node id or gui.get_node(node_id). +
  • +
  • mode + string + The layout mode +
  • +
+ +

Returns:

+
    + + Layout + Layout component +
+ + + + +
+
+ + new_progress(self, node, key, init_value) +
+
+ Create Progress component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • node + string or node + Progress bar fill node or node name +
  • +
  • key + string + Progress bar direction: const.SIDE.X or const.SIDE.Y +
  • +
  • init_value + number or nil + Initial value of progress bar. Default: 1 +
  • +
+ +

Returns:

+
    + + Progress + Progress component +
+ + + + +
+
+ + new_rich_input(self, template, nodes) +
+
+ Create RichInput component. + As a template please check rich_input.gui layout. + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • template + string + The template string name +
  • +
  • nodes + table + Nodes table from gui.clone_tree +
  • +
+ +

Returns:

+
    + + RichInput + RichInput component +
+ + + + +
+
+ + new_rich_text(self, text_node, value) +
+
+ Create RichText component. + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • text_node + string or node + The text node to make Rich Text +
  • +
  • value + string or nil + The initial text value. Default will be gui.get_text(text_node) +
  • +
+ +

Returns:

+
    + + RichText + RichText component +
+ + + + +
+
+ + new_scroll(self, view_node, content_node) +
+
+ Create Scroll component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • view_node + string or node + The node_id or gui.get_node(node_id). Will used as user input node. +
  • +
  • content_node + string or node + The node_id or gui.get_node(node_id). Will used as scrollable node inside view_node. +
  • +
+ +

Returns:

+
    + + Scroll + Scroll component +
+ + + + +
+
+ + new_slider(self, pin_node, end_pos, callback) +
+
+ Create Slider component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • pin_node + string or node + The_node id or gui.get_node(node_id). +
  • +
  • end_pos + vector3 + The end position of slider +
  • +
  • callback + function or nil + On slider change callback +
  • +
+ +

Returns:

+
    + + Slider + Slider component +
+ + + + +
+
+ + new_static_grid(self, parent_node, item, in_row) +
+
+ Create StaticGrid component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • parent_node + string or node + The node_id or gui.get_node(node_id). Parent of all Grid items. +
  • +
  • item + string or node + Item prefab. Required to get grid's item size. Can be adjusted separately. +
  • +
  • in_row + number or nil + How many nodes in row can be placed +
  • +
+ +

Returns:

+
    + + StaticGrid + StaticGrid component +
+ + + + +
+
+ + new_swipe(self, node, on_swipe_callback) +
+
+ Create Swipe component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • node + string or node + The node_id or gui.get_node(node_id). Will used as user input node. +
  • +
  • on_swipe_callback + function or nil + Swipe callback for on_swipe_end event +
  • +
+ +

Returns:

+
    + + Swipe + Swipe component +
+ + + + +
+
+ + new_text(self, node, value, no_adjust) +
+
+ Create Text component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • node + string or node + The node_id or gui.get_node(node_id) +
  • +
  • value + string or nil + Initial text. Default value is node text from GUI scene. +
  • +
  • no_adjust + boolean or nil + If true, text will be not auto-adjust size +
  • +
+ +

Returns:

+
    + + Text + Text component +
+ + + + +
+
+ + new_timer(self, node, seconds_from, seconds_to, callback) +
+
+ Create Timer component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • node + string or node + Gui text node +
  • +
  • seconds_from + number + Start timer value in seconds +
  • +
  • seconds_to + number or nil + End timer value in seconds +
  • +
  • callback + function or nil + Function on timer end +
  • +
+ +

Returns:

+
    + + Timer + Timer component +
+ + + + +
+
+ + on_input(self, action_id, action) +
+
+ Call this in gui_script on_input function. +

Used for almost all components + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • action_id + hash + Action_id from on_input +
  • +
  • action + table + Action from on_input +
  • +
+ +

Returns:

+
    + + boolean + The boolean value is input was consumed +
+ + + + +
+
+ + on_message(self, message_id, message, sender) +
+
+ Call this in gui_script on_message function. +

Used for special actions. See SPECIFIC_UI_MESSAGES table + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • message_id + hash + Message_id from on_message +
  • +
  • message + table + Message from on_message +
  • +
  • sender + url + Sender from on_message +
  • +
+ + + + + +
+
+ + remove(self, component) +
+
+ Remove created component from Druid instance. +

Component `on_remove` function will be invoked, if exist. + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • component + BaseComponent + Component instance +
  • +
+ +

Returns:

+
    + + boolean + True if component was removed +
+ + + + +
+
+ + set_blacklist(self, blacklist_components) +
+
+ Set blacklist components for input processing. +

If blacklist is not empty and component contains in this list, + component will be not processed on input step + + +

Parameters:

+
    +
  • self + DruidInstance + DruidInstance +
  • +
  • blacklist_components + table, BaseComponent or nil + The array of component to blacklist +
  • +
+ +

Returns:

+
    + + self + DruidInstance +
+ + + + +
+
+ + set_whitelist(self, whitelist_components) +
+
+ Set whitelist components for input processing. +

If whitelist is not empty and component not contains in this list, + component will be not processed on input step + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • whitelist_components + table, BaseComponent or nil + The array of component to whitelist +
  • +
+ +

Returns:

+
    + + self + DruidInstance +
+ + + + +
+
+ + update(self, dt) +
+
+ Call this in gui_script update function. +

Used for: scroll, progress, timer components + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • dt + number + Delta time +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/DynamicGrid.html b/docs/modules/DynamicGrid.html new file mode 100644 index 0000000..d6e7af6 --- /dev/null +++ b/docs/modules/DynamicGrid.html @@ -0,0 +1,788 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module DynamicGrid

+

Component to handle placing components in row

+

Example Link

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
_get_side_vector(self, side, is_forward)Return side vector to correct node shifting
add(self, node, index, shift_policy, is_instant)Add new node to the grid
clear(self)Clear grid nodes array.
get_all_pos(self)Return array of all node positions
get_borders(self)Return grid content borders
get_index_by_node(self, node)Return grid index by node
get_offset(self)Return DynamicGrid offset, where DynamicGrid content starts.
get_pos(self, index, node, origin_index)Return pos for grid node index
get_size(self, border)Return grid content size
init(self, parent)The DynamicGrid constructor
remove(self, index, shift_policy, is_instant)Remove the item from the grid.
set_position_function(self, callback)Change set position function for grid nodes.
+

Fields

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
borderThe size of item content
first_indexThe first index of node in grid
last_indexThe last index of node in grid
node_sizeItem size
nodesList of all grid elements.
on_add_itemOn item add callback(self, node, index)
on_change_itemsOn item add or remove callback(self, index)
on_clearOn grid clear callback(self)
on_remove_itemOn item remove callback(self, index)
on_update_positionsOn update item positions callback(self)
parentParent gui node
+ +
+
+ + +

Functions

+ +
+
+ + _get_side_vector(self, side, is_forward) +
+
+ Return side vector to correct node shifting + + +

Parameters:

+
    +
  • self + +
  • +
  • side + +
  • +
  • is_forward + +
  • +
+ + + + + +
+
+ + add(self, node, index, shift_policy, is_instant) +
+
+ Add new node to the grid + + +

Parameters:

+
    +
  • self + DynamicGrid + DynamicGrid +
  • +
  • node + node + Gui node +
  • +
  • index + number or nil + The node position. By default add as last node +
  • +
  • shift_policy + number or nil + How shift nodes, if required. Default: const.SHIFT.RIGHT +
  • +
  • is_instant + boolean or nil + If true, update node positions instantly +
  • +
+ + + + + +
+
+ + clear(self) +
+
+ Clear grid nodes array. GUI nodes will be not deleted! + If you want to delete GUI nodes, use dynamic_grid.nodes array before grid:clear + + +

Parameters:

+ + +

Returns:

+
    + + druid.dynamic_grid + Current grid instance +
+ + + + +
+
+ + get_all_pos(self) +
+
+ Return array of all node positions + + +

Parameters:

+ + +

Returns:

+
    + + vector3[] + All grid node positions +
+ + + + +
+
+ + get_borders(self) +
+
+ Return grid content borders + + +

Parameters:

+ + +

Returns:

+
    + + vector3 + The grid content borders +
+ + + + +
+
+ + get_index_by_node(self, node) +
+
+ Return grid index by node + + +

Parameters:

+
    +
  • self + DynamicGrid + DynamicGrid +
  • +
  • node + node + The gui node in the grid +
  • +
+ +

Returns:

+
    + + number + The node index +
+ + + + +
+
+ + get_offset(self) +
+
+ Return DynamicGrid offset, where DynamicGrid content starts. + + +

Parameters:

+
    +
  • self + DynamicGrid + DynamicGrid The DynamicGrid instance +
  • +
+ +

Returns:

+
    + + vector3 + The DynamicGrid offset +
+ + + + +
+
+ + get_pos(self, index, node, origin_index) +
+
+ Return pos for grid node index + + +

Parameters:

+
    +
  • self + DynamicGrid + DynamicGrid +
  • +
  • index + number + The grid element index +
  • +
  • node + node + The node to be placed +
  • +
  • origin_index + number or nil + Index of nearby node +
  • +
+ +

Returns:

+
    + + vector3 + node position +
+ + + + +
+
+ + get_size(self, border) +
+
+ Return grid content size + + +

Parameters:

+
    +
  • self + DynamicGrid + DynamicGrid +
  • +
  • border + vector3 + +
  • +
+ +

Returns:

+
    + + vector3 + The grid content size +
+ + + + +
+
+ + init(self, parent) +
+
+ The DynamicGrid constructor + + +

Parameters:

+
    +
  • self + DynamicGrid + DynamicGrid +
  • +
  • parent + node + The gui node parent, where items will be placed +
  • +
+ + + + + +
+
+ + remove(self, index, shift_policy, is_instant) +
+
+ Remove the item from the grid. Note that gui node will be not deleted + + +

Parameters:

+
    +
  • self + DynamicGrid + DynamicGrid +
  • +
  • index + number + The grid node index to remove +
  • +
  • shift_policy + number or nil + How shift nodes, if required. Default: const.SHIFT.RIGHT +
  • +
  • is_instant + boolean or nil + If true, update node positions instantly +
  • +
+ +

Returns:

+
    + + node + The deleted gui node from grid +
+ + + + +
+
+ + set_position_function(self, callback) +
+
+ Change set position function for grid nodes. It will call on + update poses on grid elements. Default: gui.set_position + + +

Parameters:

+
    +
  • self + DynamicGrid + DynamicGrid +
  • +
  • callback + function + Function on node set position +
  • +
+ +

Returns:

+
    + + druid.dynamic_grid + Current grid instance +
+ + + + +
+
+

Fields

+ +
+
+ + border +
+
+ The size of item content + + +
    +
  • border + vector4 + +
  • +
+ + + + + +
+
+ + first_index +
+
+ The first index of node in grid + + +
    +
  • first_index + number + +
  • +
+ + + + + +
+
+ + last_index +
+
+ The last index of node in grid + + +
    +
  • last_index + number + +
  • +
+ + + + + +
+
+ + node_size +
+
+ Item size + + +
    +
  • node_size + vector3 + +
  • +
+ + + + + +
+
+ + nodes +
+
+ List of all grid elements. Contains from node, pos, size, pivot + + +
    +
  • nodes + node[] + +
  • +
+ + + + + +
+
+ + on_add_item +
+
+ On item add callback(self, node, index) + + + + + + + + +
+
+ + on_change_items +
+
+ On item add or remove callback(self, index) + + + + + + + + +
+
+ + on_clear +
+
+ On grid clear callback(self) + + + + + + + + +
+
+ + on_remove_item +
+
+ On item remove callback(self, index) + + + + + + + + +
+
+ + on_update_positions +
+
+ On update item positions callback(self) + + +
    +
  • on_update_positions + DruidEvent + DruidEvent +
  • +
+ + + + + +
+
+ + parent +
+
+ Parent gui node + + +
    +
  • parent + node + +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/Helper.html b/docs/modules/Helper.html new file mode 100644 index 0000000..1bc2ed6 --- /dev/null +++ b/docs/modules/Helper.html @@ -0,0 +1,927 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module Helper

+

Helper module with various usefull GUI functions.

+

+

Usage:

+
    +
    local helper = require("druid.helper")
    +helper.centrate_nodes(0, node_1, node_2)
    +
    +
+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
helper.add_array(target, source)Add all elements from source array to the target array
helper.centrate_nodes(margin, ...)Centerate nodes by x position with margin.
helper.clamp(a, min, max)Clamp value between min and max
helper.contains(t, value)Check if value is in array and return index of it
helper.deepcopy(orig_table)Make a copy table with all nested tables
helper.distance(x1, y1, x2, y2)Calculate distance between two points
helper.get_border(node, offset)Distance from node position to his borders
helper.get_closest_stencil_node(node)Return closest non inverted clipping parent node for given node
helper.get_gui_scale()Get current GUI scale for each side
helper.get_pivot_offset(pivot)Get node offset for given GUI pivot.
helper.get_scaled_size(node)Get node size adjusted by scale
helper.get_scene_scale(node, include_passed_node_scale)Get cumulative parent's node scale
helper.get_screen_aspect_koef()Get current screen stretch multiplier for each side
helper.get_text_metrics_from_node(text_node)Get text metric from GUI node.
helper.insert_with_shift(array, any, index, shift_policy)Add value to array with shift policy
helper.is_mobile()Check if device is native mobile (Android or iOS)
helper.is_multitouch_supported()Check if device is mobile and can support multitouch
helper.is_web()Check if device is HTML5
helper.is_web_mobile()Check if device is HTML5 mobile
helper.lerp(a, b, t)Lerp between two values
helper.remove_with_shift(array, index, shift_policy)Remove value from array with shift policy
helper.round(num, num_decimal_places)Round number to specified decimal places
helper.sign(val)Return sign of value (-1, 0, 1)
helper.step(current, target, step)Move value from current to target value with step amount
helper.table_to_string(t)Simple table to one-line string converter
+ +
+
+ + +

Functions

+ +
+
+ + helper.add_array(target, source) +
+
+ Add all elements from source array to the target array + + +

Parameters:

+
    +
  • target + any[] + Array to put elements from source +
  • +
  • source + any[] or nil + The source array to get elements from +
  • +
+ +

Returns:

+
    + + any[] + The target array +
+ + + + +
+
+ + helper.centrate_nodes(margin, ...) +
+
+ Centerate nodes by x position with margin. +

This functions calculate total width of nodes and set position for each node. + The centrate will be around 0 x position. + + +

Parameters:

+
    +
  • margin + number or nil + Offset between nodes +
  • +
  • ... + Gui nodes +
  • +
+ + + + + +
+
+ + helper.clamp(a, min, max) +
+
+ Clamp value between min and max + + +

Parameters:

+
    +
  • a + number + Value +
  • +
  • min + number + Min value +
  • +
  • max + number + Max value +
  • +
+ +

Returns:

+
    + + number + Clamped value +
+ + + + +
+
+ + helper.contains(t, value) +
+
+ Check if value is in array and return index of it + + +

Parameters:

+
    +
  • t + table + Array +
  • +
  • value + Value +
  • +
+ +

Returns:

+
    + + number or nil + Index of value or nil +
+ + + + +
+
+ + helper.deepcopy(orig_table) +
+
+ Make a copy table with all nested tables + + +

Parameters:

+
    +
  • orig_table + table + Original table +
  • +
+ +

Returns:

+
    + + table + Copy of original table +
+ + + + +
+
+ + helper.distance(x1, y1, x2, y2) +
+
+ Calculate distance between two points + + +

Parameters:

+
    +
  • x1 + number + First point x +
  • +
  • y1 + number + First point y +
  • +
  • x2 + number + Second point x +
  • +
  • y2 + number + Second point y +
  • +
+ +

Returns:

+
    + + number + Distance +
+ + + + +
+
+ + helper.get_border(node, offset) +
+
+ Distance from node position to his borders + + +

Parameters:

+
    +
  • node + node + GUI node +
  • +
  • offset + vector3 or nil + Offset from node position. Pass current node position to get non relative border values +
  • +
+ +

Returns:

+
    + + vector4 + Vector4 with border values (left, top, right, down) +
+ + + + +
+
+ + helper.get_closest_stencil_node(node) +
+
+ Return closest non inverted clipping parent node for given node + + +

Parameters:

+
    +
  • node + node + GUI node +
  • +
+ +

Returns:

+
    + + node or nil + The closest stencil node or nil +
+ + + + +
+
+ + helper.get_gui_scale() +
+
+ Get current GUI scale for each side + + + +

Returns:

+
    +
  1. + number + scale_x
  2. +
  3. + number + scale_y
  4. +
+ + + + +
+
+ + helper.get_pivot_offset(pivot) +
+
+ Get node offset for given GUI pivot. +

Offset shown in [-0.5 .. 0.5] range, where -0.5 is left or bottom, 0.5 is right or top. + + +

Parameters:

+
    +
  • pivot + number + The gui.PIVOT_* constant +
  • +
+ +

Returns:

+
    + + vector3 + Vector offset with [-0.5..0.5] values +
+ + + + +
+
+ + helper.get_scaled_size(node) +
+
+ Get node size adjusted by scale + + +

Parameters:

+
    +
  • node + node + GUI node +
  • +
+ +

Returns:

+
    + + vector3 + Scaled size +
+ + + + +
+
+ + helper.get_scene_scale(node, include_passed_node_scale) +
+
+ Get cumulative parent's node scale + + +

Parameters:

+
    +
  • node + node + Gui node +
  • +
  • include_passed_node_scale + boolean or nil + True if add current node scale to result +
  • +
+ +

Returns:

+
    + + vector3 + The scene node scale +
+ + + + +
+
+ + helper.get_screen_aspect_koef() +
+
+ Get current screen stretch multiplier for each side + + + +

Returns:

+
    +
  1. + number + stretch_x
  2. +
  3. + number + stretch_y
  4. +
+ + + + +
+
+ + helper.get_text_metrics_from_node(text_node) +
+
+ Get text metric from GUI node. + + +

Parameters:

+
    +
  • text_node + node + +
  • +
+ +

Returns:

+
    + + GUITextMetrics + +
+ + + +

Usage:

+
    +
    type GUITextMetrics = {
    +  width: number,
    +  height: number,
    +  max_ascent: number,
    +  max_descent: number
    +}
    +
+ +
+
+ + helper.insert_with_shift(array, any, index, shift_policy) +
+
+ Add value to array with shift policy Shift policy can be: left, right, no_shift + + +

Parameters:

+
    +
  • array + table + Array +
  • +
  • any + Item to insert +
  • +
  • index + number or nil + Index to insert. If nil, item will be inserted at the end of array +
  • +
  • shift_policy + number or nil + The druid_const.SHIFT.* constant +
  • +
+ +

Returns:

+
    + + any + Inserted item +
+ + + + +
+
+ + helper.is_mobile() +
+
+ Check if device is native mobile (Android or iOS) + + + +

Returns:

+
    + + boolean + Is mobile +
+ + + + +
+
+ + helper.is_multitouch_supported() +
+
+ Check if device is mobile and can support multitouch + + + +

Returns:

+
    + + boolean + Is multitouch supported +
+ + + + +
+
+ + helper.is_web() +
+
+ Check if device is HTML5 + + + +

Returns:

+
    + + boolean + Is web +
+ + + + +
+
+ + helper.is_web_mobile() +
+
+ Check if device is HTML5 mobile + + + +

Returns:

+
    + + boolean + Is web mobile +
+ + + + +
+
+ + helper.lerp(a, b, t) +
+
+ Lerp between two values + + +

Parameters:

+
    +
  • a + number + First value +
  • +
  • b + number + Second value +
  • +
  • t + number + Lerp amount +
  • +
+ +

Returns:

+
    + + number + Lerped value +
+ + + + +
+
+ + helper.remove_with_shift(array, index, shift_policy) +
+
+ Remove value from array with shift policy Shift policy can be: left, right, no_shift + + +

Parameters:

+
    +
  • array + table + Array +
  • +
  • index + number or nil + Index to remove. If nil, item will be removed from the end of array +
  • +
  • shift_policy + number or nil + The druid_const.SHIFT.* constant +
  • +
+ +

Returns:

+
    + + any + Removed item +
+ + + + +
+
+ + helper.round(num, num_decimal_places) +
+
+ Round number to specified decimal places + + +

Parameters:

+
    +
  • num + number + Number +
  • +
  • num_decimal_places + number or nil + Decimal places +
  • +
+ +

Returns:

+
    + + number + Rounded number +
+ + + + +
+
+ + helper.sign(val) +
+
+ Return sign of value (-1, 0, 1) + + +

Parameters:

+
    +
  • val + number + Value +
  • +
+ +

Returns:

+
    + + number + Sign +
+ + + + +
+
+ + helper.step(current, target, step) +
+
+ Move value from current to target value with step amount + + +

Parameters:

+
    +
  • current + number + Current value +
  • +
  • target + number + Target value +
  • +
  • step + number + Step amount +
  • +
+ +

Returns:

+
    + + number + New value +
+ + + + +
+
+ + helper.table_to_string(t) +
+
+ Simple table to one-line string converter + + +

Parameters:

+ + +

Returns:

+
    + + string + +
+ + + + +
+
+ + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/Hotkey.html b/docs/modules/Hotkey.html new file mode 100644 index 0000000..6237aa5 --- /dev/null +++ b/docs/modules/Hotkey.html @@ -0,0 +1,373 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module Hotkey

+

Druid hotkey component

+

Example Link

+ + +

Functions

+ + + + + + + + + + + + + +
add_hotkey(self, keys, callback_argument)Add hotkey for component callback
init(self, keys, callback, callback_argument)The Hotkey constructor
set_repeat(self, is_enabled_repeated)If true, the callback will be triggered on action.repeated
+

Tables

+ + + + + +
styleComponent style params.
+

Fields

+ + + + + + + + + + + + + + + + + + + + + +
buttonButton component from click_node
click_nodeButton trigger node
nodeVisual node
on_hotkey_pressedOn hotkey released callback(self, argument)
on_hotkey_releasedOn hotkey released callback(self, argument)
+ +
+
+ + +

Functions

+ +
+
+ + add_hotkey(self, keys, callback_argument) +
+
+ Add hotkey for component callback + + +

Parameters:

+
    +
  • self + Hotkey + Hotkey +
  • +
  • keys + string[], hash[], string or hash + that have to be pressed before key pressed to activate +
  • +
  • callback_argument + any or nil + The argument to pass into the callback function +
  • +
+ +

Returns:

+
    + + Hotkey + Current instance +
+ + + + +
+
+ + init(self, keys, callback, callback_argument) +
+
+ The Hotkey constructor + + +

Parameters:

+
    +
  • self + Hotkey + Hotkey +
  • +
  • keys + string[] or string + The keys to be pressed for trigger callback. Should contains one key and any modificator keys +
  • +
  • callback + function + The callback function +
  • +
  • callback_argument + any or nil + The argument to pass into the callback function +
  • +
+ + + + + +
+
+ + set_repeat(self, is_enabled_repeated) +
+
+ If true, the callback will be triggered on action.repeated + + +

Parameters:

+
    +
  • self + Hotkey + Hotkey +
  • +
  • is_enabled_repeated + bool + The flag value +
  • +
+ +

Returns:

+
    + + Hotkey + +
+ + + + +
+
+

Tables

+ +
+
+ + style +
+
+ Component style params. + You can override this component styles params in druid styles table + or create your own style + + +

Fields:

+
    +
  • MODIFICATORS + string[] + The list of action_id as hotkey modificators +
  • +
+ + + + + +
+
+

Fields

+ +
+
+ + button +
+
+ Button component from click_node + + +
    +
  • button + Button + Button +
  • +
+ + + + + +
+
+ + click_node +
+
+ Button trigger node + + +
    +
  • click_node + node or nil + +
  • +
+ + + + + +
+
+ + node +
+
+ Visual node + + +
    +
  • node + node + +
  • +
+ + + + + +
+
+ + on_hotkey_pressed +
+
+ On hotkey released callback(self, argument) + + +
    +
  • on_hotkey_pressed + DruidEvent + DruidEvent +
  • +
+ + + + + +
+
+ + on_hotkey_released +
+
+ On hotkey released callback(self, argument) + + +
    +
  • on_hotkey_released + DruidEvent + DruidEvent +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/Hover.html b/docs/modules/Hover.html new file mode 100644 index 0000000..65c7eed --- /dev/null +++ b/docs/modules/Hover.html @@ -0,0 +1,469 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module Hover

+

Component to handle hover node interaction

+

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
init(self, node, on_hover_callback, on_mouse_hover)The Hover constructor
is_enabled(self)Return current hover enabled state
is_hovered(self)Return current hover state.
is_mouse_hovered(self)Return current hover state.
set_click_zone(self, zone)Strict hover click area.
set_enabled(self, state)Set enable state of hover component.
set_hover(self, state)Set hover state
set_mouse_hover(self, state)Set mouse hover state
+

Tables

+ + + + + +
styleComponent style params.
+

Fields

+ + + + + + + + + + + + + +
nodeHover node
on_hoverOn hover callback(self, state, hover_instance)
on_mouse_hoverOn mouse hover callback(self, state, hover_instance)
+ +
+
+ + +

Functions

+ +
+
+ + init(self, node, on_hover_callback, on_mouse_hover) +
+
+ The Hover constructor + + +

Parameters:

+
    +
  • self + Hover + Hover +
  • +
  • node + node + Gui node +
  • +
  • on_hover_callback + function + Hover callback +
  • +
  • on_mouse_hover + function + On mouse hover callback +
  • +
+ + + + + +
+
+ + is_enabled(self) +
+
+ Return current hover enabled state + + +

Parameters:

+
    +
  • self + Hover + Hover +
  • +
+ +

Returns:

+
    + + boolean + The hover enabled state +
+ + + + +
+
+ + is_hovered(self) +
+
+ Return current hover state. True if touch action was on the node at current time + + +

Parameters:

+
    +
  • self + Hover + Hover +
  • +
+ +

Returns:

+
    + + boolean + The current hovered state +
+ + + + +
+
+ + is_mouse_hovered(self) +
+
+ Return current hover state. True if nil action_id (usually desktop mouse) was on the node at current time + + +

Parameters:

+
    +
  • self + Hover + Hover +
  • +
+ +

Returns:

+
    + + boolean + The current hovered state +
+ + + + +
+
+ + set_click_zone(self, zone) +
+
+ Strict hover click area. Useful for + no click events outside stencil node + + +

Parameters:

+ + + + + + +
+
+ + set_enabled(self, state) +
+
+ Set enable state of hover component. + If hover is not enabled, it will not generate + any hover events + + +

Parameters:

+
    +
  • self + Hover + Hover +
  • +
  • state + boolean or nil + The hover enabled state +
  • +
+ + + + + +
+
+ + set_hover(self, state) +
+
+ Set hover state + + +

Parameters:

+
    +
  • self + Hover + Hover +
  • +
  • state + boolean or nil + The hover state +
  • +
+ + + + + +
+
+ + set_mouse_hover(self, state) +
+
+ Set mouse hover state + + +

Parameters:

+
    +
  • self + Hover + Hover +
  • +
  • state + boolean or nil + The mouse hover state +
  • +
+ + + + + +
+
+

Tables

+ +
+
+ + style +
+
+ Component style params. + You can override this component styles params in druid styles table + or create your own style + + +

Fields:

+
    +
  • ON_HOVER_CURSOR + string + Mouse hover style on node hover + (optional) +
  • +
  • ON_MOUSE_HOVER_CURSOR + string + Mouse hover style on node mouse hover + (optional) +
  • +
+ + + + + +
+
+

Fields

+ +
+
+ + node +
+
+ Hover node + + +
    +
  • node + node + +
  • +
+ + + + + +
+
+ + on_hover +
+
+ On hover callback(self, state, hover_instance) + + + + + + + + +
+
+ + on_mouse_hover +
+
+ On mouse hover callback(self, state, hover_instance) + + + + + + + + +
+
+ + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/Input.html b/docs/modules/Input.html new file mode 100644 index 0000000..ee1a9e4 --- /dev/null +++ b/docs/modules/Input.html @@ -0,0 +1,1086 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module Input

+

Druid input text component.

+

+ Carry on user text input +

Example Link

+

Info:

+
    +
  • Author: Part of code from Britzl gooey input component
  • +
+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
get_text(self)Return current input field text
get_text_selected_replaced(self, text)Replace selected text with new text
init(self, click_node, text_node, keyboard_type)The Input constructor
move_selection(self, delta, is_add_to_selection, is_move_to_end)Change cursor position by delta
reset_changes(self)Reset current input selection and return previous value
select(self)Select input field.
select_cursor(self, cursor_index, start_index, end_index)Set cursor position in input field
set_allowed_characters(self, characters)Set allowed charaters for input field.
set_max_length(self, max_length)Set maximum length for input field.
set_text(self, input_text)Set text for input field
unselect(self)Remove selection from input.
+

Tables

+ + + + + +
styleComponent style params.
+

Fields

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
allowerd_charactersPattern matching for user input
buttonButton component
current_valueCurrent input value with marked text
cursor_indexThe cursor index.
end_indexTheselection end index.
is_emptyIs current input is empty now
is_selectedIs current input selected now
keyboard_typeGui keyboard type for input field
marked_text_widthMarked text width
marked_valueMarked text for input field.
max_lengthMax length for input text
on_input_emptyOn input field text change to empty string callback(self, input_text)
on_input_fullOn input field text change to max length string callback(self, input_text)
on_input_selectOn input field select callback(self, input_instance)
on_input_textOn input field text change callback(self, input_text)
on_input_unselectOn input field unselect callback(self, input_text, input_instance)
on_input_wrongOn trying user input with not allowed character callback(self, params, input_text)
on_select_cursor_changeOn cursor position change callback(self, cursor_index, start_index, end_index)
previous_valuePrevious input value
start_indexThe selection start index.
textText component
text_widthText width
valueCurrent input value
+ +
+
+ + +

Functions

+ +
+
+ + get_text(self) +
+
+ Return current input field text + + +

Parameters:

+
    +
  • self + Input + Input +
  • +
+ +

Returns:

+
    + + string + The current input field text +
+ + + + +
+
+ + get_text_selected_replaced(self, text) +
+
+ Replace selected text with new text + + +

Parameters:

+
    +
  • self + Input + Input +
  • +
  • text + string + The text to replace selected text +
  • +
+ +

Returns:

+
    + + string + New input text +
+ + + + +
+
+ + init(self, click_node, text_node, keyboard_type) +
+
+ The Input constructor + + +

Parameters:

+
    +
  • self + Input + Input +
  • +
  • click_node + node + Node to enabled input component +
  • +
  • text_node + node or Text + Text node what will be changed on user input. You can pass text component instead of text node name Text +
  • +
  • keyboard_type + number or nil + Gui keyboard type for input field +
  • +
+ + + + + +
+
+ + move_selection(self, delta, is_add_to_selection, is_move_to_end) +
+
+ Change cursor position by delta + + +

Parameters:

+
    +
  • self + Input + Input +
  • +
  • delta + number + side for cursor position, -1 for left, 1 for right +
  • +
  • is_add_to_selection + boolean + (Shift key) +
  • +
  • is_move_to_end + boolean + (Ctrl key) +
  • +
+ + + + + +
+
+ + reset_changes(self) +
+
+ Reset current input selection and return previous value + + +

Parameters:

+
    +
  • self + Input + Input +
  • +
+ +

Returns:

+
    + + druid.input + Current input instance +
+ + + + +
+
+ + select(self) +
+
+ Select input field. It will show the keyboard and trigger on_select events + + +

Parameters:

+
    +
  • self + Input + Input +
  • +
+ + + + + +
+
+ + select_cursor(self, cursor_index, start_index, end_index) +
+
+ Set cursor position in input field + + +

Parameters:

+
    +
  • self + Input + Input +
  • +
  • cursor_index + number or nil + Cursor index for cursor position, if nil - will be set to the end of the text +
  • +
  • start_index + number or nil + Start index for cursor position, if nil - will be set to the end of the text +
  • +
  • end_index + number or nil + End index for cursor position, if nil - will be set to the start_index +
  • +
+ +

Returns:

+
    + + druid.input + Current input instance +
+ + + + +
+
+ + set_allowed_characters(self, characters) +
+
+ Set allowed charaters for input field. + See: https://defold.com/ref/stable/string/ + ex: [%a%d] for alpha and numeric + + +

Parameters:

+
    +
  • self + Input + Input +
  • +
  • characters + string + Regulax exp. for validate user input +
  • +
+ +

Returns:

+
    + + druid.input + Current input instance +
+ + + + +
+
+ + set_max_length(self, max_length) +
+
+ Set maximum length for input field. + Pass nil to make input field unliminted (by default) + + +

Parameters:

+
    +
  • self + Input + Input +
  • +
  • max_length + number + Maximum length for input text field +
  • +
+ +

Returns:

+
    + + druid.input + Current input instance +
+ + + + +
+
+ + set_text(self, input_text) +
+
+ Set text for input field + + +

Parameters:

+
    +
  • self + Input + Input +
  • +
  • input_text + string + The string to apply for input field +
  • +
+ + + + + +
+
+ + unselect(self) +
+
+ Remove selection from input. It will hide the keyboard and trigger on_unselect events + + +

Parameters:

+
    +
  • self + Input + Input +
  • +
+ + + + + +
+
+

Tables

+ +
+
+ + style +
+
+ Component style params. + You can override this component styles params in druid styles table + or create your own style + + +

Fields:

+
    +
  • IS_LONGTAP_ERASE + boolean + Is long tap will erase current input data. Default: false +
  • +
  • MASK_DEFAULT_CHAR + string + Default character mask for password input. Default: *] +
  • +
  • IS_UNSELECT_ON_RESELECT + boolean + If true, call unselect on select selected input. Default: false +
  • +
  • on_select + function + (self, button_node) Callback on input field selecting +
  • +
  • on_unselect + function + (self, button_node) Callback on input field unselecting +
  • +
  • on_input_wrong + function + (self, button_node) Callback on wrong user input +
  • +
+ + + + + +
+
+

Fields

+ +
+
+ + allowerd_characters +
+
+ Pattern matching for user input + + +
    +
  • allowerd_characters + string or nil + +
  • +
+ + + + + +
+
+ + button +
+
+ Button component + + +
    +
  • button + Button + Button +
  • +
+ + + + + +
+
+ + current_value +
+
+ Current input value with marked text + + +
    +
  • current_value + string + +
  • +
+ + + + + +
+
+ + cursor_index +
+
+ The cursor index. The index of letter cursor after. Leftmost cursor - 0 + + +
    +
  • cursor_index + number + +
  • +
+ + + + + +
+
+ + end_index +
+
+ Theselection end index. The index of letter cursor before. Rightmost selection - #text + + +
    +
  • end_index + number + +
  • +
+ + + + + +
+
+ + is_empty +
+
+ Is current input is empty now + + +
    +
  • is_empty + boolean + +
  • +
+ + + + + +
+
+ + is_selected +
+
+ Is current input selected now + + +
    +
  • is_selected + boolean + +
  • +
+ + + + + +
+
+ + keyboard_type +
+
+ Gui keyboard type for input field + + +
    +
  • keyboard_type + number + +
  • +
+ + + + + +
+
+ + marked_text_width +
+
+ Marked text width + + +
    +
  • marked_text_width + number + +
  • +
+ + + + + +
+
+ + marked_value +
+
+ Marked text for input field. Info: https://defold.com/manuals/input-key-and-text/#marked-text + + +
    +
  • marked_value + string + +
  • +
+ + + + + +
+
+ + max_length +
+
+ Max length for input text + + +
    +
  • max_length + number or nil + +
  • +
+ + + + + +
+
+ + on_input_empty +
+
+ On input field text change to empty string callback(self, input_text) + + + + + + + + +
+
+ + on_input_full +
+
+ On input field text change to max length string callback(self, input_text) + + + + + + + + +
+
+ + on_input_select +
+
+ On input field select callback(self, input_instance) + + + + + + + + +
+
+ + on_input_text +
+
+ On input field text change callback(self, input_text) + + + + + + + + +
+
+ + on_input_unselect +
+
+ On input field unselect callback(self, input_text, input_instance) + + +
    +
  • on_input_unselect + DruidEvent + DruidEvent +
  • +
+ + + + + +
+
+ + on_input_wrong +
+
+ On trying user input with not allowed character callback(self, params, input_text) + + + + + + + + +
+
+ + on_select_cursor_change +
+
+ On cursor position change callback(self, cursor_index, start_index, end_index) + + +
    +
  • on_select_cursor_change + DruidEvent + DruidEvent +
  • +
+ + + + + +
+
+ + previous_value +
+
+ Previous input value + + +
    +
  • previous_value + string + +
  • +
+ + + + + +
+
+ + start_index +
+
+ The selection start index. The index of letter cursor after. Leftmost selection - 0 + + +
    +
  • start_index + number + +
  • +
+ + + + + +
+
+ + text +
+
+ Text component + + +
    +
  • text + Text + Text +
  • +
+ + + + + +
+
+ + text_width +
+
+ Text width + + +
    +
  • text_width + number + +
  • +
+ + + + + +
+
+ + value +
+
+ Current input value + + + + + + + + +
+
+ + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/LangText.html b/docs/modules/LangText.html new file mode 100644 index 0000000..be1a8b1 --- /dev/null +++ b/docs/modules/LangText.html @@ -0,0 +1,380 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module LangText

+

Component to wrap over GUI Text nodes with localization helpers +

# Overview # +

• The initialization of druid.set_text_function is required to enable localization + using the localization ID.

+

+

• The LangText component supports up to 7 string format parameters. + This limitation exists due to certain issues with using ... arguments. +

# Notes # +

Example Link

+ + +

Functions

+ + + + + + + + + + + + + + + + + +
format(self, a, b, c, d, e, f, g)Format string with new text params on localized text
init(self, node, locale_id, adjust_type)The LangText constructor
set_to(self, text)Setup raw text to lang_text component
translate(self, locale_id, a, b, c, d, e, f, g)Translate the text by locale_id
+

Fields

+ + + + + + + + + + + + + +
nodeText node
on_changeOn change text callback
textThe text component
+ +
+
+ + +

Functions

+ +
+
+ + format(self, a, b, c, d, e, f, g) +
+
+ Format string with new text params on localized text + + +

Parameters:

+
    +
  • self + LangText + LangText +
  • +
  • a + string or nil + Optional param to string.format +
  • +
  • b + string or nil + Optional param to string.format +
  • +
  • c + string or nil + Optional param to string.format +
  • +
  • d + string or nil + Optional param to string.format +
  • +
  • e + string or nil + Optional param to string.format +
  • +
  • f + string or nil + Optional param to string.format +
  • +
  • g + string or nil + Optional param to string.format +
  • +
+ +

Returns:

+
    + + LangText + Current instance +
+ + + + +
+
+ + init(self, node, locale_id, adjust_type) +
+
+ The LangText constructor + + +

Parameters:

+
    +
  • self + LangText + LangText +
  • +
  • node + string or node + The node_id or gui.get_node(node_id) +
  • +
  • locale_id + string or nil + Default locale id or text from node as default +
  • +
  • adjust_type + string or nil + Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference +
  • +
+ + + + + +
+
+ + set_to(self, text) +
+
+ Setup raw text to lang_text component + + +

Parameters:

+
    +
  • self + LangText + LangText +
  • +
  • text + string + Text for text node +
  • +
+ +

Returns:

+
    + + LangText + Current instance +
+ + + + +
+
+ + translate(self, locale_id, a, b, c, d, e, f, g) +
+
+ Translate the text by locale_id + + +

Parameters:

+
    +
  • self + LangText + LangText +
  • +
  • locale_id + string + Locale id +
  • +
  • a + string or nil + Optional param to string.format +
  • +
  • b + string or nil + Optional param to string.format +
  • +
  • c + string or nil + Optional param to string.format +
  • +
  • d + string or nil + Optional param to string.format +
  • +
  • e + string or nil + Optional param to string.format +
  • +
  • f + string or nil + Optional param to string.format +
  • +
  • g + string or nil + Optional param to string.format +
  • +
+ +

Returns:

+
    + + LangText + Current instance +
+ + + + +
+
+

Fields

+ +
+
+ + node +
+
+ Text node + + +
    +
  • node + node + +
  • +
+ + + + + +
+
+ + on_change +
+
+ On change text callback + + + + + + + + +
+
+ + text +
+
+ The text component + + +
    +
  • text + Text + Text +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/Layout.html b/docs/modules/Layout.html new file mode 100644 index 0000000..0058f48 --- /dev/null +++ b/docs/modules/Layout.html @@ -0,0 +1,147 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module Layout

+

Layout management on node

+

Example Link

+ + +

Fields

+ + + + + + + + + +
modeCurrent layout mode
nodeLayout node
+ +
+
+ + +

Fields

+ +
+
+ + mode +
+
+ Current layout mode + + + + + + + + +
+
+ + node +
+
+ Layout node + + +
    +
  • node + node + +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/PinKnob.html b/docs/modules/PinKnob.html new file mode 100644 index 0000000..d97d64e --- /dev/null +++ b/docs/modules/PinKnob.html @@ -0,0 +1,299 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module PinKnob

+

Druid pin knob custom component.

+

+ It's simple rotating input element

+ + +

Functions

+ + + + + + + + + + + + + +
init(self, callback, template, nodes)The PinKnob constructor
set_angle(self, cur_value, min, max)Set current and min/max angles for component
set_friction(self, value)Set current and min/max angles for component
+

Fields

+ + + + + + + + + + + + + +
druidThe component druid instance
is_dragIs currently under user control
nodeThe pin node
+ +
+
+ + +

Functions

+ +
+
+ + init(self, callback, template, nodes) +
+
+ The PinKnob constructor + + +

Parameters:

+
    +
  • self + PinKnob + PinKnob +
  • +
  • callback + function + Callback(self, value) on value changed +
  • +
  • template + string + The template string name +
  • +
  • nodes + table + Nodes table from gui.clone_tree +
  • +
+ + + + + +
+
+ + set_angle(self, cur_value, min, max) +
+
+ Set current and min/max angles for component + + +

Parameters:

+
    +
  • self + PinKnob + PinKnob +
  • +
  • cur_value + number + The new value for pin knob +
  • +
  • min + number + The minimum value for pin knob +
  • +
  • max + number + The maximum value for pin knob +
  • +
+ +

Returns:

+
    + + PinKnob + PinKnob +
+ + + + +
+
+ + set_friction(self, value) +
+
+ Set current and min/max angles for component + + +

Parameters:

+
    +
  • self + PinKnob + PinKnob +
  • +
  • value + number or nil + The spin speed multiplier. Default: 1 +
  • +
+ +

Returns:

+
    + + PinKnob + PinKnob +
+ + + + +
+
+

Fields

+ +
+
+ + druid +
+
+ The component druid instance + + + + + + + + +
+
+ + is_drag +
+
+ Is currently under user control + + +
    +
  • is_drag + boolean + +
  • +
+ + + + + +
+
+ + node +
+
+ The pin node + + +
    +
  • node + node + +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/Progress.html b/docs/modules/Progress.html new file mode 100644 index 0000000..d9fa818 --- /dev/null +++ b/docs/modules/Progress.html @@ -0,0 +1,569 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module Progress

+

Druid component to handle the progress bars.

+

+ # Overview # +

# Notes # +

• Progress Node should be fully filled in your GUI scene node. It will be the progress maximum size +

• Progress correct working with Slice9 nodes, it trying to set size by _set_size_ first, if it is not possible, it set up sizing via _set_scale_ +

• Progress bar can fill only by vertical or horizontal size. If you want make diagonal progress bar, just rotate node in GUI scene +

• If you have glitchy or dark texture bug with progress bar, try to disable mipmaps in your texture profiles +

+ Example Link

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
empty(self)Empty a progress bar
fill(self)Fill a progress bar and stop progress animation
get(self)Return current progress bar value
init(self, node, key, init_value)The Progress constructor
set_max_size(self, max_size)Set progress bar max node size
set_steps(self, steps, callback)Set points on progress bar to fire the callback
set_to(self, to)Instant fill progress bar to value
to(self, to, callback)Start animation of a progress bar
+

Tables

+ + + + + +
styleComponent style params.
+

Fields

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
keyThe progress bar direction.
max_sizeMaximum size of progress bar
nodeProgress bar fill node
on_changeOn progress bar change callback(self, new_value)
scaleCurrent progress bar scale
sizeCurrent progress bar size
sliceProgress bar slice9 settings
+ +
+
+ + +

Functions

+ +
+
+ + empty(self) +
+
+ Empty a progress bar + + +

Parameters:

+ + + + + + +
+
+ + fill(self) +
+
+ Fill a progress bar and stop progress animation + + +

Parameters:

+ + + + + + +
+
+ + get(self) +
+
+ Return current progress bar value + + +

Parameters:

+ + + + + + +
+
+ + init(self, node, key, init_value) +
+
+ The Progress constructor + + +

Parameters:

+
    +
  • self + Progress + Progress +
  • +
  • node + string or node + Node name or GUI Node itself. +
  • +
  • key + string + Progress bar direction: const.SIDE.X or const.SIDE.Y +
  • +
  • init_value + number or nil + Initial value of progress bar. Default: 1 +
  • +
+ + + + + +
+
+ + set_max_size(self, max_size) +
+
+ Set progress bar max node size + + +

Parameters:

+
    +
  • self + Progress + Progress +
  • +
  • max_size + vector3 + The new node maximum (full) size +
  • +
+ +

Returns:

+
    + + Progress + Progress +
+ + + + +
+
+ + set_steps(self, steps, callback) +
+
+ Set points on progress bar to fire the callback + + +

Parameters:

+
    +
  • self + Progress + Progress +
  • +
  • steps + number[] + Array of progress bar values +
  • +
  • callback + function + Callback on intersect step value +
  • +
+ + + + +

Usage:

+
    +
    progress:set_steps({0, 0.3, 0.6, 1}, function(self, step) end)
    +
+ +
+
+ + set_to(self, to) +
+
+ Instant fill progress bar to value + + +

Parameters:

+
    +
  • self + Progress + Progress +
  • +
  • to + number + Progress bar value, from 0 to 1 +
  • +
+ + + + + +
+
+ + to(self, to, callback) +
+
+ Start animation of a progress bar + + +

Parameters:

+
    +
  • self + Progress + Progress +
  • +
  • to + number + value between 0..1 +
  • +
  • callback + function or nil + Callback on animation ends +
  • +
+ + + + + +
+
+

Tables

+ +
+
+ + style +
+
+ Component style params. + You can override this component styles params in druid styles table + or create your own style + + +

Fields:

+
    +
  • SPEED + number or nil + Progress bas fill rate. More -> faster. Default: 5 +
  • +
  • MIN_DELTA + number or nil + Minimum step to fill progress bar. Default: 0.005 +
  • +
+ + + + + +
+
+

Fields

+ +
+
+ + key +
+
+ The progress bar direction. +

The values are: "x" or "y". (const.SIDE.X or const.SIDE.Y) + + +

+ + + + + +
+
+ + max_size +
+
+ Maximum size of progress bar + + +
    +
  • max_size + number + +
  • +
+ + + + + +
+
+ + node +
+
+ Progress bar fill node + + +
    +
  • node + node + +
  • +
+ + + + + +
+
+ + on_change +
+
+ On progress bar change callback(self, new_value) + + + + + + + + +
+
+ + scale +
+
+ Current progress bar scale + + +
    +
  • scale + vector3 + +
  • +
+ + + + + +
+
+ + size +
+
+ Current progress bar size + + +
    +
  • size + vector3 + +
  • +
+ + + + + +
+
+ + slice +
+
+ Progress bar slice9 settings + + +
    +
  • slice + vector4 + +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/RadioGroup.html b/docs/modules/RadioGroup.html new file mode 100644 index 0000000..41f2b10 --- /dev/null +++ b/docs/modules/RadioGroup.html @@ -0,0 +1,259 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module RadioGroup

+

Radio group module

+

Example Link

+ + +

Functions

+ + + + + + + + + + + + + +
get_state(self)Return radio group state
init(self, nodes, callback, click_nodes)The RadioGroup constructor
set_state(self, index, is_instant)Set radio group state
+

Fields

+ + + + + + + + + +
checkboxesArray of checkbox components
on_radio_clickOn any checkbox click
+ +
+
+ + +

Functions

+ +
+
+ + get_state(self) +
+
+ Return radio group state + + +

Parameters:

+ + +

Returns:

+
    + + number + Index in radio group +
+ + + + +
+
+ + init(self, nodes, callback, click_nodes) +
+
+ The RadioGroup constructor + + +

Parameters:

+
    +
  • self + RadioGroup + RadioGroup +
  • +
  • nodes + node[] + Array of gui node +
  • +
  • callback + function + Radio callback +
  • +
  • click_nodes + node[] or nil + Array of trigger nodes, by default equals to nodes. Default - nodes +
  • +
+ + + + + +
+
+ + set_state(self, index, is_instant) +
+
+ Set radio group state + + +

Parameters:

+
    +
  • self + RadioGroup + RadioGroup +
  • +
  • index + number + Index in radio group +
  • +
  • is_instant + boolean or nil + If is instant state change +
  • +
+ + + + + +
+
+

Fields

+ +
+
+ + checkboxes +
+
+ Array of checkbox components + + +
    +
  • checkboxes + Checkbox[] + +
  • +
+ + + + + +
+
+ + on_radio_click +
+
+ On any checkbox click + + + + + + + + +
+
+ + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/RichInput.html b/docs/modules/RichInput.html new file mode 100644 index 0000000..6c5cdf8 --- /dev/null +++ b/docs/modules/RichInput.html @@ -0,0 +1,567 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module RichInput

+

Druid Rich Input custom component.

+

+ It's wrapper on Input component with cursor and placeholder text

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
get_text(self)Set input field text
init(self, template, nodes)The RichInput constructor
select(self)Select input field
set_allowed_characters(self, characters)Set allowed charaters for input field.
set_font(self, font)Set input field font
set_placeholder(self, placeholder_text)Set placeholder text
set_text(self, text)Set input field text
+

Fields

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
cursorOn input field text change to empty string callback(self, input_text)
cursor_positionOn input field text change to empty string callback(self, input_text)
cursor_textOn input field text change to empty string callback(self, input_text)
dragOn input field text change to empty string callback(self, input_text)
druidThe component druid instance
inputOn input field text change callback(self, input_text)
input_textOn input field text change to empty string callback(self, input_text)
placeholderOn input field text change to empty string callback(self, input_text)
rootRoot node
text_positionOn input field text change to empty string callback(self, input_text)
+ +
+
+ + +

Functions

+ +
+
+ + get_text(self) +
+
+ Set input field text + + +

Parameters:

+ + + + + + +
+
+ + init(self, template, nodes) +
+
+ The RichInput constructor + + +

Parameters:

+
    +
  • self + RichInput + RichInput +
  • +
  • template + string + The template string name +
  • +
  • nodes + table + Nodes table from gui.clone_tree +
  • +
+ + + + + +
+
+ + select(self) +
+
+ Select input field + + +

Parameters:

+ + + + + + +
+
+ + set_allowed_characters(self, characters) +
+
+ Set allowed charaters for input field. + See: https://defold.com/ref/stable/string/ + ex: [%a%d] for alpha and numeric + + +

Parameters:

+
    +
  • self + RichInput + RichInput +
  • +
  • characters + string + Regulax exp. for validate user input +
  • +
+ +

Returns:

+
    + + RichInput + Current instance +
+ + + + +
+
+ + set_font(self, font) +
+
+ Set input field font + + +

Parameters:

+
    +
  • self + RichInput + RichInput +
  • +
  • font + hash + The font hash +
  • +
+ +

Returns:

+
    + + druid.input + Current input instance +
+ + + + +
+
+ + set_placeholder(self, placeholder_text) +
+
+ Set placeholder text + + +

Parameters:

+
    +
  • self + RichInput + RichInput +
  • +
  • placeholder_text + string + The placeholder text +
  • +
+ + + + + +
+
+ + set_text(self, text) +
+
+ Set input field text + + +

Parameters:

+ + +

Returns:

+
    + + druid.input + Current input instance +
+ + + + +
+
+

Fields

+ +
+
+ + cursor +
+
+ On input field text change to empty string callback(self, input_text) + + +
    +
  • cursor + node + +
  • +
+ + + + + +
+
+ + cursor_position +
+
+ On input field text change to empty string callback(self, input_text) + + +
    +
  • cursor_position + vector3 + +
  • +
+ + + + + +
+
+ + cursor_text +
+
+ On input field text change to empty string callback(self, input_text) + + +
    +
  • cursor_text + node + +
  • +
+ + + + + +
+
+ + drag +
+
+ On input field text change to empty string callback(self, input_text) + + +
    +
  • drag + druid.drag + +
  • +
+ + + + + +
+
+ + druid +
+
+ The component druid instance + + + + + + + + +
+
+ + input +
+
+ On input field text change callback(self, input_text) + + +
    +
  • input + Input + Input +
  • +
+ + + + + +
+
+ + input_text +
+
+ On input field text change to empty string callback(self, input_text) + + +
    +
  • input_text + druid.text + +
  • +
+ + + + + +
+
+ + placeholder +
+
+ On input field text change to empty string callback(self, input_text) + + +
    +
  • placeholder + druid.text + +
  • +
+ + + + + +
+
+ + root +
+
+ Root node + + +
    +
  • root + node + +
  • +
+ + + + + +
+
+ + text_position +
+
+ On input field text change to empty string callback(self, input_text) + + +
    +
  • text_position + vector3 + +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/RichText.html b/docs/modules/RichText.html new file mode 100644 index 0000000..075846c --- /dev/null +++ b/docs/modules/RichText.html @@ -0,0 +1,560 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module RichText

+

Druid Rich Text Custom Component.

+

+ # Overview # +

This custom component is inspired by defold-richtext by britzl. + It uses a similar syntax for tags but currently supports fewer tags. +

Create Rich Text on your GUI Text Node. All properties of the text node will be used as default for the text. +

# Notes # +

• Nested tags are supported +

Example Link

+

Usage:

+
    +
  • local RichText = require("druid.custom.rich_text.rich_text")
    +...
    +self.rich_text = self.druid:new(RichText, "rich_text")
    +self.rich_text:set_text("Hello, Druid Rich Text!")
    +
  • +
  • type druid.rich_text.word = {
    +  node: Node,
    +  relative_scale: number,
    +  color: vector4,
    +  position: vector3,
    +  offset: vector3,
    +  scale: vector3,
    +  size: vector3,
    +  metrics: druid.rich_text.metrics,
    +  pivot: Pivot,
    +  text: string,
    +  shadow: vector4,
    +  outline: vector4,
    +  font: string,
    +  image: druid.rich_text.image,
    +  br: boolean,
    +  nobr: boolean,
    +}
    +
    +type druid.rich_text.word.image = {
    +  texture: string,
    +  anim: string,
    +  width: number,
    +  height: number,
    +}
    +
    +type druid.rich_text.lines_metrics = {
    +  text_width: number,
    +  text_height: number,
    +  lines: table<number, druid.rich_text.metrics>,
    +}
    +
    +type druid.rich_text.metrics = {
    +  width: number,
    +  height: number,
    +  offset_x: number|nil,
    +  offset_y: number|nil,
    +  node_size: vector3|nil @For images only,
    +}
    +
  • +
+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
characters(self, word)Split a word into it's characters
clear()Clear all created words.
get_line_metric()Get current line metrics
get_text(self)Get current text
get_words()Get all current words.
init(self, text_node, value)The RichText constructor
set_text(self, text)Set text for Rich Text
tagged(self, tag)Get all words, which has a passed tag.
+

Tables

+ + + + + +
styleComponent style params.
+

Fields

+ + + + + + + + + + + + + +
druidThe component druid instance
rootThe root node of the Rich Text
text_prefabThe text prefab node
+ +
+
+ + +

Functions

+ +
+
+ + characters(self, word) +
+
+ Split a word into it's characters + + +

Parameters:

+
    +
  • self + RichText + RichText +
  • +
  • word + druid.rich_text.word + +
  • +
+ +

Returns:

+
    + + druid.rich_text.word[] + characters +
+ + + + +
+
+ + clear() +
+
+ Clear all created words. + + + + + + + +
+
+ + get_line_metric() +
+
+ Get current line metrics + + + +

Returns:

+
    + + druid.rich_text.lines_metrics + +
+ + + + +
+
+ + get_text(self) +
+
+ Get current text + + +

Parameters:

+ + +

Returns:

+
    + + string + text +
+ + + + +
+
+ + get_words() +
+
+ Get all current words. + + + +

Returns:

+
    + + table + druid.rich_text.word[] +
+ + + + +
+
+ + init(self, text_node, value) +
+
+ The RichText constructor + + +

Parameters:

+
    +
  • self + RichText + RichText +
  • +
  • text_node + node or string + The text node to make Rich Text +
  • +
  • value + string or nil + The initial text value. Default will be gui.get_text(text_node) +
  • +
+ + + + + +
+
+ + set_text(self, text) +
+
+ Set text for Rich Text + + +

Parameters:

+
    +
  • self + RichText + RichText +
  • +
  • text + string or nil + The text to set +
  • +
+ +

Returns:

+
    +
  1. + druid.rich_text.word[] + words
  2. +
  3. + druid.rich_text.lines_metrics + line_metrics
  4. +
+ + + +

Usage:

+
    +
    • color: Change text color
    +
    +<color=red>Foobar</color>
    +<color=1.0,0,0,1.0>Foobar</color>
    +<color=#ff0000>Foobar</color>
    +<color=#ff0000ff>Foobar</color>
    +
    +• shadow: Change text shadow
    +
    +<shadow=red>Foobar</shadow>
    +<shadow=1.0,0,0,1.0>Foobar</shadow>
    +<shadow=#ff0000>Foobar</shadow>
    +<shadow=#ff0000ff>Foobar</shadow>
    +
    +• outline: Change text shadow
    +
    +<outline=red>Foobar</outline>
    +<outline=1.0,0,0,1.0>Foobar</outline>
    +<outline=#ff0000>Foobar</outline>
    +<outline=#ff0000ff>Foobar</outline>
    +
    +• font: Change font
    +
    +<font=MyCoolFont>Foobar</font>
    +
    +• size: Change text size, relative to default size
    +
    +<size=2>Twice as large</size>
    +
    +• br: Insert a line break
    +
    +<br/>
    +
    +• nobr: Prevent the text from breaking
    +
    +Words <nobr>inside tag</nobr> won't break
    +
    +• img: Display image
    +
    +<img=texture:image/>
    +<img=texture:image,size/>
    +<img=texture:image,width,height/>
    +
+ +
+
+ + tagged(self, tag) +
+
+ Get all words, which has a passed tag. + + +

Parameters:

+ + +

Returns:

+
    + + druid.rich_text.word[] + words +
+ + + + +
+
+

Tables

+ +
+
+ + style +
+
+ Component style params. + You can override this component styles params in Druid styles table + or create your own style + + +

Fields:

+
    +
  • COLORS + table or nil + Rich Text color aliases. Default: {} +
  • +
  • ADJUST_STEPS + number or nil + Amount steps of attemps text adjust by height. Default: 20 +
  • +
  • ADJUST_SCALE_DELTA + number or nil + Scale step on each height adjust step. Default: 0.02 +
  • +
+ + + + + +
+
+

Fields

+ +
+
+ + druid +
+
+ The component druid instance + + + + + + + + +
+
+ + root +
+
+ The root node of the Rich Text + + +
    +
  • root + node + +
  • +
+ + + + + +
+
+ + text_prefab +
+
+ The text prefab node + + +
    +
  • text_prefab + node + +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/Scroll.html b/docs/modules/Scroll.html new file mode 100644 index 0000000..457f77c --- /dev/null +++ b/docs/modules/Scroll.html @@ -0,0 +1,1183 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module Scroll

+

Component to handle scroll content.

+

+ # Overview # +

The Scroll component is designed to handle scrollable content and consists of two nodes: the scroll parent and the scroll input. +

The scroll input represents the user input zone and remains static. +

The scroll parent is the movable part of the scroll and changes its position. +

The initial scroll size can be set by adjusting the size of the scroll parent. + If the size of the scroll parent is smaller than the scroll input size, scrolling is not available. +

# Notes # +

• By default, the scroll style includes inertia and extra size for a stretching effect. + These settings can be adjusted using the scroll style settings. + For more details, refer to the scroll style settings. +

• "Points of interest" can be set up for the scroll. + The scroll will always be centered on the closest point of interest. + This feature allows creating a slider without inertia and with points of interest on each scroll element. +

• The scroll content size can be adjusted using the scroll:set_size(node_size) method. + This method sets a new size for the _content node. +

• Inertial scrolling mode can be enabled or disabled using the scroll:set_inert(state) method. +

• The extra stretch size can be adjusted using the scroll:set_extra_stretch_size method. +

• Multitouch is required for scrolling. The scroll component correctly handles + touch ID swaps while dragging the scroll. +

Example Link

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
bind_grid(self, grid)Bind the grid component (Static or Dynamic) to recalculate + scroll size on grid changes
get_percent(self)Return current scroll progress status.
get_scroll_size(self)Return vector of scroll size with width and height.
init(self, view_node, content_node)The Scroll constructor
is_inert(self)Return if scroll have inertion.
is_node_in_view(self, node)Check node if it visible now on scroll.
scroll_to(self, point, is_instant)Start scroll to target point.
scroll_to_index(self, index, skip_cb)Scroll to item in scroll by point index.
scroll_to_percent(self, percent, is_instant)Start scroll to target scroll percent
set_click_zone(self, node)Strict drag scroll area.
set_extra_stretch_size(self, stretch_size)Set extra size for scroll stretching.
set_horizontal_scroll(self, state)Lock or unlock horizontal scroll
set_inert(self, state)Enable or disable scroll inert.
set_points(self, points)Set points of interest.
set_size(self, size, offset)Set scroll content size.
set_vertical_scroll(self, state)Lock or unlock vertical scroll
set_view_size(self, size)Set new scroll view size in case the node size was changed.
update_view_size(self)Refresh scroll view size
+

Tables

+ + + + + +
styleComponent style params.
+

Fields

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
_is_inertFlag, if scroll now moving by inertion
available_posAvailable position for content node: (min_x, max_y, max_x, min_y)
available_sizeSize of available positions: (width, height, 0)
content_nodeScroll content node
dragDrag Druid component
inertionCurrent inert speed
is_animateFlag, if scroll now animating by gui.animate
on_point_scrollOn scroll_to_index function callback(self, index, point)
on_scrollOn scroll move callback(self, position)
on_scroll_toOn scroll_to function callback(self, target, is_instant)
positionCurrent scroll posisition
selectedCurrent index of points of interests
target_positionCurrent scroll target position
view_nodeScroll view node
view_sizeScroll view size
+ +
+
+ + +

Functions

+ +
+
+ + bind_grid(self, grid) +
+
+ Bind the grid component (Static or Dynamic) to recalculate + scroll size on grid changes + + +

Parameters:

+
    +
  • self + Scroll + Scroll +
  • +
  • grid + StaticGrid + Druid grid component +
  • +
+ +

Returns:

+
    + + druid.scroll + Current scroll instance +
+ + + + +
+
+ + get_percent(self) +
+
+ Return current scroll progress status. + Values will be in [0..1] interval + + +

Parameters:

+
    +
  • self + Scroll + Scroll +
  • +
+ +

Returns:

+
    + + vector3 + New vector with scroll progress values +
+ + + + +
+
+ + get_scroll_size(self) +
+
+ Return vector of scroll size with width and height. + + +

Parameters:

+
    +
  • self + Scroll + Scroll +
  • +
+ +

Returns:

+
    + + vector3 + Available scroll size +
+ + + + +
+
+ + init(self, view_node, content_node) +
+
+ The Scroll constructor + + +

Parameters:

+
    +
  • self + Scroll + Scroll +
  • +
  • view_node + string or node + GUI view scroll node +
  • +
  • content_node + string or node + GUI content scroll node +
  • +
+ + + + + +
+
+ + is_inert(self) +
+
+ Return if scroll have inertion. + + +

Parameters:

+
    +
  • self + Scroll + Scroll +
  • +
+ +

Returns:

+
    + + boolean + @If scroll have inertion +
+ + + + +
+
+ + is_node_in_view(self, node) +
+
+ Check node if it visible now on scroll. + Extra border is not affected. Return true for elements in extra scroll zone + + +

Parameters:

+
    +
  • self + Scroll + Scroll +
  • +
  • node + node + The node to check +
  • +
+ +

Returns:

+
    + + boolean + True if node in visible scroll area +
+ + + + +
+
+ + scroll_to(self, point, is_instant) +
+
+ Start scroll to target point. + + +

Parameters:

+
    +
  • self + Scroll + Scroll +
  • +
  • point + vector3 + Target point +
  • +
  • is_instant + boolean or nil + Instant scroll flag +
  • +
+ + + + +

Usage:

+
    +
  • scroll:scroll_to(vmath.vector3(0, 50, 0))
  • +
  • scroll:scroll_to(vmath.vector3(0), true)
  • +
+ +
+
+ + scroll_to_index(self, index, skip_cb) +
+
+ Scroll to item in scroll by point index. + + +

Parameters:

+
    +
  • self + Scroll + Scroll +
  • +
  • index + number + Point index +
  • +
  • skip_cb + boolean or nil + If true, skip the point callback +
  • +
+ + + + + +
+
+ + scroll_to_percent(self, percent, is_instant) +
+
+ Start scroll to target scroll percent + + +

Parameters:

+
    +
  • self + Scroll + Scroll +
  • +
  • percent + vector3 + target percent +
  • +
  • is_instant + boolean or nil + instant scroll flag +
  • +
+ + + + +

Usage:

+
    +
    scroll:scroll_to_percent(vmath.vector3(0.5, 0, 0))
    +
+ +
+
+ + set_click_zone(self, node) +
+
+ Strict drag scroll area. Useful for + restrict events outside stencil node + + +

Parameters:

+
    +
  • self + Drag + +
  • +
  • node + node or string + Gui node +
  • +
+ + + + + +
+
+ + set_extra_stretch_size(self, stretch_size) +
+
+ Set extra size for scroll stretching. + Set 0 to disable stretching effect + + +

Parameters:

+
    +
  • self + Scroll + Scroll +
  • +
  • stretch_size + number or nil + Size in pixels of additional scroll area +
  • +
+ +

Returns:

+
    + + druid.scroll + Current scroll instance +
+ + + + +
+
+ + set_horizontal_scroll(self, state) +
+
+ Lock or unlock horizontal scroll + + +

Parameters:

+
    +
  • self + Scroll + Scroll +
  • +
  • state + boolean or nil + True, if horizontal scroll is enabled +
  • +
+ +

Returns:

+
    + + druid.scroll + Current scroll instance +
+ + + + +
+
+ + set_inert(self, state) +
+
+ Enable or disable scroll inert. + If disabled, scroll through points (if exist) + If no points, just simple drag without inertion + + +

Parameters:

+
    +
  • self + Scroll + Scroll +
  • +
  • state + boolean or nil + Inert scroll state +
  • +
+ +

Returns:

+
    + + druid.scroll + Current scroll instance +
+ + + + +
+
+ + set_points(self, points) +
+
+ Set points of interest. + Scroll will always centered on closer points + + +

Parameters:

+
    +
  • self + Scroll + Scroll +
  • +
  • points + table + Array of vector3 points +
  • +
+ +

Returns:

+
    + + druid.scroll + Current scroll instance +
+ + + + +
+
+ + set_size(self, size, offset) +
+
+ Set scroll content size. + It will change content gui node size + + +

Parameters:

+
    +
  • self + Scroll + Scroll +
  • +
  • size + vector3 + The new size for content node +
  • +
  • offset + vector3 or nil + Offset value to set, where content is starts +
  • +
+ +

Returns:

+
    + + druid.scroll + Current scroll instance +
+ + + + +
+
+ + set_vertical_scroll(self, state) +
+
+ Lock or unlock vertical scroll + + +

Parameters:

+
    +
  • self + Scroll + Scroll +
  • +
  • state + boolean or nil + True, if vertical scroll is enabled +
  • +
+ +

Returns:

+
    + + druid.scroll + Current scroll instance +
+ + + + +
+
+ + set_view_size(self, size) +
+
+ Set new scroll view size in case the node size was changed. + + +

Parameters:

+
    +
  • self + Scroll + Scroll +
  • +
  • size + vector3 + The new size for view node +
  • +
+ +

Returns:

+
    + + druid.scroll + Current scroll instance +
+ + + + +
+
+ + update_view_size(self) +
+
+ Refresh scroll view size + + +

Parameters:

+
    +
  • self + Scroll + Scroll +
  • +
+ + + + + +
+
+

Tables

+ +
+
+ + style +
+
+ Component style params. + You can override this component styles params in druid styles table + or create your own style + + +

Fields:

+
    +
  • FRICT + number or nil + Multiplier for free inertion. Default: 0 +
  • +
  • FRICT_HOLD + number or nil + Multiplier for inertion, while touching. Default: 0 +
  • +
  • INERT_THRESHOLD + number or nil + Scroll speed to stop inertion. Default: 3 +
  • +
  • INERT_SPEED + number or nil + Multiplier for inertion speed. Default: 30 +
  • +
  • POINTS_DEADZONE + number or nil + Speed to check points of interests in no_inertion mode. Default: 20 +
  • +
  • BACK_SPEED + number or nil + Scroll back returning lerp speed. Default: 35 +
  • +
  • ANIM_SPEED + number or nil + Scroll gui.animation speed for scroll_to function. Default: 2 +
  • +
  • EXTRA_STRETCH_SIZE + number or nil + extra size in pixels outside of scroll (stretch effect). Default: 0 +
  • +
  • SMALL_CONTENT_SCROLL + boolean or nil + If true, content node with size less than view node size can be scrolled. Default: false +
  • +
  • WHEEL_SCROLL_SPEED + boolean or nil + The scroll speed via mouse wheel scroll or touchpad. Set to 0 to disable wheel scrolling. Default: 0 +
  • +
  • WHEEL_SCROLL_INVERTED + boolean or nil + If true, invert direction for touchpad and mouse wheel scroll. Default: false +
  • +
  • WHEEL_SCROLL_BY_INERTION + boolean or nil + If true, wheel will add inertion to scroll. Direct set position otherwise.. Default: false +
  • +
+ + + + + +
+
+

Fields

+ +
+
+ + _is_inert +
+
+ Flag, if scroll now moving by inertion + + +
    +
  • _is_inert + boolean + +
  • +
+ + + + + +
+
+ + available_pos +
+
+ Available position for content node: (min_x, max_y, max_x, min_y) + + +
    +
  • available_pos + vector4 + +
  • +
+ + + + + +
+
+ + available_size +
+
+ Size of available positions: (width, height, 0) + + +
    +
  • available_size + vector3 + +
  • +
+ + + + + +
+
+ + content_node +
+
+ Scroll content node + + +
    +
  • content_node + node + +
  • +
+ + + + + +
+
+ + drag +
+
+ Drag Druid component + + +
    +
  • drag + Drag + Drag +
  • +
+ + + + + +
+
+ + inertion +
+
+ Current inert speed + + +
    +
  • inertion + vector3 + +
  • +
+ + + + + +
+
+ + is_animate +
+
+ Flag, if scroll now animating by gui.animate + + +
    +
  • is_animate + boolean + +
  • +
+ + + + + +
+
+ + on_point_scroll +
+
+ On scroll_to_index function callback(self, index, point) + + + + + + + + +
+
+ + on_scroll +
+
+ On scroll move callback(self, position) + + + + + + + + +
+
+ + on_scroll_to +
+
+ On scroll_to function callback(self, target, is_instant) + + + + + + + + +
+
+ + position +
+
+ Current scroll posisition + + +
    +
  • position + vector3 + +
  • +
+ + + + + +
+
+ + selected +
+
+ Current index of points of interests + + +
    +
  • selected + number or nil + +
  • +
+ + + + + +
+
+ + target_position +
+
+ Current scroll target position + + +
    +
  • target_position + vector3 + +
  • +
+ + + + + +
+
+ + view_node +
+
+ Scroll view node + + +
    +
  • view_node + node + +
  • +
+ + + + + +
+
+ + view_size +
+
+ Scroll view size + + +
    +
  • view_size + vector3 + +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/Slider.html b/docs/modules/Slider.html new file mode 100644 index 0000000..45ce723 --- /dev/null +++ b/docs/modules/Slider.html @@ -0,0 +1,531 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module Slider

+

Druid slider component

+

Example Link

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + +
init(self, node, end_pos, callback)The Slider constructor
is_enabled(self)Check if Slider component is enabled
set(self, value, is_silent)Set value for slider
set_enabled(self, is_enabled)Set Slider input enabled or disabled
set_input_node(self, input_node)Set input zone for slider.
set_steps(self, steps)Set slider steps.
+

Fields

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
distLength between start and end position
end_posEnd pin node position
is_dragCurrent drag state
nodeSlider pin node
on_change_valueOn change value callback(self, value)
posCurrent pin node position
start_posStart pin node position
target_posTarger pin node position
valueCurrent slider value
+ +
+
+ + +

Functions

+ +
+
+ + init(self, node, end_pos, callback) +
+
+ The Slider constructor + + +

Parameters:

+
    +
  • self + Slider + Slider +
  • +
  • node + node + Gui pin node +
  • +
  • end_pos + vector3 + The end position of slider +
  • +
  • callback + function or nil + On slider change callback +
  • +
+ + + + + +
+
+ + is_enabled(self) +
+
+ Check if Slider component is enabled + + +

Parameters:

+
    +
  • self + Slider + Slider +
  • +
+ +

Returns:

+
    + + boolean + +
+ + + + +
+
+ + set(self, value, is_silent) +
+
+ Set value for slider + + +

Parameters:

+
    +
  • self + Slider + Slider +
  • +
  • value + number + Value from 0 to 1 +
  • +
  • is_silent + boolean or nil + Don't trigger event if true +
  • +
+ + + + + +
+
+ + set_enabled(self, is_enabled) +
+
+ Set Slider input enabled or disabled + + +

Parameters:

+
    +
  • self + Slider + Slider +
  • +
  • is_enabled + boolean + +
  • +
+ + + + + +
+
+ + set_input_node(self, input_node) +
+
+ Set input zone for slider. + User can touch any place of node, pin instantly will + move at this position and node drag will start. + This function require the Defold version 1.3.0+ + + +

Parameters:

+ + +

Returns:

+
    + + Slider + Slider +
+ + + + +
+
+ + set_steps(self, steps) +
+
+ Set slider steps. Pin node will + apply closest step position + + +

Parameters:

+
    +
  • self + Slider + Slider +
  • +
  • steps + number[] + Array of steps +
  • +
+ +

Returns:

+
    + + Slider + Slider +
+ + + +

Usage:

+
    +
    slider:set_steps({0, 0.2, 0.6, 1})
    +
+ +
+
+

Fields

+ +
+
+ + dist +
+
+ Length between start and end position + + +
    +
  • dist + vector3 + +
  • +
+ + + + + +
+
+ + end_pos +
+
+ End pin node position + + +
    +
  • end_pos + vector3 + +
  • +
+ + + + + +
+
+ + is_drag +
+
+ Current drag state + + +
    +
  • is_drag + boolean + +
  • +
+ + + + + +
+
+ + node +
+
+ Slider pin node + + +
    +
  • node + node + +
  • +
+ + + + + +
+
+ + on_change_value +
+
+ On change value callback(self, value) + + + + + + + + +
+
+ + pos +
+
+ Current pin node position + + +
    +
  • pos + vector3 + +
  • +
+ + + + + +
+
+ + start_pos +
+
+ Start pin node position + + +
    +
  • start_pos + vector3 + +
  • +
+ + + + + +
+
+ + target_pos +
+
+ Targer pin node position + + +
    +
  • target_pos + vector3 + +
  • +
+ + + + + +
+
+ + value +
+
+ Current slider value + + +
    +
  • value + number + +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/StaticGrid.html b/docs/modules/StaticGrid.html new file mode 100644 index 0000000..5281ef5 --- /dev/null +++ b/docs/modules/StaticGrid.html @@ -0,0 +1,1094 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module StaticGrid

+

Component to handle component's position by row and columns.

+

+ # Overview # +

The Static Grid component allows for positioning components in rows and columns. + It provides a static grid layout with constant node sizes, allowing for pre-calculated + node positions and the option to include gaps between nodes. +

# Notes # +

• In a static grid, the node size remains constant, enabling the calculation of node + positions before placement. If you want add gaps between nodes, increase the root prefab size, + including the padding and margin. +

• The static grid can automatically shift elements when nodes are added or removed. +

• When a node is added, the grid will set the node's parent to the specified parent_node. +

• You can obtain an array of positions for each element, which can be used to set + points of interest in a scroll component. +

• The size of all elements can be retrieved for setting up the size in a scroll component. +

• The grid can be bound to a scroll component for automatic resizing of the scroll content size. +

• The pivot of the parent_node affects the node placement within the grid. +

• A prefab node is used to determine the node size and anchor. +

• You can specify a position_function for animations using the + _static_grid:set_position_function(node, pos) callback. The default position function is gui.set_position(). +

Example Link

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
add(self, item, index, shift_policy, is_instant)Add new item to the grid
clear(self)Clear grid nodes array.
get_all_pos(self)Return array of all node positions
get_borders(self)Return grid content borders
get_index(self, pos)Return index for grid pos
get_index_by_node(self, node)Return grid index by node
get_offset(self)Return StaticGrid offset, where StaticGrid content starts.
get_pos(self, index)Return pos for grid node index
get_size(self)Return grid content size
init(self, parent, element, in_row)The StaticGrid constructor
refresh(self)Update grid content
remove(self, index, shift_policy, is_instant)Remove the item from the grid.
set_anchor(self, anchor)Set grid anchor.
set_in_row(self, in_row)Set new in_row elements for grid
set_item_size(self[, width[, height]])Set new node size for grid
set_items(self, nodes[, is_instant=false])Set new items to the grid.
set_position_function(self, callback)Change set position function for grid nodes.
sort_nodes(self, comparator)Sort grid nodes by custom comparator function
+

Tables

+ + + + + +
styleComponent style params.
+

Fields

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
anchorItem anchor [0..1]
borderThe size of item content
first_indexThe first index of node in grid
last_indexThe last index of node in grid
node_sizeItem size
nodesList of all grid nodes
on_add_itemOn item add callback(self, node, index)
on_change_itemsOn item add, remove or change in_row callback(self, index|nil)
on_clearOn grid clear callback(self)
on_remove_itemOn item remove callback(self, index)
on_update_positionsOn update item positions callback(self)
parentParent gui node
pivotItem pivot [-0.5..0.5]
+ +
+
+ + +

Functions

+ +
+
+ + add(self, item, index, shift_policy, is_instant) +
+
+ Add new item to the grid + + +

Parameters:

+
    +
  • self + StaticGrid + StaticGrid +
  • +
  • item + node + GUI node +
  • +
  • index + number or nil + The item position. By default add as last item +
  • +
  • shift_policy + number or nil + How shift nodes, if required. Default: const.SHIFT.RIGHT +
  • +
  • is_instant + boolean or nil + If true, update node positions instantly +
  • +
+ + + + + +
+
+ + clear(self) +
+
+ Clear grid nodes array. GUI nodes will be not deleted! + If you want to delete GUI nodes, use static_grid.nodes array before grid:clear + + +

Parameters:

+ + +

Returns:

+
    + + druid.static_grid + Current grid instance +
+ + + + +
+
+ + get_all_pos(self) +
+
+ Return array of all node positions + + +

Parameters:

+ + +

Returns:

+
    + + vector3[] + All grid node positions +
+ + + + +
+
+ + get_borders(self) +
+
+ Return grid content borders + + +

Parameters:

+ + +

Returns:

+
    + + vector3 + The grid content borders +
+ + + + +
+
+ + get_index(self, pos) +
+
+ Return index for grid pos + + +

Parameters:

+
    +
  • self + StaticGrid + StaticGrid +
  • +
  • pos + vector3 + The node position in the grid +
  • +
+ +

Returns:

+
    + + number + The node index +
+ + + + +
+
+ + get_index_by_node(self, node) +
+
+ Return grid index by node + + +

Parameters:

+
    +
  • self + StaticGrid + StaticGrid +
  • +
  • node + node + The gui node in the grid +
  • +
+ +

Returns:

+
    + + number + The node index +
+ + + + +
+
+ + get_offset(self) +
+
+ Return StaticGrid offset, where StaticGrid content starts. + + +

Parameters:

+
    +
  • self + StaticGrid + StaticGrid The StaticGrid instance +
  • +
+ +

Returns:

+
    + + vector3 + The StaticGrid offset +
+ + + + +
+
+ + get_pos(self, index) +
+
+ Return pos for grid node index + + +

Parameters:

+
    +
  • self + StaticGrid + StaticGrid +
  • +
  • index + number + The grid element index +
  • +
+ +

Returns:

+
    + + vector3 + @Node position +
+ + + + +
+
+ + get_size(self) +
+
+ Return grid content size + + +

Parameters:

+ + +

Returns:

+
    + + vector3 + The grid content size +
+ + + + +
+
+ + init(self, parent, element, in_row) +
+
+ The StaticGrid constructor + + +

Parameters:

+
    +
  • self + StaticGrid + StaticGrid +
  • +
  • parent + string or node + The GUI Node container, where grid's items will be placed +
  • +
  • element + node + Element prefab. Need to get it size +
  • +
  • in_row + number or nil + How many nodes in row can be placed. By default 1 +
  • +
+ + + + + +
+
+ + refresh(self) +
+
+ Update grid content + + +

Parameters:

+ + + + + + +
+
+ + remove(self, index, shift_policy, is_instant) +
+
+ Remove the item from the grid. Note that gui node will be not deleted + + +

Parameters:

+
    +
  • self + StaticGrid + StaticGrid +
  • +
  • index + number + The grid node index to remove +
  • +
  • shift_policy + number or nil + How shift nodes, if required. Default: const.SHIFT.RIGHT +
  • +
  • is_instant + boolean or nil + If true, update node positions instantly +
  • +
+ +

Returns:

+
    + + node + The deleted gui node from grid +
+ + + + +
+
+ + set_anchor(self, anchor) +
+
+ Set grid anchor. Default anchor is equal to anchor of grid parent node + + +

Parameters:

+
    +
  • self + StaticGrid + StaticGrid +
  • +
  • anchor + vector3 + Anchor +
  • +
+ + + + + +
+
+ + set_in_row(self, in_row) +
+
+ Set new in_row elements for grid + + +

Parameters:

+
    +
  • self + StaticGrid + StaticGrid +
  • +
  • in_row + number + The new in_row value +
  • +
+ +

Returns:

+
    + + druid.static_grid + Current grid instance +
+ + + + +
+
+ + set_item_size(self[, width[, height]]) +
+
+ Set new node size for grid + + +

Parameters:

+
    +
  • self + StaticGrid + StaticGrid +
  • +
  • width + number + The new node width + (optional) +
  • +
  • height + number + The new node height + (optional) +
  • +
+ +

Returns:

+
    + + druid.static_grid + Current grid instance +
+ + + + +
+
+ + set_items(self, nodes[, is_instant=false]) +
+
+ Set new items to the grid. All previous items will be removed + + +

Parameters:

+
    +
  • self + StaticGrid + StaticGrid +
  • +
  • nodes + node[] + The new grid nodes +
  • +
  • is_instant + boolean + If true, update node positions instantly + (default false) +
  • +
+ + + + + +
+
+ + set_position_function(self, callback) +
+
+ Change set position function for grid nodes. It will call on + update poses on grid elements. Default: gui.set_position + + +

Parameters:

+
    +
  • self + StaticGrid + StaticGrid +
  • +
  • callback + function + Function on node set position +
  • +
+ +

Returns:

+
    + + druid.static_grid + Current grid instance +
+ + + + +
+
+ + sort_nodes(self, comparator) +
+
+ Sort grid nodes by custom comparator function + + +

Parameters:

+
    +
  • self + StaticGrid + StaticGrid +
  • +
  • comparator + function + The comparator function. (a, b) -> boolean +
  • +
+ +

Returns:

+
    + + druid.static_grid + Current grid instance +
+ + + + +
+
+

Tables

+ +
+
+ + style +
+
+ Component style params. + You can override this component styles params in druid styles table + or create your own style + + +

Fields:

+
    +
  • IS_DYNAMIC_NODE_POSES + boolean or nil + If true, always center grid content as grid pivot sets. Default: false +
  • +
  • IS_ALIGN_LAST_ROW + boolean or nil + If true, always align last row of the grid as grid pivot sets. Default: false +
  • +
+ + + + + +
+
+

Fields

+ +
+
+ + anchor +
+
+ Item anchor [0..1] + + +
    +
  • anchor + vector3 + +
  • +
+ + + + + +
+
+ + border +
+
+ The size of item content + + +
    +
  • border + vector4 + +
  • +
+ + + + + +
+
+ + first_index +
+
+ The first index of node in grid + + +
    +
  • first_index + number + +
  • +
+ + + + + +
+
+ + last_index +
+
+ The last index of node in grid + + +
    +
  • last_index + number + +
  • +
+ + + + + +
+
+ + node_size +
+
+ Item size + + +
    +
  • node_size + vector3 + +
  • +
+ + + + + +
+
+ + nodes +
+
+ List of all grid nodes + + +
    +
  • nodes + node[] + +
  • +
+ + + + + +
+
+ + on_add_item +
+
+ On item add callback(self, node, index) + + + + + + + + +
+
+ + on_change_items +
+
+ On item add, remove or change in_row callback(self, index|nil) + + + + + + + + +
+
+ + on_clear +
+
+ On grid clear callback(self) + + + + + + + + +
+
+ + on_remove_item +
+
+ On item remove callback(self, index) + + + + + + + + +
+
+ + on_update_positions +
+
+ On update item positions callback(self) + + +
    +
  • on_update_positions + DruidEvent + DruidEvent +
  • +
+ + + + + +
+
+ + parent +
+
+ Parent gui node + + +
    +
  • parent + node + +
  • +
+ + + + + +
+
+ + pivot +
+
+ Item pivot [-0.5..0.5] + + +
    +
  • pivot + vector3 + +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/Swipe.html b/docs/modules/Swipe.html new file mode 100644 index 0000000..9b7a2a9 --- /dev/null +++ b/docs/modules/Swipe.html @@ -0,0 +1,288 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module Swipe

+

Component to handle swipe gestures on node.

+

+ Swipe will be triggered, if swipe was started and + ended on one node +

Example Link

+ + +

Functions

+ + + + + + + + + +
init(self, node, on_swipe_callback)The Swipe constructor
set_click_zone(self, zone)Strict swipe click area.
+

Tables

+ + + + + +
styleComponent style params.
+

Fields

+ + + + + + + + + + + + + +
click_zoneRestriction zone
nodeSwipe node
on_swipeTrigger on swipe event(self, swipe_side, dist, delta_time)
+ +
+
+ + +

Functions

+ +
+
+ + init(self, node, on_swipe_callback) +
+
+ The Swipe constructor + + +

Parameters:

+
    +
  • self + Swipe + Swipe +
  • +
  • node + node + Gui node +
  • +
  • on_swipe_callback + function + Swipe callback for on_swipe_end event +
  • +
+ + + + + +
+
+ + set_click_zone(self, zone) +
+
+ Strict swipe click area. Useful for + restrict events outside stencil node + + +

Parameters:

+ + + + + + +
+
+

Tables

+ +
+
+ + style +
+
+ Component style params. + You can override this component styles params in druid styles table + or create your own style + + +

Fields:

+
    +
  • SWIPE_TIME + number or nil + Maximum time for swipe trigger. Default: 0.4 +
  • +
  • SWIPE_THRESHOLD + number or nil + Minimum distance for swipe trigger. Default: 50 +
  • +
  • SWIPE_TRIGGER_ON_MOVE + boolean or nil + If true, trigger on swipe moving, not only release action. Default: false +
  • +
+ + + + + +
+
+

Fields

+ +
+
+ + click_zone +
+
+ Restriction zone + + +
    +
  • click_zone + node or nil + +
  • +
+ + + + + +
+
+ + node +
+
+ Swipe node + + +
    +
  • node + node + +
  • +
+ + + + + +
+
+ + on_swipe +
+
+ Trigger on swipe event(self, swipe_side, dist, delta_time) + + + + + + + + +
+
+ + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/Text.html b/docs/modules/Text.html new file mode 100644 index 0000000..bcf6e6c --- /dev/null +++ b/docs/modules/Text.html @@ -0,0 +1,942 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module Text

+

Component for Wrapping GUI Text Nodes: Druid Text +

## Overview ## +

Druid Text is a component that provides various adjustment modes for text nodes.

+

It allows text to be scaled down to fit within the size of the text node. +

## Notes ## +

• The text pivot can be changed using the text:set_pivot method. + The anchoring will be inside the text node's area size. +

• There are several text adjustment types available. The default is DOWNSCALE. + You can change the default adjustment type in the Text style. Refer to the example below to see all available adjustment types: +

- const.TEXT_ADJUST.DOWNSCALE: Changes the text's scale to fit within the text node's size. +

- const.TEXT_ADJUST.TRIM: Trims the text with a postfix (default: "...", can be overridden in styles) + to fit within the text node's size. +

- const.TEXT_ADJUST.NO_ADJUST: No adjustment is applied, similar + to the default Defold Text Node behavior. +

- const.TEXT_ADJUST.DOWNSCALE_LIMITED: Changes the text's scale + with a limited downscale. You can set the minimum scale using the text:set_minimal_scale() function. +

- const.TEXT_ADJUST.SCROLL: Changes the text's pivot to imitate scrolling within the text box. + For better effect, use with a stencil node. +

- const.TEXT_ADJUST.SCALE_THEN_SCROLL: Combines two modes: limited downscale first, then scroll. +

Example Link

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
get_text_adjust(self, adjust_type)Return current text adjust type
get_text_index_by_width(self, width)Get chars count by width
get_text_size(self, text)Calculate text width with font with respect to trailing space
init(self, node, value, adjust_type)The Text constructor
is_multiline(self)Return true, if text with line break
set_alpha(self, alpha)Set alpha
set_color(self, color)Set color
set_minimal_scale(self, minimal_scale)Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types
set_pivot(self, pivot)Set text pivot.
set_scale(self, scale)Set scale
set_size(self, size)Set text area size
set_text_adjust(self, adjust_type, minimal_scale)Set text adjust, refresh the current text visuals, if needed
set_to(self, set_to)Set text to text field
+

Tables

+ + + + + +
styleComponent style params.
+

Fields

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
adjust_typeCurrent text size adjust settings
colorCurrent text color
last_valueThe last text value
nodeText node
node_idThe node id of text node
on_set_pivotOn change pivot callback(self, pivot)
on_set_textOn set text callback(self, text)
on_update_text_scaleOn adjust text size callback(self, new_scale, text_metrics)
posCurrent text position
scaleCurrent text node scale
start_scaleInitial text node scale
start_sizeInitial text node size
text_areaCurrent text node available are
+ +
+
+ + +

Functions

+ +
+
+ + get_text_adjust(self, adjust_type) +
+
+ Return current text adjust type + + +

Parameters:

+
    +
  • self + +
  • +
  • adjust_type + +
  • +
+ +

Returns:

+
    + + number + The current text adjust type +
+ + + + +
+
+ + get_text_index_by_width(self, width) +
+
+ Get chars count by width + + +

Parameters:

+
    +
  • self + Text + Text +
  • +
  • width + number + +
  • +
+ +

Returns:

+
    + + number + Chars count +
+ + + + +
+
+ + get_text_size(self, text) +
+
+ Calculate text width with font with respect to trailing space + + +

Parameters:

+
    +
  • self + Text + Text +
  • +
  • text + string + |nil +
  • +
+ +

Returns:

+
    +
  1. + number + Width
  2. +
  3. + number + Height
  4. +
+ + + + +
+
+ + init(self, node, value, adjust_type) +
+
+ The Text constructor + + +

Parameters:

+
    +
  • self + Text + Text +
  • +
  • node + string or node + Node name or GUI Text Node itself +
  • +
  • value + string or nil + Initial text. Default value is node text from GUI scene. Default: nil +
  • +
  • adjust_type + string or nil + Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference. Default: DOWNSCALE +
  • +
+ + + + + +
+
+ + is_multiline(self) +
+
+ Return true, if text with line break + + +

Parameters:

+
    +
  • self + Text + Text +
  • +
+ +

Returns:

+
    + + boolean + Is text node with line break +
+ + + + +
+
+ + set_alpha(self, alpha) +
+
+ Set alpha + + +

Parameters:

+
    +
  • self + Text + Text +
  • +
  • alpha + number + Alpha for node +
  • +
+ +

Returns:

+
    + + Text + Current text instance +
+ + + + +
+
+ + set_color(self, color) +
+
+ Set color + + +

Parameters:

+
    +
  • self + Text + Text +
  • +
  • color + vector4 + Color for node +
  • +
+ +

Returns:

+
    + + Text + Current text instance +
+ + + + +
+
+ + set_minimal_scale(self, minimal_scale) +
+
+ Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types + + +

Parameters:

+
    +
  • self + Text + Text +
  • +
  • minimal_scale + number + If pass nil - not use minimal scale +
  • +
+ +

Returns:

+
    + + Text + Current text instance +
+ + + + +
+
+ + set_pivot(self, pivot) +
+
+ Set text pivot. Text will re-anchor inside text area + + +

Parameters:

+
    +
  • self + Text + Text +
  • +
  • pivot + number + The gui.PIVOT_* constant +
  • +
+ +

Returns:

+
    + + Text + Current text instance +
+ + + + +
+
+ + set_scale(self, scale) +
+
+ Set scale + + +

Parameters:

+
    +
  • self + Text + Text +
  • +
  • scale + vector3 + Scale for node +
  • +
+ +

Returns:

+
    + + Text + Current text instance +
+ + + + +
+
+ + set_size(self, size) +
+
+ Set text area size + + +

Parameters:

+
    +
  • self + Text + Text +
  • +
  • size + vector3 + The new text area size +
  • +
+ +

Returns:

+
    + + Text + Current text instance +
+ + + + +
+
+ + set_text_adjust(self, adjust_type, minimal_scale) +
+
+ Set text adjust, refresh the current text visuals, if needed + + +

Parameters:

+
    +
  • self + Text + Text +
  • +
  • adjust_type + string or nil + See const.TEXT_ADJUST. If pass nil - use current adjust type +
  • +
  • minimal_scale + number or nil + If pass nil - not use minimal scale +
  • +
+ +

Returns:

+
    + + Text + Current text instance +
+ + + + +
+
+ + set_to(self, set_to) +
+
+ Set text to text field + + +

Parameters:

+
    +
  • self + Text + Text +
  • +
  • set_to + string + Text for node +
  • +
+ +

Returns:

+
    + + Text + Current text instance +
+ + + + +
+
+

Tables

+ +
+
+ + style +
+
+ Component style params. + You can override this component styles params in druid styles table + or create your own style + + +

Fields:

+
    +
  • TRIM_POSTFIX + string or nil + The postfix for TRIM adjust type. Default: ... +
  • +
  • DEFAULT_ADJUST + string or nil + The default adjust type for any text component. Default: DOWNSCALE +
  • +
  • ADJUST_STEPS + string or nil + Amount of iterations for text adjust by height. Default: 20 +
  • +
  • ADJUST_SCALE_DELTA + string or nil + Scale step on each height adjust step. Default: 0.02 +
  • +
+ + + + + +
+
+

Fields

+ +
+
+ + adjust_type +
+
+ Current text size adjust settings + + +
    +
  • adjust_type + number + +
  • +
+ + + + + +
+
+ + color +
+
+ Current text color + + +
    +
  • color + vector3 + +
  • +
+ + + + + +
+
+ + last_value +
+
+ The last text value + + + + + + + + +
+
+ + node +
+
+ Text node + + +
    +
  • node + node + +
  • +
+ + + + + +
+
+ + node_id +
+
+ The node id of text node + + +
    +
  • node_id + hash + +
  • +
+ + + + + +
+
+ + on_set_pivot +
+
+ On change pivot callback(self, pivot) + + + + + + + + +
+
+ + on_set_text +
+
+ On set text callback(self, text) + + + + + + + + +
+
+ + on_update_text_scale +
+
+ On adjust text size callback(self, new_scale, text_metrics) + + +
    +
  • on_update_text_scale + DruidEvent + DruidEvent +
  • +
+ + + + + +
+
+ + pos +
+
+ Current text position + + +
    +
  • pos + vector3 + +
  • +
+ + + + + +
+
+ + scale +
+
+ Current text node scale + + +
    +
  • scale + vector3 + +
  • +
+ + + + + +
+
+ + start_scale +
+
+ Initial text node scale + + +
    +
  • start_scale + vector3 + +
  • +
+ + + + + +
+
+ + start_size +
+
+ Initial text node size + + +
    +
  • start_size + vector3 + +
  • +
+ + + + + +
+
+ + text_area +
+
+ Current text node available are + + +
    +
  • text_area + vector3 + +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/Timer.html b/docs/modules/Timer.html new file mode 100644 index 0000000..7fabb1b --- /dev/null +++ b/docs/modules/Timer.html @@ -0,0 +1,409 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module Timer

+

Component to handle GUI timers.

+

+ Timer updating by game delta time. If game is not focused - + timer will be not updated.

+ + +

Functions

+ + + + + + + + + + + + + + + + + +
init(self, node, seconds_from, seconds_to, callback)The Timer constructor
set_interval(self, from, to)Set time interval
set_state(self, is_on)Called when update
set_to(self, set_to)Set text to text field
+

Fields

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fromInitial timer value
nodeTrigger node
on_set_enabledOn timer change enabled state callback(self, is_enabled)
on_tickOn timer tick.
on_timer_endOn timer end callback
targetTarget timer value
valueCurrent timer value
+ +
+
+ + +

Functions

+ +
+
+ + init(self, node, seconds_from, seconds_to, callback) +
+
+ The Timer constructor + + +

Parameters:

+
    +
  • self + Timer + Timer +
  • +
  • node + node + Gui text node +
  • +
  • seconds_from + number or nil + Start timer value in seconds +
  • +
  • seconds_to + number or nil + End timer value in seconds +
  • +
  • callback + function or nil + Function on timer end +
  • +
+ + + + + +
+
+ + set_interval(self, from, to) +
+
+ Set time interval + + +

Parameters:

+
    +
  • self + Timer + Timer +
  • +
  • from + number + Start time in seconds +
  • +
  • to + number + Target time in seconds +
  • +
+ + + + + +
+
+ + set_state(self, is_on) +
+
+ Called when update + + +

Parameters:

+
    +
  • self + Timer + Timer +
  • +
  • is_on + boolean or nil + Timer enable state +
  • +
+ + + + + +
+
+ + set_to(self, set_to) +
+
+ Set text to text field + + +

Parameters:

+
    +
  • self + Timer + Timer +
  • +
  • set_to + number + Value in seconds +
  • +
+ + + + + +
+
+

Fields

+ +
+
+ + from +
+
+ Initial timer value + + +
    +
  • from + number + +
  • +
+ + + + + +
+
+ + node +
+
+ Trigger node + + +
    +
  • node + node + +
  • +
+ + + + + +
+
+ + on_set_enabled +
+
+ On timer change enabled state callback(self, is_enabled) + + + + + + + + +
+
+ + on_tick +
+
+ On timer tick. Fire every second callback(self, value) + + + + + + + + +
+
+ + on_timer_end +
+
+ On timer end callback + + +
    +
  • on_timer_end + DruidEvent + (self, Timer) DruidEvent +
  • +
+ + + + + +
+
+ + target +
+
+ Target timer value + + +
    +
  • target + number + +
  • +
+ + + + + +
+
+ + value +
+
+ Current timer value + + +
    +
  • value + number + +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/druid.extended.layout.html b/docs/modules/druid.extended.layout.html new file mode 100644 index 0000000..4f01fd5 --- /dev/null +++ b/docs/modules/druid.extended.layout.html @@ -0,0 +1,95 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module druid.extended.layout

+

Druid layout module +

# Overview # +

Layout component works like Dynamic Grid before - for aligning elements in a row or column.

+

Works like a Figma layout. +

# Notes

+ + + +
+
+ + + + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + diff --git a/docs/modules/druid.system.utf8.html b/docs/modules/druid.system.utf8.html new file mode 100644 index 0000000..0582106 --- /dev/null +++ b/docs/modules/druid.system.utf8.html @@ -0,0 +1,93 @@ + + + + + Defold Druid UI Framework + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module druid.system.utf8

+

+

+ + + +
+
+ + + + +
+
+
+generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
+
+ + From 0514625f9a78723f1eec3a948e51aab0cd0b8872 Mon Sep 17 00:00:00 2001 From: Insality Date: Thu, 30 Jan 2025 01:44:03 +0200 Subject: [PATCH 45/50] Progress with widget examples --- druid/editor_scripts/widget.lua_template | 6 + example/druid.gui | 1447 +++++++++-------- example/druid.gui_script | 2 +- .../basic/rich_text/rich_text_tags.lua | 2 +- example/examples/intro/examples_list.lua | 8 + .../how_to_use_example/how_to_use_example.gui | 257 +++ .../how_to_use_example/how_to_use_example.lua | 33 + example/examples/intro/intro/intro.lua | 6 +- example/examples/widgets/examples_list.lua | 131 +- 9 files changed, 1195 insertions(+), 697 deletions(-) create mode 100644 example/examples/intro/how_to_use_example/how_to_use_example.gui create mode 100644 example/examples/intro/how_to_use_example/how_to_use_example.lua diff --git a/druid/editor_scripts/widget.lua_template b/druid/editor_scripts/widget.lua_template index 9d0f2c6..dfbc7ed 100644 --- a/druid/editor_scripts/widget.lua_template +++ b/druid/editor_scripts/widget.lua_template @@ -7,6 +7,12 @@ local M = {} function M:init() + -- Now we have next functions to use here: + -- self:get_node([node_id]) -- Get node inside widget by id + -- self.druid to access Druid Instance API, like: + -- self.druid:new_button([node_id], [callback]) + -- self.druid:new_text([node_id], [text]) + -- And all functions from component.lua file self.root = self:get_node("root") self.button = self.druid:new_button("button", self.on_button, self) end diff --git a/example/druid.gui b/example/druid.gui index 3f325af..5c805e3 100644 --- a/example/druid.gui +++ b/example/druid.gui @@ -367,189 +367,189 @@ nodes { y: -175.0 } type: TYPE_TEMPLATE - id: "properties_panel" + id: "example_properties_panel" parent: "container_settings" inherit_alpha: true template: "/example/components/properties_panel/properties_panel.gui" } nodes { type: TYPE_BOX - id: "properties_panel/root" - parent: "properties_panel" + id: "example_properties_panel/root" + parent: "example_properties_panel" template_node_child: true } nodes { type: TYPE_TEXT - id: "properties_panel/text_header" - parent: "properties_panel/root" + id: "example_properties_panel/text_header" + parent: "example_properties_panel/root" template_node_child: true } nodes { type: TYPE_BOX - id: "properties_panel/scroll_view" - parent: "properties_panel/root" + id: "example_properties_panel/scroll_view" + parent: "example_properties_panel/root" template_node_child: true } nodes { type: TYPE_BOX - id: "properties_panel/scroll_content" - parent: "properties_panel/scroll_view" + id: "example_properties_panel/scroll_content" + parent: "example_properties_panel/scroll_view" template_node_child: true } nodes { type: TYPE_BOX - id: "properties_panel/item_size" - parent: "properties_panel/scroll_content" + id: "example_properties_panel/item_size" + parent: "example_properties_panel/scroll_content" template_node_child: true } nodes { type: TYPE_BOX - id: "properties_panel/separator" - parent: "properties_panel/root" + id: "example_properties_panel/separator" + parent: "example_properties_panel/root" template_node_child: true } nodes { type: TYPE_BOX - id: "properties_panel/propeties" - parent: "properties_panel/root" + id: "example_properties_panel/propeties" + parent: "example_properties_panel/root" template_node_child: true } nodes { type: TYPE_TEMPLATE - id: "properties_panel/property_slider" - parent: "properties_panel/propeties" + id: "example_properties_panel/property_slider" + parent: "example_properties_panel/propeties" template_node_child: true } nodes { type: TYPE_BOX - id: "properties_panel/property_slider/root" - parent: "properties_panel/property_slider" + id: "example_properties_panel/property_slider/root" + parent: "example_properties_panel/property_slider" template_node_child: true } nodes { type: TYPE_TEXT - id: "properties_panel/property_slider/text_name" - parent: "properties_panel/property_slider/root" + id: "example_properties_panel/property_slider/text_name" + parent: "example_properties_panel/property_slider/root" template_node_child: true } nodes { type: TYPE_BOX - id: "properties_panel/property_slider/E_Anchor" - parent: "properties_panel/property_slider/root" + id: "example_properties_panel/property_slider/E_Anchor" + parent: "example_properties_panel/property_slider/root" template_node_child: true } nodes { type: TYPE_BOX - id: "properties_panel/property_slider/button" - parent: "properties_panel/property_slider/E_Anchor" + id: "example_properties_panel/property_slider/button" + parent: "example_properties_panel/property_slider/E_Anchor" template_node_child: true } nodes { type: TYPE_BOX - id: "properties_panel/property_slider/selected" - parent: "properties_panel/property_slider/button" + id: "example_properties_panel/property_slider/selected" + parent: "example_properties_panel/property_slider/button" template_node_child: true } nodes { type: TYPE_TEXT - id: "properties_panel/property_slider/text_value" - parent: "properties_panel/property_slider/button" + id: "example_properties_panel/property_slider/text_value" + parent: "example_properties_panel/property_slider/button" template_node_child: true } nodes { type: TYPE_BOX - id: "properties_panel/property_slider/slider" - parent: "properties_panel/property_slider/root" + id: "example_properties_panel/property_slider/slider" + parent: "example_properties_panel/property_slider/root" template_node_child: true } nodes { type: TYPE_BOX - id: "properties_panel/property_slider/slider_back" - parent: "properties_panel/property_slider/slider" + id: "example_properties_panel/property_slider/slider_back" + parent: "example_properties_panel/property_slider/slider" template_node_child: true } nodes { type: TYPE_BOX - id: "properties_panel/property_slider/slider_pin" - parent: "properties_panel/property_slider/slider" + id: "example_properties_panel/property_slider/slider_pin" + parent: "example_properties_panel/property_slider/slider" template_node_child: true } nodes { type: TYPE_TEMPLATE - id: "properties_panel/property_checkbox" - parent: "properties_panel/propeties" + id: "example_properties_panel/property_checkbox" + parent: "example_properties_panel/propeties" template_node_child: true } nodes { type: TYPE_BOX - id: "properties_panel/property_checkbox/root" - parent: "properties_panel/property_checkbox" + id: "example_properties_panel/property_checkbox/root" + parent: "example_properties_panel/property_checkbox" template_node_child: true } nodes { type: TYPE_TEXT - id: "properties_panel/property_checkbox/text_name" - parent: "properties_panel/property_checkbox/root" + id: "example_properties_panel/property_checkbox/text_name" + parent: "example_properties_panel/property_checkbox/root" template_node_child: true } nodes { type: TYPE_BOX - id: "properties_panel/property_checkbox/button" - parent: "properties_panel/property_checkbox/root" + id: "example_properties_panel/property_checkbox/button" + parent: "example_properties_panel/property_checkbox/root" template_node_child: true } nodes { type: TYPE_BOX - id: "properties_panel/property_checkbox/icon" - parent: "properties_panel/property_checkbox/button" + id: "example_properties_panel/property_checkbox/icon" + parent: "example_properties_panel/property_checkbox/button" template_node_child: true } nodes { type: TYPE_BOX - id: "properties_panel/property_checkbox/selected" - parent: "properties_panel/property_checkbox/button" + id: "example_properties_panel/property_checkbox/selected" + parent: "example_properties_panel/property_checkbox/button" template_node_child: true } nodes { type: TYPE_TEMPLATE - id: "properties_panel/property_button" - parent: "properties_panel/propeties" + id: "example_properties_panel/property_button" + parent: "example_properties_panel/propeties" template_node_child: true } nodes { type: TYPE_BOX - id: "properties_panel/property_button/root" - parent: "properties_panel/property_button" + id: "example_properties_panel/property_button/root" + parent: "example_properties_panel/property_button" template_node_child: true } nodes { type: TYPE_TEXT - id: "properties_panel/property_button/text_name" - parent: "properties_panel/property_button/root" + id: "example_properties_panel/property_button/text_name" + parent: "example_properties_panel/property_button/root" template_node_child: true } nodes { type: TYPE_BOX - id: "properties_panel/property_button/button" - parent: "properties_panel/property_button/root" + id: "example_properties_panel/property_button/button" + parent: "example_properties_panel/property_button/root" template_node_child: true } nodes { type: TYPE_BOX - id: "properties_panel/property_button/selected" - parent: "properties_panel/property_button/button" + id: "example_properties_panel/property_button/selected" + parent: "example_properties_panel/property_button/button" template_node_child: true } nodes { type: TYPE_TEXT - id: "properties_panel/property_button/text_button" - parent: "properties_panel/property_button/button" + id: "example_properties_panel/property_button/text_button" + parent: "example_properties_panel/property_button/button" template_node_child: true } nodes { type: TYPE_TEXT - id: "properties_panel/text_no_properties" - parent: "properties_panel/root" + id: "example_properties_panel/text_no_properties" + parent: "example_properties_panel/root" template_node_child: true } nodes { @@ -3918,785 +3918,874 @@ nodes { } nodes { type: TYPE_TEMPLATE - id: "example_memory_panel" + id: "fps_panel" parent: "widgets" inherit_alpha: true - template: "/example/examples/widgets/memory_panel/example_memory_panel.gui" + template: "/druid/widget/fps_panel/fps_panel.gui" } nodes { type: TYPE_BOX - id: "example_memory_panel/root" - parent: "example_memory_panel" + id: "fps_panel/root" + parent: "fps_panel" template_node_child: true } nodes { type: TYPE_TEMPLATE - id: "example_memory_panel/memory_panel" - parent: "example_memory_panel/root" + id: "fps_panel/mini_graph" + parent: "fps_panel/root" template_node_child: true } nodes { type: TYPE_BOX - id: "example_memory_panel/memory_panel/root" - parent: "example_memory_panel/memory_panel" + id: "fps_panel/mini_graph/root" + parent: "fps_panel/mini_graph" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "fps_panel/mini_graph/header" + parent: "fps_panel/mini_graph/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "fps_panel/mini_graph/text_header" + parent: "fps_panel/mini_graph/header" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "fps_panel/mini_graph/icon_drag" + parent: "fps_panel/mini_graph/header" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "fps_panel/mini_graph/content" + parent: "fps_panel/mini_graph/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "fps_panel/mini_graph/prefab_line" + parent: "fps_panel/mini_graph/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "fps_panel/mini_graph/color_low" + parent: "fps_panel/mini_graph/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "fps_panel/content" + parent: "fps_panel/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "fps_panel/text_min_fps" + parent: "fps_panel/content" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "fps_panel/text_fps" + parent: "fps_panel/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "fps_panel/line_second_1" + parent: "fps_panel/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "fps_panel/line_second_2" + parent: "fps_panel/content" template_node_child: true } nodes { type: TYPE_TEMPLATE - id: "example_memory_panel/memory_panel/mini_graph" - parent: "example_memory_panel/memory_panel/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_memory_panel/memory_panel/mini_graph/root" - parent: "example_memory_panel/memory_panel/mini_graph" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_memory_panel/memory_panel/mini_graph/header" - parent: "example_memory_panel/memory_panel/mini_graph/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_memory_panel/memory_panel/mini_graph/text_header" - parent: "example_memory_panel/memory_panel/mini_graph/header" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_memory_panel/memory_panel/mini_graph/icon_drag" - parent: "example_memory_panel/memory_panel/mini_graph/header" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_memory_panel/memory_panel/mini_graph/content" - parent: "example_memory_panel/memory_panel/mini_graph/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_memory_panel/memory_panel/mini_graph/prefab_line" - parent: "example_memory_panel/memory_panel/mini_graph/content" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_memory_panel/memory_panel/mini_graph/color_low" - parent: "example_memory_panel/memory_panel/mini_graph/content" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_memory_panel/memory_panel/content" - parent: "example_memory_panel/memory_panel/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_memory_panel/memory_panel/text_max_value" - parent: "example_memory_panel/memory_panel/content" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_memory_panel/memory_panel/text_per_second" - parent: "example_memory_panel/memory_panel/content" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_memory_panel/memory_panel/line_second_1" - parent: "example_memory_panel/memory_panel/content" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_memory_panel/memory_panel/line_second_2" - parent: "example_memory_panel/memory_panel/content" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_memory_panel/memory_panel/text_memory" - parent: "example_memory_panel/memory_panel/content" - template_node_child: true -} -nodes { - type: TYPE_TEMPLATE - id: "example_fps_panel" + id: "properties_panel" parent: "widgets" inherit_alpha: true - template: "/example/examples/widgets/fps_panel/example_fps_panel.gui" + template: "/druid/widget/properties_panel/properties_panel.gui" } nodes { type: TYPE_BOX - id: "example_fps_panel/root" - parent: "example_fps_panel" - template_node_child: true -} -nodes { - type: TYPE_TEMPLATE - id: "example_fps_panel/fps_panel" - parent: "example_fps_panel/root" + id: "properties_panel/root" + parent: "properties_panel" template_node_child: true } nodes { type: TYPE_BOX - id: "example_fps_panel/fps_panel/root" - parent: "example_fps_panel/fps_panel" - template_node_child: true -} -nodes { - type: TYPE_TEMPLATE - id: "example_fps_panel/fps_panel/mini_graph" - parent: "example_fps_panel/fps_panel/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_fps_panel/fps_panel/mini_graph/root" - parent: "example_fps_panel/fps_panel/mini_graph" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_fps_panel/fps_panel/mini_graph/header" - parent: "example_fps_panel/fps_panel/mini_graph/root" + id: "properties_panel/header" + parent: "properties_panel/root" template_node_child: true } nodes { type: TYPE_TEXT - id: "example_fps_panel/fps_panel/mini_graph/text_header" - parent: "example_fps_panel/fps_panel/mini_graph/header" + id: "properties_panel/text_header" + parent: "properties_panel/header" template_node_child: true } nodes { type: TYPE_BOX - id: "example_fps_panel/fps_panel/mini_graph/icon_drag" - parent: "example_fps_panel/fps_panel/mini_graph/header" + id: "properties_panel/icon_drag" + parent: "properties_panel/header" template_node_child: true } nodes { type: TYPE_BOX - id: "example_fps_panel/fps_panel/mini_graph/content" - parent: "example_fps_panel/fps_panel/mini_graph/root" + id: "properties_panel/content" + parent: "properties_panel/root" template_node_child: true } nodes { type: TYPE_BOX - id: "example_fps_panel/fps_panel/mini_graph/prefab_line" - parent: "example_fps_panel/fps_panel/mini_graph/content" + id: "properties_panel/scroll_view" + parent: "properties_panel/content" template_node_child: true } nodes { type: TYPE_BOX - id: "example_fps_panel/fps_panel/mini_graph/color_low" - parent: "example_fps_panel/fps_panel/mini_graph/content" + id: "properties_panel/scroll_content" + parent: "properties_panel/scroll_view" template_node_child: true } nodes { type: TYPE_BOX - id: "example_fps_panel/fps_panel/content" - parent: "example_fps_panel/fps_panel/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_fps_panel/fps_panel/text_min_fps" - parent: "example_fps_panel/fps_panel/content" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_fps_panel/fps_panel/text_fps" - parent: "example_fps_panel/fps_panel/content" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_fps_panel/fps_panel/line_second_1" - parent: "example_fps_panel/fps_panel/content" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_fps_panel/fps_panel/line_second_2" - parent: "example_fps_panel/fps_panel/content" + id: "properties_panel/propeties" + parent: "properties_panel/content" template_node_child: true } nodes { type: TYPE_TEMPLATE - id: "example_properties_panel" + id: "properties_panel/property_slider" + parent: "properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_slider/root" + parent: "properties_panel/property_slider" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_slider/text_name" + parent: "properties_panel/property_slider/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_slider/E_Anchor" + parent: "properties_panel/property_slider/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_slider/slider" + parent: "properties_panel/property_slider/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_slider/slider_back" + parent: "properties_panel/property_slider/slider" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_slider/slider_pin" + parent: "properties_panel/property_slider/slider" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_slider/button" + parent: "properties_panel/property_slider/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_slider/selected" + parent: "properties_panel/property_slider/button" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_slider/text_value" + parent: "properties_panel/property_slider/button" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "properties_panel/property_checkbox" + parent: "properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_checkbox/root" + parent: "properties_panel/property_checkbox" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_checkbox/text_name" + parent: "properties_panel/property_checkbox/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_checkbox/E_Anchor" + parent: "properties_panel/property_checkbox/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_checkbox/button" + parent: "properties_panel/property_checkbox/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_checkbox/icon" + parent: "properties_panel/property_checkbox/button" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_checkbox/selected" + parent: "properties_panel/property_checkbox/button" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "properties_panel/property_button" + parent: "properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_button/root" + parent: "properties_panel/property_button" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_button/text_name" + parent: "properties_panel/property_button/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_button/E_Anchor" + parent: "properties_panel/property_button/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_button/button" + parent: "properties_panel/property_button/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_button/selected" + parent: "properties_panel/property_button/button" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_button/text_button" + parent: "properties_panel/property_button/button" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "properties_panel/property_input" + parent: "properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_input/root" + parent: "properties_panel/property_input" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_input/text_name" + parent: "properties_panel/property_input/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_input/E_Anchor" + parent: "properties_panel/property_input/root" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "properties_panel/property_input/rich_input" + parent: "properties_panel/property_input/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_input/rich_input/root" + parent: "properties_panel/property_input/rich_input" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_input/rich_input/button" + parent: "properties_panel/property_input/rich_input/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_input/rich_input/placeholder_text" + parent: "properties_panel/property_input/rich_input/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_input/rich_input/input_text" + parent: "properties_panel/property_input/rich_input/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_input/rich_input/cursor_node" + parent: "properties_panel/property_input/rich_input/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_input/rich_input/cursor_text" + parent: "properties_panel/property_input/rich_input/cursor_node" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_input/selected" + parent: "properties_panel/property_input/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "properties_panel/property_text" + parent: "properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_text/root" + parent: "properties_panel/property_text" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_text/text_name" + parent: "properties_panel/property_text/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_text/text_right" + parent: "properties_panel/property_text/root" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "properties_panel/property_left_right_selector" + parent: "properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_left_right_selector/root" + parent: "properties_panel/property_left_right_selector" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_left_right_selector/text_name" + parent: "properties_panel/property_left_right_selector/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_left_right_selector/E_Anchor" + parent: "properties_panel/property_left_right_selector/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_left_right_selector/button_left" + parent: "properties_panel/property_left_right_selector/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_left_right_selector/icon_left" + parent: "properties_panel/property_left_right_selector/button_left" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_left_right_selector/button_right" + parent: "properties_panel/property_left_right_selector/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_left_right_selector/icon_right" + parent: "properties_panel/property_left_right_selector/button_right" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_left_right_selector/selected" + parent: "properties_panel/property_left_right_selector/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_left_right_selector/text_value" + parent: "properties_panel/property_left_right_selector/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "properties_panel/property_vector3" + parent: "properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_vector3/root" + parent: "properties_panel/property_vector3" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_vector3/text_name" + parent: "properties_panel/property_vector3/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_vector3/E_Anchor" + parent: "properties_panel/property_vector3/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_vector3/field_x" + parent: "properties_panel/property_vector3/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_vector3/text_x" + parent: "properties_panel/property_vector3/field_x" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "properties_panel/property_vector3/rich_input_x" + parent: "properties_panel/property_vector3/field_x" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_vector3/rich_input_x/root" + parent: "properties_panel/property_vector3/rich_input_x" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_vector3/rich_input_x/button" + parent: "properties_panel/property_vector3/rich_input_x/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_vector3/rich_input_x/placeholder_text" + parent: "properties_panel/property_vector3/rich_input_x/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_vector3/rich_input_x/input_text" + parent: "properties_panel/property_vector3/rich_input_x/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_vector3/rich_input_x/cursor_node" + parent: "properties_panel/property_vector3/rich_input_x/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_vector3/rich_input_x/cursor_text" + parent: "properties_panel/property_vector3/rich_input_x/cursor_node" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_vector3/selected_x" + parent: "properties_panel/property_vector3/field_x" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_vector3/field_y" + parent: "properties_panel/property_vector3/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_vector3/text_y" + parent: "properties_panel/property_vector3/field_y" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "properties_panel/property_vector3/rich_input_y" + parent: "properties_panel/property_vector3/field_y" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_vector3/rich_input_y/root" + parent: "properties_panel/property_vector3/rich_input_y" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_vector3/rich_input_y/button" + parent: "properties_panel/property_vector3/rich_input_y/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_vector3/rich_input_y/placeholder_text" + parent: "properties_panel/property_vector3/rich_input_y/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_vector3/rich_input_y/input_text" + parent: "properties_panel/property_vector3/rich_input_y/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_vector3/rich_input_y/cursor_node" + parent: "properties_panel/property_vector3/rich_input_y/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_vector3/rich_input_y/cursor_text" + parent: "properties_panel/property_vector3/rich_input_y/cursor_node" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_vector3/selected_y" + parent: "properties_panel/property_vector3/field_y" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_vector3/field_z" + parent: "properties_panel/property_vector3/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_vector3/text_z" + parent: "properties_panel/property_vector3/field_z" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "properties_panel/property_vector3/rich_input_z" + parent: "properties_panel/property_vector3/field_z" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_vector3/rich_input_z/root" + parent: "properties_panel/property_vector3/rich_input_z" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_vector3/rich_input_z/button" + parent: "properties_panel/property_vector3/rich_input_z/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_vector3/rich_input_z/placeholder_text" + parent: "properties_panel/property_vector3/rich_input_z/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_vector3/rich_input_z/input_text" + parent: "properties_panel/property_vector3/rich_input_z/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_vector3/rich_input_z/cursor_node" + parent: "properties_panel/property_vector3/rich_input_z/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_vector3/rich_input_z/cursor_text" + parent: "properties_panel/property_vector3/rich_input_z/cursor_node" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_vector3/selected_z" + parent: "properties_panel/property_vector3/field_z" + template_node_child: true +} +nodes { + type: TYPE_TEMPLATE + id: "memory_panel" parent: "widgets" inherit_alpha: true - template: "/example/examples/widgets/properties_panel/example_properties_panel.gui" + template: "/druid/widget/memory_panel/memory_panel.gui" } nodes { type: TYPE_BOX - id: "example_properties_panel/root" - parent: "example_properties_panel" + id: "memory_panel/root" + parent: "memory_panel" template_node_child: true } nodes { type: TYPE_TEMPLATE - id: "example_properties_panel/properties_panel" - parent: "example_properties_panel/root" + id: "memory_panel/mini_graph" + parent: "memory_panel/root" template_node_child: true } nodes { type: TYPE_BOX - id: "example_properties_panel/properties_panel/root" - parent: "example_properties_panel/properties_panel" + id: "memory_panel/mini_graph/root" + parent: "memory_panel/mini_graph" template_node_child: true } nodes { type: TYPE_BOX - id: "example_properties_panel/properties_panel/header" - parent: "example_properties_panel/properties_panel/root" + id: "memory_panel/mini_graph/header" + parent: "memory_panel/mini_graph/root" template_node_child: true } nodes { type: TYPE_TEXT - id: "example_properties_panel/properties_panel/text_header" - parent: "example_properties_panel/properties_panel/header" + id: "memory_panel/mini_graph/text_header" + parent: "memory_panel/mini_graph/header" template_node_child: true } nodes { type: TYPE_BOX - id: "example_properties_panel/properties_panel/icon_drag" - parent: "example_properties_panel/properties_panel/header" + id: "memory_panel/mini_graph/icon_drag" + parent: "memory_panel/mini_graph/header" template_node_child: true } nodes { type: TYPE_BOX - id: "example_properties_panel/properties_panel/content" - parent: "example_properties_panel/properties_panel/root" + id: "memory_panel/mini_graph/content" + parent: "memory_panel/mini_graph/root" template_node_child: true } nodes { type: TYPE_BOX - id: "example_properties_panel/properties_panel/scroll_view" - parent: "example_properties_panel/properties_panel/content" + id: "memory_panel/mini_graph/prefab_line" + parent: "memory_panel/mini_graph/content" template_node_child: true } nodes { type: TYPE_BOX - id: "example_properties_panel/properties_panel/scroll_content" - parent: "example_properties_panel/properties_panel/scroll_view" + id: "memory_panel/mini_graph/color_low" + parent: "memory_panel/mini_graph/content" template_node_child: true } nodes { type: TYPE_BOX - id: "example_properties_panel/properties_panel/propeties" - parent: "example_properties_panel/properties_panel/content" + id: "memory_panel/content" + parent: "memory_panel/root" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "memory_panel/text_max_value" + parent: "memory_panel/content" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "memory_panel/text_per_second" + parent: "memory_panel/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "memory_panel/line_second_1" + parent: "memory_panel/content" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "memory_panel/line_second_2" + parent: "memory_panel/content" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "memory_panel/text_memory" + parent: "memory_panel/content" template_node_child: true } nodes { type: TYPE_TEMPLATE - id: "example_properties_panel/properties_panel/property_slider" - parent: "example_properties_panel/properties_panel/propeties" + id: "mini_graph" + parent: "widgets" + inherit_alpha: true + template: "/druid/widget/mini_graph/mini_graph.gui" +} +nodes { + type: TYPE_BOX + id: "mini_graph/root" + parent: "mini_graph" template_node_child: true } nodes { type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_slider/root" - parent: "example_properties_panel/properties_panel/property_slider" + id: "mini_graph/header" + parent: "mini_graph/root" template_node_child: true } nodes { type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_slider/text_name" - parent: "example_properties_panel/properties_panel/property_slider/root" + id: "mini_graph/text_header" + parent: "mini_graph/header" template_node_child: true } nodes { type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_slider/E_Anchor" - parent: "example_properties_panel/properties_panel/property_slider/root" + id: "mini_graph/icon_drag" + parent: "mini_graph/header" template_node_child: true } nodes { type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_slider/slider" - parent: "example_properties_panel/properties_panel/property_slider/E_Anchor" + id: "mini_graph/content" + parent: "mini_graph/root" template_node_child: true } nodes { type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_slider/slider_back" - parent: "example_properties_panel/properties_panel/property_slider/slider" + id: "mini_graph/prefab_line" + parent: "mini_graph/content" template_node_child: true } nodes { type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_slider/slider_pin" - parent: "example_properties_panel/properties_panel/property_slider/slider" + id: "mini_graph/color_low" + parent: "mini_graph/content" template_node_child: true } nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_slider/button" - parent: "example_properties_panel/properties_panel/property_slider/E_Anchor" - template_node_child: true + position { + x: -200.0 + } + type: TYPE_TEMPLATE + id: "property_input" + parent: "widgets" + inherit_alpha: true + template: "/druid/widget/properties_panel/properties/property_input.gui" } nodes { type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_slider/selected" - parent: "example_properties_panel/properties_panel/property_slider/button" + id: "property_input/root" + parent: "property_input" template_node_child: true } nodes { type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_slider/text_value" - parent: "example_properties_panel/properties_panel/property_slider/button" + id: "property_input/text_name" + parent: "property_input/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_input/E_Anchor" + parent: "property_input/root" template_node_child: true } nodes { type: TYPE_TEMPLATE - id: "example_properties_panel/properties_panel/property_checkbox" - parent: "example_properties_panel/properties_panel/propeties" + id: "property_input/rich_input" + parent: "property_input/E_Anchor" template_node_child: true } nodes { type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_checkbox/root" - parent: "example_properties_panel/properties_panel/property_checkbox" + id: "property_input/rich_input/root" + parent: "property_input/rich_input" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "property_input/rich_input/button" + parent: "property_input/rich_input/root" template_node_child: true } nodes { type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_checkbox/text_name" - parent: "example_properties_panel/properties_panel/property_checkbox/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_checkbox/E_Anchor" - parent: "example_properties_panel/properties_panel/property_checkbox/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_checkbox/button" - parent: "example_properties_panel/properties_panel/property_checkbox/E_Anchor" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_checkbox/icon" - parent: "example_properties_panel/properties_panel/property_checkbox/button" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_checkbox/selected" - parent: "example_properties_panel/properties_panel/property_checkbox/button" - template_node_child: true -} -nodes { - type: TYPE_TEMPLATE - id: "example_properties_panel/properties_panel/property_button" - parent: "example_properties_panel/properties_panel/propeties" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_button/root" - parent: "example_properties_panel/properties_panel/property_button" + id: "property_input/rich_input/placeholder_text" + parent: "property_input/rich_input/root" template_node_child: true } nodes { type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_button/text_name" - parent: "example_properties_panel/properties_panel/property_button/root" + id: "property_input/rich_input/input_text" + parent: "property_input/rich_input/root" template_node_child: true } nodes { type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_button/E_Anchor" - parent: "example_properties_panel/properties_panel/property_button/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_button/button" - parent: "example_properties_panel/properties_panel/property_button/E_Anchor" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_button/selected" - parent: "example_properties_panel/properties_panel/property_button/button" + id: "property_input/rich_input/cursor_node" + parent: "property_input/rich_input/root" template_node_child: true } nodes { type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_button/text_button" - parent: "example_properties_panel/properties_panel/property_button/button" - template_node_child: true -} -nodes { - type: TYPE_TEMPLATE - id: "example_properties_panel/properties_panel/property_input" - parent: "example_properties_panel/properties_panel/propeties" + id: "property_input/rich_input/cursor_text" + parent: "property_input/rich_input/cursor_node" template_node_child: true } nodes { type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_input/root" - parent: "example_properties_panel/properties_panel/property_input" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_input/text_name" - parent: "example_properties_panel/properties_panel/property_input/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_input/E_Anchor" - parent: "example_properties_panel/properties_panel/property_input/root" - template_node_child: true -} -nodes { - type: TYPE_TEMPLATE - id: "example_properties_panel/properties_panel/property_input/rich_input" - parent: "example_properties_panel/properties_panel/property_input/E_Anchor" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_input/rich_input/root" - parent: "example_properties_panel/properties_panel/property_input/rich_input" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_input/rich_input/button" - parent: "example_properties_panel/properties_panel/property_input/rich_input/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_input/rich_input/placeholder_text" - parent: "example_properties_panel/properties_panel/property_input/rich_input/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_input/rich_input/input_text" - parent: "example_properties_panel/properties_panel/property_input/rich_input/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_input/rich_input/cursor_node" - parent: "example_properties_panel/properties_panel/property_input/rich_input/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_input/rich_input/cursor_text" - parent: "example_properties_panel/properties_panel/property_input/rich_input/cursor_node" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_input/selected" - parent: "example_properties_panel/properties_panel/property_input/E_Anchor" - template_node_child: true -} -nodes { - type: TYPE_TEMPLATE - id: "example_properties_panel/properties_panel/property_text" - parent: "example_properties_panel/properties_panel/propeties" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_text/root" - parent: "example_properties_panel/properties_panel/property_text" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_text/text_name" - parent: "example_properties_panel/properties_panel/property_text/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_text/text_right" - parent: "example_properties_panel/properties_panel/property_text/root" - template_node_child: true -} -nodes { - type: TYPE_TEMPLATE - id: "example_properties_panel/properties_panel/property_left_right_selector" - parent: "example_properties_panel/properties_panel/propeties" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_left_right_selector/root" - parent: "example_properties_panel/properties_panel/property_left_right_selector" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_left_right_selector/text_name" - parent: "example_properties_panel/properties_panel/property_left_right_selector/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_left_right_selector/E_Anchor" - parent: "example_properties_panel/properties_panel/property_left_right_selector/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_left_right_selector/button_left" - parent: "example_properties_panel/properties_panel/property_left_right_selector/E_Anchor" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_left_right_selector/icon_left" - parent: "example_properties_panel/properties_panel/property_left_right_selector/button_left" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_left_right_selector/button_right" - parent: "example_properties_panel/properties_panel/property_left_right_selector/E_Anchor" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_left_right_selector/icon_right" - parent: "example_properties_panel/properties_panel/property_left_right_selector/button_right" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_left_right_selector/selected" - parent: "example_properties_panel/properties_panel/property_left_right_selector/E_Anchor" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_left_right_selector/text_value" - parent: "example_properties_panel/properties_panel/property_left_right_selector/E_Anchor" - template_node_child: true -} -nodes { - type: TYPE_TEMPLATE - id: "example_properties_panel/properties_panel/property_vector3" - parent: "example_properties_panel/properties_panel/propeties" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_vector3/root" - parent: "example_properties_panel/properties_panel/property_vector3" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_vector3/text_name" - parent: "example_properties_panel/properties_panel/property_vector3/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_vector3/E_Anchor" - parent: "example_properties_panel/properties_panel/property_vector3/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_vector3/field_x" - parent: "example_properties_panel/properties_panel/property_vector3/E_Anchor" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_vector3/text_x" - parent: "example_properties_panel/properties_panel/property_vector3/field_x" - template_node_child: true -} -nodes { - type: TYPE_TEMPLATE - id: "example_properties_panel/properties_panel/property_vector3/rich_input_x" - parent: "example_properties_panel/properties_panel/property_vector3/field_x" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_vector3/rich_input_x/root" - parent: "example_properties_panel/properties_panel/property_vector3/rich_input_x" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_vector3/rich_input_x/button" - parent: "example_properties_panel/properties_panel/property_vector3/rich_input_x/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_vector3/rich_input_x/placeholder_text" - parent: "example_properties_panel/properties_panel/property_vector3/rich_input_x/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_vector3/rich_input_x/input_text" - parent: "example_properties_panel/properties_panel/property_vector3/rich_input_x/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_vector3/rich_input_x/cursor_node" - parent: "example_properties_panel/properties_panel/property_vector3/rich_input_x/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_vector3/rich_input_x/cursor_text" - parent: "example_properties_panel/properties_panel/property_vector3/rich_input_x/cursor_node" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_vector3/selected_x" - parent: "example_properties_panel/properties_panel/property_vector3/field_x" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_vector3/field_y" - parent: "example_properties_panel/properties_panel/property_vector3/E_Anchor" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_vector3/text_y" - parent: "example_properties_panel/properties_panel/property_vector3/field_y" - template_node_child: true -} -nodes { - type: TYPE_TEMPLATE - id: "example_properties_panel/properties_panel/property_vector3/rich_input_y" - parent: "example_properties_panel/properties_panel/property_vector3/field_y" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_vector3/rich_input_y/root" - parent: "example_properties_panel/properties_panel/property_vector3/rich_input_y" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_vector3/rich_input_y/button" - parent: "example_properties_panel/properties_panel/property_vector3/rich_input_y/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_vector3/rich_input_y/placeholder_text" - parent: "example_properties_panel/properties_panel/property_vector3/rich_input_y/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_vector3/rich_input_y/input_text" - parent: "example_properties_panel/properties_panel/property_vector3/rich_input_y/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_vector3/rich_input_y/cursor_node" - parent: "example_properties_panel/properties_panel/property_vector3/rich_input_y/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_vector3/rich_input_y/cursor_text" - parent: "example_properties_panel/properties_panel/property_vector3/rich_input_y/cursor_node" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_vector3/selected_y" - parent: "example_properties_panel/properties_panel/property_vector3/field_y" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_vector3/field_z" - parent: "example_properties_panel/properties_panel/property_vector3/E_Anchor" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_vector3/text_z" - parent: "example_properties_panel/properties_panel/property_vector3/field_z" - template_node_child: true -} -nodes { - type: TYPE_TEMPLATE - id: "example_properties_panel/properties_panel/property_vector3/rich_input_z" - parent: "example_properties_panel/properties_panel/property_vector3/field_z" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_vector3/rich_input_z/root" - parent: "example_properties_panel/properties_panel/property_vector3/rich_input_z" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_vector3/rich_input_z/button" - parent: "example_properties_panel/properties_panel/property_vector3/rich_input_z/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_vector3/rich_input_z/placeholder_text" - parent: "example_properties_panel/properties_panel/property_vector3/rich_input_z/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_vector3/rich_input_z/input_text" - parent: "example_properties_panel/properties_panel/property_vector3/rich_input_z/root" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_vector3/rich_input_z/cursor_node" - parent: "example_properties_panel/properties_panel/property_vector3/rich_input_z/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "example_properties_panel/properties_panel/property_vector3/rich_input_z/cursor_text" - parent: "example_properties_panel/properties_panel/property_vector3/rich_input_z/cursor_node" - template_node_child: true -} -nodes { - type: TYPE_BOX - id: "example_properties_panel/properties_panel/property_vector3/selected_z" - parent: "example_properties_panel/properties_panel/property_vector3/field_z" + id: "property_input/selected" + parent: "property_input/E_Anchor" template_node_child: true } nodes { diff --git a/example/druid.gui_script b/example/druid.gui_script index 1a7eb7c..4b5c865 100644 --- a/example/druid.gui_script +++ b/example/druid.gui_script @@ -89,7 +89,7 @@ local function setup_components(self) self.examples_list_view = self.druid:new(examples_list_view, "examples_list_view") --[[@as examples_list_view]] self.container_examples:add_container(self.examples_list_view.root) - self.properties_panel = self.druid:new(properties_panel, "properties_panel") --[[@as properties_panel]] + self.properties_panel = self.druid:new(properties_panel, "example_properties_panel") --[[@as properties_panel]] self.container_settings:add_container(self.properties_panel.root) self.output_list = self.druid:new(output_list, "output_list") --[[@as output_list]] diff --git a/example/examples/basic/rich_text/rich_text_tags.lua b/example/examples/basic/rich_text/rich_text_tags.lua index dc8f6c7..3e92a8f 100644 --- a/example/examples/basic/rich_text/rich_text_tags.lua +++ b/example/examples/basic/rich_text/rich_text_tags.lua @@ -25,7 +25,7 @@ function M:init(template, nodes) self.rich_text_breaks:set_text("Hello, I'm Rich Text
With \"Line Breaks\"\nEnabled in GUI") self.rich_text_image = self.druid:new_rich_text("rich_text_image") --[[@as druid.rich_text]] - self.rich_text_image:set_text("Hello, I'mRich Text ") + self.rich_text_image:set_text("Hello, I'mRich Text ") self.position = { [self.rich_text_color] = gui.get_position(self.rich_text_color.root), diff --git a/example/examples/intro/examples_list.lua b/example/examples/intro/examples_list.lua index 0366886..0618863 100644 --- a/example/examples/intro/examples_list.lua +++ b/example/examples/intro/examples_list.lua @@ -12,6 +12,14 @@ function M.get_examples() code_url = "example/examples/intro/intro/intro.lua", component_class = require("example.examples.intro.intro.intro"), }, + --{ + -- name_id = "ui_example_how_to_use_example", + -- information_text_id = "ui_example_how_to_use_example_description", + -- template = "how_to_use_example", + -- root = "how_to_use_example/root", + -- code_url = "example/examples/intro/how_to_use_example/how_to_use_example.lua", + -- component_class = require("example.examples.intro.how_to_use_example.how_to_use_example"), + --} } end diff --git a/example/examples/intro/how_to_use_example/how_to_use_example.gui b/example/examples/intro/how_to_use_example/how_to_use_example.gui new file mode 100644 index 0000000..78283a9 --- /dev/null +++ b/example/examples/intro/how_to_use_example/how_to_use_example.gui @@ -0,0 +1,257 @@ +fonts { + name: "text_bold" + font: "/example/assets/fonts/text_bold.font" +} +fonts { + name: "text_regular" + font: "/example/assets/fonts/text_regular.font" +} +textures { + name: "druid_example" + texture: "/example/assets/druid_example.atlas" +} +textures { + name: "druid_logo" + texture: "/example/assets/druid_logo.atlas" +} +nodes { + size { + x: 600.0 + y: 1000.0 + } + color { + x: 0.173 + y: 0.184 + z: 0.204 + } + type: TYPE_BOX + texture: "druid_example/ui_circle_64" + id: "root" + inherit_alpha: true + slice9 { + x: 32.0 + y: 32.0 + z: 32.0 + w: 32.0 + } +} +nodes { + position { + x: -180.0 + y: 375.0 + } + type: TYPE_BOX + texture: "druid_logo/icon_druid" + id: "icon_druid_left" + parent: "root" + layer: "druid_logo" + inherit_alpha: true + alpha: 0.75 + size_mode: SIZE_MODE_AUTO +} +nodes { + position { + x: 180.0 + y: 375.0 + } + type: TYPE_BOX + texture: "druid_logo/icon_druid" + id: "icon_druid_right" + parent: "root" + layer: "druid_logo" + inherit_alpha: true + alpha: 0.75 + size_mode: SIZE_MODE_AUTO +} +nodes { + position { + y: 255.0 + } + scale { + x: 2.0 + y: 2.0 + } + size { + x: 200.0 + y: 40.0 + } + color { + x: 0.941 + y: 0.984 + } + type: TYPE_TEXT + text: "Hello!" + font: "text_bold" + id: "text_hello" + parent: "root" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} +nodes { + position { + x: -210.0 + y: 191.0 + } + scale { + x: 0.7 + y: 0.7 + } + size { + x: 600.0 + y: 400.0 + } + color { + x: 0.525 + y: 0.525 + z: 0.525 + } + type: TYPE_TEXT + text: "Welcome to Druid Example Page\n" + "\n" + "Navigate over examples on the left\n" + "\n" + "Check example info on the right" + font: "text_bold" + id: "text_description" + pivot: PIVOT_NW + line_break: true + parent: "root" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} +nodes { + position { + x: -210.0 + y: -189.0 + } + scale { + x: 0.7 + y: 0.7 + } + size { + x: 600.0 + y: 300.0 + } + color { + x: 0.525 + y: 0.525 + z: 0.525 + } + type: TYPE_TEXT + text: "Your donation helps me stay engaged in creating valuable projects for Defold.\n" + "\n" + "If you appreciate what I\'m doing, please consider supporting me!" + font: "text_bold" + id: "text_support" + pivot: PIVOT_W + line_break: true + parent: "root" + inherit_alpha: true + outline_alpha: 0.0 + shadow_alpha: 0.0 +} +nodes { + position { + x: -170.0 + y: -364.0 + } + type: TYPE_BOX + texture: "druid_example/icon_heart" + id: "icon_heart1" + parent: "root" + inherit_alpha: true + alpha: 0.75 + size_mode: SIZE_MODE_AUTO +} +nodes { + position { + y: -364.0 + } + type: TYPE_BOX + texture: "druid_example/icon_heart" + id: "icon_heart2" + parent: "root" + inherit_alpha: true + alpha: 0.75 + size_mode: SIZE_MODE_AUTO +} +nodes { + position { + x: 170.0 + y: -364.0 + } + type: TYPE_BOX + texture: "druid_example/icon_heart" + id: "icon_heart3" + parent: "root" + inherit_alpha: true + alpha: 0.75 + size_mode: SIZE_MODE_AUTO +} +nodes { + position { + y: -450.0 + } + size { + x: 500.0 + y: 80.0 + } + type: TYPE_BOX + id: "sponsor" + parent: "root" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO + visible: false +} +nodes { + position { + x: -196.0 + y: -3.0 + } + type: TYPE_BOX + texture: "druid_logo/sponsor_github" + id: "sponsor_github" + parent: "sponsor" + layer: "druid_logo" + inherit_alpha: true + alpha: 0.75 + size_mode: SIZE_MODE_AUTO +} +nodes { + position { + x: 21.0 + y: -3.0 + } + type: TYPE_BOX + texture: "druid_logo/sponsor_coffee" + id: "sponsor_coffee" + parent: "sponsor" + layer: "druid_logo" + inherit_alpha: true + alpha: 0.75 + size_mode: SIZE_MODE_AUTO +} +nodes { + position { + x: 217.0 + y: -3.0 + } + type: TYPE_BOX + texture: "druid_logo/sponsor_kofi" + id: "sponsor_kofi" + parent: "sponsor" + layer: "druid_logo" + inherit_alpha: true + alpha: 0.75 + size_mode: SIZE_MODE_AUTO +} +layers { + name: "druid_logo" +} +layers { + name: "text_regular" +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/example/examples/intro/how_to_use_example/how_to_use_example.lua b/example/examples/intro/how_to_use_example/how_to_use_example.lua new file mode 100644 index 0000000..b797f98 --- /dev/null +++ b/example/examples/intro/how_to_use_example/how_to_use_example.lua @@ -0,0 +1,33 @@ +local component = require("druid.component") +local panthera = require("panthera.panthera") + +---@class how_to_use_example: druid.base_component +---@field root node +local M = component.create("how_to_use_example") + +---@param template string +---@param nodes table +function M:init(template, nodes) + self.druid = self:get_druid(template, nodes) + self.root = self:get_node("root") + + self.druid:new_rich_text("text_hello", "Hello!") + + self.druid:new_button("sponsor_github", self.open_link, "https://github.com/sponsors/insality") + self.druid:new_button("sponsor_coffee", self.open_link, "https://www.buymeacoffee.com/insality") + self.druid:new_button("sponsor_kofi", self.open_link, "https://ko-fi.com/insality") + + self.druid:new_layout("sponsor") + :add("sponsor_github") + :add("sponsor_coffee") + :add("sponsor_kofi") + :set_margin(8, 0) +end + + +function M:open_link(link) + sys.open_url(link, { target = "_blank" }) +end + + +return M diff --git a/example/examples/intro/intro/intro.lua b/example/examples/intro/intro/intro.lua index abeee0e..10ea849 100644 --- a/example/examples/intro/intro/intro.lua +++ b/example/examples/intro/intro/intro.lua @@ -3,7 +3,6 @@ local panthera = require("panthera.panthera") local intro_panthera = require("example.examples.intro.intro.intro_panthera") ---@class intro: druid.base_component ----@field druid druid_instance ---@field root node local M = component.create("intro") @@ -35,4 +34,9 @@ function M:open_link(link) end +function M:on_remove() + panthera.stop(self.animation) +end + + return M diff --git a/example/examples/widgets/examples_list.lua b/example/examples/widgets/examples_list.lua index 14c7728..d127fb0 100644 --- a/example/examples/widgets/examples_list.lua +++ b/example/examples/widgets/examples_list.lua @@ -11,6 +11,72 @@ function M.get_examples() code_url = "example/examples/widgets/hover_hint/hover_hint_example.lua", component_class = require("example.examples.widgets.hover_hint.hover_hint_example"), }, + { + name_id = "ui_example_widget_properties_panel", + information_text_id = "ui_example_widget_properties_panel_description", + template = "properties_panel", + root = "properties_panel/root", + code_url = "example/examples/widgets/properties_panel/properties_panel.lua", + widget_class = require("druid.widget.properties_panel.properties_panel"), + on_create = function(instance, output_list) + ---@cast instance widget.properties_panel + + instance:add_button(function(button) + button:set_text_button("Button") + button.button.on_click:subscribe(function() + print("Button clicked") + end) + end) + + instance:add_checkbox(function(checkbox) + --print("Checkbox clicked", value) + checkbox:set_text_property("Checkbox") + checkbox.on_change_value:subscribe(function(value) + print("Checkbox clicked", value) + end) + checkbox:set_value(false) + end) + + instance:add_input(function(input) + input:set_text_property("Input") + input:set_text_value("Initial") + input:on_change(function(text) + print("Input changed", text) + end) + end) + + instance:add_left_right_selector(function(selector) + selector:set_template("Arrows Number") + selector.on_change_value:subscribe(function(value) + print("Left Right Selector changed", value) + end) + selector:set_number_type(0, 42, true, 1) + selector:set_value(0) + end) + + instance:add_left_right_selector(function(selector) + selector:set_template("Arrows Array") + selector.on_change_value:subscribe(function(value) + print("Left Right Array value", value) + end) + selector:set_array_type({"Zero", "One", "Two", "Three", "Four", "Five"}, false, 1) + selector:set_value("Zero") + end) + + instance:add_slider(function(slider) + slider:set_text_property("Slider") + slider:set_value(0.5) + slider:on_change(function(value) + print("Slider changed", value) + end) + end) + + instance:add_text(function(text) + text:set_text_property("Text") + text:set_text_value("Hello, World!") + end) + end, + }, { name_id = "ui_example_widget_property_button", information_text_id = "ui_example_widget_property_button_description", @@ -25,6 +91,14 @@ function M.get_examples() end) end, }, + { + name_id = "ui_example_widget_property_input", + information_text_id = "ui_example_widget_property_input_description", + template = "property_input", + root = "property_input/root", + code_url = "druid/widget/properties_panel/properties/property_input.lua", + widget_class = require("druid.widget.properties_panel.properties.property_input"), + }, { name_id = "ui_example_widget_property_slider", information_text_id = "ui_example_widget_property_slider_description", @@ -56,27 +130,54 @@ function M.get_examples() { name_id = "ui_example_widget_memory_panel", information_text_id = "ui_example_widget_memory_panel_description", - template = "example_memory_panel", - root = "example_memory_panel/root", - code_url = "example/examples/widgets/memory_panel/example_memory_panel.lua", - widget_class = require("example.examples.widgets.memory_panel.example_memory_panel"), + template = "memory_panel", + root = "memory_panel/root", + code_url = "druid.widget.memory_panel.memory_panel.lua", + widget_class = require("druid.widget.memory_panel.memory_panel"), + on_create = function(instance, output_list) + ---@cast instance widget.memory_panel + print("Memory panel created") + end, }, { name_id = "ui_example_widget_fps_panel", information_text_id = "ui_example_widget_fps_panel_description", - template = "example_fps_panel", - root = "example_fps_panel/root", - code_url = "example/examples/widgets/fps_panel/example_fps_panel.lua", - widget_class = require("example.examples.widgets.fps_panel.example_fps_panel"), + template = "fps_panel", + root = "fps_panel/root", + code_url = "druid.widget.fps_panel.fps_panel.lua", + widget_class = require("druid.widget.fps_panel.fps_panel"), + on_create = function(instance, output_list) + ---@cast instance widget.fps_panel + print("FPS panel created") + end, }, { - name_id = "ui_example_widget_properties_panel", - information_text_id = "ui_example_widget_properties_panel_description", - template = "example_properties_panel", - root = "example_properties_panel/root", - code_url = "example/examples/widgets/properties_panel/example_properties_panel.lua", - widget_class = require("example.examples.widgets.properties_panel.example_properties_panel"), - }, + name_id = "ui_example_widget_mini_graph", + information_text_id = "ui_example_widget_mini_graph_description", + template = "mini_graph", + root = "mini_graph/root", + code_url = "druid.widget.mini_graph.mini_graph.lua", + widget_class = require("druid.widget.mini_graph.mini_graph"), + on_create = function(instance, output_list) + ---@cast instance widget.mini_graph + instance:set_samples(50) + end, + properties_control = function(instance, properties_panel) + ---@cast instance widget.mini_graph + properties_panel:add_slider("value", 0.5, function(value) + -- Remap to -1, 2 + value = value * 3 - 1 + for index = 1, 50 do + -- Take value each 0.1 step, the higher value at argument value + local x = index * (1 / 50) + local distance = math.abs(x - value) + local line_v = 1 - distance^2 + + instance:set_line_value(index, line_v) + end + end) + end, + } } end From b6c0e1556ada17b0df353f7f4fb9d882e93d6071 Mon Sep 17 00:00:00 2001 From: Insality Date: Thu, 30 Jan 2025 19:30:56 +0200 Subject: [PATCH 46/50] Update the panel druid profiler, remove events counter --- .../panel_druid_profiler.gui | 114 +++--------------- .../panel_druid_profiler.lua | 51 ++------ example/druid.gui | 30 ++--- settings_deployer | 2 +- 4 files changed, 41 insertions(+), 156 deletions(-) diff --git a/example/components/panel_druid_profiler/panel_druid_profiler.gui b/example/components/panel_druid_profiler/panel_druid_profiler.gui index 80e85df..3824272 100644 --- a/example/components/panel_druid_profiler/panel_druid_profiler.gui +++ b/example/components/panel_druid_profiler/panel_druid_profiler.gui @@ -17,10 +17,25 @@ nodes { z: 0.157 } type: TYPE_BOX + texture: "druid_example/pixel" id: "root" adjust_mode: ADJUST_MODE_STRETCH inherit_alpha: true } +nodes { + size { + x: 1040.0 + y: 50.0 + } + type: TYPE_BOX + id: "layout" + xanchor: XANCHOR_LEFT + adjust_mode: ADJUST_MODE_STRETCH + parent: "root" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO + visible: false +} nodes { position { x: -530.0 @@ -32,7 +47,7 @@ nodes { type: TYPE_BOX id: "group_memory" pivot: PIVOT_W - parent: "root" + parent: "layout" inherit_alpha: true visible: false } @@ -149,7 +164,7 @@ nodes { } nodes { position { - x: -130.0 + x: -31.0 } size { x: 16.0 @@ -158,7 +173,7 @@ nodes { type: TYPE_BOX texture: "druid_example/empty" id: "group_fps" - parent: "root" + parent: "layout" inherit_alpha: true visible: false } @@ -279,7 +294,7 @@ nodes { } nodes { position { - x: 130.0 + x: 355.0 } size { x: 16.0 @@ -288,7 +303,7 @@ nodes { type: TYPE_BOX texture: "druid_example/empty" id: "group_components" - parent: "root" + parent: "layout" inherit_alpha: true visible: false } @@ -366,95 +381,6 @@ nodes { outline_alpha: 0.0 shadow_alpha: 0.0 } -nodes { - position { - x: 530.0 - } - size { - x: 16.0 - y: 50.0 - } - type: TYPE_BOX - id: "group_events" - pivot: PIVOT_E - parent: "root" - inherit_alpha: true - visible: false -} -nodes { - position { - x: -163.0 - } - scale { - x: 0.8 - y: 0.8 - } - size { - x: 200.0 - y: 50.0 - } - color { - x: 0.306 - y: 0.31 - z: 0.314 - } - type: TYPE_TEXT - text: "Events" - font: "text_bold" - id: "text_events" - outline { - x: 1.0 - y: 1.0 - z: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - } - parent: "group_events" - layer: "text_bold" - inherit_alpha: true - outline_alpha: 0.0 - shadow_alpha: 0.0 -} -nodes { - position { - x: -59.0 - } - scale { - x: 0.8 - y: 0.8 - } - size { - x: 200.0 - y: 50.0 - } - color { - x: 0.463 - y: 0.475 - z: 0.49 - } - type: TYPE_TEXT - text: "6000" - font: "text_bold" - id: "text_events_amount" - outline { - x: 1.0 - y: 1.0 - z: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - } - parent: "group_events" - layer: "text_bold" - inherit_alpha: true - outline_alpha: 0.0 - shadow_alpha: 0.0 -} layers { name: "druid" } diff --git a/example/components/panel_druid_profiler/panel_druid_profiler.lua b/example/components/panel_druid_profiler/panel_druid_profiler.lua index f300711..233e50b 100644 --- a/example/components/panel_druid_profiler/panel_druid_profiler.lua +++ b/example/components/panel_druid_profiler/panel_druid_profiler.lua @@ -18,25 +18,30 @@ function M:init(template, nodes) self.group_memory = self.root:add_container("group_memory") self.group_fps = self.root:add_container("group_fps") self.group_components = self.root:add_container("group_components") - self.group_events = self.root:add_container("group_events") + + self.root:add_container("layout", nil, function() + self.layout:set_dirty() + end) + self.layout = self.druid:new_layout("layout", "horizontal") + self.layout:add(self.group_memory.node) + self.layout:add(self.group_fps.node) + self.layout:add(self.group_components.node) + self.layout:set_justify(true) self.druid:new_button("group_memory", self.run_collectgarbage) self.group_memory:set_min_size(270, nil) self.group_fps:set_min_size(270, nil) self.group_components:set_min_size(270, nil) - self.group_events:set_min_size(270, nil) self.text_memory_amount = self.druid:new_text("text_memory_amount") self.text_fps_amount = self.druid:new_text("text_fps_amount") self.text_fps_min = self.druid:new_text("text_fps_min") self.text_components_amount = self.druid:new_text("text_components_amount") - self.text_events_amount = self.druid:new_text("text_events_amount") self.druid:new_lang_text("text_memory", "ui_profiler_memory") self.druid:new_lang_text("text_fps", "ui_profiler_fps") self.druid:new_lang_text("text_components", "ui_profiler_components") - self.druid:new_lang_text("text_events", "ui_profiler_events") self.previous_time = nil self.fps_samples = {} @@ -55,17 +60,12 @@ function M:init(template, nodes) self:get_node("text_components"), self:get_node("text_components_amount"), } - self.nodes_events = { - self:get_node("text_events"), - self:get_node("text_events_amount"), - } timer.delay(0.16, true, function() self:update_memory() self:update_fps() self:update_components() - self:update_events() - self:align_fps_components() + self.layout:set_dirty() end) end @@ -74,8 +74,7 @@ function M:on_language_change() self:update_memory() self:update_fps() self:update_components() - self:update_events() - self:align_fps_components() + self.layout:set_dirty() end @@ -120,34 +119,6 @@ function M:update_components() end -function M:update_events() - self.text_events_amount:set_text("unsupported") - - local width = helper.centrate_nodes(2, unpack(self.nodes_events)) - for index = 1, #self.nodes_events do - local node = self.nodes_events[index] - local position_x = gui.get(node, "position.x") - gui.set(node, "position.x", position_x - width/2) - end - self.group_events:set_size(width, nil) -end - - -function M:align_fps_components() - local pos_x_memory = gui.get(self.group_memory.node, "position.x") + gui.get(self.group_memory.node, "size.x") - local pos_x_events = gui.get(self.group_events.node, "position.x") - gui.get(self.group_events.node, "size.x") - local width = pos_x_events - pos_x_memory - - -- Align FPS and Components - local fps_size = gui.get(self.group_fps.node, "size.x") - local components_size = gui.get(self.group_components.node, "size.x") - - local free_width = width - fps_size - components_size - gui.set(self.group_fps.node, "position.x", pos_x_memory + fps_size/2 + free_width/3) - gui.set(self.group_components.node, "position.x", pos_x_events - components_size/2 - free_width/3) -end - - function M:update() self:sample_fps() end diff --git a/example/druid.gui b/example/druid.gui index 5c805e3..1538aa4 100644 --- a/example/druid.gui +++ b/example/druid.gui @@ -4824,10 +4824,16 @@ nodes { } nodes { type: TYPE_BOX - id: "panel_druid_profiler/group_memory" + id: "panel_druid_profiler/layout" parent: "panel_druid_profiler/root" template_node_child: true } +nodes { + type: TYPE_BOX + id: "panel_druid_profiler/group_memory" + parent: "panel_druid_profiler/layout" + template_node_child: true +} nodes { type: TYPE_TEXT id: "panel_druid_profiler/text_memory" @@ -4849,7 +4855,7 @@ nodes { nodes { type: TYPE_BOX id: "panel_druid_profiler/group_fps" - parent: "panel_druid_profiler/root" + parent: "panel_druid_profiler/layout" template_node_child: true } nodes { @@ -4873,7 +4879,7 @@ nodes { nodes { type: TYPE_BOX id: "panel_druid_profiler/group_components" - parent: "panel_druid_profiler/root" + parent: "panel_druid_profiler/layout" template_node_child: true } nodes { @@ -4888,24 +4894,6 @@ nodes { parent: "panel_druid_profiler/group_components" template_node_child: true } -nodes { - type: TYPE_BOX - id: "panel_druid_profiler/group_events" - parent: "panel_druid_profiler/root" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "panel_druid_profiler/text_events" - parent: "panel_druid_profiler/group_events" - template_node_child: true -} -nodes { - type: TYPE_TEXT - id: "panel_druid_profiler/text_events_amount" - parent: "panel_druid_profiler/group_events" - template_node_child: true -} layers { name: "druid" } diff --git a/settings_deployer b/settings_deployer index e2a6722..155dcc9 100644 --- a/settings_deployer +++ b/settings_deployer @@ -2,7 +2,7 @@ bob_folder=./ # You can point bob version for project in format "filename:sha" -bob_sha="195:87b6907759f7b8dff830d54b2250b8d721bde291" +bob_sha="196:11d2cd3a9be17b2fc5a2cb5cea59bbfb4af1ca96" # Select Defold channel. Values: stable, beta, alpha bob_channel="stable" From 96ce3eee958b40161e36fe6c0e7520cb5918af66 Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 8 Feb 2025 00:11:29 +0200 Subject: [PATCH 47/50] Update --- .defignore | 3 +- .gitignore | 3 +- druid/base/button.lua | 3 +- druid/base/scroll.lua | 50 +++++++++++++++++--------- druid/base/text.lua | 4 +-- druid/component.lua | 9 ++--- druid/custom/rich_text/rich_text.lua | 2 +- druid/system/druid_annotations.lua | 34 ++---------------- druid/system/druid_instance.lua | 3 +- druid/widget/mini_graph/mini_graph.lua | 10 +++++- 10 files changed, 60 insertions(+), 61 deletions(-) diff --git a/.defignore b/.defignore index 3e22129..9447348 100644 --- a/.defignore +++ b/.defignore @@ -1 +1,2 @@ -/dist \ No newline at end of file +/dist +/.deployer_cache \ No newline at end of file diff --git a/.gitignore b/.gitignore index b8e9de9..6dced02 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ deployer_version_settings.txt bob*.jar manifest.private.der manifest.public.der -/.editor_settings \ No newline at end of file +/.editor_settings +/.deployer_cache diff --git a/druid/base/button.lua b/druid/base/button.lua index 345e00e..f1c48dc 100755 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -141,8 +141,9 @@ local const = require("druid.const") local helper = require("druid.helper") local component = require("druid.component") +---Clickable node with various interaction callbacks ---@class druid.button: druid.base_component ----@field on_click event +---@field on_click event function(self, custom_args, button_instance) ---@field on_pressed event ---@field on_repeated_click event ---@field on_long_click event diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index fd9d8ab..172899d 100755 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -91,14 +91,30 @@ local helper = require("druid.helper") local component = require("druid.component") ---@class druid.scroll: druid.base_component ----@field on_scroll event ----@field on_scroll_to event ----@field on_point_scroll event ----@field view_node node ----@field view_border vector4 ----@field content_node node ----@field view_size vector3 ----@field position vector3 +---@field node node +---@field click_zone node|nil +---@field on_scroll event On scroll move callback(self, position) +---@field on_scroll_to event On scroll_to function callback(self, target, is_instant) +---@field on_point_scroll event On scroll_to_index function callback(self, index, point) +---@field view_node node Scroll view node +---@field view_border vector4 Scroll view border +---@field content_node node Scroll content node +---@field view_size vector3 Scroll view size +---@field position vector3 Current scroll position +---@field target_position vector3 Current scroll target position +---@field available_pos vector4 Available position for content node: (min_x, max_y, max_x, min_y) +---@field available_size vector3 Size of available positions: (width, height, 0) +---@field drag druid.drag Drag Druid component +---@field selected number|nil Current index of points of interests +---@field is_animate boolean Flag, if scroll now animating by gui.animate +---@field private _is_inert boolean Flag, if scroll now moving by inertion +---@field private inertion vector3 Current inert speed +---@field private _is_horizontal_scroll boolean Flag, if scroll now horizontal +---@field private _is_vertical_scroll boolean Flag, if scroll now vertical +---@field private _grid_on_change event Grid on change items event +---@field private _grid_on_change_callback function Grid on change items callback +---@field private _offset vector3 Offset value to set, where content is starts +---@field private style table Component style params local M = component.create("scroll") @@ -228,8 +244,8 @@ end function M:update(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.position.x = gui.get(self.content_node, "position.x") --[[@as number]] + self.position.y = gui.get(self.content_node, "position.y") --[[@as number]] self.on_scroll:trigger(self:get_context(), self.position) end @@ -383,7 +399,7 @@ end --- Enable or disable scroll inert. -- If disabled, scroll through points (if exist) -- If no points, just simple drag without inertion ----@param state boolean|nil Inert scroll state +---@param state boolean Inert scroll state ---@return druid.scroll Current scroll instance function M:set_inert(state) self._is_inert = state @@ -436,21 +452,21 @@ end --- Lock or unlock horizontal scroll ----@param state boolean|nil True, if horizontal scroll is enabled +---@param state boolean True, if horizontal scroll is enabled ---@return druid.scroll Current scroll instance function M:set_horizontal_scroll(state) self._is_horizontal_scroll = state - self.drag.can_x = self.available_size.x > 0 and state + self.drag.can_x = self.available_size.x > 0 and state or false return self end --- Lock or unlock vertical scroll ----@param state boolean|nil True, if vertical scroll is enabled +---@param state boolean True, if vertical scroll is enabled ---@return druid.scroll Current scroll instance function M:set_vertical_scroll(state) self._is_vertical_scroll = state - self.drag.can_y = self.available_size.y > 0 and state + self.drag.can_y = self.available_size.y > 0 and state or false return self end @@ -497,7 +513,7 @@ end --- Bind the grid component (Static or Dynamic) to recalculate -- scroll size on grid changes ----@param grid druid.grid Druid grid component +---@param grid druid.grid|nil Druid grid component ---@return druid.scroll Current scroll instance function M:bind_grid(grid) if self._grid_on_change then @@ -508,7 +524,7 @@ function M:bind_grid(grid) end if not grid then - return + return self end self._grid_on_change = grid.on_change_items diff --git a/druid/base/text.lua b/druid/base/text.lua index 461299f..a0cd877 100755 --- a/druid/base/text.lua +++ b/druid/base/text.lua @@ -89,7 +89,7 @@ local utf8 = utf8 or utf8_lua --[[@as utf8]] ---@field on_update_text_scale event ---@field on_set_pivot event ---@field style table ----@field private start_pivot number +---@field private start_pivot userdata ---@field private start_scale vector3 ---@field private scale vector3 local M = component.create("text") @@ -491,7 +491,7 @@ end --- Set text pivot. Text will re-anchor inside text area ----@param pivot number The gui.PIVOT_* constant +---@param pivot userdata The gui.PIVOT_* constant ---@return druid.text Current text instance function M:set_pivot(pivot) local prev_pivot = gui.get_pivot(self.node) diff --git a/druid/component.lua b/druid/component.lua index df216eb..0156fad 100644 --- a/druid/component.lua +++ b/druid/component.lua @@ -4,7 +4,7 @@ local helper = require("druid.helper") ---@class druid.base_component.meta ---@field template string ---@field context table ----@field nodes table|nil +---@field nodes table|nil ---@field style table|nil ---@field druid druid_instance ---@field input_enabled boolean @@ -41,6 +41,7 @@ local INTERESTS = {} -- Cache interests per component class in runtime local uid = 0 +---@private function M.create_uid() uid = uid + 1 return uid @@ -107,7 +108,7 @@ end ---Set current component nodes, returned from `gui.clone_tree` function. ----@param nodes table +---@param nodes table ---@return druid.base_component function M:set_nodes(nodes) self._meta.nodes = nodes @@ -132,7 +133,7 @@ end ---Get Druid instance for inner component creation. ---@param template string|nil ----@param nodes table|nil +---@param nodes table|nil ---@return druid_instance function M:get_druid(template, nodes) local context = { _context = self } @@ -305,7 +306,7 @@ end ---Get current component nodes ----@return table +---@return table|nil function M:get_nodes() local nodes = self._meta.nodes local parent = self:get_parent_component() diff --git a/druid/custom/rich_text/rich_text.lua b/druid/custom/rich_text/rich_text.lua index 91f9da2..30d1c35 100644 --- a/druid/custom/rich_text/rich_text.lua +++ b/druid/custom/rich_text/rich_text.lua @@ -272,7 +272,7 @@ end ---@return druid.rich_text.word[] words function M:tagged(tag) if not self._words then - return + return {} end return rich_text.tagged(self._words, tag) diff --git a/druid/system/druid_annotations.lua b/druid/system/druid_annotations.lua index 60f45ae..68d2ac0 100644 --- a/druid/system/druid_annotations.lua +++ b/druid/system/druid_annotations.lua @@ -1,5 +1,6 @@ ---@class druid.widget: druid.base_component ----@field druid druid_instance +---@field druid druid_instance Ready to use druid instance +---@field root node ---@class GUITextMetrics ---@field width number @@ -23,33 +24,4 @@ ---@field format fun() ---@field lower fun() ---@field upper fun() ----@field rep fun() - ----@class action ----@field value number The amount of input given by the user. This is usually 1 for buttons and 0-1 for analogue inputs. This is not present for mouse movement. ----@field pressed boolean If the input was pressed this frame. This is not present for mouse movement. ----@field released boolean If the input was released this frame. This is not present for mouse movement. ----@field repeated boolean If the input was repeated this frame. This is similar to how a key on a keyboard is repeated when you hold it down. This is not present for mouse movement. ----@field x number The x value of a pointer device, if present. ----@field y number The y value of a pointer device, if present. ----@field screen_x number The screen space x value of a pointer device, if present. ----@field screen_y number The screen space y value of a pointer device, if present. ----@field dx number The change in x value of a pointer device, if present. ----@field dy number The change in y value of a pointer device, if present. ----@field screen_dx number The change in screen space x value of a pointer device, if present. ----@field screen_dy number The change in screen space y value of a pointer device, if present. ----@field gamepad number The index of the gamepad device that provided the input. ----@field touch touch[] List of touch input, one element per finger, if present. See table below about touch input - ----@class touch ----@field id number A number identifying the touch input during its duration. ----@field pressed boolean True if the finger was pressed this frame. ----@field released boolean True if the finger was released this frame. ----@field tap_count number Number of taps, one for single, two for double-tap, etc ----@field x number The x touch location. ----@field y number The y touch location. ----@field dx number The change in x value. ----@field dy number The change in y value. ----@field acc_x number|nil Accelerometer x value (if present). ----@field acc_y number|nil Accelerometer y value (if present). ----@field acc_z number|nil Accelerometer z value (if present). +---@field rep fun() \ No newline at end of file diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index 3749c79..e3ba150 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -200,8 +200,7 @@ end --- Druid class constructor ---@param context table Druid context. Usually it is self of gui script ----@param style table Druid style table ----@private +---@param style table? Druid style table function M:initialize(context, style) self._context = context self._style = style or settings.default_style diff --git a/druid/widget/mini_graph/mini_graph.lua b/druid/widget/mini_graph/mini_graph.lua index eb4a37b..3cebd5b 100644 --- a/druid/widget/mini_graph/mini_graph.lua +++ b/druid/widget/mini_graph/mini_graph.lua @@ -69,6 +69,15 @@ function M:set_samples(samples) end +function M:get_samples() + return self.samples +end + + +---Set normalized to control the color of the line +--- for index = 1, mini_graph:get_samples() do +--- mini_graph:set_line_value(index, math.random()) +--- end ---@param index number ---@param value number The normalized value from 0 to 1 function M:set_line_value(index, value) @@ -83,7 +92,6 @@ function M:set_line_value(index, value) local target_color = color.lerp(normalized, self.color_zero, self.color_one) gui.set_color(line, target_color) self:set_line_height(index) - end From 7a6f529c82b04a83e898efb008b2cb3cbecd0071 Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 8 Feb 2025 00:28:20 +0200 Subject: [PATCH 48/50] Update --- druid/base/scroll.lua | 5 +++-- druid/base/static_grid.lua | 8 +++++--- druid/component.lua | 2 +- druid/custom/rich_text/rich_text.lua | 7 +++++++ druid/extended/lang_text.lua | 2 +- druid/system/druid_instance.lua | 10 +++++----- druid/widget/properties_panel/properties_panel.lua | 7 +++++-- 7 files changed, 27 insertions(+), 14 deletions(-) diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index 172899d..aec7977 100755 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -528,11 +528,12 @@ function M:bind_grid(grid) end self._grid_on_change = grid.on_change_items - self._grid_on_change_callback = self._grid_on_change:subscribe(function() + self._grid_on_change_callback = function() local size = grid:get_size() local offset = grid:get_offset() self:set_size(size, offset) - end) + end + self._grid_on_change:subscribe(self._grid_on_change_callback) self:set_size(grid:get_size(), grid:get_offset()) return self diff --git a/druid/base/static_grid.lua b/druid/base/static_grid.lua index 7788d99..a138fe2 100644 --- a/druid/base/static_grid.lua +++ b/druid/base/static_grid.lua @@ -201,7 +201,7 @@ end --- Return grid index by node ---@param node node The gui node in the grid ----@return number The node index +---@return number|nil index The node index function M:get_index_by_node(node) for index, grid_node in pairs(self.nodes) do if node == grid_node then @@ -356,7 +356,7 @@ end --- Return grid content borders ----@return vector3 The grid content borders +---@return vector4 The grid content borders function M:get_borders() return self.border end @@ -463,10 +463,12 @@ end --- Sort grid nodes by custom comparator function ---@param comparator function The comparator function. (a, b) -> boolean ----@return druid.grid Current grid instance +---@return druid.grid self Current grid instance function M:sort_nodes(comparator) table.sort(self.nodes, comparator) self:_update(true) + + return self end diff --git a/druid/component.lua b/druid/component.lua index 0156fad..3c82000 100644 --- a/druid/component.lua +++ b/druid/component.lua @@ -25,7 +25,7 @@ local helper = require("druid.helper") ---@field update fun(self:druid.base_component, dt:number)|nil ---@field on_remove fun(self:druid.base_component)|nil ---@field on_input fun(self:druid.base_component, action_id:number, action:table)|nil ----@field on_message fun(self:druid.base_component, message_id:hash, message:table, sender:userdata)|nil +---@field on_message fun(self:druid.base_component, message_id:hash, message:table, sender:url)|nil ---@field on_late_init fun(self:druid.base_component)|nil ---@field on_focus_lost fun(self:druid.base_component)|nil ---@field on_focus_gained fun(self:druid.base_component)|nil diff --git a/druid/custom/rich_text/rich_text.lua b/druid/custom/rich_text/rich_text.lua index 30d1c35..80deec4 100644 --- a/druid/custom/rich_text/rich_text.lua +++ b/druid/custom/rich_text/rich_text.lua @@ -121,6 +121,13 @@ local rich_text = require("druid.custom.rich_text.module.rt") ---@field width number ---@field height number +---@class druid.rich_text.style +---@field COLORS table +---@field ADJUST_STEPS number +---@field ADJUST_SCALE_DELTA number +---@field ADJUST_TYPE string +---@field ADJUST_SCALE number + ---@class druid.rich_text.lines_metrics ---@field text_width number ---@field text_height number diff --git a/druid/extended/lang_text.lua b/druid/extended/lang_text.lua index 8c8c276..d0745c9 100755 --- a/druid/extended/lang_text.lua +++ b/druid/extended/lang_text.lua @@ -71,7 +71,7 @@ end ---@param text string Text for text node ---@return druid.lang_text Current instance function M:set_to(text) - self.last_locale = false + self.last_locale = nil self.text:set_text(text) self.on_change:trigger() diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index e3ba150..f9d0de2 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -474,14 +474,14 @@ end ---@generic T: druid.base_component ---@param widget T ---@param template string|nil The template name used by widget ----@param nodes table|node|nil The nodes table from gui.clone_tree or prefab node to use for clone +---@param nodes table|node|nil The nodes table from gui.clone_tree or prefab node to use for clone ---@vararg any ---@return T function M:new_widget(widget, template, nodes, ...) local instance = create_widget(self, widget) if type(nodes) == "userdata" then - nodes = gui.clone_tree(nodes) + nodes = gui.clone_tree(nodes) --[[@as table]] end instance.druid = instance:get_druid(template, nodes) @@ -543,10 +543,10 @@ local text = require("druid.base.text") ---Create Text component ---@param node string|node The node_id or gui.get_node(node_id) ---@param value string|nil Initial text. Default value is node text from GUI scene. ----@param no_adjust boolean|nil If true, text will be not auto-adjust size +---@param adjust_type string|nil Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference ---@return druid.text Text component -function M:new_text(node, value, no_adjust) - return self:new(text, node, value, no_adjust) +function M:new_text(node, value, adjust_type) + return self:new(text, node, value, adjust_type) end diff --git a/druid/widget/properties_panel/properties_panel.lua b/druid/widget/properties_panel/properties_panel.lua index f19af12..cae5d3f 100644 --- a/druid/widget/properties_panel/properties_panel.lua +++ b/druid/widget/properties_panel/properties_panel.lua @@ -136,7 +136,10 @@ function M:on_size_changed(new_size) local width = self.layout:get_size().x - self.layout.padding.x - self.layout.padding.z for index = 1, #self.properties do - self.properties[index].container:set_size(width) + local property = self.properties[index] + if property.container then + property.container:set_size(width) + end end self.paginator.container:set_size(width) end @@ -216,7 +219,7 @@ end ---@generic T: druid.widget ---@param widget_class T ---@param template string|nil ----@param nodes table|node|nil +---@param nodes table|node|nil ---@param on_create fun(widget: T)|nil ---@return widget.properties_panel function M:add_inner_widget(widget_class, template, nodes, on_create) From 16d20da5ab305dd748536b2c5a175a6e8b287897 Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 8 Feb 2025 00:31:35 +0200 Subject: [PATCH 49/50] Update --- druid/system/druid_instance.lua | 46 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index f9d0de2..774b9e3 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -88,17 +88,17 @@ local function create_widget(self, widget_class) local uid = base_component.create_uid() instance._component = { _uid = uid, - name = "Druid Widget #" .. uid, + name = "Druid Widget", input_priority = const.PRIORITY_INPUT, default_input_priority = const.PRIORITY_INPUT, _is_input_priority_changed = true, -- Default true for sort once time after GUI init } instance._meta = { - template = "", - context = self._context, - nodes = nil, - style = nil, druid = self, + template = "", + nodes = nil, + context = self._context, + style = nil, input_enabled = true, children = {}, parent = type(self._context) ~= "userdata" and self._context, @@ -512,7 +512,7 @@ end local blocker = require("druid.base.blocker") ---Create Blocker component ---@param node string|node The node_id or gui.get_node(node_id) ----@return druid.blocker Blocker component +---@return druid.blocker component Blocker component function M:new_blocker(node) return self:new(blocker, node) end @@ -522,7 +522,7 @@ local back_handler = require("druid.base.back_handler") ---Create BackHandler component ---@param callback function|nil The callback(self, custom_args) to call on back event ---@param params any|nil Callback argument ----@return druid.back_handler BackHandler component +---@return druid.back_handler component BackHandler component function M:new_back_handler(callback, params) return self:new(back_handler, callback, params) end @@ -533,7 +533,7 @@ local hover = require("druid.base.hover") ---@param node string|node The node_id or gui.get_node(node_id) ---@param on_hover_callback function|nil Hover callback ---@param on_mouse_hover_callback function|nil Mouse hover callback ----@return druid.hover Hover component +---@return druid.hover component Hover component function M:new_hover(node, on_hover_callback, on_mouse_hover_callback) return self:new(hover, node, on_hover_callback, on_mouse_hover_callback) end @@ -544,7 +544,7 @@ local text = require("druid.base.text") ---@param node string|node The node_id or gui.get_node(node_id) ---@param value string|nil Initial text. Default value is node text from GUI scene. ---@param adjust_type string|nil Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference ----@return druid.text Text component +---@return druid.text component Text component function M:new_text(node, value, adjust_type) return self:new(text, node, value, adjust_type) end @@ -555,7 +555,7 @@ local static_grid = require("druid.base.static_grid") ---@param parent_node string|node The node_id or gui.get_node(node_id). Parent of all Grid items. ---@param item string|node Item prefab. Required to get grid's item size. Can be adjusted separately. ---@param in_row number|nil How many nodes in row can be placed ----@return druid.grid grid component +---@return druid.grid component Grid component function M:new_grid(parent_node, item, in_row) return self:new(static_grid, parent_node, item, in_row) end @@ -565,7 +565,7 @@ local scroll = require("druid.base.scroll") ---Create Scroll component ---@param view_node string|node The node_id or gui.get_node(node_id). Will used as user input node. ---@param content_node string|node The node_id or gui.get_node(node_id). Will used as scrollable node inside view_node. ----@return druid.scroll Scroll component +---@return druid.scroll component Scroll component function M:new_scroll(view_node, content_node) return self:new(scroll, view_node, content_node) end @@ -575,7 +575,7 @@ local drag = require("druid.base.drag") ---Create Drag component ---@param node string|node The node_id or gui.get_node(node_id). Will used as user input node. ---@param on_drag_callback function|nil Callback for on_drag_event(self, dx, dy) ----@return druid.drag Drag component +---@return druid.drag component Drag component function M:new_drag(node, on_drag_callback) return self:new(drag, node, on_drag_callback) end @@ -585,7 +585,7 @@ local swipe = require("druid.extended.swipe") ---Create Swipe component ---@param node string|node The node_id or gui.get_node(node_id). Will used as user input node. ---@param on_swipe_callback function|nil Swipe callback for on_swipe_end event ----@return druid.swipe Swipe component +---@return druid.swipe component Swipe component function M:new_swipe(node, on_swipe_callback) return self:new(swipe, node, on_swipe_callback) end @@ -596,7 +596,7 @@ local lang_text = require("druid.extended.lang_text") ---@param node string|node The_node id or gui.get_node(node_id) ---@param locale_id string|nil Default locale id or text from node as default ---@param adjust_type string|nil Adjust type for text node. Default: const.TEXT_ADJUST.DOWNSCALE ----@return druid.lang_text lang_text component +---@return druid.lang_text component LangText component function M:new_lang_text(node, locale_id, adjust_type) return self:new(lang_text, node, locale_id, adjust_type) end @@ -607,7 +607,7 @@ local slider = require("druid.extended.slider") ---@param pin_node string|node The_node id or gui.get_node(node_id). ---@param end_pos vector3 The end position of slider ---@param callback function|nil On slider change callback ----@return druid.slider slider component +---@return druid.slider component Slider component function M:new_slider(pin_node, end_pos, callback) return self:new(slider, pin_node, end_pos, callback) end @@ -618,7 +618,7 @@ local input = require("druid.extended.input") ---@param click_node string|node Button node to enabled input component ---@param text_node string|node|druid.text Text node what will be changed on user input ---@param keyboard_type number|nil Gui keyboard type for input field ----@return druid.input input component +---@return druid.input component Input component function M:new_input(click_node, text_node, keyboard_type) return self:new(input, click_node, text_node, keyboard_type) end @@ -629,7 +629,7 @@ local data_list = require("druid.extended.data_list") ---@param druid_scroll druid.scroll The Scroll instance for Data List component ---@param druid_grid druid.grid The StaticGrid} or @{DynamicGrid instance for Data List component ---@param create_function function The create function callback(self, data, index, data_list). Function should return (node, [component]) ----@return druid.data_list data_list component +---@return druid.data_list component DataList component function M:new_data_list(druid_scroll, druid_grid, create_function) return self:new(data_list, druid_scroll, druid_grid, create_function) end @@ -641,7 +641,7 @@ local timer_component = require("druid.extended.timer") ---@param seconds_from number|nil Start timer value in seconds ---@param seconds_to number|nil End timer value in seconds ---@param callback function|nil Function on timer end ----@return druid.timer timer component +---@return druid.timer component Timer component function M:new_timer(node, seconds_from, seconds_to, callback) return self:new(timer_component, node, seconds_from, seconds_to, callback) end @@ -652,7 +652,7 @@ local progress = require("druid.extended.progress") ---@param node string|node Progress bar fill node or node name ---@param key string Progress bar direction: const.SIDE.X or const.SIDE.Y ---@param init_value number|nil Initial value of progress bar. Default: 1 ----@return druid.progress progress component +---@return druid.progress component Progress component function M:new_progress(node, key, init_value) return self:new(progress, node, key, init_value) end @@ -662,7 +662,7 @@ local layout = require("druid.extended.layout") ---Create Layout component ---@param node string|node The_node id or gui.get_node(node_id). ---@param mode string|nil vertical|horizontal|horizontal_wrap. Default: horizontal ----@return druid.layout layout component +---@return druid.layout component Layout component function M:new_layout(node, mode) return self:new(layout, node, mode) end @@ -684,7 +684,7 @@ local hotkey = require("druid.extended.hotkey") ---@param keys_array string|string[] Keys for trigger action. Should contains one action key and any amount of modificator keys ---@param callback function|nil The callback function ---@param callback_argument any|nil The argument to pass into the callback function ----@return druid.hotkey hotkey component +---@return druid.hotkey component Hotkey component function M:new_hotkey(keys_array, callback, callback_argument) return self:new(hotkey, keys_array, callback, callback_argument) end @@ -694,7 +694,7 @@ local rich_text = require("druid.custom.rich_text.rich_text") ---Create RichText component. ---@param text_node string|node The text node to make Rich Text ---@param value string|nil The initial text value. Default will be gui.get_text(text_node) ----@return druid.rich_text RichText component +---@return druid.rich_text component RichText component function M:new_rich_text(text_node, value) return self:new(rich_text, text_node, value) end @@ -705,7 +705,7 @@ local rich_input = require("druid.custom.rich_input.rich_input") -- As a template please check rich_input.gui layout. ---@param template string The template string name ---@param nodes table|nil Nodes table from gui.clone_tree ----@return druid.rich_input RichInput component +---@return druid.rich_input component RichInput component function M:new_rich_input(template, nodes) return self:new(rich_input, template, nodes) end From d06ebd53f9aa2845420e6d588e29fa72c3906f54 Mon Sep 17 00:00:00 2001 From: Insality Date: Sun, 9 Feb 2025 14:42:25 +0200 Subject: [PATCH 50/50] Update --- docs_md/api_reference/druid_button.md | 0 docs_md/quick_api_reference.md | 74 +++++++++++++++++++++++++++ druid/base/scroll.lua | 46 ++++++++--------- druid/custom/rich_text/module/rt.lua | 2 +- druid/custom/rich_text/rich_text.lua | 1 + druid/system/druid_annotations.lua | 4 +- druid/system/druid_instance.lua | 3 +- 7 files changed, 103 insertions(+), 27 deletions(-) create mode 100644 docs_md/api_reference/druid_button.md create mode 100644 docs_md/quick_api_reference.md diff --git a/docs_md/api_reference/druid_button.md b/docs_md/api_reference/druid_button.md new file mode 100644 index 0000000..e69de29 diff --git a/docs_md/quick_api_reference.md b/docs_md/quick_api_reference.md new file mode 100644 index 0000000..e53c5d1 --- /dev/null +++ b/docs_md/quick_api_reference.md @@ -0,0 +1,74 @@ +# Quick API Reference + +## Druid +```lua +local druid = require("druid.druid") + +druid.init_window_listener() +druid.on_language_change() +druid.on_window_callback(window_event) +druid.set_default_style(style) +druid.set_sound_function(callback) +druid.set_text_function(callback) + +self.druid = druid.new(context, [style]) +``` + +## Druid Instance +```lua +self.druid:final() +self.druid:update(dt) +self.druid:on_input(action_id, action) +self.druid:on_message(message_id, message, sender) + +self.druid:new(component, ...) +self.druid:new_back_handler([callback], [params]) +self.druid:new_blocker(node) +self.druid:new_button(node, [callback], [params], [anim_node]) +self.druid:new_container(node, [mode], [callback]) +self.druid:new_data_list(druid_scroll, druid_grid, create_function) +self.druid:new_drag(node, [on_drag_callback]) +self.druid:new_grid(parent_node, item, [in_row]) +self.druid:new_hotkey(keys_array, [callback], [callback_argument]) +self.druid:new_hover(node, [on_hover_callback], [on_mouse_hover_callback]) +self.druid:new_input(click_node, text_node, [keyboard_type]) +self.druid:new_lang_text(node, [locale_id], [adjust_type]) +self.druid:new_layout(node, [mode]) +self.druid:new_progress(node, key, [init_value]) +self.druid:new_rich_input(template, [nodes]) +self.druid:new_rich_text(text_node, [value]) +self.druid:new_scroll(view_node, content_node) +self.druid:new_slider(pin_node, end_pos, [callback]) +self.druid:new_swipe(node, [on_swipe_callback]) +self.druid:new_text(node, [value], [no_adjust]) +self.druid:new_timer(node, [seconds_from], [seconds_to], [callback]) +self.druid:new_widget(widget, [template], [nodes], ...) +self.druid:on_window_event([window_event]) +self.druid:remove(component) +self.druid:set_blacklist(blacklist_components) +self.druid:set_whitelist(whitelist_components) +``` + +## Components +### Base Component +### Blocker +### Button +### Container +### Data List +### Drag +### Grid +### Hotkey +### Hover +### Input +### Lang Text +### Layout +### Progress +### Rich Input +### Rich Text +### Scroll +### Slider +### Swipe +### Text +### Timer + +## Helper diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index aec7977..4bd7f75 100755 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -91,30 +91,30 @@ local helper = require("druid.helper") local component = require("druid.component") ---@class druid.scroll: druid.base_component ----@field node node ----@field click_zone node|nil ----@field on_scroll event On scroll move callback(self, position) ----@field on_scroll_to event On scroll_to function callback(self, target, is_instant) ----@field on_point_scroll event On scroll_to_index function callback(self, index, point) ----@field view_node node Scroll view node ----@field view_border vector4 Scroll view border ----@field content_node node Scroll content node ----@field view_size vector3 Scroll view size +---@field node node The root node +---@field click_zone node|nil Optional click zone to restrict scroll area +---@field on_scroll event Triggered on scroll move with (self, position) +---@field on_scroll_to event Triggered on scroll_to with (self, target, is_instant) +---@field on_point_scroll event Triggered on scroll_to_index with (self, index, point) +---@field view_node node The scroll view node (static part) +---@field view_border vector4 The scroll view borders +---@field content_node node The scroll content node (moving part) +---@field view_size vector3 Size of the view node ---@field position vector3 Current scroll position ----@field target_position vector3 Current scroll target position ----@field available_pos vector4 Available position for content node: (min_x, max_y, max_x, min_y) ----@field available_size vector3 Size of available positions: (width, height, 0) ----@field drag druid.drag Drag Druid component ----@field selected number|nil Current index of points of interests ----@field is_animate boolean Flag, if scroll now animating by gui.animate ----@field private _is_inert boolean Flag, if scroll now moving by inertion ----@field private inertion vector3 Current inert speed ----@field private _is_horizontal_scroll boolean Flag, if scroll now horizontal ----@field private _is_vertical_scroll boolean Flag, if scroll now vertical ----@field private _grid_on_change event Grid on change items event ----@field private _grid_on_change_callback function Grid on change items callback ----@field private _offset vector3 Offset value to set, where content is starts ----@field private style table Component style params +---@field target_position vector3 Target scroll position for animations +---@field available_pos vector4 Available content position (min_x, max_y, max_x, min_y) +---@field available_size vector3 Size of available positions (width, height, 0) +---@field drag druid.drag The drag component instance +---@field selected number|nil Current selected point of interest index +---@field is_animate boolean True if scroll is animating +---@field private _is_inert boolean True if inertial scrolling is enabled +---@field private inertion vector3 Current inertial movement vector +---@field private _is_horizontal_scroll boolean True if horizontal scroll enabled +---@field private _is_vertical_scroll boolean True if vertical scroll enabled +---@field private _grid_on_change event Grid items change event +---@field private _grid_on_change_callback function Grid change callback +---@field private _offset vector3 Content start offset +---@field private style table Component style parameters local M = component.create("scroll") diff --git a/druid/custom/rich_text/module/rt.lua b/druid/custom/rich_text/module/rt.lua index 83d1b85..8239877 100755 --- a/druid/custom/rich_text/module/rt.lua +++ b/druid/custom/rich_text/module/rt.lua @@ -424,7 +424,7 @@ function M._update_nodes(lines, settings) gui.set_outline(node, word.outline) gui.set_shadow(node, word.shadow) gui.set_text(node, word.text) - gui.set_color(node, word.color or word.text_color) + gui.set_color(node, word.color) gui.set_font(node, word.font or settings.font) end word.node = node diff --git a/druid/custom/rich_text/rich_text.lua b/druid/custom/rich_text/rich_text.lua index 80deec4..6e2fb8d 100644 --- a/druid/custom/rich_text/rich_text.lua +++ b/druid/custom/rich_text/rich_text.lua @@ -100,6 +100,7 @@ local rich_text = require("druid.custom.rich_text.module.rt") ---@class druid.rich_text.word ---@field node node ---@field relative_scale number +---@field source_text string ---@field color vector4 ---@field position vector3 ---@field offset vector3 diff --git a/druid/system/druid_annotations.lua b/druid/system/druid_annotations.lua index 68d2ac0..a08b449 100644 --- a/druid/system/druid_annotations.lua +++ b/druid/system/druid_annotations.lua @@ -7,6 +7,8 @@ ---@field height number ---@field max_ascent number ---@field max_descent number +---@field offset_x number +---@field offset_y number ---@class utf8 ---@field len fun(s: string):number @@ -24,4 +26,4 @@ ---@field format fun() ---@field lower fun() ---@field upper fun() ----@field rep fun() \ No newline at end of file +---@field rep fun() diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index 774b9e3..beca2d1 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -85,9 +85,8 @@ local function create_widget(self, widget_class) __index = setmetatable(widget_class, WIDGET_METATABLE) }) - local uid = base_component.create_uid() instance._component = { - _uid = uid, + _uid = base_component.create_uid(), name = "Druid Widget", input_priority = const.PRIORITY_INPUT, default_input_priority = const.PRIORITY_INPUT,