mirror of
https://github.com/Insality/druid
synced 2025-06-27 02:17:52 +02:00
Update
This commit is contained in:
parent
b6c0e1556a
commit
96ce3eee95
@ -1 +1,2 @@
|
||||
/dist
|
||||
/.deployer_cache
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -16,3 +16,4 @@ bob*.jar
|
||||
manifest.private.der
|
||||
manifest.public.der
|
||||
/.editor_settings
|
||||
/.deployer_cache
|
||||
|
@ -141,8 +141,9 @@ local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
---Clickable node with various interaction callbacks
|
||||
---@class druid.button: druid.base_component
|
||||
---@field on_click event
|
||||
---@field on_click event function(self, custom_args, button_instance)
|
||||
---@field on_pressed event
|
||||
---@field on_repeated_click event
|
||||
---@field on_long_click event
|
||||
|
@ -91,14 +91,30 @@ local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class druid.scroll: druid.base_component
|
||||
---@field on_scroll event
|
||||
---@field on_scroll_to event
|
||||
---@field on_point_scroll event
|
||||
---@field view_node node
|
||||
---@field view_border vector4
|
||||
---@field content_node node
|
||||
---@field view_size vector3
|
||||
---@field position vector3
|
||||
---@field node node
|
||||
---@field click_zone node|nil
|
||||
---@field on_scroll event On scroll move callback(self, position)
|
||||
---@field on_scroll_to event On scroll_to function callback(self, target, is_instant)
|
||||
---@field on_point_scroll event On scroll_to_index function callback(self, index, point)
|
||||
---@field view_node node Scroll view node
|
||||
---@field view_border vector4 Scroll view border
|
||||
---@field content_node node Scroll content node
|
||||
---@field view_size vector3 Scroll view size
|
||||
---@field position vector3 Current scroll position
|
||||
---@field target_position vector3 Current scroll target position
|
||||
---@field available_pos vector4 Available position for content node: (min_x, max_y, max_x, min_y)
|
||||
---@field available_size vector3 Size of available positions: (width, height, 0)
|
||||
---@field drag druid.drag Drag Druid component
|
||||
---@field selected number|nil Current index of points of interests
|
||||
---@field is_animate boolean Flag, if scroll now animating by gui.animate
|
||||
---@field private _is_inert boolean Flag, if scroll now moving by inertion
|
||||
---@field private inertion vector3 Current inert speed
|
||||
---@field private _is_horizontal_scroll boolean Flag, if scroll now horizontal
|
||||
---@field private _is_vertical_scroll boolean Flag, if scroll now vertical
|
||||
---@field private _grid_on_change event Grid on change items event
|
||||
---@field private _grid_on_change_callback function Grid on change items callback
|
||||
---@field private _offset vector3 Offset value to set, where content is starts
|
||||
---@field private style table Component style params
|
||||
local M = component.create("scroll")
|
||||
|
||||
|
||||
@ -228,8 +244,8 @@ end
|
||||
|
||||
function M:update(dt)
|
||||
if self.is_animate then
|
||||
self.position.x = gui.get(self.content_node, "position.x")
|
||||
self.position.y = gui.get(self.content_node, "position.y")
|
||||
self.position.x = gui.get(self.content_node, "position.x") --[[@as number]]
|
||||
self.position.y = gui.get(self.content_node, "position.y") --[[@as number]]
|
||||
self.on_scroll:trigger(self:get_context(), self.position)
|
||||
end
|
||||
|
||||
@ -383,7 +399,7 @@ end
|
||||
--- Enable or disable scroll inert.
|
||||
-- If disabled, scroll through points (if exist)
|
||||
-- If no points, just simple drag without inertion
|
||||
---@param state boolean|nil Inert scroll state
|
||||
---@param state boolean Inert scroll state
|
||||
---@return druid.scroll Current scroll instance
|
||||
function M:set_inert(state)
|
||||
self._is_inert = state
|
||||
@ -436,21 +452,21 @@ end
|
||||
|
||||
|
||||
--- Lock or unlock horizontal scroll
|
||||
---@param state boolean|nil True, if horizontal scroll is enabled
|
||||
---@param state boolean True, if horizontal scroll is enabled
|
||||
---@return druid.scroll Current scroll instance
|
||||
function M:set_horizontal_scroll(state)
|
||||
self._is_horizontal_scroll = state
|
||||
self.drag.can_x = self.available_size.x > 0 and state
|
||||
self.drag.can_x = self.available_size.x > 0 and state or false
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Lock or unlock vertical scroll
|
||||
---@param state boolean|nil True, if vertical scroll is enabled
|
||||
---@param state boolean True, if vertical scroll is enabled
|
||||
---@return druid.scroll Current scroll instance
|
||||
function M:set_vertical_scroll(state)
|
||||
self._is_vertical_scroll = state
|
||||
self.drag.can_y = self.available_size.y > 0 and state
|
||||
self.drag.can_y = self.available_size.y > 0 and state or false
|
||||
return self
|
||||
end
|
||||
|
||||
@ -497,7 +513,7 @@ end
|
||||
|
||||
--- Bind the grid component (Static or Dynamic) to recalculate
|
||||
-- scroll size on grid changes
|
||||
---@param grid druid.grid Druid grid component
|
||||
---@param grid druid.grid|nil Druid grid component
|
||||
---@return druid.scroll Current scroll instance
|
||||
function M:bind_grid(grid)
|
||||
if self._grid_on_change then
|
||||
@ -508,7 +524,7 @@ function M:bind_grid(grid)
|
||||
end
|
||||
|
||||
if not grid then
|
||||
return
|
||||
return self
|
||||
end
|
||||
|
||||
self._grid_on_change = grid.on_change_items
|
||||
|
@ -89,7 +89,7 @@ local utf8 = utf8 or utf8_lua --[[@as utf8]]
|
||||
---@field on_update_text_scale event
|
||||
---@field on_set_pivot event
|
||||
---@field style table
|
||||
---@field private start_pivot number
|
||||
---@field private start_pivot userdata
|
||||
---@field private start_scale vector3
|
||||
---@field private scale vector3
|
||||
local M = component.create("text")
|
||||
@ -491,7 +491,7 @@ end
|
||||
|
||||
|
||||
--- Set text pivot. Text will re-anchor inside text area
|
||||
---@param pivot number The gui.PIVOT_* constant
|
||||
---@param pivot userdata The gui.PIVOT_* constant
|
||||
---@return druid.text Current text instance
|
||||
function M:set_pivot(pivot)
|
||||
local prev_pivot = gui.get_pivot(self.node)
|
||||
|
@ -4,7 +4,7 @@ local helper = require("druid.helper")
|
||||
---@class druid.base_component.meta
|
||||
---@field template string
|
||||
---@field context table
|
||||
---@field nodes table<string|hash, node>|nil
|
||||
---@field nodes table<hash, node>|nil
|
||||
---@field style table|nil
|
||||
---@field druid druid_instance
|
||||
---@field input_enabled boolean
|
||||
@ -41,6 +41,7 @@ local INTERESTS = {} -- Cache interests per component class in runtime
|
||||
|
||||
|
||||
local uid = 0
|
||||
---@private
|
||||
function M.create_uid()
|
||||
uid = uid + 1
|
||||
return uid
|
||||
@ -107,7 +108,7 @@ end
|
||||
|
||||
|
||||
---Set current component nodes, returned from `gui.clone_tree` function.
|
||||
---@param nodes table<string|hash, node>
|
||||
---@param nodes table<hash, node>
|
||||
---@return druid.base_component
|
||||
function M:set_nodes(nodes)
|
||||
self._meta.nodes = nodes
|
||||
@ -132,7 +133,7 @@ end
|
||||
|
||||
---Get Druid instance for inner component creation.
|
||||
---@param template string|nil
|
||||
---@param nodes table<string|hash, node>|nil
|
||||
---@param nodes table<hash, node>|nil
|
||||
---@return druid_instance
|
||||
function M:get_druid(template, nodes)
|
||||
local context = { _context = self }
|
||||
@ -305,7 +306,7 @@ end
|
||||
|
||||
|
||||
---Get current component nodes
|
||||
---@return table<hash, node>
|
||||
---@return table<hash, node>|nil
|
||||
function M:get_nodes()
|
||||
local nodes = self._meta.nodes
|
||||
local parent = self:get_parent_component()
|
||||
|
@ -272,7 +272,7 @@ end
|
||||
---@return druid.rich_text.word[] words
|
||||
function M:tagged(tag)
|
||||
if not self._words then
|
||||
return
|
||||
return {}
|
||||
end
|
||||
|
||||
return rich_text.tagged(self._words, tag)
|
||||
|
@ -1,5 +1,6 @@
|
||||
---@class druid.widget: druid.base_component
|
||||
---@field druid druid_instance
|
||||
---@field druid druid_instance Ready to use druid instance
|
||||
---@field root node
|
||||
|
||||
---@class GUITextMetrics
|
||||
---@field width number
|
||||
@ -24,32 +25,3 @@
|
||||
---@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).
|
||||
|
@ -200,8 +200,7 @@ end
|
||||
|
||||
--- Druid class constructor
|
||||
---@param context table Druid context. Usually it is self of gui script
|
||||
---@param style table Druid style table
|
||||
---@private
|
||||
---@param style table? Druid style table
|
||||
function M:initialize(context, style)
|
||||
self._context = context
|
||||
self._style = style or settings.default_style
|
||||
|
@ -69,6 +69,15 @@ function M:set_samples(samples)
|
||||
end
|
||||
|
||||
|
||||
function M:get_samples()
|
||||
return self.samples
|
||||
end
|
||||
|
||||
|
||||
---Set normalized to control the color of the line
|
||||
--- for index = 1, mini_graph:get_samples() do
|
||||
--- mini_graph:set_line_value(index, math.random())
|
||||
--- end
|
||||
---@param index number
|
||||
---@param value number The normalized value from 0 to 1
|
||||
function M:set_line_value(index, value)
|
||||
@ -83,7 +92,6 @@ function M:set_line_value(index, value)
|
||||
local target_color = color.lerp(normalized, self.color_zero, self.color_one)
|
||||
gui.set_color(line, target_color)
|
||||
self:set_line_height(index)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user