diff --git a/docs_md/api_reference/druid_button.md b/docs_md/api_reference/druid_button.md new file mode 100644 index 0000000..e69de29 diff --git a/docs_md/quick_api_reference.md b/docs_md/quick_api_reference.md new file mode 100644 index 0000000..e53c5d1 --- /dev/null +++ b/docs_md/quick_api_reference.md @@ -0,0 +1,74 @@ +# Quick API Reference + +## Druid +```lua +local druid = require("druid.druid") + +druid.init_window_listener() +druid.on_language_change() +druid.on_window_callback(window_event) +druid.set_default_style(style) +druid.set_sound_function(callback) +druid.set_text_function(callback) + +self.druid = druid.new(context, [style]) +``` + +## Druid Instance +```lua +self.druid:final() +self.druid:update(dt) +self.druid:on_input(action_id, action) +self.druid:on_message(message_id, message, sender) + +self.druid:new(component, ...) +self.druid:new_back_handler([callback], [params]) +self.druid:new_blocker(node) +self.druid:new_button(node, [callback], [params], [anim_node]) +self.druid:new_container(node, [mode], [callback]) +self.druid:new_data_list(druid_scroll, druid_grid, create_function) +self.druid:new_drag(node, [on_drag_callback]) +self.druid:new_grid(parent_node, item, [in_row]) +self.druid:new_hotkey(keys_array, [callback], [callback_argument]) +self.druid:new_hover(node, [on_hover_callback], [on_mouse_hover_callback]) +self.druid:new_input(click_node, text_node, [keyboard_type]) +self.druid:new_lang_text(node, [locale_id], [adjust_type]) +self.druid:new_layout(node, [mode]) +self.druid:new_progress(node, key, [init_value]) +self.druid:new_rich_input(template, [nodes]) +self.druid:new_rich_text(text_node, [value]) +self.druid:new_scroll(view_node, content_node) +self.druid:new_slider(pin_node, end_pos, [callback]) +self.druid:new_swipe(node, [on_swipe_callback]) +self.druid:new_text(node, [value], [no_adjust]) +self.druid:new_timer(node, [seconds_from], [seconds_to], [callback]) +self.druid:new_widget(widget, [template], [nodes], ...) +self.druid:on_window_event([window_event]) +self.druid:remove(component) +self.druid:set_blacklist(blacklist_components) +self.druid:set_whitelist(whitelist_components) +``` + +## Components +### Base Component +### Blocker +### Button +### Container +### Data List +### Drag +### Grid +### Hotkey +### Hover +### Input +### Lang Text +### Layout +### Progress +### Rich Input +### Rich Text +### Scroll +### Slider +### Swipe +### Text +### Timer + +## Helper diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index aec7977..4bd7f75 100755 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -91,30 +91,30 @@ local helper = require("druid.helper") local component = require("druid.component") ---@class druid.scroll: druid.base_component ----@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 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) +---@field on_scroll_to event Triggered on scroll_to with (self, target, is_instant) +---@field on_point_scroll event Triggered on scroll_to_index with (self, index, point) +---@field view_node node The scroll view node (static part) +---@field view_border vector4 The scroll view borders +---@field content_node node The scroll content node (moving part) +---@field view_size vector3 Size of the view node ---@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 +---@field target_position vector3 Target scroll position for animations +---@field available_pos vector4 Available content position (min_x, max_y, max_x, min_y) +---@field available_size vector3 Size of available positions (width, height, 0) +---@field drag druid.drag The drag component instance +---@field selected number|nil Current selected point of interest index +---@field is_animate boolean True if scroll is animating +---@field private _is_inert boolean True if inertial scrolling is enabled +---@field private inertion vector3 Current inertial movement vector +---@field private _is_horizontal_scroll boolean True if horizontal scroll enabled +---@field private _is_vertical_scroll boolean True if vertical scroll enabled +---@field private _grid_on_change event Grid items change event +---@field private _grid_on_change_callback function Grid change callback +---@field private _offset vector3 Content start offset +---@field private style table Component style parameters local M = component.create("scroll") diff --git a/druid/custom/rich_text/module/rt.lua b/druid/custom/rich_text/module/rt.lua index 83d1b85..8239877 100755 --- a/druid/custom/rich_text/module/rt.lua +++ b/druid/custom/rich_text/module/rt.lua @@ -424,7 +424,7 @@ function M._update_nodes(lines, settings) gui.set_outline(node, word.outline) gui.set_shadow(node, word.shadow) gui.set_text(node, word.text) - gui.set_color(node, word.color or word.text_color) + gui.set_color(node, word.color) gui.set_font(node, word.font or settings.font) end word.node = node diff --git a/druid/custom/rich_text/rich_text.lua b/druid/custom/rich_text/rich_text.lua index 80deec4..6e2fb8d 100644 --- a/druid/custom/rich_text/rich_text.lua +++ b/druid/custom/rich_text/rich_text.lua @@ -100,6 +100,7 @@ local rich_text = require("druid.custom.rich_text.module.rt") ---@class druid.rich_text.word ---@field node node ---@field relative_scale number +---@field source_text string ---@field color vector4 ---@field position vector3 ---@field offset vector3 diff --git a/druid/system/druid_annotations.lua b/druid/system/druid_annotations.lua index 68d2ac0..a08b449 100644 --- a/druid/system/druid_annotations.lua +++ b/druid/system/druid_annotations.lua @@ -7,6 +7,8 @@ ---@field height number ---@field max_ascent number ---@field max_descent number +---@field offset_x number +---@field offset_y number ---@class utf8 ---@field len fun(s: string):number @@ -24,4 +26,4 @@ ---@field format fun() ---@field lower fun() ---@field upper fun() ----@field rep fun() \ No newline at end of file +---@field rep fun() diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index 774b9e3..beca2d1 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -85,9 +85,8 @@ local function create_widget(self, widget_class) __index = setmetatable(widget_class, WIDGET_METATABLE) }) - local uid = base_component.create_uid() instance._component = { - _uid = uid, + _uid = base_component.create_uid(), name = "Druid Widget", input_priority = const.PRIORITY_INPUT, default_input_priority = const.PRIORITY_INPUT,