From 999c6222a0029529a1a58f100e9438e14c71bda5 Mon Sep 17 00:00:00 2001 From: Insality Date: Thu, 7 Nov 2024 18:32:46 +0100 Subject: [PATCH] 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)