mirror of
https://github.com/Insality/druid
synced 2025-06-27 18:37:45 +02:00
Replace event with event library
This commit is contained in:
parent
6552ea5cac
commit
c00fb3590c
@ -1,9 +1,9 @@
|
|||||||
local event = require("druid.event")
|
local event = require("event.event")
|
||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
---@class druid.back_handler: druid.base_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
|
---@field params any|nil Custom args to pass in the callback
|
||||||
local M = component.create("back_handler")
|
local M = component.create("back_handler")
|
||||||
|
|
||||||
|
@ -35,16 +35,16 @@
|
|||||||
-- @alias druid.button
|
-- @alias druid.button
|
||||||
|
|
||||||
|
|
||||||
--- The druid.event: Event on successful release action over button.
|
--- The event: Event on successful release action over button.
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- Custom args passed in Button constructor
|
-- -- Custom args passed in Button constructor
|
||||||
-- button.on_click:subscribe(function(self, custom_args, button_instance)
|
-- button.on_click:subscribe(function(self, custom_args, button_instance)
|
||||||
-- print("On button click!")
|
-- print("On button click!")
|
||||||
-- end)
|
-- 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
|
-- This callback will be triggered if user hold the button. The repeat rate pick from `input.repeat_interval` in game.project
|
||||||
-- @usage
|
-- @usage
|
||||||
@ -52,10 +52,10 @@
|
|||||||
-- button.on_repeated_click:subscribe(function(self, custom_args, button_instance, click_count)
|
-- button.on_repeated_click:subscribe(function(self, custom_args, button_instance, click_count)
|
||||||
-- print("On repeated Button click!")
|
-- print("On repeated Button click!")
|
||||||
-- end)
|
-- 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.
|
-- 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
|
-- 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)
|
-- button.on_long_click:subscribe(function(self, custom_args, button_instance, hold_time)
|
||||||
-- print("On long Button click!")
|
-- print("On long Button click!")
|
||||||
-- end)
|
-- 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
|
-- If secondary click was too fast after previous one, the double
|
||||||
-- click will be called instead usual click (if on_double_click subscriber exists)
|
-- 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)
|
-- button.on_double_click:subscribe(function(self, custom_args, button_instance, click_amount)
|
||||||
-- print("On double Button click!")
|
-- print("On double Button click!")
|
||||||
-- end)
|
-- 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.
|
-- 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)
|
-- button.on_double_click:subscribe(function(self, custom_args, button_instance, time)
|
||||||
-- print("On hold Button callback!")
|
-- print("On hold Button callback!")
|
||||||
-- end)
|
-- 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
|
-- 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)
|
-- button.on_click_outside:subscribe(function(self, custom_args, button_instance)
|
||||||
-- print("On click Button outside!")
|
-- print("On click Button outside!")
|
||||||
-- end)
|
-- 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
|
-- @usage
|
||||||
-- -- Custom args passed in Button constructor
|
-- -- Custom args passed in Button constructor
|
||||||
-- button.on_pressed:subscribe(function(self, custom_args, button_instance)
|
-- button.on_pressed:subscribe(function(self, custom_args, button_instance)
|
||||||
-- print("On Button pressed!")
|
-- print("On Button pressed!")
|
||||||
-- end)
|
-- end)
|
||||||
-- @tfield druid.event on_pressed druid.event
|
-- @tfield event on_pressed event
|
||||||
|
|
||||||
--- Button trigger node
|
--- Button trigger node
|
||||||
-- @tfield node node
|
-- @tfield node node
|
||||||
@ -136,19 +136,19 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
local Event = require("druid.event")
|
local event = require("event.event")
|
||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
---@class druid.button: druid.base_component
|
---@class druid.button: druid.base_component
|
||||||
---@field on_click druid.event
|
---@field on_click event
|
||||||
---@field on_pressed druid.event
|
---@field on_pressed event
|
||||||
---@field on_repeated_click druid.event
|
---@field on_repeated_click event
|
||||||
---@field on_long_click druid.event
|
---@field on_long_click event
|
||||||
---@field on_double_click druid.event
|
---@field on_double_click event
|
||||||
---@field on_hold_callback druid.event
|
---@field on_hold_callback event
|
||||||
---@field on_click_outside druid.event
|
---@field on_click_outside event
|
||||||
---@field node node
|
---@field node node
|
||||||
---@field node_id hash
|
---@field node_id hash
|
||||||
---@field anim_node node
|
---@field anim_node node
|
||||||
@ -229,6 +229,7 @@ local function on_button_hold(self, press_time)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@param self druid.button
|
||||||
local function on_button_release(self)
|
local function on_button_release(self)
|
||||||
if self.is_repeated_started then
|
if self.is_repeated_started then
|
||||||
return false
|
return false
|
||||||
@ -253,10 +254,10 @@ local function on_button_release(self)
|
|||||||
|
|
||||||
local time = socket.gettime()
|
local time = socket.gettime()
|
||||||
local is_long_click = (time - self.last_pressed_time) >= self.style.LONGTAP_TIME
|
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
|
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
|
if is_long_click then
|
||||||
local is_hold_complete = (time - self.last_pressed_time) >= self.style.AUTOHOLD_TRIGGER
|
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
|
self._is_html5_listener_set = false
|
||||||
|
|
||||||
-- Events
|
-- Events
|
||||||
self.on_click = Event(callback)
|
self.on_click = event.create(callback)
|
||||||
self.on_pressed = Event()
|
self.on_pressed = event.create()
|
||||||
self.on_repeated_click = Event()
|
self.on_repeated_click = event.create()
|
||||||
self.on_long_click = Event()
|
self.on_long_click = event.create()
|
||||||
self.on_double_click = Event()
|
self.on_double_click = event.create()
|
||||||
self.on_hold_callback = Event()
|
self.on_hold_callback = event.create()
|
||||||
self.on_click_outside = Event()
|
self.on_click_outside = event.create()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -408,7 +409,7 @@ function M:on_input(action_id, action)
|
|||||||
|
|
||||||
-- While hold button, repeat rate pick from input.repeat_interval
|
-- While hold button, repeat rate pick from input.repeat_interval
|
||||||
if action.repeated then
|
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)
|
on_button_repeated_click(self)
|
||||||
return is_consume
|
return is_consume
|
||||||
end
|
end
|
||||||
@ -418,7 +419,7 @@ function M:on_input(action_id, action)
|
|||||||
return on_button_release(self) and is_consume
|
return on_button_release(self) and is_consume
|
||||||
end
|
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
|
local press_time = socket.gettime() - self.last_pressed_time
|
||||||
|
|
||||||
if self.style.AUTOHOLD_TRIGGER <= press_time then
|
if self.style.AUTOHOLD_TRIGGER <= press_time then
|
||||||
|
@ -14,19 +14,19 @@
|
|||||||
-- @tfield node node
|
-- @tfield node node
|
||||||
|
|
||||||
--- Event on touch start callback(self)
|
--- 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)
|
--- 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)
|
--- 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)
|
--- 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)
|
--- 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
|
--- Is component now touching
|
||||||
-- @tfield boolean is_touch
|
-- @tfield boolean is_touch
|
||||||
@ -57,18 +57,18 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
local Event = require("druid.event")
|
local event = require("event.event")
|
||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
---@class druid.drag: druid.base_component
|
---@class druid.drag: druid.base_component
|
||||||
---@field node node
|
---@field node node
|
||||||
---@field on_touch_start druid.event
|
---@field on_touch_start event
|
||||||
---@field on_touch_end druid.event
|
---@field on_touch_end event
|
||||||
---@field on_drag_start druid.event
|
---@field on_drag_start event
|
||||||
---@field on_drag druid.event
|
---@field on_drag event
|
||||||
---@field on_drag_end druid.event
|
---@field on_drag_end event
|
||||||
---@field style table
|
---@field style table
|
||||||
---@field click_zone node
|
---@field click_zone node
|
||||||
---@field is_touch boolean
|
---@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._scene_scale = helper.get_scene_scale(self.node)
|
||||||
|
|
||||||
self.click_zone = nil
|
self.click_zone = nil
|
||||||
self.on_touch_start = Event()
|
self.on_touch_start = event.create()
|
||||||
self.on_touch_end = Event()
|
self.on_touch_end = event.create()
|
||||||
self.on_drag_start = Event()
|
self.on_drag_start = event.create()
|
||||||
self.on_drag = Event(on_drag_callback)
|
self.on_drag = event.create(on_drag_callback)
|
||||||
self.on_drag_end = Event()
|
self.on_drag_end = event.create()
|
||||||
|
|
||||||
self:on_window_resized()
|
self:on_window_resized()
|
||||||
self:set_drag_cursors(true)
|
self:set_drag_cursors(true)
|
||||||
|
@ -9,22 +9,22 @@
|
|||||||
-- @tfield node node
|
-- @tfield node node
|
||||||
|
|
||||||
--- On hover callback(self, state, hover_instance)
|
--- 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)
|
--- 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 const = require("druid.const")
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
---@class druid.hover: druid.base_component
|
---@class druid.hover: druid.base_component
|
||||||
---@field node node
|
---@field node node
|
||||||
---@field on_hover druid.event
|
---@field on_hover event
|
||||||
---@field on_mouse_hover druid.event
|
---@field on_mouse_hover event
|
||||||
---@field style table
|
---@field style table
|
||||||
---@field click_zone node
|
---@field click_zone node
|
||||||
---@field private _is_hovered boolean
|
---@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_enabled = true
|
||||||
self._is_mobile = helper.is_mobile()
|
self._is_mobile = helper.is_mobile()
|
||||||
|
|
||||||
self.on_hover = Event(on_hover_callback)
|
self.on_hover = event.create(on_hover_callback)
|
||||||
self.on_mouse_hover = Event(on_mouse_hover)
|
self.on_mouse_hover = event.create(on_mouse_hover)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,13 +39,13 @@
|
|||||||
|
|
||||||
|
|
||||||
--- On scroll move callback(self, position)
|
--- 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)
|
--- 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)
|
--- 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
|
--- Scroll view node
|
||||||
-- @tfield node 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 const = require("druid.const")
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
---@class druid.scroll: druid.base_component
|
---@class druid.scroll: druid.base_component
|
||||||
---@field on_scroll druid.event
|
---@field on_scroll event
|
||||||
---@field on_scroll_to druid.event
|
---@field on_scroll_to event
|
||||||
---@field on_point_scroll druid.event
|
---@field on_point_scroll event
|
||||||
---@field view_node node
|
---@field view_node node
|
||||||
---@field view_border vector4
|
---@field view_border vector4
|
||||||
---@field content_node node
|
---@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.hover.on_mouse_hover:subscribe(self._on_mouse_hover)
|
||||||
self._is_mouse_hover = false
|
self._is_mouse_hover = false
|
||||||
|
|
||||||
self.on_scroll = Event()
|
self.on_scroll = event.create()
|
||||||
self.on_scroll_to = Event()
|
self.on_scroll_to = event.create()
|
||||||
self.on_point_scroll = Event()
|
self.on_point_scroll = event.create()
|
||||||
|
|
||||||
self.selected = nil
|
self.selected = nil
|
||||||
self.is_animate = false
|
self.is_animate = false
|
||||||
|
@ -37,19 +37,19 @@
|
|||||||
-- @alias druid.grid
|
-- @alias druid.grid
|
||||||
|
|
||||||
--- On item add callback(self, node, index)
|
--- 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)
|
--- 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)
|
--- 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)
|
--- On grid clear callback(self)
|
||||||
-- @tfield druid.event on_clear druid.event
|
-- @tfield event on_clear event
|
||||||
|
|
||||||
--- On update item positions callback(self)
|
--- On update item positions callback(self)
|
||||||
-- @tfield druid.event on_update_positions druid.event
|
-- @tfield event on_update_positions event
|
||||||
|
|
||||||
--- Parent gui node
|
--- Parent gui node
|
||||||
-- @tfield node parent
|
-- @tfield node parent
|
||||||
@ -78,16 +78,16 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
local Event = require("druid.event")
|
local event = require("event.event")
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
---@class druid.grid: druid.base_component
|
---@class druid.grid: druid.base_component
|
||||||
---@field on_add_item druid.event
|
---@field on_add_item event
|
||||||
---@field on_remove_item druid.event
|
---@field on_remove_item event
|
||||||
---@field on_change_items druid.event
|
---@field on_change_items event
|
||||||
---@field on_clear druid.event
|
---@field on_clear event
|
||||||
---@field on_update_positions druid.event
|
---@field on_update_positions event
|
||||||
---@field parent node
|
---@field parent node
|
||||||
---@field nodes node[]
|
---@field nodes node[]
|
||||||
---@field first_index number
|
---@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.border = vmath.vector4(0) -- Current grid content size
|
||||||
|
|
||||||
self.on_add_item = Event()
|
self.on_add_item = event.create()
|
||||||
self.on_remove_item = Event()
|
self.on_remove_item = event.create()
|
||||||
self.on_change_items = Event()
|
self.on_change_items = event.create()
|
||||||
self.on_clear = Event()
|
self.on_clear = event.create()
|
||||||
self.on_update_positions = Event()
|
self.on_update_positions = event.create()
|
||||||
|
|
||||||
self._set_position_function = gui.set_position
|
self._set_position_function = gui.set_position
|
||||||
end
|
end
|
||||||
|
@ -36,13 +36,13 @@
|
|||||||
-- @alias druid.text
|
-- @alias druid.text
|
||||||
|
|
||||||
--- On set text callback(self, 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)
|
--- 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)
|
--- On change pivot callback(self, pivot)
|
||||||
-- @tfield druid.event on_set_pivot druid.event
|
-- @tfield event on_set_pivot event
|
||||||
|
|
||||||
--- Text node
|
--- Text node
|
||||||
-- @tfield node node
|
-- @tfield node node
|
||||||
@ -76,7 +76,7 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
local Event = require("druid.event")
|
local event = require("event.event")
|
||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local utf8_lua = require("druid.system.utf8")
|
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
|
---@class druid.text: druid.base_component
|
||||||
---@field node node
|
---@field node node
|
||||||
---@field on_set_text druid.event
|
---@field on_set_text event
|
||||||
---@field on_update_text_scale druid.event
|
---@field on_update_text_scale event
|
||||||
---@field on_set_pivot druid.event
|
---@field on_set_pivot event
|
||||||
---@field style table
|
---@field style table
|
||||||
---@field private start_pivot number
|
---@field private start_pivot number
|
||||||
---@field private start_scale vector3
|
---@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.adjust_type = adjust_type or self.style.DEFAULT_ADJUST
|
||||||
self.color = gui.get_color(self.node)
|
self.color = gui.get_color(self.node)
|
||||||
|
|
||||||
self.on_set_text = Event()
|
self.on_set_text = event.create()
|
||||||
self.on_set_pivot = Event()
|
self.on_set_pivot = event.create()
|
||||||
self.on_update_text_scale = Event()
|
self.on_update_text_scale = event.create()
|
||||||
|
|
||||||
self:set_text(value or gui.get_text(self.node))
|
self:set_text(value or gui.get_text(self.node))
|
||||||
return self
|
return self
|
||||||
|
166
druid/event.lua
166
druid/event.lua
@ -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,
|
|
||||||
})
|
|
@ -13,7 +13,7 @@
|
|||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
local Event = require("druid.event")
|
local event = require("event.event")
|
||||||
|
|
||||||
---@class druid.container: druid.base_component
|
---@class druid.container: druid.base_component
|
||||||
---@field node node
|
---@field node node
|
||||||
@ -29,7 +29,7 @@ local Event = require("druid.event")
|
|||||||
---@field fit_size vector3
|
---@field fit_size vector3
|
||||||
---@field min_size_x number|nil
|
---@field min_size_x number|nil
|
||||||
---@field min_size_y 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 _parent_container druid.container
|
||||||
---@field _containers table
|
---@field _containers table
|
||||||
---@field _draggable_corners 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_size_mode(self.node, gui.SIZE_MODE_MANUAL)
|
||||||
gui.set_adjust_mode(self.node, gui.ADJUST_FIT)
|
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.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.center_offset = -vmath.vector3(self.size.x * self.pivot_offset.x, self.size.y * self.pivot_offset.y, 0)
|
||||||
|
@ -25,27 +25,27 @@
|
|||||||
-- @tfield number last_index
|
-- @tfield number last_index
|
||||||
|
|
||||||
--- Event triggered when scroll progress is changed; event(self, progress_value)
|
--- 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)
|
---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)
|
---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 const = require("druid.const")
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
local Event = require("druid.event")
|
local event = require("event.event")
|
||||||
|
|
||||||
---@class druid.data_list: druid.base_component
|
---@class druid.data_list: druid.base_component
|
||||||
---@field scroll druid.scroll
|
---@field scroll druid.scroll
|
||||||
---@field grid druid.grid
|
---@field grid druid.grid
|
||||||
---@field on_scroll_progress_change druid.event
|
---@field on_scroll_progress_change event
|
||||||
---@field on_element_add druid.event
|
---@field on_element_add event
|
||||||
---@field on_element_remove druid.event
|
---@field on_element_remove event
|
||||||
---@field private _create_function function
|
---@field private _create_function function
|
||||||
---@field private _is_use_cache boolean
|
---@field private _is_use_cache boolean
|
||||||
---@field private _cache table
|
---@field private _cache table
|
||||||
@ -79,9 +79,9 @@ function M:init(scroll, grid, create_function)
|
|||||||
|
|
||||||
self.scroll.on_scroll:subscribe(self._refresh, self)
|
self.scroll.on_scroll:subscribe(self._refresh, self)
|
||||||
|
|
||||||
self.on_scroll_progress_change = Event()
|
self.on_scroll_progress_change = event.create()
|
||||||
self.on_element_add = Event()
|
self.on_element_add = event.create()
|
||||||
self.on_element_remove = Event()
|
self.on_element_remove = event.create()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,10 +8,10 @@
|
|||||||
-- @alias druid.hotkey
|
-- @alias druid.hotkey
|
||||||
|
|
||||||
--- On hotkey released callback(self, argument)
|
--- 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)
|
--- On hotkey released callback(self, argument)
|
||||||
-- @tfield druid.event on_hotkey_released druid.event
|
-- @tfield event on_hotkey_released event
|
||||||
|
|
||||||
--- Visual node
|
--- Visual node
|
||||||
-- @tfield node node
|
-- @tfield node node
|
||||||
@ -26,11 +26,11 @@
|
|||||||
|
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
local Event = require("druid.event")
|
local event = require("event.event")
|
||||||
|
|
||||||
---@class druid.hotkey: druid.base_component
|
---@class druid.hotkey: druid.base_component
|
||||||
---@field on_hotkey_pressed druid.event
|
---@field on_hotkey_pressed event
|
||||||
---@field on_hotkey_released druid.event
|
---@field on_hotkey_released event
|
||||||
---@field style table
|
---@field style table
|
||||||
---@field private _hotkeys table
|
---@field private _hotkeys table
|
||||||
---@field private _modificators table
|
---@field private _modificators table
|
||||||
@ -47,8 +47,8 @@ function M:init(keys, callback, callback_argument)
|
|||||||
self._hotkeys = {}
|
self._hotkeys = {}
|
||||||
self._modificators = {}
|
self._modificators = {}
|
||||||
|
|
||||||
self.on_hotkey_pressed = Event()
|
self.on_hotkey_pressed = event.create()
|
||||||
self.on_hotkey_released = Event(callback)
|
self.on_hotkey_released = event.create(callback)
|
||||||
|
|
||||||
if keys then
|
if keys then
|
||||||
self:add_hotkey(keys, callback_argument)
|
self:add_hotkey(keys, callback_argument)
|
||||||
|
@ -10,25 +10,25 @@
|
|||||||
-- @alias druid.input
|
-- @alias druid.input
|
||||||
|
|
||||||
--- On input field select callback(self, input_instance)
|
--- 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)
|
--- 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)
|
--- 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)
|
--- 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)
|
--- 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)
|
--- 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)
|
--- 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
|
--- The cursor index. The index of letter cursor after. Leftmost cursor - 0
|
||||||
-- @tfield number cursor_index
|
-- @tfield number cursor_index
|
||||||
@ -80,7 +80,7 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
local Event = require("druid.event")
|
local event = require("event.event")
|
||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
@ -88,13 +88,13 @@ local utf8_lua = require("druid.system.utf8")
|
|||||||
local utf8 = utf8 or utf8_lua
|
local utf8 = utf8 or utf8_lua
|
||||||
|
|
||||||
---@class druid.input: druid.base_component
|
---@class druid.input: druid.base_component
|
||||||
---@field on_input_select druid.event
|
---@field on_input_select event
|
||||||
---@field on_input_unselect druid.event
|
---@field on_input_unselect event
|
||||||
---@field on_input_text druid.event
|
---@field on_input_text event
|
||||||
---@field on_input_empty druid.event
|
---@field on_input_empty event
|
||||||
---@field on_input_full druid.event
|
---@field on_input_full event
|
||||||
---@field on_input_wrong druid.event
|
---@field on_input_wrong event
|
||||||
---@field on_select_cursor_change druid.event
|
---@field on_select_cursor_change event
|
||||||
---@field style table
|
---@field style table
|
||||||
---@field text druid.text
|
---@field text druid.text
|
||||||
local M = component.create("input")
|
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)
|
self.button:set_web_user_interaction(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.on_input_select = Event()
|
self.on_input_select = event.create()
|
||||||
self.on_input_unselect = Event()
|
self.on_input_unselect = event.create()
|
||||||
self.on_input_text = Event()
|
self.on_input_text = event.create()
|
||||||
self.on_input_empty = Event()
|
self.on_input_empty = event.create()
|
||||||
self.on_input_full = Event()
|
self.on_input_full = event.create()
|
||||||
self.on_input_wrong = Event()
|
self.on_input_wrong = event.create()
|
||||||
self.on_select_cursor_change = Event()
|
self.on_select_cursor_change = event.create()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
-- @alias druid.lang_text
|
-- @alias druid.lang_text
|
||||||
|
|
||||||
--- On change text callback
|
--- On change text callback
|
||||||
-- @tfield druid.event on_change druid.event
|
-- @tfield event on_change event
|
||||||
|
|
||||||
--- The text component
|
--- The text component
|
||||||
-- @tfield Text text Text
|
-- @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 settings = require("druid.system.settings")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
---@class druid.lang_text: druid.base_component
|
---@class druid.lang_text: druid.base_component
|
||||||
---@field text druid.text
|
---@field text druid.text
|
||||||
---@field node node
|
---@field node node
|
||||||
---@field on_change druid.event
|
---@field on_change event
|
||||||
---@field private last_locale_args table
|
---@field private last_locale_args table
|
||||||
---@field private last_locale string
|
---@field private last_locale string
|
||||||
local M = component.create("lang_text")
|
local M = component.create("lang_text")
|
||||||
@ -51,7 +51,7 @@ function M:init(node, locale_id, adjust_type)
|
|||||||
self.node = self.text.node
|
self.node = self.text.node
|
||||||
self.last_locale_args = {}
|
self.last_locale_args = {}
|
||||||
|
|
||||||
self.on_change = Event()
|
self.on_change = event.create()
|
||||||
|
|
||||||
self:translate(locale_id or gui.get_text(self.node))
|
self:translate(locale_id or gui.get_text(self.node))
|
||||||
self.text.on_set_text:subscribe(self.on_change.trigger, self.on_change)
|
self.text.on_set_text:subscribe(self.on_change.trigger, self.on_change)
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
local event = require("druid.event")
|
local event = require("event.event")
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
---@alias druid.layout.mode "horizontal"|"vertical"|"horizontal_wrap"
|
---@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)
|
---@field subscribe fun(_, callback: fun(new_size: vector3), context: any|nil)
|
||||||
|
|
||||||
---@class druid.layout.row_data
|
---@class druid.layout.row_data
|
||||||
@ -30,7 +30,7 @@ local component = require("druid.component")
|
|||||||
---@field is_resize_width boolean
|
---@field is_resize_width boolean
|
||||||
---@field is_resize_height boolean
|
---@field is_resize_height boolean
|
||||||
---@field is_justify 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")
|
local M = component.create("layout")
|
||||||
|
|
||||||
---Layout component constructor
|
---Layout component constructor
|
||||||
@ -54,7 +54,7 @@ function M:init(node_or_node_id, layout_type)
|
|||||||
self.is_resize_height = false
|
self.is_resize_height = false
|
||||||
self.is_justify = 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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
-- @alias druid.progress
|
-- @alias druid.progress
|
||||||
|
|
||||||
--- On progress bar change callback(self, new_value)
|
--- On progress bar change callback(self, new_value)
|
||||||
-- @tfield druid.event on_change druid.event
|
-- @tfield event on_change event
|
||||||
|
|
||||||
--- Progress bar fill node
|
--- Progress bar fill node
|
||||||
-- @tfield node node
|
-- @tfield node node
|
||||||
@ -44,14 +44,14 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
local Event = require("druid.event")
|
local event = require("event.event")
|
||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
---@class druid.progress: druid.base_component
|
---@class druid.progress: druid.base_component
|
||||||
---@field node node
|
---@field node node
|
||||||
---@field on_change druid.event
|
---@field on_change event
|
||||||
---@field style table
|
---@field style table
|
||||||
---@field key string
|
---@field key string
|
||||||
---@field prop hash
|
---@field prop hash
|
||||||
@ -154,7 +154,7 @@ function M:init(node, key, init_value)
|
|||||||
0
|
0
|
||||||
)
|
)
|
||||||
|
|
||||||
self.on_change = Event()
|
self.on_change = event.create()
|
||||||
|
|
||||||
self:set_to(self.last_value)
|
self:set_to(self.last_value)
|
||||||
end
|
end
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
-- @alias druid.slider
|
-- @alias druid.slider
|
||||||
|
|
||||||
--- On change value callback(self, value)
|
--- On change value callback(self, value)
|
||||||
-- @tfield druid.event on_change_value druid.event
|
-- @tfield event on_change_value event
|
||||||
|
|
||||||
--- Slider pin node
|
--- Slider pin node
|
||||||
-- @tfield node node
|
-- @tfield node node
|
||||||
@ -37,14 +37,14 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
local Event = require("druid.event")
|
local event = require("event.event")
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
---@class druid.slider: druid.base_component
|
---@class druid.slider: druid.base_component
|
||||||
---@field node node
|
---@field node node
|
||||||
---@field on_change_value druid.event
|
---@field on_change_value event
|
||||||
---@field style table
|
---@field style table
|
||||||
---@field private start_pos vector3
|
---@field private start_pos vector3
|
||||||
---@field private pos vector3
|
---@field private pos vector3
|
||||||
@ -85,7 +85,7 @@ function M:init(node, end_pos, callback)
|
|||||||
self.is_drag = false
|
self.is_drag = false
|
||||||
self.value = 0
|
self.value = 0
|
||||||
|
|
||||||
self.on_change_value = Event(callback)
|
self.on_change_value = event.create(callback)
|
||||||
self:on_window_resized()
|
self:on_window_resized()
|
||||||
|
|
||||||
assert(self.dist.x == 0 or self.dist.y == 0, "Slider for now can be only vertical or horizontal")
|
assert(self.dist.x == 0 or self.dist.y == 0, "Slider for now can be only vertical or horizontal")
|
||||||
|
@ -16,18 +16,18 @@
|
|||||||
---@param click_zone node|nil
|
---@param click_zone node|nil
|
||||||
|
|
||||||
--- Trigger on swipe event(self, swipe_side, dist, delta_time)
|
--- 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 const = require("druid.const")
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
---@class druid.swipe: druid.base_component
|
---@class druid.swipe: druid.base_component
|
||||||
---@field node node
|
---@field node node
|
||||||
---@field on_swipe druid.event
|
---@field on_swipe event
|
||||||
---@field style table
|
---@field style table
|
||||||
---@field click_zone node
|
---@field click_zone node
|
||||||
---@field private _trigger_on_move boolean
|
---@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._start_pos = vmath.vector3(0)
|
||||||
|
|
||||||
self.click_zone = nil
|
self.click_zone = nil
|
||||||
self.on_swipe = Event(on_swipe_callback)
|
self.on_swipe = event.create(on_swipe_callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
local Event = require("druid.event")
|
local event = require("event.event")
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
---@class druid.timer: druid.base_component
|
---@class druid.timer: druid.base_component
|
||||||
---@field on_tick druid.event
|
---@field on_tick event
|
||||||
---@field on_set_enabled druid.event
|
---@field on_set_enabled event
|
||||||
---@field on_timer_end druid.event
|
---@field on_timer_end event
|
||||||
---@field style table
|
---@field style table
|
||||||
---@field node node
|
---@field node node
|
||||||
---@field from number
|
---@field from number
|
||||||
@ -31,9 +31,9 @@ function M:init(node, seconds_from, seconds_to, callback)
|
|||||||
self.node = self:get_node(node)
|
self.node = self:get_node(node)
|
||||||
seconds_to = math.max(seconds_to or 0, 0)
|
seconds_to = math.max(seconds_to or 0, 0)
|
||||||
|
|
||||||
self.on_tick = Event()
|
self.on_tick = event.create()
|
||||||
self.on_set_enabled = Event()
|
self.on_set_enabled = event.create()
|
||||||
self.on_timer_end = Event(callback)
|
self.on_timer_end = event.create(callback)
|
||||||
|
|
||||||
if seconds_from then
|
if seconds_from then
|
||||||
seconds_from = math.max(seconds_from, 0)
|
seconds_from = math.max(seconds_from, 0)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
--
|
--
|
||||||
-- 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
|
||||||
--
|
--
|
||||||
-- 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.
|
-- BaseComponent - The parent class of all Druid components. You can find all default component methods there.
|
||||||
--
|
--
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local event = require("druid.event")
|
local event = require("event.event")
|
||||||
|
|
||||||
---@class widget.property_left_right_selector: druid.widget
|
---@class widget.property_left_right_selector: druid.widget
|
||||||
---@field root node
|
---@field root node
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
local Event = require("druid.event")
|
local event = require("event.event")
|
||||||
|
|
||||||
---@class druid.container: druid.base_component
|
---@class druid.container: druid.base_component
|
||||||
---@field node node
|
---@field node node
|
||||||
@ -29,7 +29,7 @@ local Event = require("druid.event")
|
|||||||
---@field fit_size vector3
|
---@field fit_size vector3
|
||||||
---@field min_size_x number|nil
|
---@field min_size_x number|nil
|
||||||
---@field min_size_y 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 _parent_container druid.container
|
||||||
---@field _containers table
|
---@field _containers table
|
||||||
---@field _draggable_corners 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_size_mode(self.node, gui.SIZE_MODE_MANUAL)
|
||||||
gui.set_adjust_mode(self.node, gui.ADJUST_FIT)
|
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.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.center_offset = -vmath.vector3(self.size.x * self.pivot_offset.x, self.size.y * self.pivot_offset.y, 0)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local event = require("druid.event")
|
local event = require("event.event")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
local container = require("example.components.container.container")
|
local container = require("example.components.container.container")
|
||||||
local lang_text = require("druid.extended.lang_text")
|
local lang_text = require("druid.extended.lang_text")
|
||||||
@ -39,9 +39,9 @@ function M:init(template, nodes)
|
|||||||
|
|
||||||
self.selected_example = nil
|
self.selected_example = nil
|
||||||
self.examples = {}
|
self.examples = {}
|
||||||
self.on_debug_info = event()
|
self.on_debug_info = event.create()
|
||||||
self.on_set_information = event()
|
self.on_set_information = event.create()
|
||||||
self.add_log_text = event()
|
self.add_log_text = event.create()
|
||||||
|
|
||||||
timer.delay(0.1, true, function()
|
timer.delay(0.1, true, function()
|
||||||
self:update_debug_info()
|
self:update_debug_info()
|
||||||
|
@ -6,7 +6,7 @@ local lang_text = require("druid.extended.lang_text")
|
|||||||
---@field root druid.container
|
---@field root druid.container
|
||||||
---@field text druid.lang_text
|
---@field text druid.lang_text
|
||||||
---@field druid druid_instance
|
---@field druid druid_instance
|
||||||
---@field on_click druid.event
|
---@field on_click event
|
||||||
local M = component.create("examples_list_view_item")
|
local M = component.create("examples_list_view_item")
|
||||||
|
|
||||||
---@param template string
|
---@param template string
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local event = require("druid.event")
|
local event = require("event.event")
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
local container = require("example.components.container.container")
|
local container = require("example.components.container.container")
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
local event = require("druid.event")
|
local event = require("event.event")
|
||||||
|
|
||||||
---@class checkbox: druid.base_component
|
---@class checkbox: druid.base_component
|
||||||
---@field druid druid_instance
|
---@field druid druid_instance
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local event = require("druid.event")
|
local event = require("event.event")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
-- Require checkbox component from checkbox example
|
-- Require checkbox component from checkbox example
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
local event = require("druid.event")
|
local event = require("event.event")
|
||||||
|
|
||||||
-- Require checkbox component from checkbox example
|
-- Require checkbox component from checkbox example
|
||||||
local checkbox = require("example.examples.basic.checkbox.checkbox")
|
local checkbox = require("example.examples.basic.checkbox.checkbox")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
local rich_text = require("druid.custom.rich_text.rich_text")
|
local rich_text = require("druid.custom.rich_text.rich_text")
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local event = require("druid.event")
|
local event = require("event.event")
|
||||||
|
|
||||||
---@class rich_text_tags_custom: druid.base_component
|
---@class rich_text_tags_custom: druid.base_component
|
||||||
---@field druid druid_instance
|
---@field druid druid_instance
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local event = require("druid.event")
|
local event = require("event.event")
|
||||||
local timer = require("druid.extended.timer")
|
local timer = require("druid.extended.timer")
|
||||||
|
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local event = require("druid.event")
|
local event = require("event.event")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
local data_list = require("druid.extended.data_list")
|
local data_list = require("druid.extended.data_list")
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ function M:init(template, nodes)
|
|||||||
end
|
end
|
||||||
self.data_list:set_data(data)
|
self.data_list:set_data(data)
|
||||||
|
|
||||||
self.on_item_click = event()
|
self.on_item_click = event.create()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local event = require("druid.event")
|
local event = require("event.event")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
local data_list = require("druid.extended.data_list")
|
local data_list = require("druid.extended.data_list")
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ function M:init(template, nodes)
|
|||||||
end
|
end
|
||||||
self.data_list:set_data(data)
|
self.data_list:set_data(data)
|
||||||
|
|
||||||
self.on_item_click = event()
|
self.on_item_click = event.create()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local event = require("druid.event")
|
local event = require("event.event")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
local data_list = require("druid.extended.data_list")
|
local data_list = require("druid.extended.data_list")
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ function M:init(template, nodes)
|
|||||||
end
|
end
|
||||||
self.data_list:set_data(data)
|
self.data_list:set_data(data)
|
||||||
|
|
||||||
self.on_item_click = event()
|
self.on_item_click = event.create()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
local event = require("druid.event")
|
local event = require("event.event")
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
---@class on_screen_input: druid.base_component
|
---@class on_screen_input: druid.base_component
|
||||||
---@field druid druid_instance
|
---@field druid druid_instance
|
||||||
---@field on_action druid.event @()
|
---@field on_action event @()
|
||||||
---@field on_movement druid.event @(x: number, y: number, dt: number) X/Y values are in range -1..1
|
---@field on_movement event @(x: number, y: number, dt: number) X/Y values are in range -1..1
|
||||||
---@field on_movement_stop druid.event @()
|
---@field on_movement_stop event @()
|
||||||
local M = component.create("on_screen_input")
|
local M = component.create("on_screen_input")
|
||||||
|
|
||||||
local STICK_DISTANCE = 80
|
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_root = self:get_node("on_screen_stick/stick_root")
|
||||||
self.stick_position = gui.get_position(self.stick_root)
|
self.stick_position = gui.get_position(self.stick_root)
|
||||||
|
|
||||||
self.on_action = event()
|
self.on_action = event.create()
|
||||||
self.on_movement = event()
|
self.on_movement = event.create()
|
||||||
self.on_movement_stop = event()
|
self.on_movement_stop = event.create()
|
||||||
|
|
||||||
self.is_multitouch = helper.is_multitouch_supported()
|
self.is_multitouch = helper.is_multitouch_supported()
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
local panthera = require("panthera.panthera")
|
local panthera = require("panthera.panthera")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local event = require("druid.event")
|
local event = require("event.event")
|
||||||
local lang_text = require("druid.extended.lang_text")
|
local lang_text = require("druid.extended.lang_text")
|
||||||
local rich_text = require("druid.custom.rich_text.rich_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:setup_rich_text()
|
||||||
self.on_update = event()
|
self.on_update = event.create()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,7 +59,15 @@ function M.get_examples()
|
|||||||
template = "example_memory_panel",
|
template = "example_memory_panel",
|
||||||
root = "example_memory_panel/root",
|
root = "example_memory_panel/root",
|
||||||
code_url = "example/examples/widgets/memory_panel/example_memory_panel.lua",
|
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
|
end
|
||||||
|
104
example/examples/widgets/fps_panel/example_fps_panel.gui
Normal file
104
example/examples/widgets/fps_panel/example_fps_panel.gui
Normal file
@ -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
|
12
example/examples/widgets/fps_panel/example_fps_panel.lua
Normal file
12
example/examples/widgets/fps_panel/example_fps_panel.lua
Normal file
@ -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
|
@ -1,6 +1,6 @@
|
|||||||
local lang = require("lang.lang")
|
local lang = require("lang.lang")
|
||||||
local druid = require("druid.druid")
|
local druid = require("druid.druid")
|
||||||
local event = require("druid.event")
|
local event = require("event.event")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
local lang_text = require("druid.extended.lang_text")
|
local lang_text = require("druid.extended.lang_text")
|
||||||
local panthera = require("panthera.panthera")
|
local panthera = require("panthera.panthera")
|
||||||
@ -13,7 +13,7 @@ local window_animation_panthera = require("example.examples.windows.window_anima
|
|||||||
---@field druid druid_instance
|
---@field druid druid_instance
|
||||||
---@field lang_buttons table<string, druid.button>
|
---@field lang_buttons table<string, druid.button>
|
||||||
---@field grid druid.grid
|
---@field grid druid.grid
|
||||||
---@field on_language_change druid.event
|
---@field on_language_change event
|
||||||
local M = component.create("window_language")
|
local M = component.create("window_language")
|
||||||
|
|
||||||
---Color: #F0FBFF
|
---Color: #F0FBFF
|
||||||
@ -44,7 +44,7 @@ function M:init(template, nodes)
|
|||||||
|
|
||||||
self:load_langs()
|
self:load_langs()
|
||||||
|
|
||||||
self.on_language_change = event()
|
self.on_language_change = event.create()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -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#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#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#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]
|
[library]
|
||||||
include_dirs = druid
|
include_dirs = druid
|
||||||
|
Loading…
x
Reference in New Issue
Block a user