mirror of
https://github.com/Insality/druid.git
synced 2025-09-27 18:12:19 +02:00
Rename type druid.base_component -> druid.component
This commit is contained in:
@@ -2,7 +2,7 @@ local event = require("event.event")
|
||||
local const = require("druid.const")
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class druid.back_handler: druid.base_component
|
||||
---@class druid.back_handler: druid.component
|
||||
---@field on_back event Trigger on back handler action, fun(self, params)
|
||||
---@field params any|nil Custom args to pass in the callback
|
||||
local M = component.create("back_handler")
|
||||
|
@@ -1,7 +1,7 @@
|
||||
local const = require("druid.const")
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class druid.blocker: druid.base_component
|
||||
---@class druid.blocker: druid.component
|
||||
---@field node node
|
||||
---@field private _is_enabled boolean
|
||||
local M = component.create("blocker")
|
||||
|
@@ -142,7 +142,7 @@ local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
---Clickable node with various interaction callbacks
|
||||
---@class druid.button: druid.base_component
|
||||
---@class druid.button: druid.component
|
||||
---@field on_click event function(self, custom_args, button_instance)
|
||||
---@field on_pressed event
|
||||
---@field on_repeated_click event
|
||||
|
@@ -66,7 +66,7 @@ local component = require("druid.component")
|
||||
---@field DRAG_DEADZONE number Distance in pixels to start dragging. Default: 10
|
||||
---@field NO_USE_SCREEN_KOEF boolean If screen aspect ratio affects on drag values. Default: false
|
||||
|
||||
---@class druid.drag: druid.base_component
|
||||
---@class druid.drag: druid.component
|
||||
---@field node node
|
||||
---@field on_touch_start event
|
||||
---@field on_touch_end event
|
||||
|
@@ -21,7 +21,7 @@ local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class druid.hover: druid.base_component
|
||||
---@class druid.hover: druid.component
|
||||
---@field node node
|
||||
---@field on_hover event
|
||||
---@field on_mouse_hover event
|
||||
|
@@ -90,7 +90,7 @@ local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class druid.scroll: druid.base_component
|
||||
---@class druid.scroll: druid.component
|
||||
---@field node node The root node
|
||||
---@field click_zone node|nil Optional click zone to restrict scroll area
|
||||
---@field on_scroll event Triggered on scroll move with (self, position)
|
||||
|
@@ -82,7 +82,7 @@ local event = require("event.event")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class druid.grid: druid.base_component
|
||||
---@class druid.grid: druid.component
|
||||
---@field on_add_item event
|
||||
---@field on_remove_item event
|
||||
---@field on_change_items event
|
||||
|
@@ -83,7 +83,7 @@ local utf8_lua = require("druid.system.utf8")
|
||||
local component = require("druid.component")
|
||||
local utf8 = utf8 or utf8_lua --[[@as utf8]]
|
||||
|
||||
---@class druid.text: druid.base_component
|
||||
---@class druid.text: druid.component
|
||||
---@field node node
|
||||
---@field on_set_text event
|
||||
---@field on_update_text_scale event
|
||||
|
@@ -1,7 +1,7 @@
|
||||
local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
|
||||
---@class druid.base_component.meta
|
||||
---@class druid.component.meta
|
||||
---@field template string
|
||||
---@field context table
|
||||
---@field nodes table<hash, node>|nil
|
||||
@@ -9,32 +9,32 @@ local helper = require("druid.helper")
|
||||
---@field druid druid.instance
|
||||
---@field input_enabled boolean
|
||||
---@field children table
|
||||
---@field parent druid.base_component|nil
|
||||
---@field parent druid.component|nil
|
||||
---@field instance_class table
|
||||
|
||||
---@class druid.base_component.component
|
||||
---@class druid.component.component
|
||||
---@field name string
|
||||
---@field input_priority number
|
||||
---@field default_input_priority number
|
||||
---@field _is_input_priority_changed boolean
|
||||
---@field _uid number
|
||||
|
||||
---@class druid.base_component
|
||||
---@class druid.component
|
||||
---@field druid druid.instance Druid instance to create inner components
|
||||
---@field init fun(self:druid.base_component, ...)|nil
|
||||
---@field update fun(self:druid.base_component, dt:number)|nil
|
||||
---@field on_remove fun(self:druid.base_component)|nil
|
||||
---@field on_input fun(self:druid.base_component, action_id:number, action:table)|nil
|
||||
---@field on_message fun(self:druid.base_component, message_id:hash, message:table, sender:url)|nil
|
||||
---@field on_late_init fun(self:druid.base_component)|nil
|
||||
---@field on_focus_lost fun(self:druid.base_component)|nil
|
||||
---@field on_focus_gained fun(self:druid.base_component)|nil
|
||||
---@field on_style_change fun(self:druid.base_component, style: table)|nil
|
||||
---@field on_layout_change fun(self:druid.base_component)|nil
|
||||
---@field on_window_resized fun(self:druid.base_component)|nil
|
||||
---@field on_language_change fun(self:druid.base_component)|nil
|
||||
---@field private _component druid.base_component.component
|
||||
---@field private _meta druid.base_component.meta
|
||||
---@field init fun(self:druid.component, ...)|nil
|
||||
---@field update fun(self:druid.component, dt:number)|nil
|
||||
---@field on_remove fun(self:druid.component)|nil
|
||||
---@field on_input fun(self:druid.component, action_id:number, action:table)|nil
|
||||
---@field on_message fun(self:druid.component, message_id:hash, message:table, sender:url)|nil
|
||||
---@field on_late_init fun(self:druid.component)|nil
|
||||
---@field on_focus_lost fun(self:druid.component)|nil
|
||||
---@field on_focus_gained fun(self:druid.component)|nil
|
||||
---@field on_style_change fun(self:druid.component, style: table)|nil
|
||||
---@field on_layout_change fun(self:druid.component)|nil
|
||||
---@field on_window_resized fun(self:druid.component)|nil
|
||||
---@field on_language_change fun(self:druid.component)|nil
|
||||
---@field private _component druid.component.component
|
||||
---@field private _meta druid.component.meta
|
||||
local M = {}
|
||||
|
||||
local INTERESTS = {} -- Cache interests per component class in runtime
|
||||
@@ -54,7 +54,7 @@ end
|
||||
---@param druid_style table|nil
|
||||
---@return T self The component itself for chaining
|
||||
function M:set_style(druid_style)
|
||||
---@cast self druid.base_component
|
||||
---@cast self druid.component
|
||||
|
||||
self._meta.style = druid_style or {}
|
||||
local component_style = self._meta.style[self._component.name] or {}
|
||||
@@ -75,7 +75,7 @@ end
|
||||
---@param template string|nil
|
||||
---@return T self The component itself for chaining
|
||||
function M:set_template(template)
|
||||
---@cast self druid.base_component
|
||||
---@cast self druid.component
|
||||
|
||||
template = template or ""
|
||||
|
||||
@@ -109,7 +109,7 @@ end
|
||||
|
||||
---Set current component nodes, returned from `gui.clone_tree` function.
|
||||
---@param nodes table<hash, node>
|
||||
---@return druid.base_component
|
||||
---@return druid.component
|
||||
function M:set_nodes(nodes)
|
||||
self._meta.nodes = nodes
|
||||
return self
|
||||
@@ -176,7 +176,7 @@ end
|
||||
---Set component input priority, the bigger number processed first. Default value: 10
|
||||
---@param value number
|
||||
---@param is_temporary boolean|nil If true, the reset input priority will return to previous value
|
||||
---@return druid.base_component self The component itself for chaining
|
||||
---@return druid.component self The component itself for chaining
|
||||
function M:set_input_priority(value, is_temporary)
|
||||
assert(value)
|
||||
|
||||
@@ -201,7 +201,7 @@ end
|
||||
|
||||
|
||||
---Reset component input priority to it's default value, that was set in `create` function or `set_input_priority`
|
||||
---@return druid.base_component self The component itself for chaining
|
||||
---@return druid.component self The component itself for chaining
|
||||
function M:reset_input_priority()
|
||||
self:set_input_priority(self._component.default_input_priority)
|
||||
return self
|
||||
@@ -219,7 +219,7 @@ end
|
||||
---If input is disabled, the component will not receive input events.
|
||||
---Recursive for all children components.
|
||||
---@param state boolean
|
||||
---@return druid.base_component self The component itself for chaining
|
||||
---@return druid.component self The component itself for chaining
|
||||
function M:set_input_enabled(state)
|
||||
self._meta.input_enabled = state
|
||||
|
||||
@@ -232,7 +232,7 @@ end
|
||||
|
||||
|
||||
---Get parent component
|
||||
---@return druid.base_component|nil parent The parent component if exist or nil
|
||||
---@return druid.component|nil parent The parent component if exist or nil
|
||||
function M:get_parent_component()
|
||||
return self._meta.parent
|
||||
end
|
||||
@@ -243,7 +243,7 @@ end
|
||||
---@param context table Druid context. Usually it is self of script
|
||||
---@param style table Druid style module
|
||||
---@param instance_class table The component instance class
|
||||
---@return druid.base_component BaseComponent itself
|
||||
---@return druid.component BaseComponent itself
|
||||
---@private
|
||||
function M:setup_component(druid_instance, context, style, instance_class)
|
||||
self._meta = {
|
||||
@@ -254,7 +254,7 @@ function M:setup_component(druid_instance, context, style, instance_class)
|
||||
druid = druid_instance,
|
||||
input_enabled = true,
|
||||
children = {},
|
||||
parent = type(context) ~= "userdata" and context --[[@as druid.base_component]],
|
||||
parent = type(context) ~= "userdata" and context --[[@as druid.component]],
|
||||
instance_class = instance_class
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ end
|
||||
|
||||
|
||||
---Add child to component children list
|
||||
---@generic T: druid.base_component
|
||||
---@generic T: druid.component
|
||||
---@param child T The druid component instance
|
||||
---@return T self The component itself for chaining
|
||||
---@private
|
||||
@@ -332,7 +332,7 @@ end
|
||||
|
||||
|
||||
---Remove child from component children list
|
||||
---@generic T: druid.base_component
|
||||
---@generic T: druid.component
|
||||
---@param child T The druid component instance
|
||||
---@return boolean true if child was removed
|
||||
---@private
|
||||
@@ -367,7 +367,7 @@ end
|
||||
---Сreate a new component class, which will inherit from the base Druid component.
|
||||
---@param name string|nil The name of the component
|
||||
---@param input_priority number|nil The input priority. The bigger number processed first. Default value: 10
|
||||
---@return druid.base_component
|
||||
---@return druid.component
|
||||
function M.create(name, input_priority)
|
||||
local new_class = setmetatable({}, {
|
||||
__index = M,
|
||||
|
@@ -43,7 +43,7 @@ local const = require("druid.const")
|
||||
local utf8_lua = require("druid.system.utf8")
|
||||
local utf8 = utf8 or utf8_lua
|
||||
|
||||
---@class druid.rich_input: druid.base_component
|
||||
---@class druid.rich_input: druid.component
|
||||
---@field root node
|
||||
---@field input druid.input
|
||||
---@field cursor node
|
||||
|
@@ -142,7 +142,7 @@ local rich_text = require("druid.custom.rich_text.module.rt")
|
||||
---@field offset_y number|nil
|
||||
---@field node_size vector3|nil
|
||||
|
||||
---@class druid.rich_text: druid.base_component
|
||||
---@class druid.rich_text: druid.component
|
||||
---@field root node
|
||||
---@field text_prefab node
|
||||
---@field private _last_value string
|
||||
|
@@ -15,7 +15,7 @@ local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
local event = require("event.event")
|
||||
|
||||
---@class druid.container: druid.base_component
|
||||
---@class druid.container: druid.component
|
||||
---@field node node
|
||||
---@field druid druid.instance
|
||||
---@field node_offset vector4
|
||||
|
@@ -40,7 +40,7 @@ local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
local event = require("event.event")
|
||||
|
||||
---@class druid.data_list: druid.base_component
|
||||
---@class druid.data_list: druid.component
|
||||
---@field scroll druid.scroll
|
||||
---@field grid druid.grid
|
||||
---@field on_scroll_progress_change event
|
||||
@@ -187,7 +187,7 @@ end
|
||||
|
||||
|
||||
--- Return all currenly created components in DataList
|
||||
---@return druid.base_component[] List of created nodes
|
||||
---@return druid.component[] List of created nodes
|
||||
function M:get_created_components()
|
||||
local components = {}
|
||||
|
||||
|
@@ -28,7 +28,7 @@ local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
local event = require("event.event")
|
||||
|
||||
---@class druid.hotkey: druid.base_component
|
||||
---@class druid.hotkey: druid.component
|
||||
---@field on_hotkey_pressed event
|
||||
---@field on_hotkey_released event
|
||||
---@field style table
|
||||
|
@@ -87,7 +87,7 @@ local component = require("druid.component")
|
||||
local utf8_lua = require("druid.system.utf8")
|
||||
local utf8 = utf8 or utf8_lua
|
||||
|
||||
---@class druid.input: druid.base_component
|
||||
---@class druid.input: druid.component
|
||||
---@field on_input_select event
|
||||
---@field on_input_unselect event
|
||||
---@field on_input_text event
|
||||
|
@@ -32,7 +32,7 @@ local event = require("event.event")
|
||||
local settings = require("druid.system.settings")
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class druid.lang_text: druid.base_component
|
||||
---@class druid.lang_text: druid.component
|
||||
---@field text druid.text
|
||||
---@field node node
|
||||
---@field on_change event
|
||||
|
@@ -19,7 +19,7 @@ local component = require("druid.component")
|
||||
---@field nodes_height table<node, number>
|
||||
---@field rows druid.layout.row_data[]>
|
||||
|
||||
---@class druid.layout: druid.base_component
|
||||
---@class druid.layout: druid.component
|
||||
---@field node node
|
||||
---@field rows_data druid.layout.rows_data Last calculated rows data
|
||||
---@field is_dirty boolean
|
||||
|
@@ -49,7 +49,7 @@ local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class druid.progress: druid.base_component
|
||||
---@class druid.progress: druid.component
|
||||
---@field node node
|
||||
---@field on_change event
|
||||
---@field style table
|
||||
|
@@ -42,7 +42,7 @@ local helper = require("druid.helper")
|
||||
local const = require("druid.const")
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class druid.slider: druid.base_component
|
||||
---@class druid.slider: druid.component
|
||||
---@field node node
|
||||
---@field on_change_value event
|
||||
---@field style table
|
||||
|
@@ -25,7 +25,7 @@ local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class druid.swipe: druid.base_component
|
||||
---@class druid.swipe: druid.component
|
||||
---@field node node
|
||||
---@field on_swipe event function(side, dist, dt), side - "left", "right", "up", "down"
|
||||
---@field style table
|
||||
|
@@ -2,7 +2,7 @@ local event = require("event.event")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class druid.timer: druid.base_component
|
||||
---@class druid.timer: druid.component
|
||||
---@field on_tick event
|
||||
---@field on_set_enabled event
|
||||
---@field on_timer_end event
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---@class druid.widget: druid.base_component
|
||||
---@class druid.widget: druid.component
|
||||
---@field druid druid.instance Ready to use druid instance
|
||||
---@field root node
|
||||
---@field root node Is it really needed?
|
||||
|
||||
---@class GUITextMetrics
|
||||
---@field width number
|
||||
|
@@ -7,19 +7,19 @@ local settings = require("druid.system.settings")
|
||||
local base_component = require("druid.component")
|
||||
|
||||
---@class druid.instance
|
||||
---@field components_all druid.base_component[] All created components
|
||||
---@field components_interest table<string, druid.base_component[]> All components sorted by interest
|
||||
---@field components_all druid.component[] All created components
|
||||
---@field components_interest table<string, druid.component[]> All components sorted by interest
|
||||
---@field url url
|
||||
---@field private _context table Druid context
|
||||
---@field private _style table Druid style table
|
||||
---@field private _deleted boolean
|
||||
---@field private _is_late_remove_enabled boolean
|
||||
---@field private _late_remove druid.base_component[]
|
||||
---@field private _input_blacklist druid.base_component[]|nil
|
||||
---@field private _input_whitelist druid.base_component[]|nil
|
||||
---@field private _late_remove druid.component[]
|
||||
---@field private _input_blacklist druid.component[]|nil
|
||||
---@field private _input_whitelist druid.component[]|nil
|
||||
---@field private input_inited boolean
|
||||
---@field private _late_init_timer_id number
|
||||
---@field private _input_components druid.base_component[]
|
||||
---@field private _input_components druid.component[]
|
||||
local M = {}
|
||||
|
||||
local MSG_ADD_FOCUS = hash("acquire_input_focus")
|
||||
@@ -81,7 +81,7 @@ local WIDGET_METATABLE = { __index = base_component }
|
||||
|
||||
---Create the Druid component instance
|
||||
---@param self druid.instance
|
||||
---@param widget_class druid.base_component
|
||||
---@param widget_class druid.component
|
||||
local function create_widget(self, widget_class)
|
||||
local instance = setmetatable({}, {
|
||||
__index = setmetatable(widget_class, WIDGET_METATABLE)
|
||||
@@ -148,7 +148,7 @@ end
|
||||
|
||||
|
||||
---Check whitelists and blacklists for input components
|
||||
---@param component druid.base_component
|
||||
---@param component druid.component
|
||||
---@return boolean
|
||||
function M:_can_use_input_component(component)
|
||||
local can_by_whitelist = true
|
||||
@@ -224,7 +224,7 @@ end
|
||||
|
||||
|
||||
---Create new Druid component instance
|
||||
---@generic T: druid.base_component
|
||||
---@generic T: druid.component
|
||||
---@param component T
|
||||
---@vararg any
|
||||
---@return T
|
||||
@@ -264,7 +264,7 @@ end
|
||||
--- Remove created component from Druid instance.
|
||||
--
|
||||
-- Component `on_remove` function will be invoked, if exist.
|
||||
---@generic T: druid.base_component
|
||||
---@generic T: druid.component
|
||||
---@param component T Component instance
|
||||
---@return boolean True if component was removed
|
||||
function M:remove(component)
|
||||
@@ -420,7 +420,7 @@ end
|
||||
---Set whitelist components for input processing.
|
||||
---If whitelist is not empty and component not contains in this list,
|
||||
---component will be not processed on input step
|
||||
---@param whitelist_components table|druid.base_component[] The array of component to whitelist
|
||||
---@param whitelist_components table|druid.component[] The array of component to whitelist
|
||||
---@return druid.instance
|
||||
function M:set_whitelist(whitelist_components)
|
||||
if whitelist_components and whitelist_components._component then
|
||||
@@ -440,7 +440,7 @@ end
|
||||
---Set blacklist components for input processing.
|
||||
---If blacklist is not empty and component contains in this list,
|
||||
---component will be not processed on input step DruidInstance
|
||||
---@param blacklist_components table|druid.base_component[] The array of component to blacklist
|
||||
---@param blacklist_components table|druid.component[] The array of component to blacklist
|
||||
---@return druid.instance
|
||||
function M:set_blacklist(blacklist_components)
|
||||
if blacklist_components and blacklist_components._component then
|
||||
@@ -472,7 +472,7 @@ end
|
||||
|
||||
|
||||
---Create new Druid widget instance
|
||||
---@generic T: druid.base_component
|
||||
---@generic T: druid.component
|
||||
---@param widget T
|
||||
---@param template string|nil The template name used by widget
|
||||
---@param nodes table<hash, node>|node|nil The nodes table from gui.clone_tree or prefab node to use for clone
|
||||
|
@@ -1,6 +1,6 @@
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class new_component: druid.base_component
|
||||
---@class new_component: druid.component
|
||||
local M = component.create("new_component")
|
||||
|
||||
-- Component constructor. Template name and nodes are optional. Pass it if you use it in your component
|
||||
|
Reference in New Issue
Block a user