mirror of
https://github.com/Insality/druid
synced 2025-09-27 10:02:19 +02:00
Refactor text setting methods and remove ldoc files
This commit is contained in:
@@ -1,2 +1,55 @@
|
||||
---@class druid.widget: druid.base_component
|
||||
---@field druid druid_instance
|
||||
---@field druid druid_instance
|
||||
|
||||
---@class GUITextMetrics
|
||||
---@field width number
|
||||
---@field height number
|
||||
---@field max_ascent number
|
||||
---@field max_descent number
|
||||
|
||||
---@class utf8
|
||||
---@field len fun(s: string):number
|
||||
---@field sub fun(s: string, start_index: number, length: number)
|
||||
---@field reverse fun()
|
||||
---@field char fun()
|
||||
---@field unicode fun()
|
||||
---@field gensub fun()
|
||||
---@field byte fun()
|
||||
---@field find fun()
|
||||
---@field match fun(s: string, m: string)
|
||||
---@field gmatch fun(s: string, m: string)
|
||||
---@field gsub fun()
|
||||
---@field dump fun()
|
||||
---@field format fun()
|
||||
---@field lower fun()
|
||||
---@field upper fun()
|
||||
---@field rep fun()
|
||||
|
||||
---@class action
|
||||
---@field value number The amount of input given by the user. This is usually 1 for buttons and 0-1 for analogue inputs. This is not present for mouse movement.
|
||||
---@field pressed boolean If the input was pressed this frame. This is not present for mouse movement.
|
||||
---@field released boolean If the input was released this frame. This is not present for mouse movement.
|
||||
---@field repeated boolean If the input was repeated this frame. This is similar to how a key on a keyboard is repeated when you hold it down. This is not present for mouse movement.
|
||||
---@field x number The x value of a pointer device, if present.
|
||||
---@field y number The y value of a pointer device, if present.
|
||||
---@field screen_x number The screen space x value of a pointer device, if present.
|
||||
---@field screen_y number The screen space y value of a pointer device, if present.
|
||||
---@field dx number The change in x value of a pointer device, if present.
|
||||
---@field dy number The change in y value of a pointer device, if present.
|
||||
---@field screen_dx number The change in screen space x value of a pointer device, if present.
|
||||
---@field screen_dy number The change in screen space y value of a pointer device, if present.
|
||||
---@field gamepad number The index of the gamepad device that provided the input.
|
||||
---@field touch touch[] List of touch input, one element per finger, if present. See table below about touch input
|
||||
|
||||
---@class touch
|
||||
---@field id number A number identifying the touch input during its duration.
|
||||
---@field pressed boolean True if the finger was pressed this frame.
|
||||
---@field released boolean True if the finger was released this frame.
|
||||
---@field tap_count number Number of taps, one for single, two for double-tap, etc
|
||||
---@field x number The x touch location.
|
||||
---@field y number The y touch location.
|
||||
---@field dx number The change in x value.
|
||||
---@field dy number The change in y value.
|
||||
---@field acc_x number|nil Accelerometer x value (if present).
|
||||
---@field acc_y number|nil Accelerometer y value (if present).
|
||||
---@field acc_z number|nil Accelerometer z value (if present).
|
||||
|
@@ -147,10 +147,9 @@ end
|
||||
|
||||
|
||||
---Check whitelists and blacklists for input components
|
||||
---@param self druid_instance
|
||||
---@param component druid.base_component
|
||||
---@return boolean
|
||||
local function can_use_input_component(self, component)
|
||||
function M:_can_use_input_component(component)
|
||||
local can_by_whitelist = true
|
||||
local can_by_blacklist = true
|
||||
|
||||
@@ -166,13 +165,13 @@ local function can_use_input_component(self, component)
|
||||
end
|
||||
|
||||
|
||||
local function process_input(self, action_id, action, components)
|
||||
function M:_process_input(action_id, action, components)
|
||||
local is_input_consumed = false
|
||||
|
||||
for i = #components, 1, -1 do
|
||||
local component = components[i]
|
||||
local meta = component._meta
|
||||
if meta.input_enabled and can_use_input_component(self, component) then
|
||||
if meta.input_enabled and self:_can_use_input_component(component) then
|
||||
if not is_input_consumed then
|
||||
is_input_consumed = component:on_input(action_id, action) or false
|
||||
else
|
||||
@@ -356,7 +355,7 @@ function M:on_input(action_id, action)
|
||||
|
||||
local components = self.components_interest[const.ON_INPUT]
|
||||
check_sort_input_stack(self, components)
|
||||
local is_input_consumed = process_input(self, action_id, action, components)
|
||||
local is_input_consumed = self:_process_input(action_id, action, components)
|
||||
|
||||
self._is_late_remove_enabled = false
|
||||
self:_clear_late_remove()
|
||||
@@ -421,7 +420,7 @@ end
|
||||
---Set whitelist components for input processing.
|
||||
---If whitelist is not empty and component not contains in this list,
|
||||
---component will be not processed on input step
|
||||
---@param whitelist_components table|druid.base_component[]|nil The array of component to whitelist
|
||||
---@param whitelist_components table|druid.base_component[] The array of component to whitelist
|
||||
---@return druid_instance
|
||||
function M:set_whitelist(whitelist_components)
|
||||
if whitelist_components and whitelist_components._component then
|
||||
@@ -441,7 +440,7 @@ end
|
||||
---Set blacklist components for input processing.
|
||||
---If blacklist is not empty and component contains in this list,
|
||||
---component will be not processed on input step DruidInstance
|
||||
---@param blacklist_components table|druid.base_component[]|nil The array of component to blacklist
|
||||
---@param blacklist_components table|druid.base_component[] The array of component to blacklist
|
||||
---@return druid_instance
|
||||
function M:set_blacklist(blacklist_components)
|
||||
if blacklist_components and blacklist_components._component then
|
||||
|
Reference in New Issue
Block a user