diff --git a/README.md b/README.md index ec3991b..2f00cad 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + [![](media/druid_logo.png)](https://insality.github.io/druid/) [![GitHub release (latest by date)](https://img.shields.io/github/v/release/insality/druid)](https://github.com/Insality/druid/releases) diff --git a/annotations.lua b/annotations.lua new file mode 100644 index 0000000..38a5e4a --- /dev/null +++ b/annotations.lua @@ -0,0 +1,1138 @@ +-- luacheck: ignore + + +---@class druid +local druid = {} + +--- Create Druid instance. +---@param context table Druid context. Usually it is self of script +---@param style table Druid style module +---@return druid_instance Druid instance +function druid.new(context, style) end + +--- Druid on language change. +function druid.on_language_change() end + +--- Callback on global language change event. +function druid.on_language_change() end + +--- Callback on global layout change event. +function druid.on_layout_change() end + +--- Callback on global window event. +---@param event string Event param from window listener +function druid.on_window_callback(event) end + +--- Register external druid component. +---@param name string module name +---@param module table lua table with component +function druid.register(name, module) end + +--- Set new default style. +---@param style table Druid style module +function druid.set_default_style(style) end + +--- Set sound function. +---@param callback function Sound play callback +function druid.set_sound_function(callback) end + +--- Set text function Druid locale component will call this function to get translated text. +---@param callback function Get localized text function +function druid.set_text_function(callback) end + + +---@class druid.back_handler : druid.base_component +---@field on_back druid_event On back handler callback(self, params) +local druid__back_handler = {} + +--- Component init function +---@param self druid.back_handler +---@param callback callback On back button +---@param params any Callback argument +function druid__back_handler.init(self, callback, params) end + +--- Input handler for component +---@param self druid.back_handler +---@param action_id string on_input action id +---@param action table on_input action +function druid__back_handler.on_input(self, action_id, action) end + + +---@class druid.base_component +local druid__base_component = {} + +--- Get current component context +---@param self druid.base_component +---@return table BaseComponent context +function druid__base_component.get_context(self) end + +--- Return druid with context of calling component. +---@param self druid.base_component +---@return Druid Druid instance with component context +function druid__base_component.get_druid(self) end + +--- Return component name +---@param self druid.base_component +---@return string The component name +function druid__base_component.get_name(self) end + +--- Get node for component by name. +---@param self druid.base_component +---@param node_or_name string|node Node name or node itself +---@return node Gui node +function druid__base_component.get_node(self, node_or_name) end + +--- Return the parent for current component +---@param self druid.base_component +---@return druid.base_component|nil The druid component instance or nil +function druid__base_component.get_parent_component(self) end + +--- Increase input priority in current input stack +---@param self druid.base_component +function druid__base_component.increase_input_priority(self) end + +--- Reset input priority in current input stack +---@param self druid.base_component +function druid__base_component.reset_input_priority(self) end + +--- Set component input state. +---@param self druid.base_component +---@param state bool The component input state +---@return druid.base_component BaseComponent itself +function druid__base_component.set_input_enabled(self, state) end + +--- Set current component nodes +---@param self druid.base_component +---@param nodes table BaseComponent nodes table +function druid__base_component.set_nodes(self, nodes) end + +--- Set current component style table. +---@param self druid.base_component +---@param druid_style table Druid style module +function druid__base_component.set_style(self, druid_style) end + +--- Set current component template name +---@param self druid.base_component +---@param template string BaseComponent template name +function druid__base_component.set_template(self, template) end + +--- Setup component context and his style table +---@param self druid.base_component +---@param druid_instance table The parent druid instance +---@param context table Druid context. Usually it is self of script +---@param style table Druid style module +---@return component BaseComponent itself +function druid__base_component.setup_component(self, druid_instance, context, style) end + + +---@class druid.blocker : druid.base_component +local druid__blocker = {} + +--- Component init function +---@param self druid.blocker +---@param node node Gui node +function druid__blocker.init(self, node) end + +--- Return blocked enabled state +---@param self druid.blocker +---@return bool True, if blocker is enabled +function druid__blocker.is_enabled(self) end + +--- Set enabled blocker component state +---@param self druid.blocker +---@param state bool Enabled state +function druid__blocker.set_enabled(self, state) end + + +---@class druid.button : druid.base_component +---@field anim_node node Animation node +---@field hover druid.hover Druid hover logic component +---@field node node Trigger node +---@field on_click druid_event On release button callback(self, params, button_instance) +---@field on_click_outside druid_event On click outside of button(self, params, button_instance) +---@field on_double_click druid_event On double tap button callback(self, params, button_instance, click_amount) +---@field on_hold_callback druid_event On button hold before long_click callback(self, params, button_instance, time) +---@field on_long_click druid_event On long tap button callback(self, params, button_instance, time) +---@field on_repeated_click druid_event On repeated action button callback(self, params, button_instance, click_amount) +---@field params any Params to click callbacks +---@field pos vector3 Initial pos of anim_node +---@field start_pos vector3 Initial pos of anim_node +---@field start_scale vector3 Initial scale of anim_node +---@field style druid.button.style Component style params. +local druid__button = {} + +--- Get key-code to trigger this button +---@param self druid.button +---@return hash The action_id of the key +function druid__button.get_key_trigger(self) end + +--- Component init function +---@param self druid.button +---@param node node Gui node +---@param callback function Button callback +---@param params table Button callback params +---@param anim_node node Button anim node (node, if not provided) +function druid__button.init(self, node, callback, params, anim_node) end + +--- Return button enabled state +---@param self druid.button +---@return bool True, if button is enabled +function druid__button.is_enabled(self) end + +--- Strict button click area. +---@param self druid.button +---@param zone node Gui node +---@return druid.button Current button instance +function druid__button.set_click_zone(self, zone) end + +--- Set enabled button component state +---@param self druid.button +---@param state bool Enabled state +---@return druid.button Current button instance +function druid__button.set_enabled(self, state) end + +--- Set key-code to trigger this button +---@param self druid.button +---@param key hash The action_id of the key +---@return druid.button Current button instance +function druid__button.set_key_trigger(self, key) end + + +---@class druid.button.style +---@field AUTOHOLD_TRIGGER field Maximum hold time to trigger button release while holding +---@field DOUBLETAP_TIME field Time between double taps +---@field LONGTAP_TIME field Minimum time to trigger on_hold_callback +---@field on_click field (self, node) +---@field on_click_disabled field (self, node) +---@field on_hover field (self, node, hover_state) +---@field on_mouse_hover field (self, node, hover_state) +---@field on_set_enabled field (self, node, enabled_state) +local druid__button__style = {} + + +---@class druid.checkbox : druid.base_component +---@field click_node node Button trigger node +---@field node node Visual node +---@field on_change_state druid_event On change state callback(self, state) +---@field style druid.checkbox.style Component style params. +local druid__checkbox = {} + +--- Return checkbox state +---@param self druid.checkbox +---@return bool Checkbox state +function druid__checkbox.get_state(self) end + +--- Component init function +---@param self druid.checkbox +---@param node node Gui node +---@param callback function Checkbox callback +---@param click_node node Trigger node, by default equals to node +function druid__checkbox.init(self, node, callback, click_node) end + +--- Set checkbox state +---@param self druid.checkbox +---@param state bool Checkbox state +---@param is_silent bool Don't trigger on_change_state if true +function druid__checkbox.set_state(self, state, is_silent) end + + +---@class druid.checkbox.style +---@field on_change_state field (self, node, state) +local druid__checkbox__style = {} + + +---@class druid.checkbox_group : druid.base_component +---@field on_checkbox_click druid_event On any checkbox click callback(self, index) +local druid__checkbox_group = {} + +--- Return checkbox group state +---@param self druid.checkbox_group +---@return bool[] Array if checkboxes state +function druid__checkbox_group.get_state(self) end + +--- Component init function +---@param self druid.checkbox_group +---@param nodes node[] Array of gui node +---@param callback function Checkbox callback +---@param click_nodes node[] Array of trigger nodes, by default equals to nodes +function druid__checkbox_group.init(self, nodes, callback, click_nodes) end + +--- Set checkbox group state +---@param self druid.checkbox_group +---@param indexes bool[] Array of checkbox state +function druid__checkbox_group.set_state(self, indexes) end + + +---@class druid.drag : druid.base_component +---@field can_x bool Is drag component process vertical dragging. +---@field can_y bool Is drag component process horizontal. +---@field is_drag bool Is component now dragging +---@field is_touch bool Is component now touching +---@field on_drag druid_event on drag progress callback(self, dx, dy) +---@field on_drag_end druid_event Event on drag end callback(self) +---@field on_drag_start druid_event Event on drag start callback(self) +---@field on_touch_end druid_event Event on touch end callback(self) +---@field on_touch_start druid_event Event on touch start callback(self) +---@field style druid.drag.style Component style params. +---@field x number Current touch x position +---@field y number Current touch y position +local druid__drag = {} + +--- Drag component constructor +---@param self druid.drag +---@param node node GUI node to detect dragging +---@param on_drag_callback function Callback for on_drag_event(self, dx, dy) +function druid__drag.init(self, node, on_drag_callback) end + +--- Strict drag click area. +---@param self druid.drag +---@param zone node Gui node +function druid__drag.set_click_zone(self, zone) end + + +---@class druid.drag.style +---@field DRAG_DEADZONE field Distance in pixels to start dragging +local druid__drag__style = {} + + +---@class druid.dynamic_grid : druid.base_component +---@field first_index number The first index of node in grid +---@field last_index number The last index of node in grid +---@field node_size vector3 Item size +---@field nodes node[] List of all grid nodes +---@field on_add_item druid_event On item add callback(self, node, index) +---@field on_change_items druid_event On item add or remove callback(self, index) +---@field on_clear druid_event On grid clear callback(self) +---@field on_remove_item druid_event On item remove callback(self, index) +---@field on_update_positions druid_event On update item positions callback(self) +---@field parent node Parent gui node +local druid__dynamic_grid = {} + +--- Return side vector to correct node shifting +---@param self unknown +---@param side unknown +---@param is_forward unknown +function druid__dynamic_grid._get_side_vector(self, side, is_forward) end + +--- Add new node to the grid +---@param self druid.dynamic_grid +---@param node node Gui node +---@param index number The node position. By default add as last node +---@param is_shift_left bool If true, shift all nodes to the left, otherwise shift nodes to the right +function druid__dynamic_grid.add(self, node, index, is_shift_left) end + +--- Clear grid nodes array. +---@param self druid.dynamic_grid +---@return druid.dynamic_grid Current grid instance +function druid__dynamic_grid.clear(self) end + +--- Return array of all node positions +---@param self druid.dynamic_grid +---@return vector3[] All grid node positions +function druid__dynamic_grid.get_all_pos(self) end + +--- Return grid index by node +---@param self druid.dynamic_grid +---@param node node The gui node in the grid +---@return number The node index +function druid__dynamic_grid.get_index_by_node(self, node) end + +--- Return pos for grid node index +---@param self druid.dynamic_grid +---@param index number The grid element index +---@param node node The node to be placed +---@param origin_index number Index of nearby node +---@return vector3 Node position +function druid__dynamic_grid.get_pos(self, index, node, origin_index) end + +--- Return grid content size +---@param self druid.dynamic_grid +---@param border vector3 +---@return vector3 The grid content size +function druid__dynamic_grid.get_size(self, border) end + +--- Component init function +---@param self druid.dynamic_grid +---@param parent node The gui node parent, where items will be placed +function druid__dynamic_grid.init(self, parent) end + +--- Remove the item from the grid. +---@param self druid.dynamic_grid +---@param index number The grid node index to remove +---@param is_shift_left bool If true, shift all nodes to the left, otherwise shift nodes to the right +function druid__dynamic_grid.remove(self, index, is_shift_left) end + +--- Change set position function for grid nodes. +---@param self druid.dynamic_grid +---@param callback function Function on node set position +---@return druid.dynamic_grid Current grid instance +function druid__dynamic_grid.set_position_function(self, callback) end + + +---@class druid.hover : druid.base_component +---@field on_hover druid_event On hover callback(self, state) +local druid__hover = {} + +--- Component init function +---@param self druid.hover +---@param node node Gui node +---@param on_hover_callback function Hover callback +function druid__hover.init(self, node, on_hover_callback) end + +--- Return current hover enabled state +---@param self druid.hover +---@return bool The hover enabled state +function druid__hover.is_enabled(self) end + +--- Strict hover click area. +---@param self druid.hover +---@param zone node Gui node +function druid__hover.set_click_zone(self, zone) end + +--- Set enable state of hover component. +---@param self druid.hover +---@param state bool The hover enabled state +function druid__hover.set_enabled(self, state) end + +--- Set hover state +---@param self druid.hover +---@param state bool The hover state +function druid__hover.set_hover(self, state) end + +--- Set mouse hover state +---@param self druid.hover +---@param state bool The mouse hover state +function druid__hover.set_mouse_hover(self, state) end + + +---@class druid.input : druid.base_component +---@field allowerd_characters string Pattern matching for user input +---@field button druid.button Button component +---@field is_empty bool Is current input is empty now +---@field is_selected bool Is current input selected now +---@field max_length number Max length for input text +---@field on_input_empty druid_event On input field text change to empty string callback(self, input_text) +---@field on_input_full druid_event On input field text change to max length string callback(self, input_text) +---@field on_input_select druid_event On input field select callback(self, button_node) +---@field on_input_text druid_event On input field text change callback(self, input_text) +---@field on_input_unselect druid_event On input field unselect callback(self, button_node) +---@field on_input_wrong druid_event On trying user input with not allowed character callback(self, params, button_instance) +---@field style druid.input.style Component style params. +---@field text druid.text Text component +local druid__input = {} + +--- Return current input field text +---@param self druid.input +---@return string The current input field text +function druid__input.get_text(self) end + +--- Reset current input selection and return previous value +---@param self druid.input +function druid__input.reset_changes(self) end + +--- Set allowed charaters for input field. +---@param self druid.input +---@param characters string Regulax exp. for validate user input +---@return druid.input Current input instance +function druid__input.set_allowed_characters(self, characters) end + +--- Set maximum length for input field. +---@param self druid.input +---@param max_length number Maximum length for input text field +---@return druid.input Current input instance +function druid__input.set_max_length(self, max_length) end + +--- Set text for input field +---@param self druid.input +---@param input_text string The string to apply for input field +function druid__input.set_text(self, input_text) end + + +---@class druid.input.style +---@field IS_LONGTAP_ERASE field Is long tap will erase current input data +---@field MASK_DEFAULT_CHAR field Default character mask for password input +---@field button_style field Custom button style for input node +---@field on_input_wrong field (self, button_node) Callback on wrong user input +---@field on_select field (self, button_node) Callback on input field selecting +---@field on_unselect field (self, button_node) Callback on input field unselecting +local druid__input__style = {} + + +---@class druid.lang_text : druid.base_component +---@field on_change druid_event On change text callback +local druid__lang_text = {} + +--- Component init function +---@param self druid.lang_text +---@param node node The text node +---@param locale_id string Default locale id +---@param no_adjust bool If true, will not correct text size +function druid__lang_text.init(self, node, locale_id, no_adjust) end + +--- Setup raw text to lang_text component +---@param self druid.lang_text +---@param text string Text for text node +function druid__lang_text.set_to(self, text) end + +--- Translate the text by locale_id +---@param self druid.lang_text +---@param locale_id string Locale id +function druid__lang_text.translate(self, locale_id) end + + +---@class druid.progress : druid.base_component +---@field key string The progress bar direction +---@field max_size number Maximum size of progress bar +---@field node node Progress bar fill node +---@field on_change druid_event On progress bar change callback(self, new_value) +---@field scale vector3 Current progress bar scale +---@field size vector3 Current progress bar size +---@field style druid.progress.style Component style params. +local druid__progress = {} + +--- Empty a progress bar +---@param self druid.progress +function druid__progress.empty(self) end + +--- Fill a progress bar and stop progress animation +---@param self druid.progress +function druid__progress.fill(self) end + +--- Return current progress bar value +---@param self druid.progress +function druid__progress.get(self) end + +--- Component init function +---@param self druid.progress +---@param node string|node Progress bar fill node or node name +---@param key string Progress bar direction: const.SIDE.X or const.SIDE.Y +---@param init_value number Initial value of progress bar +function druid__progress.init(self, node, key, init_value) end + +--- Set points on progress bar to fire the callback +---@param self druid.progress +---@param steps number[] Array of progress bar values +---@param callback function Callback on intersect step value +function druid__progress.set_steps(self, steps, callback) end + +--- Instant fill progress bar to value +---@param self druid.progress +---@param to number Progress bar value, from 0 to 1 +function druid__progress.set_to(self, to) end + +--- Start animation of a progress bar +---@param self druid.progress +---@param to number value between 0..1 +---@param callback function Callback on animation ends +function druid__progress.to(self, to, callback) end + + +---@class druid.progress.style +---@field MIN_DELTA field Minimum step to fill progress bar +---@field SPEED field Progress bas fill rate. More -> faster +local druid__progress__style = {} + + +---@class druid.radio_group : druid.base_component +---@field on_radio_click druid_event On any checkbox click +local druid__radio_group = {} + +--- Return radio group state +---@param self druid.radio_group +---@return number Index in radio group +function druid__radio_group.get_state(self) end + +--- Component init function +---@param self druid.radio_group +---@param nodes node[] Array of gui node +---@param callback function Radio callback +---@param click_nodes node[] Array of trigger nodes, by default equals to nodes +function druid__radio_group.init(self, nodes, callback, click_nodes) end + +--- Set radio group state +---@param self druid.radio_group +---@param index number Index in radio group +function druid__radio_group.set_state(self, index) end + + +---@class druid.scroll : druid.base_component +---@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 content_node node Scroll content node +---@field drag Drag Drag Druid component +---@field inertion vector3 Current inert speed +---@field is_inert bool Flag, if scroll now moving by inertion +---@field on_point_scroll druid_event On scroll_to_index function callback(self, index, point) +---@field on_scroll druid_event On scroll move callback(self, position) +---@field on_scroll_to druid_event On scroll_to function callback(self, target, is_instant) +---@field position vector3 Current scroll posisition +---@field selected number Current index of points of interests +---@field style druid.scroll.style Component style params. +---@field target_position vector3 Current scroll target position +---@field view_node node Scroll view node +local druid__scroll = {} + +--- Cancel animation on other animation or input touch +---@param self unknown +function druid__scroll._cancel_animate(self) end + +--- Bind the grid component (Static or Dynamic) to recalculate scroll size on grid changes +---@param self druid.scroll +---@param grid StaticGrid|DynamicGrid Druid grid component +---@return druid.scroll Current scroll instance +function druid__scroll.bind_grid(self, grid) end + +--- Return current scroll progress status. +---@param self druid.scroll +---@return vector3 New vector with scroll progress values +function druid__scroll.get_percent(self) end + +--- Return vector of scroll size with width and height. +---@param self druid.scroll +---@return vector3 Available scroll size +function druid__scroll.get_scroll_size(self) end + +--- Scroll constructor +---@param self druid.scroll +---@param view_node node GUI view scroll node +---@param content_node node GUI content scroll node +function druid__scroll.init(self, view_node, content_node) end + +--- Return if scroll have inertion. +---@param self druid.scroll +---@return bool If scroll have inertion +function druid__scroll.is_inert(self) end + +--- Start scroll to target point. +---@param self druid.scroll +---@param point vector3 Target point +---@param is_instant bool Instant scroll flag +function druid__scroll.scroll_to(self, point, is_instant) end + +--- Scroll to item in scroll by point index. +---@param self druid.scroll +---@param index number Point index +---@param skip_cb bool If true, skip the point callback +function druid__scroll.scroll_to_index(self, index, skip_cb) end + +--- Start scroll to target scroll percent +---@param self druid.scroll +---@param percent vector3 target percent +---@param is_instant bool instant scroll flag +function druid__scroll.scroll_to_percent(self, percent, is_instant) end + +--- Set extra size for scroll stretching. +---@param self druid.scroll +---@param stretch_size number Size in pixels of additional scroll area +---@return druid.scroll Current scroll instance +function druid__scroll.set_extra_stretch_size(self, stretch_size) end + +--- Lock or unlock horizontal scroll +---@param self druid.scroll +---@param state bool True, if horizontal scroll is enabled +---@return druid.scroll Current scroll instance +function druid__scroll.set_horizontal_scroll(self, state) end + +--- Enable or disable scroll inert. +---@param self druid.scroll +---@param state bool Inert scroll state +---@return druid.scroll Current scroll instance +function druid__scroll.set_inert(self, state) end + +--- Set points of interest. +---@param self druid.scroll +---@param points table Array of vector3 points +---@return druid.scroll Current scroll instance +function druid__scroll.set_points(self, points) end + +--- Set scroll content size. +---@param self druid.scroll +---@param size vector3 The new size for content node +---@return druid.scroll Current scroll instance +function druid__scroll.set_size(self, size) end + +--- Lock or unlock vertical scroll +---@param self druid.scroll +---@param state bool True, if vertical scroll is enabled +---@return druid.scroll Current scroll instance +function druid__scroll.set_vertical_scroll(self, state) end + + +---@class druid.scroll.style +---@field ANIM_SPEED field Scroll gui.animation speed for scroll_to function +---@field BACK_SPEED field Scroll back returning lerp speed +---@field EXTRA_STRETCH_SIZE field extra size in pixels outside of scroll (stretch effect) +---@field FRICT field Multiplier for free inertion +---@field FRICT_HOLD field Multiplier for inertion, while touching +---@field INERT_SPEED field Multiplier for inertion speed +---@field INERT_THRESHOLD field Scroll speed to stop inertion +---@field POINTS_DEADZONE field Speed to check points of interests in no_inertion mode +---@field SMALL_CONTENT_SCROLL field If true, content node with size less than view node size can be scrolled +local druid__scroll__style = {} + + +---@class druid.slider : druid.base_component +---@field dist number Length between start and end position +---@field end_pos vector3 End pin node position +---@field is_drag bool Current drag state +---@field node node Slider pin node +---@field on_change_value druid_event On change value callback(self, value) +---@field pos vector3 Current pin node position +---@field start_pos vector3 Start pin node position +---@field target_pos vector3 Targer pin node position +local druid__slider = {} + +--- Component init function +---@param self druid.slider +---@param node node Gui pin node +---@param end_pos vector3 The end position of slider +---@param callback function On slider change callback +function druid__slider.init(self, node, end_pos, callback) end + +--- Set value for slider +---@param self druid.slider +---@param value number Value from 0 to 1 +---@param is_silent bool Don't trigger event if true +function druid__slider.set(self, value, is_silent) end + +--- Set slider steps. +---@param self druid.slider +---@param steps number[] Array of steps +function druid__slider.set_steps(self, steps) end + + +---@class druid.static_grid : druid.base_component +---@field anchor vector3 Item anchor +---@field first_index number The first index of node in grid +---@field last_index number The last index of node in grid +---@field node_size vector3 Item size +---@field nodes node[] List of all grid nodes +---@field on_add_item druid_event On item add callback(self, node, index) +---@field on_change_items druid_event On item add or remove callback(self, index) +---@field on_clear druid_event On grid clear callback(self) +---@field on_remove_item druid_event On item remove callback(self, index) +---@field on_update_positions druid_event On update item positions callback(self) +---@field parent node Parent gui node +local druid__static_grid = {} + +--- Add new item to the grid +---@param self druid.static_grid +---@param item node Gui node +---@param index number The item position. By default add as last item +function druid__static_grid.add(self, item, index) end + +--- Clear grid nodes array. +---@param self druid.static_grid +---@return druid.static_grid Current grid instance +function druid__static_grid.clear(self) end + +--- Return array of all node positions +---@param self druid.static_grid +---@return vector3[] All grid node positions +function druid__static_grid.get_all_pos(self) end + +--- Return index for grid pos +---@param self druid.static_grid +---@param pos vector3 The node position in the grid +---@return number The node index +function druid__static_grid.get_index(self, pos) end + +--- Return grid index by node +---@param self druid.static_grid +---@param node node The gui node in the grid +---@return number The node index +function druid__static_grid.get_index_by_node(self, node) end + +--- Return pos for grid node index +---@param self druid.static_grid +---@param index number The grid element index +---@return vector3 Node position +function druid__static_grid.get_pos(self, index) end + +--- Return grid content size +---@param self druid.static_grid +---@return vector3 The grid content size +function druid__static_grid.get_size(self) end + +--- Component init function +---@param self druid.static_grid +---@param parent node The gui node parent, where items will be placed +---@param element node Element prefab. Need to get it size +---@param in_row number How many nodes in row can be placed +function druid__static_grid.init(self, parent, element, in_row) end + +--- Remove the item from the grid. +---@param self druid.static_grid +---@param index number The grid node index to remove +---@param is_shift_nodes bool If true, will shift nodes left after index +function druid__static_grid.remove(self, index, is_shift_nodes) end + +--- Set grid anchor. +---@param self druid.static_grid +---@param anchor vector3 Anchor +function druid__static_grid.set_anchor(self, anchor) end + +--- Change set position function for grid nodes. +---@param self druid.static_grid +---@param callback function Function on node set position +---@return druid.static_grid Current grid instance +function druid__static_grid.set_position_function(self, callback) end + + +---@class druid.swipe : druid.base_component +---@field click_zone node Restriction zone +---@field node node Swipe node +---@field style druid.swipe.style Component style params. +local druid__swipe = {} + +--- Component init function +---@param self druid.swipe +---@param node node Gui node +---@param on_swipe_callback function Swipe callback for on_swipe_end event +function druid__swipe.init(self, node, on_swipe_callback) end + +--- Strict swipe click area. +---@param self druid.swipe +---@param zone node Gui node +function druid__swipe.set_click_zone(self, zone) end + + +---@class druid.swipe.style +---@field SWIPE_THRESHOLD field Minimum distance for swipe trigger +---@field SWIPE_TIME field Maximum time for swipe trigger +---@field SWIPE_TRIGGER_ON_MOVE field If true, trigger on swipe moving, not only release action +local druid__swipe__style = {} + + +---@class druid.text : druid.base_component +---@field is_no_adjust bool Current text size adjust settings +---@field node node Text node +---@field on_set_pivot druid_event On change pivot callback(self, pivot) +---@field on_set_text druid_event On set text callback(self, text) +---@field on_update_text_scale druid_event On adjust text size callback(self, new_scale) +---@field pos vector3 Current text position +---@field scale vector3 Current text node scale +---@field start_scale vector3 Initial text node scale +---@field start_size vector3 Initial text node size +---@field text_area vector3 Current text node available are +local druid__text = {} + +--- Calculate text width with font with respect to trailing space +---@param self druid.text +---@param text string +function druid__text.get_text_width(self, text) end + +--- Component init function +---@param self druid.text +---@param node node Gui text node +---@param value string Initial text. Default value is node text from GUI scene. +---@param no_adjust bool If true, text will be not auto-adjust size +function druid__text.init(self, node, value, no_adjust) end + +--- Return true, if text with line break +---@param self druid.text +---@return bool Is text node with line break +function druid__text.is_multiline(self) end + +--- Set alpha +---@param self druid.text +---@param alpha number Alpha for node +function druid__text.set_alpha(self, alpha) end + +--- Set color +---@param self druid.text +---@param color vector4 Color for node +function druid__text.set_color(self, color) end + +--- Set text pivot. +---@param self druid.text +---@param pivot gui.pivot Gui pivot constant +function druid__text.set_pivot(self, pivot) end + +--- Set scale +---@param self druid.text +---@param scale vector3 Scale for node +function druid__text.set_scale(self, scale) end + +--- Set text to text field +---@param self druid.text +---@param set_to string Text for node +function druid__text.set_to(self, set_to) end + + +---@class druid.timer : druid.base_component +---@field from number Initial timer value +---@field node node Trigger node +---@field on_set_enabled druid_event On timer change enabled state callback(self, is_enabled) +---@field on_tick druid_event On timer tick. +---@field on_timer_end druid_event On timer end callback +---@field target number Target timer value +local druid__timer = {} + +--- Component init function +---@param self druid.timer +---@param node node Gui text node +---@param seconds_from number Start timer value in seconds +---@param seconds_to number End timer value in seconds +---@param callback function Function on timer end +function druid__timer.init(self, node, seconds_from, seconds_to, callback) end + +--- Set time interval +---@param self druid.timer +---@param from number Start time in seconds +---@param to number Target time in seconds +function druid__timer.set_interval(self, from, to) end + +--- Called when update +---@param self druid.timer +---@param is_on bool Timer enable state +function druid__timer.set_state(self, is_on) end + +--- Set text to text field +---@param self druid.timer +---@param set_to number Value in seconds +function druid__timer.set_to(self, set_to) end + + +---@class druid_event +local druid_event = {} + +--- Clear the all event handlers +---@param self druid_event +function druid_event.clear(self) end + +--- Event constructur +---@param self druid_event +---@param initial_callback function Subscribe the callback on new event, if callback exist +function druid_event.initialize(self, initial_callback) end + +--- Return true, if event have at lease one handler +---@param self druid_event +---@return bool True if event have handlers +function druid_event.is_exist(self) end + +--- Subscribe callback on event +---@param self druid_event +---@param callback function Callback itself +function druid_event.subscribe(self, callback) end + +--- Trigger the event and call all subscribed callbacks +---@param self druid_event +---@param ... any All event params +function druid_event.trigger(self, ...) end + +--- Unsubscribe callback on event +---@param self druid_event +---@param callback function Callback itself +function druid_event.unsubscribe(self, callback) end + + +---@class druid_instance +local druid_instance = {} + +--- Create new druid component +---@param self druid_instance +---@param component Component Component module +---@param ... args Other component params to pass it to component:init function +function druid_instance.create(self, component, ...) end + +--- Call on final function on gui_script. +---@param self druid_instance +function druid_instance.final(self) end + +--- Druid class constructor +---@param self druid_instance +---@param context table Druid context. Usually it is self of script +---@param style table Druid style module +function druid_instance.initialize(self, context, style) end + +--- Create back_handler basic component +---@param self druid_instance +---@param ... args back_handler init args +---@return druid.back_handler back_handler component +function druid_instance.new_back_handler(self, ...) end + +--- Create blocker basic component +---@param self druid_instance +---@param ... args blocker init args +---@return druid.blocker blocker component +function druid_instance.new_blocker(self, ...) end + +--- Create button basic component +---@param self druid_instance +---@param ... args button init args +---@return druid.button button component +function druid_instance.new_button(self, ...) end + +--- Create checkbox component +---@param self druid_instance +---@param ... args checkbox init args +---@return druid.checkbox checkbox component +function druid_instance.new_checkbox(self, ...) end + +--- Create checkbox_group component +---@param self druid_instance +---@param ... args checkbox_group init args +---@return druid.checkbox_group checkbox_group component +function druid_instance.new_checkbox_group(self, ...) end + +--- Create drag basic component +---@param self druid_instance +---@param ... args drag init args +---@return druid.drag drag component +function druid_instance.new_drag(self, ...) end + +--- Create dynamic grid component +---@param self druid_instance +---@param ... args grid init args +---@return druid.dynamic_grid grid component +function druid_instance.new_dynamic_grid(self, ...) end + +--- Create grid basic component Deprecated +---@param self druid_instance +---@param ... args grid init args +---@return druid.static_grid grid component +function druid_instance.new_grid(self, ...) end + +--- Create hover basic component +---@param self druid_instance +---@param ... args hover init args +---@return druid.hover hover component +function druid_instance.new_hover(self, ...) end + +--- Create input component +---@param self druid_instance +---@param ... args input init args +---@return druid.input input component +function druid_instance.new_input(self, ...) end + +--- Create lang_text component +---@param self druid_instance +---@param ... args lang_text init args +---@return druid.lang_text lang_text component +function druid_instance.new_lang_text(self, ...) end + +--- Create progress component +---@param self druid_instance +---@param ... args progress init args +---@return druid.progress progress component +function druid_instance.new_progress(self, ...) end + +--- Create radio_group component +---@param self druid_instance +---@param ... args radio_group init args +---@return druid.radio_group radio_group component +function druid_instance.new_radio_group(self, ...) end + +--- Create scroll basic component +---@param self druid_instance +---@param ... args scroll init args +---@return druid.scroll scroll component +function druid_instance.new_scroll(self, ...) end + +--- Create slider component +---@param self druid_instance +---@param ... args slider init args +---@return druid.slider slider component +function druid_instance.new_slider(self, ...) end + +--- Create static grid basic component +---@param self druid_instance +---@param ... args grid init args +---@return druid.static_grid grid component +function druid_instance.new_static_grid(self, ...) end + +--- Create swipe basic component +---@param self druid_instance +---@param ... args swipe init args +---@return druid.swipe swipe component +function druid_instance.new_swipe(self, ...) end + +--- Create text basic component +---@param self druid_instance +---@param ... args text init args +---@return Tet text component +function druid_instance.new_text(self, ...) end + +--- Create timer component +---@param self druid_instance +---@param ... args timer init args +---@return druid.timer timer component +function druid_instance.new_timer(self, ...) end + +--- Druid on focus gained interest function. +---@param self druid_instance +function druid_instance.on_focus_gained(self) end + +--- Druid on focus lost interest function. +---@param self druid_instance +function druid_instance.on_focus_lost(self) end + +--- Druid on_input function +---@param self druid_instance +---@param action_id hash Action_id from on_input +---@param action table Action from on_input +function druid_instance.on_input(self, action_id, action) end + +--- Druid on layout change function. +---@param self druid_instance +function druid_instance.on_layout_change(self) end + +--- Druid on_message function +---@param self druid_instance +---@param message_id hash Message_id from on_message +---@param message table Message from on_message +---@param sender hash Sender from on_message +function druid_instance.on_message(self, message_id, message, sender) end + +--- Remove component from druid instance. +---@param self druid_instance +---@param component Component Component instance +function druid_instance.remove(self, component) end + +--- Druid update function +---@param self druid_instance +---@param dt number Delta time +function druid_instance.update(self, dt) end + + +---@class helper +local helper = {} + +--- Center two nodes. +---@param icon_node box Gui box node +---@param text_node text Gui text node +---@param margin number Offset between nodes +function helper.centrate_icon_with_text(icon_node, text_node, margin) end + +--- Center two nodes. +---@param text_node text Gui text node +---@param icon_node box Gui box node +---@param margin number Offset between nodes +function helper.centrate_text_with_icon(text_node, icon_node, margin) end + +--- Show deprecated message. +---@param message string The deprecated message +function helper.deprecated(message) end + +--- Distance from node to size border +---@return vector4 (left, top, right, down) +function helper.get_border() end + +--- Get node offset for given gui pivot +---@param pivot gui.pivot The node pivot +---@return vector3 Vector offset with [-1..1] values +function helper.get_pivot_offset(pivot) end + +--- Check if node is enabled in gui hierarchy. +---@param node node Gui node +---@return bool Is enabled in hierarchy +function helper.is_enabled(node) end + +--- Check if device is mobile (Android or iOS) +function helper.is_mobile() end + +--- Check if device is HTML5 +function helper.is_web() end + + diff --git a/config.ld b/config.ld index 273a754..7448c16 100644 --- a/config.ld +++ b/config.ld @@ -11,7 +11,6 @@ package='druid' sort=false dir='./docs' style='!fixed' -format='discount' -topics={"./docs_md", "README.md"} +topics={} use_markdown_titles=true no_space_before_args=true \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 33c7f80..8062499 100644 --- a/docs/index.html +++ b/docs/index.html @@ -31,40 +31,29 @@

Modules

-

Topics

- @@ -77,43 +66,43 @@

Modules

- + - + - + - + - + - + - + - + - + - + @@ -121,44 +110,44 @@ - + - + - + - + - + - + - + - + - + - + @@ -166,51 +155,16 @@ - +
druid.back_handlerBackHandler Component to handle back key (android, backspace)
druid.blockerBlocker Component to block input on specify zone by node
druid.buttonButton Component to handle basic GUI button
druid.dragDrag Component to handle drag action on node.
druid.hoverHover Component to handle hover node interaction
druid.scrollScroll Component to handle scroll content.
druid.static_gridStaticGrid Component to handle placing components by row and columns.
druid.swipeSwipe Component to handle swipe gestures on node.
druid.textText Component to handle all GUI texts.
componentBaseComponent Basic class for all Druid components.
Druid UI Library.
druid_eventDruidEvent Lua event small library
druid.checkboxCheckbox Druid checkbox component
druid.checkbox_groupCheckboxGroup Checkbox group module
druid.dynamic_gridDynamicGrid Component to handle placing components in row
druid.inputInput Druid input text component.
druid.lang_textLangText Component to handle all GUI texts Good working with localization system
druid.progressProgress Basic progress bar component.
druid.radio_groupRadioGroup Radio group module
druid.sliderSlider Druid slider component
druid.timerTimer Component to handle GUI timers.
Text node or icon node can be nil
druid_instanceDruidInstance Instance of Druid.
-

Topics

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
01-components.md
02-creating_custom_components.md
03-styles.md
04-druid_assets.md
05-examples.md
changelog.md
faq.md
README.md
generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 +Last updated 2020-10-12 00:44:30
diff --git a/docs/modules/BackHandler.html b/docs/modules/BackHandler.html new file mode 100644 index 0000000..9a925d0 --- /dev/null +++ b/docs/modules/BackHandler.html @@ -0,0 +1,196 @@ + + + + + Defold Druid UI Library + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module BackHandler

+

Component to handle back key (android, backspace)

+

+ + +

Functions

+ + + + + + + + + +
init(self, callback[, params])Component init function
on_input(self, action_id, action)Input handler for component
+

Fields

+ + + + + +
on_backOn back handler callback(self, params)
+ +
+
+ + +

Functions

+ +
+
+ + init(self, callback[, params]) +
+
+ Component init function + + +

Parameters:

+
    +
  • self + BackHandler + +
  • +
  • callback + callback + On back button +
  • +
  • params + any + Callback argument + (optional) +
  • +
+ + + + + +
+
+ + on_input(self, action_id, action) +
+
+ Input handler for component + + +

Parameters:

+
    +
  • self + BackHandler + +
  • +
  • action_id + string + on_input action id +
  • +
  • action + table + on_input action +
  • +
+ + + + + +
+
+

Fields

+ +
+
+ + on_back +
+
+ On back handler callback(self, params) + + +
    +
  • on_back + druid_event + +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2020-10-12 00:44:30 +
+
+ + diff --git a/docs/modules/BaseComponent.html b/docs/modules/BaseComponent.html new file mode 100644 index 0000000..635b273 --- /dev/null +++ b/docs/modules/BaseComponent.html @@ -0,0 +1,479 @@ + + + + + Defold Druid UI Library + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module BaseComponent

+

Basic class for all Druid components.

+

+ To create you component, use `component.create`

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
set_style(self, druid_style)Set current component style table.
set_template(self, template)Set current component template name
set_nodes(self, nodes)Set current component nodes
get_context(self)Get current component context
increase_input_priority(self)Increase input priority in current input stack
reset_input_priority(self)Reset input priority in current input stack
get_node(self, node_or_name)Get node for component by name.
get_druid(self)Return druid with context of calling component.
get_name(self)Return component name
set_input_enabled(self, state)Set component input state.
get_parent_component(self)Return the parent for current component
setup_component(self, druid_instance, context, style)Setup component context and his style table
+ +
+
+ + +

Functions

+ +
+
+ + set_style(self, druid_style) +
+
+ Set current component style table. + Invoke `on_style_change` on component, if exist. BaseComponent should handle + their style changing and store all style params + + +

Parameters:

+
    +
  • self + BaseComponent + +
  • +
  • druid_style + table + Druid style module +
  • +
+ + + + + +
+
+ + set_template(self, template) +
+
+ Set current component template name + + +

Parameters:

+
    +
  • self + BaseComponent + +
  • +
  • template + string + BaseComponent template name +
  • +
+ + + + + +
+
+ + set_nodes(self, nodes) +
+
+ Set current component nodes + + +

Parameters:

+
    +
  • self + BaseComponent + +
  • +
  • nodes + table + BaseComponent nodes table +
  • +
+ + + + + +
+
+ + get_context(self) +
+
+ Get current component context + + +

Parameters:

+
    +
  • self + BaseComponent + +
  • +
+ +

Returns:

+
    + + table + BaseComponent context +
+ + + + +
+
+ + increase_input_priority(self) +
+
+ Increase input priority in current input stack + + +

Parameters:

+
    +
  • self + BaseComponent + +
  • +
+ + + + + +
+
+ + reset_input_priority(self) +
+
+ Reset input priority in current input stack + + +

Parameters:

+
    +
  • self + BaseComponent + +
  • +
+ + + + + +
+
+ + get_node(self, node_or_name) +
+
+ Get node for component by name. + If component has nodes, node_or_name should be string + It auto pick node by template name or from nodes by clone_tree + if they was setup via component:set_nodes, component:set_template + + +

Parameters:

+
    +
  • self + BaseComponent + +
  • +
  • node_or_name + string or node + Node name or node itself +
  • +
+ +

Returns:

+
    + + node + Gui node +
+ + + + +
+
+ + get_druid(self) +
+
+ Return druid with context of calling component. + Use it to create component inside of other components. + + +

Parameters:

+
    +
  • self + BaseComponent + +
  • +
+ +

Returns:

+
    + + Druid + Druid instance with component context +
+ + + + +
+
+ + get_name(self) +
+
+ Return component name + + +

Parameters:

+
    +
  • self + BaseComponent + +
  • +
+ +

Returns:

+
    + + string + The component name +
+ + + + +
+
+ + set_input_enabled(self, state) +
+
+ Set component input state. By default it enabled + You can disable any input of component by this function + + +

Parameters:

+
    +
  • self + BaseComponent + +
  • +
  • state + bool + The component input state +
  • +
+ +

Returns:

+
    + + BaseComponent + BaseComponent itself +
+ + + + +
+
+ + get_parent_component(self) +
+
+ Return the parent for current component + + +

Parameters:

+
    +
  • self + BaseComponent + +
  • +
+ +

Returns:

+
    + + druid.base_component or nil + The druid component instance or nil +
+ + + + +
+
+ + setup_component(self, druid_instance, context, style) +
+
+ Setup component context and his style table + + +

Parameters:

+
    +
  • self + BaseComponent + +
  • +
  • druid_instance + table + The parent druid instance +
  • +
  • context + table + Druid context. Usually it is self of script +
  • +
  • style + table + Druid style module +
  • +
+ +

Returns:

+
    + + component + BaseComponent itself +
+ + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2020-10-12 00:44:30 +
+
+ + diff --git a/docs/modules/Blocker.html b/docs/modules/Blocker.html new file mode 100644 index 0000000..179cfda --- /dev/null +++ b/docs/modules/Blocker.html @@ -0,0 +1,186 @@ + + + + + Defold Druid UI Library + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module Blocker

+

Component to block input on specify zone by node

+

+ + +

Functions

+ + + + + + + + + + + + + +
init(self, node)Component init function
set_enabled(self, state)Set enabled blocker component state
is_enabled(self)Return blocked enabled state
+ +
+
+ + +

Functions

+ +
+
+ + init(self, node) +
+
+ Component init function + + +

Parameters:

+
    +
  • self + Blocker + +
  • +
  • node + node + Gui node +
  • +
+ + + + + +
+
+ + set_enabled(self, state) +
+
+ Set enabled blocker component state + + +

Parameters:

+
    +
  • self + Blocker + +
  • +
  • state + bool + Enabled state +
  • +
+ + + + + +
+
+ + is_enabled(self) +
+
+ Return blocked enabled state + + +

Parameters:

+
    +
  • self + Blocker + +
  • +
+ +

Returns:

+
    + + bool + True, if blocker is enabled +
+ + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2020-10-12 00:44:30 +
+
+ + diff --git a/docs/modules/druid.button.html b/docs/modules/Button.html similarity index 51% rename from docs/modules/druid.button.html rename to docs/modules/Button.html index 6a9e58f..0a14166 100644 --- a/docs/modules/druid.button.html +++ b/docs/modules/Button.html @@ -34,100 +34,135 @@

Modules

-

Topics

-
-

Module druid.button

+

Module Button

Component to handle basic GUI button

-

- -

+

Functions

- + - + - + - + - + - +
init(node, callback[, params[, anim_node]])init(self, node, callback[, params[, anim_node]]) Component init function
set_enabled(state)set_enabled(self, state) Set enabled button component state
is_enabled()is_enabled(self) Return button enabled state
set_click_zone(zone)set_click_zone(self, zone) Strict button click area.
set_key_trigger(key)set_key_trigger(self, key) Set key-code to trigger this button
get_key_trigger()get_key_trigger(self) Get key-code to trigger this button

Tables

- - - - - - - - - +
EventsComponent events
FieldsComponent fields
Stylestyle Component style params.
+

Fields

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
on_clickOn release button callback(self, params, button_instance)
on_repeated_clickOn repeated action button callback(self, params, button_instance, click_amount)
on_long_clickOn long tap button callback(self, params, button_instance, time)
on_double_clickOn double tap button callback(self, params, button_instance, click_amount)
on_hold_callbackOn button hold before long_click callback(self, params, button_instance, time)
on_click_outsideOn click outside of button(self, params, button_instance)
nodeTrigger node
anim_nodeAnimation node
start_scaleInitial scale of anim_node
start_posInitial pos of anim_node
posInitial pos of anim_node
paramsParams to click callbacks
hoverDruid hover logic component


@@ -138,7 +173,7 @@
- init(node, callback[, params[, anim_node]]) + init(self, node, callback[, params[, anim_node]])
Component init function @@ -146,8 +181,12 @@

Parameters:

    +
  • self + Button + +
  • node - node + node Gui node
  • callback @@ -160,7 +199,7 @@ (optional)
  • anim_node - node + node Button anim node (node, if not provided) (optional)
  • @@ -173,7 +212,7 @@
- set_enabled(state) + set_enabled(self, state)
Set enabled button component state @@ -181,6 +220,10 @@

Parameters:

    +
  • self + Button + +
  • state bool Enabled state @@ -190,7 +233,7 @@

    Returns:

      - druid.button + Button Current button instance
    @@ -200,12 +243,19 @@
- is_enabled() + is_enabled(self)
Return button enabled state +

Parameters:

+
    +
  • self + Button + +
  • +

Returns:

    @@ -220,7 +270,7 @@
- set_click_zone(zone) + set_click_zone(self, zone)
Strict button click area. Useful for @@ -229,8 +279,12 @@

Parameters:

    +
  • self + Button + +
  • zone - node + node Gui node
@@ -238,7 +292,7 @@

Returns:

    - druid.button + Button Current button instance
@@ -248,7 +302,7 @@
- set_key_trigger(key) + set_key_trigger(self, key)
Set key-code to trigger this button @@ -256,6 +310,10 @@

Parameters:

    +
  • self + Button + +
  • key hash The action_id of the key @@ -265,7 +323,7 @@

    Returns:

      - druid.button + Button Current button instance
    @@ -275,12 +333,19 @@
- get_key_trigger() + get_key_trigger(self)
Get key-code to trigger this button +

Parameters:

+
    +
  • self + Button + +
  • +

Returns:

    @@ -298,100 +363,8 @@
    - - Events -
    -
    - Component events - - -

    Fields:

    -
      -
    • on_click - druid_event - (self, params, button_instance) On release button callback -
    • -
    • on_repeated_click - druid_event - (self, params, buttoninstance, clickamount) On repeated action button callback -
    • -
    • on_long_click - druid_event - (self, params, button_instance, time) On long tap button callback -
    • -
    • on_double_click - druid_event - (self, params, buttoninstance, clickamount) On double tap button callback -
    • -
    • on_hold_callback - druid_event - (self, params, buttoninstance, time) On button hold before longclick callback -
    • -
    • on_click_outside - druid_event - (self, params, button_instance) On click outside of button -
    • -
    - - - - - -
    -
    - - Fields -
    -
    - Component fields - - -

    Fields:

    -
      -
    • node - node - Trigger node -
    • -
    • anim_node - node - Animation node - (default node) -
    • -
    • start_scale - vector3 - Initial scale of anim_node -
    • -
    • start_pos - vector3 - Initial pos of anim_node -
    • -
    • pos - vector3 - Initial pos of anim_node -
    • -
    • params - any - Params to click callbacks -
    • -
    • hover - druid.hover - Druid hover logic component -
    • -
    • click_zone - node - Restriction zone - (optional) -
    • -
    - - - - - -
    -
    - - Style + + style
    Component style params. @@ -403,7 +376,7 @@
    • LONGTAP_TIME number - Minimum time to trigger onholdcallback + Minimum time to trigger on_hold_callback (default 0.4)
    • AUTOHOLD_TRIGGER @@ -442,6 +415,271 @@ +
    +
    +

    Fields

    + +
    +
    + + on_click +
    +
    + On release button callback(self, params, button_instance) + + +
      +
    • on_click + druid_event + +
    • +
    + + + + + +
    +
    + + on_repeated_click +
    +
    + On repeated action button callback(self, params, button_instance, click_amount) + + +
      +
    • on_repeated_click + druid_event + +
    • +
    + + + + + +
    +
    + + on_long_click +
    +
    + On long tap button callback(self, params, button_instance, time) + + +
      +
    • on_long_click + druid_event + +
    • +
    + + + + + +
    +
    + + on_double_click +
    +
    + On double tap button callback(self, params, button_instance, click_amount) + + +
      +
    • on_double_click + druid_event + +
    • +
    + + + + + +
    +
    + + on_hold_callback +
    +
    + On button hold before long_click callback(self, params, button_instance, time) + + +
      +
    • on_hold_callback + druid_event + +
    • +
    + + + + + +
    +
    + + on_click_outside +
    +
    + On click outside of button(self, params, button_instance) + + +
      +
    • on_click_outside + druid_event + +
    • +
    + + + + + +
    +
    + + node +
    +
    + Trigger node + + +
      +
    • node + node + +
    • +
    + + + + + +
    +
    + + anim_node +
    +
    + Animation node + + +
      +
    • anim_node + node + + (default node) +
    • +
    + + + + + +
    +
    + + start_scale +
    +
    + Initial scale of anim_node + + +
      +
    • start_scale + vector3 + +
    • +
    + + + + + +
    +
    + + start_pos +
    +
    + Initial pos of anim_node + + +
      +
    • start_pos + vector3 + +
    • +
    + + + + + +
    +
    + + pos +
    +
    + Initial pos of anim_node + + +
      +
    • pos + vector3 + +
    • +
    + + + + + +
    +
    + + params +
    +
    + Params to click callbacks + + +
      +
    • params + any + +
    • +
    + + + + + +
    +
    + + hover +
    +
    + Druid hover logic component + + +
      +
    • hover + druid.hover + +
    • +
    + + + + +
    @@ -450,7 +688,7 @@
generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 +Last updated 2020-10-12 00:44:30
diff --git a/docs/modules/druid.checkbox.html b/docs/modules/Checkbox.html similarity index 50% rename from docs/modules/druid.checkbox.html rename to docs/modules/Checkbox.html index d432cb6..219384b 100644 --- a/docs/modules/druid.checkbox.html +++ b/docs/modules/Checkbox.html @@ -34,88 +34,83 @@

Modules

-

Topics

-
-

Module druid.checkbox

+

Module Checkbox

Druid checkbox component

-

- -

+

Functions

- + - + - +
init(node, callback[, click=node])init(self, node, callback[, click_node=node]) Component init function
set_state(state, is_silent)set_state(self, state, is_silent) Set checkbox state
get_state()get_state(self) Return checkbox state

Tables

- - - - - - - - - +
EventsComponent events
FieldsComponent fields
Stylestyle Component style params.
+

Fields

+ + + + + + + + + + + + + +
on_change_stateOn change state callback(self, state)
nodeVisual node
click_nodeButton trigger node


@@ -126,7 +121,7 @@
- init(node, callback[, click=node]) + init(self, node, callback[, click_node=node])
Component init function @@ -134,17 +129,21 @@

Parameters:

    +
  • self + Checkbox + +
  • node - node + node Gui node
  • callback function Checkbox callback
  • -
  • click - node - node Trigger node, by default equals to node +
  • click_node + node + Trigger node, by default equals to node (default node)
@@ -156,7 +155,7 @@
- set_state(state, is_silent) + set_state(self, state, is_silent)
Set checkbox state @@ -164,13 +163,17 @@

Parameters:

    +
  • self + Checkbox + +
  • state bool Checkbox state
  • is_silent bool - Don't trigger onchangestate if true + Don't trigger on_change_state if true
@@ -181,12 +184,19 @@
- get_state() + get_state(self)
Return checkbox state +

Parameters:

+
    +
  • self + Checkbox + +
  • +

Returns:

    @@ -204,59 +214,8 @@
    - - Events -
    -
    - Component events - - -

    Fields:

    -
      -
    • on_change_state - druid_event - On change state callback -
    • -
    - - - - - -
    -
    - - Fields -
    -
    - Component fields - - -

    Fields:

    -
      -
    • node - node - Visual node -
    • -
    • click_node - node - Button trigger node - (default node) -
    • -
    • button - druid.button - Button component from click_node -
    • -
    - - - - - -
    -
    - - Style + + style
    Component style params. @@ -276,6 +235,71 @@ +
    +
    +

    Fields

    + +
    +
    + + on_change_state +
    +
    + On change state callback(self, state) + + +
      +
    • on_change_state + druid_event + +
    • +
    + + + + + +
    +
    + + node +
    +
    + Visual node + + +
      +
    • node + node + +
    • +
    + + + + + +
    +
    + + click_node +
    +
    + Button trigger node + + +
      +
    • click_node + node + + (default node) +
    • +
    + + + + +
    @@ -284,7 +308,7 @@
generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 +Last updated 2020-10-12 00:44:30
diff --git a/docs/modules/CheckboxGroup.html b/docs/modules/CheckboxGroup.html new file mode 100644 index 0000000..1b721fc --- /dev/null +++ b/docs/modules/CheckboxGroup.html @@ -0,0 +1,227 @@ + + + + + Defold Druid UI Library + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module CheckboxGroup

+

Checkbox group module

+

+ + +

Functions

+ + + + + + + + + + + + + +
init(self, nodes, callback[, click_nodes=node])Component init function
set_state(self, indexes)Set checkbox group state
get_state(self)Return checkbox group state
+

Fields

+ + + + + +
on_checkbox_clickOn any checkbox click callback(self, index)
+ +
+
+ + +

Functions

+ +
+
+ + init(self, nodes, callback[, click_nodes=node]) +
+
+ Component init function + + +

Parameters:

+
    +
  • self + CheckboxGroup + +
  • +
  • nodes + node[] + Array of gui node +
  • +
  • callback + function + Checkbox callback +
  • +
  • click_nodes + node[] + Array of trigger nodes, by default equals to nodes + (default node) +
  • +
+ + + + + +
+
+ + set_state(self, indexes) +
+
+ Set checkbox group state + + +

Parameters:

+
    +
  • self + CheckboxGroup + +
  • +
  • indexes + bool[] + Array of checkbox state +
  • +
+ + + + + +
+
+ + get_state(self) +
+
+ Return checkbox group state + + +

Parameters:

+
    +
  • self + CheckboxGroup + +
  • +
+ +

Returns:

+
    + + bool[] + Array if checkboxes state +
+ + + + +
+
+

Fields

+ +
+
+ + on_checkbox_click +
+
+ On any checkbox click callback(self, index) + + +
    +
  • on_checkbox_click + druid_event + +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2020-10-12 00:44:30 +
+
+ + diff --git a/docs/modules/Drag.html b/docs/modules/Drag.html new file mode 100644 index 0000000..e37f4e8 --- /dev/null +++ b/docs/modules/Drag.html @@ -0,0 +1,471 @@ + + + + + Defold Druid UI Library + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module Drag

+

Component to handle drag action on node.

+

+ Drag have correct handling for multitouch and swap + touched while dragging. Drag will be processed even + the cursor is outside of node, if drag is already started

+ + +

Functions

+ + + + + + + + + +
init(self, node, on_drag_callback)Drag component constructor
set_click_zone(self, zone)Strict drag click area.
+

Tables

+ + + + + +
styleComponent style params.
+

Fields

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
on_touch_startEvent on touch start callback(self)
on_touch_endEvent on touch end callback(self)
on_drag_startEvent on drag start callback(self)
on_dragon drag progress callback(self, dx, dy)
on_drag_endEvent on drag end callback(self)
is_touchIs component now touching
is_dragIs component now dragging
can_xIs drag component process vertical dragging.
can_yIs drag component process horizontal.
xCurrent touch x position
yCurrent touch y position
+ +
+
+ + +

Functions

+ +
+
+ + init(self, node, on_drag_callback) +
+
+ Drag component constructor + + +

Parameters:

+
    +
  • self + Drag + +
  • +
  • node + node + GUI node to detect dragging +
  • +
  • on_drag_callback + function + Callback for on_drag_event(self, dx, dy) +
  • +
+ + + + + +
+
+ + set_click_zone(self, zone) +
+
+ Strict drag click area. Useful for + restrict events outside stencil node + + +

Parameters:

+
    +
  • self + Drag + +
  • +
  • zone + node + Gui node +
  • +
+ + + + + +
+
+

Tables

+ +
+
+ + style +
+
+ Component style params. + You can override this component styles params in druid styles table + or create your own style + + +

Fields:

+
    +
  • DRAG_DEADZONE + number + Distance in pixels to start dragging + (default 10) +
  • +
+ + + + + +
+
+

Fields

+ +
+
+ + on_touch_start +
+
+ Event on touch start callback(self) + + +
    +
  • on_touch_start + druid_event + +
  • +
+ + + + + +
+
+ + on_touch_end +
+
+ Event on touch end callback(self) + + +
    +
  • on_touch_end + druid_event + +
  • +
+ + + + + +
+
+ + on_drag_start +
+
+ Event on drag start callback(self) + + +
    +
  • on_drag_start + druid_event + +
  • +
+ + + + + +
+
+ + on_drag +
+
+ on drag progress callback(self, dx, dy) + + +
    +
  • on_drag + druid_event + Event +
  • +
+ + + + + +
+
+ + on_drag_end +
+
+ Event on drag end callback(self) + + +
    +
  • on_drag_end + druid_event + +
  • +
+ + + + + +
+
+ + is_touch +
+
+ Is component now touching + + +
    +
  • is_touch + bool + +
  • +
+ + + + + +
+
+ + is_drag +
+
+ Is component now dragging + + +
    +
  • is_drag + bool + +
  • +
+ + + + + +
+
+ + can_x +
+
+ Is drag component process vertical dragging. Default - true + + +
    +
  • can_x + bool + +
  • +
+ + + + + +
+
+ + can_y +
+
+ Is drag component process horizontal. Default - true + + +
    +
  • can_y + bool + +
  • +
+ + + + + +
+
+ + x +
+
+ Current touch x position + + +
    +
  • x + number + +
  • +
+ + + + + +
+
+ + y +
+
+ Current touch y position + + +
    +
  • y + number + +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2020-10-12 00:44:30 +
+
+ + diff --git a/docs/modules/druid_event.html b/docs/modules/DruidEvent.html similarity index 50% rename from docs/modules/druid_event.html rename to docs/modules/DruidEvent.html index ecc8a58..8f07b3c 100644 --- a/docs/modules/druid_event.html +++ b/docs/modules/DruidEvent.html @@ -38,77 +38,64 @@

Modules

-

Topics

-
-

Module druid_event

+

Module DruidEvent

Lua event small library

-

- -

+

Functions

- + - + - + - + - + - +
Event(initial_callback)initialize(self, initial_callback) Event constructur
event:subscribe(callback)subscribe(self, callback) Subscribe callback on event
event:unsubscribe(callback)unsubscribe(self, callback) Unsubscribe callback on event
event:is_exist()is_exist(self) Return true, if event have at lease one handler
event:clear()clear(self) Clear the all event handlers
event:trigger(...)trigger(self, ...) Trigger the event and call all subscribed callbacks
@@ -121,8 +108,8 @@
- - Event(initial_callback) + + initialize(self, initial_callback)
Event constructur @@ -130,6 +117,10 @@

Parameters:

    +
  • self + DruidEvent + +
  • initial_callback function Subscribe the callback on new event, if callback exist @@ -142,8 +133,8 @@
- - event:subscribe(callback) + + subscribe(self, callback)
Subscribe callback on event @@ -151,6 +142,10 @@

Parameters:

    +
  • self + DruidEvent + +
  • callback function Callback itself @@ -163,8 +158,8 @@
- - event:unsubscribe(callback) + + unsubscribe(self, callback)
Unsubscribe callback on event @@ -172,6 +167,10 @@

Parameters:

    +
  • self + DruidEvent + +
  • callback function Callback itself @@ -184,13 +183,20 @@
- - event:is_exist() + + is_exist(self)
Return true, if event have at lease one handler +

Parameters:

+
    +
  • self + DruidEvent + +
  • +

Returns:

    @@ -204,13 +210,20 @@
- - event:clear() + + clear(self)
Clear the all event handlers +

Parameters:

+
    +
  • self + DruidEvent + +
  • +
@@ -218,8 +231,8 @@
- - event:trigger(...) + + trigger(self, ...)
Trigger the event and call all subscribed callbacks @@ -227,7 +240,12 @@

Parameters:

    +
  • self + DruidEvent + +
  • ... + any All event params
@@ -244,7 +262,7 @@
generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 +Last updated 2020-10-12 00:44:30
diff --git a/docs/modules/DruidInstance.html b/docs/modules/DruidInstance.html new file mode 100644 index 0000000..e697c3c --- /dev/null +++ b/docs/modules/DruidInstance.html @@ -0,0 +1,1110 @@ + + + + + Defold Druid UI Library + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module DruidInstance

+

Instance of Druid.

+

Make one instance per gui_script with next code: +

local druid = require("druid.druid") + function init(self) + self.druid = druid.new(self) + local button = self.druid:new_button(...) + end +

Learn Druid instance function here

+

See also:

+ + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
initialize(self, context, style)Druid class constructor
create(self, component, ...)Create new druid component
final(self)Call on final function on gui_script.
remove(self, component)Remove component from druid instance.
update(self, dt)Druid update function
on_input(self, action_id, action)Druid on_input function
on_message(self, message_id, message, sender)Druid on_message function
on_focus_lost(self)Druid on focus lost interest function.
on_focus_gained(self)Druid on focus gained interest function.
on_layout_change(self)Druid on layout change function.
druid.on_language_change()Druid on language change.
new_button(self, ...)Create button basic component
new_blocker(self, ...)Create blocker basic component
new_back_handler(self, ...)Create back_handler basic component
new_hover(self, ...)Create hover basic component
new_text(self, ...)Create text basic component
new_grid(self, ...)Create grid basic component + Deprecated
new_static_grid(self, ...)Create static grid basic component
new_scroll(self, ...)Create scroll basic component
new_swipe(self, ...)Create swipe basic component
new_drag(self, ...)Create drag basic component
new_dynamic_grid(self, ...)Create dynamic grid component
new_lang_text(self, ...)Create lang_text component
new_slider(self, ...)Create slider component
new_checkbox(self, ...)Create checkbox component
new_input(self, ...)Create input component
new_checkbox_group(self, ...)Create checkbox_group component
new_radio_group(self, ...)Create radio_group component
new_timer(self, ...)Create timer component
new_progress(self, ...)Create progress component
+ +
+
+ + +

Functions

+ +
+
+ + initialize(self, context, style) +
+
+ Druid class constructor + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • context + table + Druid context. Usually it is self of script +
  • +
  • style + table + Druid style module +
  • +
+ + + + + +
+
+ + create(self, component, ...) +
+
+ Create new druid component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • component + Component + Component module +
  • +
  • ... + args + Other component params to pass it to component:init function +
  • +
+ + + + + +
+
+ + final(self) +
+
+ Call on final function on gui_script. It will call on_remove + on all druid components + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
+ + + + + +
+
+ + remove(self, component) +
+
+ Remove component from druid instance. + Component `on_remove` function will be invoked, if exist. + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • component + Component + Component instance +
  • +
+ + + + + +
+
+ + update(self, dt) +
+
+ Druid update function + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • dt + number + Delta time +
  • +
+ + + + + +
+
+ + on_input(self, action_id, action) +
+
+ Druid on_input function + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • action_id + hash + Action_id from on_input +
  • +
  • action + table + Action from on_input +
  • +
+ + + + + +
+
+ + on_message(self, message_id, message, sender) +
+
+ Druid on_message function + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • message_id + hash + Message_id from on_message +
  • +
  • message + table + Message from on_message +
  • +
  • sender + hash + Sender from on_message +
  • +
+ + + + + +
+
+ + on_focus_lost(self) +
+
+ Druid on focus lost interest function. + This one called by on_window_callback by global window listener + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
+ + + + + +
+
+ + on_focus_gained(self) +
+
+ Druid on focus gained interest function. + This one called by on_window_callback by global window listener + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
+ + + + + +
+
+ + on_layout_change(self) +
+
+ Druid on layout change function. + Called on update gui layout + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
+ + + + + +
+
+ + druid.on_language_change() +
+
+ Druid on language change. + This one called by global gruid.on_language_change, but can be + call manualy to update all translations + + + + + + + +
+
+ + new_button(self, ...) +
+
+ Create button basic component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • ... + args + button init args +
  • +
+ +

Returns:

+
    + + Button + button component +
+ + + + +
+
+ + new_blocker(self, ...) +
+
+ Create blocker basic component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • ... + args + blocker init args +
  • +
+ +

Returns:

+
    + + Blocker + blocker component +
+ + + + +
+
+ + new_back_handler(self, ...) +
+
+ Create back_handler basic component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • ... + args + back_handler init args +
  • +
+ +

Returns:

+
    + + BackHandler + back_handler component +
+ + + + +
+
+ + new_hover(self, ...) +
+
+ Create hover basic component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • ... + args + hover init args +
  • +
+ +

Returns:

+
    + + Hover + hover component +
+ + + + +
+
+ + new_text(self, ...) +
+
+ Create text basic component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • ... + args + text init args +
  • +
+ +

Returns:

+
    + + Tet + text component +
+ + + + +
+
+ + new_grid(self, ...) +
+
+ Create grid basic component + Deprecated + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • ... + args + grid init args +
  • +
+ +

Returns:

+
    + + StaticGrid + grid component +
+ + + + +
+
+ + new_static_grid(self, ...) +
+
+ Create static grid basic component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • ... + args + grid init args +
  • +
+ +

Returns:

+
    + + StaticGrid + grid component +
+ + + + +
+
+ + new_scroll(self, ...) +
+
+ Create scroll basic component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • ... + args + scroll init args +
  • +
+ +

Returns:

+
    + + Scroll + scroll component +
+ + + + +
+
+ + new_swipe(self, ...) +
+
+ Create swipe basic component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • ... + args + swipe init args +
  • +
+ +

Returns:

+
    + + Swipe + swipe component +
+ + + + +
+
+ + new_drag(self, ...) +
+
+ Create drag basic component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • ... + args + drag init args +
  • +
+ +

Returns:

+
    + + Drag + drag component +
+ + + + +
+
+ + new_dynamic_grid(self, ...) +
+
+ Create dynamic grid component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • ... + args + grid init args +
  • +
+ +

Returns:

+
    + + DynamicGrid + grid component +
+ + + + +
+
+ + new_lang_text(self, ...) +
+
+ Create lang_text component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • ... + args + lang_text init args +
  • +
+ +

Returns:

+
    + + LangText + lang_text component +
+ + + + +
+
+ + new_slider(self, ...) +
+
+ Create slider component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • ... + args + slider init args +
  • +
+ +

Returns:

+
    + + Slider + slider component +
+ + + + +
+
+ + new_checkbox(self, ...) +
+
+ Create checkbox component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • ... + args + checkbox init args +
  • +
+ +

Returns:

+
    + + Checkbox + checkbox component +
+ + + + +
+
+ + new_input(self, ...) +
+
+ Create input component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • ... + args + input init args +
  • +
+ +

Returns:

+
    + + Input + input component +
+ + + + +
+
+ + new_checkbox_group(self, ...) +
+
+ Create checkbox_group component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • ... + args + checkbox_group init args +
  • +
+ +

Returns:

+
    + + CheckboxGroup + checkbox_group component +
+ + + + +
+
+ + new_radio_group(self, ...) +
+
+ Create radio_group component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • ... + args + radio_group init args +
  • +
+ +

Returns:

+
    + + RadioGroup + radio_group component +
+ + + + +
+
+ + new_timer(self, ...) +
+
+ Create timer component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • ... + args + timer init args +
  • +
+ +

Returns:

+
    + + Timer + timer component +
+ + + + +
+
+ + new_progress(self, ...) +
+
+ Create progress component + + +

Parameters:

+
    +
  • self + DruidInstance + +
  • +
  • ... + args + progress init args +
  • +
+ +

Returns:

+
    + + Progress + progress component +
+ + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2020-10-12 00:44:30 +
+
+ + diff --git a/docs/modules/druid.dynamic_grid.html b/docs/modules/DynamicGrid.html similarity index 53% rename from docs/modules/druid.dynamic_grid.html rename to docs/modules/DynamicGrid.html index 1bc6a53..513c24f 100644 --- a/docs/modules/druid.dynamic_grid.html +++ b/docs/modules/DynamicGrid.html @@ -33,111 +33,130 @@

Contents

Modules

-

Topics

-
-

Module druid.dynamic_grid

+

Module DynamicGrid

Component to handle placing components in row

-

- -

+

Functions

- + - + - + - + - + - + - + - + - + - +
init(parent)init(self, parent) Component init function
get_pos(index, node)get_pos(self, index, node[, origin_index]) Return pos for grid node index
add(node[, index[, is_shift_left=false]])add(self, node[, index[, is_shift_left=false]]) Add new node to the grid
remove(index[, is_shift_left=false])remove(self, index[, is_shift_left=false]) Remove the item from the grid.
get_size()get_size(self, border) Return grid content size
get_index_by_node(node)get_index_by_node(self, node) Return grid index by node
get_all_pos()get_all_pos(self) Return array of all node positions
set_position_function(callback)set_position_function(self, callback) Change set position function for grid nodes.
clear()clear(self) Clear grid nodes array.
DynamicGrid:_get_side_vector(side, is_forward)_get_side_vector(self, side, is_forward) Return side vector to correct node shifting
-

Tables

+

Fields

- - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
EventsComponent eventson_add_itemOn item add callback(self, node, index)
FieldsComponent fieldson_remove_itemOn item remove callback(self, index)
on_change_itemsOn item add or remove callback(self, index)
on_clearOn grid clear callback(self)
on_update_positionsOn update item positions callback(self)
parentParent gui node
nodesList of all grid nodes
first_indexThe first index of node in grid
last_indexThe last index of node in grid
node_sizeItem size
@@ -150,7 +169,7 @@
- init(parent) + init(self, parent)
Component init function @@ -158,6 +177,10 @@

Parameters:

    +
  • self + DynamicGrid + +
  • parent node The gui node parent, where items will be placed @@ -171,7 +194,7 @@
- get_pos(index, node) + get_pos(self, index, node[, origin_index])
Return pos for grid node index @@ -179,6 +202,10 @@

Parameters:

    +
  • self + DynamicGrid + +
  • index number The grid element index @@ -187,6 +214,11 @@ node The node to be placed
  • +
  • origin_index + number + Index of nearby node + (optional) +

Returns:

@@ -202,7 +234,7 @@
- add(node[, index[, is_shift_left=false]]) + add(self, node[, index[, is_shift_left=false]])
Add new node to the grid @@ -210,6 +242,10 @@

Parameters:

    +
  • self + DynamicGrid + +
  • node node Gui node @@ -233,7 +269,7 @@
- remove(index[, is_shift_left=false]) + remove(self, index[, is_shift_left=false])
Remove the item from the grid. Note that gui node will be not deleted @@ -241,6 +277,10 @@

Parameters:

    +
  • self + DynamicGrid + +
  • index number The grid node index to remove @@ -259,12 +299,23 @@
- get_size() + get_size(self, border)
Return grid content size +

Parameters:

+
    +
  • self + DynamicGrid + +
  • +
  • border + vector3 + +
  • +

Returns:

    @@ -279,7 +330,7 @@
- get_index_by_node(node) + get_index_by_node(self, node)
Return grid index by node @@ -287,6 +338,10 @@

Parameters:

    +
  • self + DynamicGrid + +
  • node node The gui node in the grid @@ -306,12 +361,19 @@
- get_all_pos() + get_all_pos(self)
Return array of all node positions +

Parameters:

+
    +
  • self + DynamicGrid + +
  • +

Returns:

    @@ -326,7 +388,7 @@
- set_position_function(callback) + set_position_function(self, callback)
Change set position function for grid nodes. It will call on @@ -335,6 +397,10 @@

Parameters:

    +
  • self + DynamicGrid + +
  • callback function Function on node set position @@ -354,13 +420,20 @@
- clear() + clear(self)
Clear grid nodes array. GUI nodes will be not deleted! If you want to delete GUI nodes, use dynamic_grid.nodes array before grid:clear +

Parameters:

+
    +
  • self + DynamicGrid + +
  • +

Returns:

    @@ -374,8 +447,8 @@
- - DynamicGrid:_get_side_vector(side, is_forward) + + _get_side_vector(self, side, is_forward)
Return side vector to correct node shifting @@ -383,15 +456,14 @@

Parameters:

    +
  • self + +
  • side - -
  • is_forward - -
@@ -401,38 +473,21 @@
-

Tables

+

Fields

- - Events + + on_add_item
- Component events + On item add callback(self, node, index) -

Fields:

  • on_add_item druid_event - On item add callback -
  • -
  • on_remove_item - druid_event - On item remove callback -
  • -
  • on_change_items - druid_event - On item add or remove callback -
  • -
  • on_clear - druid_event - On grid clear callback -
  • -
  • on_update_positions - druid_event - On update item positions callback +
@@ -442,38 +497,177 @@
- - Fields + + on_remove_item
- Component fields + On item remove callback(self, index) + + +
    +
  • on_remove_item + druid_event + +
  • +
+ + + + + +
+
+ + on_change_items +
+
+ On item add or remove callback(self, index) + + +
    +
  • on_change_items + druid_event + +
  • +
+ + + + + +
+
+ + on_clear +
+
+ On grid clear callback(self) + + +
    +
  • on_clear + druid_event + +
  • +
+ + + + + +
+
+ + on_update_positions +
+
+ On update item positions callback(self) + + +
    +
  • on_update_positions + druid_event + +
  • +
+ + + + + +
+
+ + parent +
+
+ Parent gui node -

Fields:

  • parent node - Parent gui node +
  • +
+ + + + + +
+
+ + nodes +
+
+ List of all grid nodes + + +
  • nodes node[] - List of all grid nodes +
  • +
+ + + + + +
+
+ + first_index +
+
+ The first index of node in grid + + +
  • first_index number - The first index of node in grid +
  • +
+ + + + + +
+
+ + last_index +
+
+ The last index of node in grid + + +
  • last_index number - The last index of node in grid +
  • +
+ + + + + +
+
+ + node_size +
+
+ Item size + + +
  • node_size vector3 - Item size -
  • -
  • border - vector4 - The size of item content +
@@ -489,7 +683,7 @@
generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 +Last updated 2020-10-12 00:44:30
diff --git a/docs/modules/druid.hover.html b/docs/modules/Hover.html similarity index 56% rename from docs/modules/druid.hover.html rename to docs/modules/Hover.html index 7115172..0b1af90 100644 --- a/docs/modules/druid.hover.html +++ b/docs/modules/Hover.html @@ -33,91 +33,78 @@

Contents

Modules

-

Topics

-
-

Module druid.hover

+

Module Hover

Component to handle hover node interaction

-

- -

+

Functions

- + - + - + - + - + - +
init(node, on_hover_callback)init(self, node, on_hover_callback) Component init function
set_hover(state)set_hover(self, state) Set hover state
set_mouse_hover(state)set_mouse_hover(self, state) Set mouse hover state
set_click_zone(zone)set_click_zone(self, zone) Strict hover click area.
set_enabled(state)set_enabled(self, state) Set enable state of hover component.
is_enabled()is_enabled(self) Return current hover enabled state
-

Tables

+

Fields

- - + +
EventsComponent eventson_hoverOn hover callback(self, state)
@@ -130,7 +117,7 @@
- init(node, on_hover_callback) + init(self, node, on_hover_callback)
Component init function @@ -138,6 +125,10 @@

Parameters:

    +
  • self + Hover + +
  • node node Gui node @@ -155,7 +146,7 @@
- set_hover(state) + set_hover(self, state)
Set hover state @@ -163,6 +154,10 @@

Parameters:

    +
  • self + Hover + +
  • state bool The hover state @@ -176,7 +171,7 @@
- set_mouse_hover(state) + set_mouse_hover(self, state)
Set mouse hover state @@ -184,6 +179,10 @@

Parameters:

    +
  • self + Hover + +
  • state bool The mouse hover state @@ -197,7 +196,7 @@
- set_click_zone(zone) + set_click_zone(self, zone)
Strict hover click area. Useful for @@ -206,6 +205,10 @@

Parameters:

    +
  • self + Hover + +
  • zone node Gui node @@ -219,7 +222,7 @@
- set_enabled(state) + set_enabled(self, state)
Set enable state of hover component. @@ -229,6 +232,10 @@

Parameters:

    +
  • self + Hover + +
  • state bool The hover enabled state @@ -242,12 +249,19 @@
- is_enabled() + is_enabled(self)
Return current hover enabled state +

Parameters:

+
    +
  • self + Hover + +
  • +

Returns:

    @@ -261,26 +275,21 @@
-

Tables

+

Fields

- - Events + + on_hover
- Component events + On hover callback(self, state) -

Fields:

  • on_hover druid_event - On hover callback (Touch pressed) -
  • -
  • on_mouse_hover - druid_event - On mouse hover callback (Touch over without action_id) +
@@ -296,7 +305,7 @@
generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 +Last updated 2020-10-12 00:44:30
diff --git a/docs/modules/druid.input.html b/docs/modules/Input.html similarity index 53% rename from docs/modules/druid.input.html rename to docs/modules/Input.html index d8292b2..a257d7e 100644 --- a/docs/modules/druid.input.html +++ b/docs/modules/Input.html @@ -34,54 +34,45 @@

Modules

-

Topics

-
-

Module druid.input

+

Module Input

Druid input text component.

-

Carry on user text input

+

+ Carry on user text input

Info:

generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 +Last updated 2020-10-12 00:44:30
diff --git a/docs/modules/druid.lang_text.html b/docs/modules/LangText.html similarity index 50% rename from docs/modules/druid.lang_text.html rename to docs/modules/LangText.html index a5d6b07..554aca9 100644 --- a/docs/modules/druid.lang_text.html +++ b/docs/modules/LangText.html @@ -33,84 +33,67 @@

Contents

Modules

-

Topics

-
-

Module druid.lang_text

+

Module LangText

Component to handle all GUI texts Good working with localization system

-

- -

+

Functions

- + - + - +
init(node, locale_id, no_adjust)init(self, node, locale_id, no_adjust) Component init function
set_to(text)set_to(self, text) Setup raw text to lang_text component
translate(locale_id)translate(self, locale_id) Translate the text by locale_id
-

Tables

+

Fields

- - - - - - + +
EventsComponent events
FieldsComponent fieldson_changeOn change text callback
@@ -123,7 +106,7 @@
- init(node, locale_id, no_adjust) + init(self, node, locale_id, no_adjust)
Component init function @@ -131,6 +114,10 @@

Parameters:

    +
  • self + LangText + +
  • node node The text node @@ -152,7 +139,7 @@
- set_to(text) + set_to(self, text)
Setup raw text to lang_text component @@ -160,6 +147,10 @@

Parameters:

    +
  • self + LangText + +
  • text string Text for text node @@ -173,7 +164,7 @@
- translate(locale_id) + translate(self, locale_id)
Translate the text by locale_id @@ -181,6 +172,10 @@

Parameters:

    +
  • self + LangText + +
  • locale_id string Locale id @@ -193,43 +188,21 @@
-

Tables

+

Fields

- - Events + + on_change
- Component events + On change text callback -

Fields:

  • on_change druid_event - On change text callback -
  • -
- - - - -
-
- - Fields -
-
- Component fields - - -

Fields:

-
    -
  • text - druid.text - The text component
@@ -245,7 +218,7 @@
generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 +Last updated 2020-10-12 00:44:30
diff --git a/docs/modules/druid.progress.html b/docs/modules/Progress.html similarity index 55% rename from docs/modules/druid.progress.html rename to docs/modules/Progress.html index 1f70c03..ffe5e2d 100644 --- a/docs/modules/druid.progress.html +++ b/docs/modules/Progress.html @@ -34,102 +34,112 @@

Modules

-

Topics

-
-

Module druid.progress

+

Module Progress

Basic progress bar component.

-

For correct progress bar init it should be in max size from gui

+

+ For correct progress bar init it should be in max size from gui

Functions

- + - + - + - + - + - + - +
init(node, key[, init_value=1])init(self, node, key[, init_value=1]) Component init function
fill()fill(self) Fill a progress bar and stop progress animation
empty()empty(self) Empty a progress bar
set_to(to)set_to(self, to) Instant fill progress bar to value
get()get(self) Return current progress bar value
set_steps(steps, callback)set_steps(self, steps, callback) Set points on progress bar to fire the callback
to(to[, callback])to(self, to[, callback]) Start animation of a progress bar

Tables

- - - - - - - - - +
EventsComponent events
FieldsComponent fields
Stylestyle Component style params.
+

Fields

+ + + + + + + + + + + + + + + + + + + + + + + + + +
on_changeOn progress bar change callback(self, new_value)
nodeProgress bar fill node
keyThe progress bar direction
scaleCurrent progress bar scale
sizeCurrent progress bar size
max_sizeMaximum size of progress bar


@@ -140,7 +150,7 @@
- init(node, key[, init_value=1]) + init(self, node, key[, init_value=1])
Component init function @@ -148,8 +158,12 @@

Parameters:

    +
  • self + Progress + +
  • node - string or node + string or node Progress bar fill node or node name
  • key @@ -170,12 +184,19 @@
- fill() + fill(self)
Fill a progress bar and stop progress animation +

Parameters:

+
    +
  • self + Progress + +
  • +
@@ -184,12 +205,19 @@
- empty() + empty(self)
Empty a progress bar +

Parameters:

+
    +
  • self + Progress + +
  • +
@@ -198,7 +226,7 @@
- set_to(to) + set_to(self, to)
Instant fill progress bar to value @@ -206,6 +234,10 @@

Parameters:

    +
  • self + Progress + +
  • to number Progress bar value, from 0 to 1 @@ -219,12 +251,19 @@
- get() + get(self)
Return current progress bar value +

Parameters:

+
    +
  • self + Progress + +
  • +
@@ -233,7 +272,7 @@
- set_steps(steps, callback) + set_steps(self, steps, callback)
Set points on progress bar to fire the callback @@ -241,6 +280,10 @@

Parameters:

    +
  • self + Progress + +
  • steps number[] Array of progress bar values @@ -262,7 +305,7 @@
- to(to[, callback]) + to(self, to[, callback])
Start animation of a progress bar @@ -270,6 +313,10 @@

Parameters:

    +
  • self + Progress + +
  • to number value between 0..1 @@ -291,70 +338,8 @@
    - - Events -
    -
    - Component events - - -

    Fields:

    -
      -
    • on_change - druid_event - On progress bar change callback -
    • -
    - - - - - -
    -
    - - Fields -
    -
    - Component fields - - -

    Fields:

    -
      -
    • node - node - Progress bar fill node -
    • -
    • key - string - The progress bar direction -
    • -
    • scale - vector3 - Current progress bar scale -
    • -
    • size - vector3 - Current progress bar size -
    • -
    • max_size - number - Maximum size of progress bar -
    • -
    • slice - vector4 - Progress bar slice9 settings -
    • -
    - - - - - -
    -
    - - Style + + style
    Component style params. @@ -380,6 +365,130 @@ +
    +
    +

    Fields

    + +
    +
    + + on_change +
    +
    + On progress bar change callback(self, new_value) + + +
      +
    • on_change + druid_event + +
    • +
    + + + + + +
    +
    + + node +
    +
    + Progress bar fill node + + +
      +
    • node + node + +
    • +
    + + + + + +
    +
    + + key +
    +
    + The progress bar direction + + + + + + + + +
    +
    + + scale +
    +
    + Current progress bar scale + + +
      +
    • scale + vector3 + +
    • +
    + + + + + +
    +
    + + size +
    +
    + Current progress bar size + + +
      +
    • size + vector3 + +
    • +
    + + + + + +
    +
    + + max_size +
    +
    + Maximum size of progress bar + + +
      +
    • max_size + number + +
    • +
    + + + + +
    @@ -388,7 +497,7 @@
generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 +Last updated 2020-10-12 00:44:30
diff --git a/docs/modules/RadioGroup.html b/docs/modules/RadioGroup.html new file mode 100644 index 0000000..043430b --- /dev/null +++ b/docs/modules/RadioGroup.html @@ -0,0 +1,227 @@ + + + + + Defold Druid UI Library + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module RadioGroup

+

Radio group module

+

+ + +

Functions

+ + + + + + + + + + + + + +
init(self, nodes, callback[, click_nodes=node])Component init function
set_state(self, index)Set radio group state
get_state(self)Return radio group state
+

Fields

+ + + + + +
on_radio_clickOn any checkbox click
+ +
+
+ + +

Functions

+ +
+
+ + init(self, nodes, callback[, click_nodes=node]) +
+
+ Component init function + + +

Parameters:

+
    +
  • self + RadioGroup + +
  • +
  • nodes + node[] + Array of gui node +
  • +
  • callback + function + Radio callback +
  • +
  • click_nodes + node[] + Array of trigger nodes, by default equals to nodes + (default node) +
  • +
+ + + + + +
+
+ + set_state(self, index) +
+
+ Set radio group state + + +

Parameters:

+
    +
  • self + RadioGroup + +
  • +
  • index + number + Index in radio group +
  • +
+ + + + + +
+
+ + get_state(self) +
+
+ Return radio group state + + +

Parameters:

+
    +
  • self + RadioGroup + +
  • +
+ +

Returns:

+
    + + number + Index in radio group +
+ + + + +
+
+

Fields

+ +
+
+ + on_radio_click +
+
+ On any checkbox click + + +
    +
  • on_radio_click + druid_event + +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +Last updated 2020-10-12 00:44:30 +
+
+ + diff --git a/docs/modules/druid.scroll.html b/docs/modules/Scroll.html similarity index 58% rename from docs/modules/druid.scroll.html rename to docs/modules/Scroll.html index 5410563..845db2a 100644 --- a/docs/modules/druid.scroll.html +++ b/docs/modules/Scroll.html @@ -34,54 +34,45 @@

Modules

-

Topics

-
-

Module druid.scroll

+

Module Scroll

Component to handle scroll content.

-

Scroll consist from two nodes: scroll parent and scroll input +

+ Scroll consist from two nodes: scroll parent and scroll input Scroll input the user input zone, it's static Scroll parent the scroll moving part, it will change position. Setup initial scroll size by changing scroll parent size. If scroll parent @@ -92,82 +83,129 @@

Functions

- - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - +
init(view_node, content_node)Scroll constructor.init(self, view_node, content_node)Scroll constructor
scroll_to(vector3[, is_instant])scroll_to(self, point[, is_instant]) Start scroll to target point.
scroll_to_index(index[, skip_cb])scroll_to_index(self, index[, skip_cb]) Scroll to item in scroll by point index.
scroll_to_percent(vector3[, is_instant])scroll_to_percent(self, percent[, is_instant]) Start scroll to target scroll percent
get_percent()get_percent(self) Return current scroll progress status.
set_size(size)set_size(self, size) Set scroll content size.
set_inert(state)set_inert(self, state) Enable or disable scroll inert.
is_inert()is_inert(self) Return if scroll have inertion.
set_extra_stretch_size([stretch_size=0])set_extra_stretch_size(self[, stretch_size=0]) Set extra size for scroll stretching.
get_scroll_size()get_scroll_size(self) Return vector of scroll size with width and height.
set_points(points)set_points(self, points) Set points of interest.
set_horizontal_scroll(state)set_horizontal_scroll(self, state) Lock or unlock horizontal scroll
set_vertical_scroll(state)set_vertical_scroll(self, state) Lock or unlock vertical scroll
bind_grid(Druid)bind_grid(self, grid) Bind the grid component (Static or Dynamic) to recalculate scroll size on grid changes
Scroll:_cancel_animate()_cancel_animate(self) Cancel animation on other animation or input touch

Tables

- - - - - - - - - +
EventsComponent events
FieldsComponent fields
Stylestyle Component style params.
+

Fields

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
on_scrollOn scroll move callback(self, position)
on_scroll_toOn scroll_to function callback(self, target, is_instant)
on_point_scrollOn scroll_to_index function callback(self, index, point)
view_nodeScroll view node
content_nodeScroll content node
is_inertFlag, if scroll now moving by inertion
inertionCurrent inert speed
positionCurrent scroll posisition
target_positionCurrent scroll target position
available_posAvailable position for content node: (min_x, max_y, max_x, min_y)
available_sizeSize of available positions: (width, height, 0)
dragDrag Druid component
selectedCurrent index of points of interests


@@ -178,14 +216,18 @@
- init(view_node, content_node) + init(self, view_node, content_node)
- Scroll constructor. + Scroll constructor

Parameters:

    +
  • self + Scroll + +
  • view_node node GUI view scroll node @@ -203,7 +245,7 @@
- scroll_to(vector3[, is_instant]) + scroll_to(self, point[, is_instant])
Start scroll to target point. @@ -211,8 +253,12 @@

Parameters:

    -
  • vector3 - point +
  • self + Scroll + +
  • +
  • point + vector3 Target point
  • is_instant @@ -234,7 +280,7 @@
- scroll_to_index(index[, skip_cb]) + scroll_to_index(self, index[, skip_cb])
Scroll to item in scroll by point index. @@ -242,6 +288,10 @@

Parameters:

    +
  • self + Scroll + +
  • index number Point index @@ -260,7 +310,7 @@
- scroll_to_percent(vector3[, is_instant]) + scroll_to_percent(self, percent[, is_instant])
Start scroll to target scroll percent @@ -268,8 +318,12 @@

Parameters:

    -
  • vector3 - point +
  • self + Scroll + +
  • +
  • percent + vector3 target percent
  • is_instant @@ -290,13 +344,20 @@
- get_percent() + get_percent(self)
Return current scroll progress status. Values will be in [0..1] interval +

Parameters:

+
    +
  • self + Scroll + +
  • +

Returns:

    @@ -311,7 +372,7 @@
- set_size(size) + set_size(self, size)
Set scroll content size. @@ -320,6 +381,10 @@

Parameters:

    +
  • self + Scroll + +
  • size vector3 The new size for content node @@ -339,7 +404,7 @@
- set_inert(state) + set_inert(self, state)
Enable or disable scroll inert. @@ -349,6 +414,10 @@

Parameters:

    +
  • self + Scroll + +
  • state bool Inert scroll state @@ -368,12 +437,19 @@
- is_inert() + is_inert(self)
Return if scroll have inertion. +

Parameters:

+
    +
  • self + Scroll + +
  • +

Returns:

    @@ -388,7 +464,7 @@
- set_extra_stretch_size([stretch_size=0]) + set_extra_stretch_size(self[, stretch_size=0])
Set extra size for scroll stretching. @@ -397,6 +473,10 @@

Parameters:

    +
  • self + Scroll + +
  • stretch_size number Size in pixels of additional scroll area @@ -417,12 +497,19 @@
- get_scroll_size() + get_scroll_size(self)
Return vector of scroll size with width and height. +

Parameters:

+
    +
  • self + Scroll + +
  • +

Returns:

    @@ -437,7 +524,7 @@
- set_points(points) + set_points(self, points)
Set points of interest. @@ -446,6 +533,10 @@

Parameters:

    +
  • self + Scroll + +
  • points table Array of vector3 points @@ -465,7 +556,7 @@
- set_horizontal_scroll(state) + set_horizontal_scroll(self, state)
Lock or unlock horizontal scroll @@ -473,6 +564,10 @@

Parameters:

    +
  • self + Scroll + +
  • state bool True, if horizontal scroll is enabled @@ -492,7 +587,7 @@
- set_vertical_scroll(state) + set_vertical_scroll(self, state)
Lock or unlock vertical scroll @@ -500,6 +595,10 @@

Parameters:

    +
  • self + Scroll + +
  • state bool True, if vertical scroll is enabled @@ -519,7 +618,7 @@
- bind_grid(Druid) + bind_grid(self, grid)
Bind the grid component (Static or Dynamic) to recalculate @@ -528,9 +627,13 @@

Parameters:

    -
  • Druid - druid.static_grid or druid.dynamic_grid - grid component +
  • self + Scroll + +
  • +
  • grid + StaticGrid or DynamicGrid + Druid grid component
@@ -546,13 +649,19 @@
- - Scroll:_cancel_animate() + + _cancel_animate(self)
Cancel animation on other animation or input touch +

Parameters:

+
    +
  • self + +
  • +
@@ -564,99 +673,8 @@
- - Events -
-
- Component events - - -

Fields:

-
    -
  • on_scroll - druid_event - On scroll move callback -
  • -
  • on_scroll_to - druid_event - On scroll_to function callback -
  • -
  • on_point_scroll - druid_event - On scrolltoindex function callback -
  • -
- - - - - -
-
- - Fields -
-
- Component fields - - -

Fields:

-
    -
  • view_node - node - Scroll view node -
  • -
  • content_node - node - Scroll content node -
  • -
  • is_inert - bool - Flag, if scroll now moving by inertion -
  • -
  • inertion - vector3 - Current inert speed -
  • -
  • position - vector3 - Current scroll posisition -
  • -
  • target_position - vector3 - Current scroll target position -
  • -
  • available_pos - vector4 - Available position for content node: (minx, maxy, maxx, miny) -
  • -
  • available_size - vector3 - Size of available positions: (width, height, 0) -
  • -
  • drag - druid.drag - Drag component -
  • -
  • Current - selected - index of points of interests - (optional) -
  • -
  • is_animate - bool - Flag, if scroll now animating by gui.animate -
  • -
- - - - - -
-
- - Style + + style
Component style params. @@ -717,6 +735,271 @@ +
+
+

Fields

+ +
+
+ + on_scroll +
+
+ On scroll move callback(self, position) + + +
    +
  • on_scroll + druid_event + +
  • +
+ + + + + +
+
+ + on_scroll_to +
+
+ On scroll_to function callback(self, target, is_instant) + + +
    +
  • on_scroll_to + druid_event + +
  • +
+ + + + + +
+
+ + on_point_scroll +
+
+ On scroll_to_index function callback(self, index, point) + + +
    +
  • on_point_scroll + druid_event + +
  • +
+ + + + + +
+
+ + view_node +
+
+ Scroll view node + + +
    +
  • view_node + node + +
  • +
+ + + + + +
+
+ + content_node +
+
+ Scroll content node + + +
    +
  • content_node + node + +
  • +
+ + + + + +
+
+ + is_inert +
+
+ Flag, if scroll now moving by inertion + + +
    +
  • is_inert + bool + +
  • +
+ + + + + +
+
+ + inertion +
+
+ Current inert speed + + +
    +
  • inertion + vector3 + +
  • +
+ + + + + +
+
+ + position +
+
+ Current scroll posisition + + +
    +
  • position + vector3 + +
  • +
+ + + + + +
+
+ + target_position +
+
+ Current scroll target position + + +
    +
  • target_position + vector3 + +
  • +
+ + + + + +
+
+ + available_pos +
+
+ Available position for content node: (min_x, max_y, max_x, min_y) + + +
    +
  • available_pos + vector4 + +
  • +
+ + + + + +
+
+ + available_size +
+
+ Size of available positions: (width, height, 0) + + +
    +
  • available_size + vector3 + +
  • +
+ + + + + +
+
+ + drag +
+
+ Drag Druid component + + +
    +
  • drag + Drag + +
  • +
+ + + + + +
+
+ + selected +
+
+ Current index of points of interests + + +
    +
  • selected + number + + (optional) +
  • +
+ + + + +
@@ -725,7 +1008,7 @@
generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 +Last updated 2020-10-12 00:44:30
diff --git a/docs/modules/druid.slider.html b/docs/modules/Slider.html similarity index 50% rename from docs/modules/druid.slider.html rename to docs/modules/Slider.html index 4c95cc7..c1c9995 100644 --- a/docs/modules/druid.slider.html +++ b/docs/modules/Slider.html @@ -33,83 +33,94 @@

Contents

Modules

-

Topics

-
-

Module druid.slider

+

Module Slider

Druid slider component

-

- -

+

Functions

- + - + - +
init(node, end_pos[, callback])init(self, node, end_pos[, callback]) Component init function
set(value[, is_silent])set(self, value[, is_silent]) Set value for slider
set_steps(steps)set_steps(self, steps) Set slider steps.
-

Tables

+

Fields

- - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + +
EventsComponent eventson_change_valueOn change value callback(self, value)
FieldsComponent fieldsnodeSlider pin node
start_posStart pin node position
posCurrent pin node position
target_posTarger pin node position
end_posEnd pin node position
distLength between start and end position
is_dragCurrent drag state
@@ -122,7 +133,7 @@
- init(node, end_pos[, callback]) + init(self, node, end_pos[, callback])
Component init function @@ -130,8 +141,12 @@

Parameters:

    +
  • self + Slider + +
  • node - node + node Gui pin node
  • end_pos @@ -152,7 +167,7 @@
- set(value[, is_silent]) + set(self, value[, is_silent])
Set value for slider @@ -160,6 +175,10 @@

Parameters:

    +
  • self + Slider + +
  • value number Value from 0 to 1 @@ -178,7 +197,7 @@
- set_steps(steps) + set_steps(self, steps)
Set slider steps. Pin node will @@ -187,6 +206,10 @@

Parameters:

    +
  • self + Slider + +
  • steps number[] Array of steps @@ -203,22 +226,21 @@
-

Tables

+

Fields

- - Events + + on_change_value
- Component events + On change value callback(self, value) -

Fields:

  • on_change_value druid_event - On change value callback +
@@ -228,46 +250,137 @@
- - Fields + + node
- Component fields + Slider pin node -

Fields:

  • node - node - Slider pin node + node +
  • +
+ + + + + +
+
+ + start_pos +
+
+ Start pin node position + + +
  • start_pos vector3 - Start pin node position +
  • +
+ + + + + +
+
+ + pos +
+
+ Current pin node position + + +
  • pos vector3 - Current pin node position +
  • +
+ + + + + +
+
+ + target_pos +
+
+ Targer pin node position + + +
  • target_pos vector3 - Targer pin node position +
  • +
+ + + + + +
+
+ + end_pos +
+
+ End pin node position + + +
  • end_pos vector3 - End pin node position +
  • +
+ + + + + +
+
+ + dist +
+
+ Length between start and end position + + +
  • dist number - Length between start and end position +
  • +
+ + + + + +
+
+ + is_drag +
+
+ Current drag state + + +
  • is_drag bool - Current drag state -
  • -
  • value - number - Current slider value +
@@ -283,7 +396,7 @@
generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 +Last updated 2020-10-12 00:44:30
diff --git a/docs/modules/druid.static_grid.html b/docs/modules/StaticGrid.html similarity index 55% rename from docs/modules/druid.static_grid.html rename to docs/modules/StaticGrid.html index 347b207..186495e 100644 --- a/docs/modules/druid.static_grid.html +++ b/docs/modules/StaticGrid.html @@ -33,113 +33,139 @@

Contents

Modules

-

Topics

-
-

Module druid.static_grid

+

Module StaticGrid

Component to handle placing components by row and columns.

-

Grid can anchor your elements, get content size and other

+

+ Grid can anchor your elements, get content size and other

Functions

- + - + - + - + - + - + - + - + - + - + - +
init(parent, element[, in_row=1])init(self, parent, element[, in_row=1]) Component init function
get_pos(index)get_pos(self, index) Return pos for grid node index
get_index(pos)get_index(self, pos) Return index for grid pos
get_index_by_node(node)get_index_by_node(self, node) Return grid index by node
set_anchor(anchor)set_anchor(self, anchor) Set grid anchor.
add(item[, index])add(self, item[, index]) Add new item to the grid
remove(index, is_shift_nodes)remove(self, index, is_shift_nodes) Remove the item from the grid.
get_size()get_size(self) Return grid content size
get_all_pos()get_all_pos(self) Return array of all node positions
set_position_function(callback)set_position_function(self, callback) Change set position function for grid nodes.
clear()clear(self) Clear grid nodes array.
-

Tables

+

Fields

- - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
EventsComponent eventson_add_itemOn item add callback(self, node, index)
FieldsComponent fieldson_remove_itemOn item remove callback(self, index)
on_change_itemsOn item add or remove callback(self, index)
on_clearOn grid clear callback(self)
on_update_positionsOn update item positions callback(self)
parentParent gui node
nodesList of all grid nodes
first_indexThe first index of node in grid
last_indexThe last index of node in grid
anchorItem anchor
node_sizeItem size
@@ -152,7 +178,7 @@
- init(parent, element[, in_row=1]) + init(self, parent, element[, in_row=1])
Component init function @@ -160,6 +186,10 @@

Parameters:

    +
  • self + StaticGrid + +
  • parent node The gui node parent, where items will be placed @@ -182,7 +212,7 @@
- get_pos(index) + get_pos(self, index)
Return pos for grid node index @@ -190,6 +220,10 @@

Parameters:

    +
  • self + StaticGrid + +
  • index number The grid element index @@ -209,7 +243,7 @@
- get_index(pos) + get_index(self, pos)
Return index for grid pos @@ -217,6 +251,10 @@

Parameters:

    +
  • self + StaticGrid + +
  • pos vector3 The node position in the grid @@ -236,7 +274,7 @@
- get_index_by_node(node) + get_index_by_node(self, node)
Return grid index by node @@ -244,6 +282,10 @@

Parameters:

    +
  • self + StaticGrid + +
  • node node The gui node in the grid @@ -263,7 +305,7 @@
- set_anchor(anchor) + set_anchor(self, anchor)
Set grid anchor. Default anchor is equal to anchor of grid parent node @@ -271,6 +313,10 @@

Parameters:

    +
  • self + StaticGrid + +
  • anchor vector3 Anchor @@ -284,7 +330,7 @@
- add(item[, index]) + add(self, item[, index])
Add new item to the grid @@ -292,6 +338,10 @@

Parameters:

    +
  • self + StaticGrid + +
  • item node Gui node @@ -310,7 +360,7 @@
- remove(index, is_shift_nodes) + remove(self, index, is_shift_nodes)
Remove the item from the grid. Note that gui node will be not deleted @@ -318,6 +368,10 @@

Parameters:

    +
  • self + StaticGrid + +
  • index number The grid node index to remove @@ -335,12 +389,19 @@
- get_size() + get_size(self)
Return grid content size +

Parameters:

+
    +
  • self + StaticGrid + +
  • +

Returns:

    @@ -355,12 +416,19 @@
- get_all_pos() + get_all_pos(self)
Return array of all node positions +

Parameters:

+
    +
  • self + StaticGrid + +
  • +

Returns:

    @@ -375,7 +443,7 @@
- set_position_function(callback) + set_position_function(self, callback)
Change set position function for grid nodes. It will call on @@ -384,6 +452,10 @@

Parameters:

    +
  • self + StaticGrid + +
  • callback function Function on node set position @@ -403,13 +475,20 @@
- clear() + clear(self)
Clear grid nodes array. GUI nodes will be not deleted! If you want to delete GUI nodes, use static_grid.nodes array before grid:clear +

Parameters:

+
    +
  • self + StaticGrid + +
  • +

Returns:

    @@ -423,38 +502,21 @@
-

Tables

+

Fields

- - Events + + on_add_item
- Component events + On item add callback(self, node, index) -

Fields:

  • on_add_item druid_event - On item add callback -
  • -
  • on_remove_item - druid_event - On item remove callback -
  • -
  • on_change_items - druid_event - On item add or remove callback -
  • -
  • on_clear - druid_event - On grid clear callback -
  • -
  • on_update_positions - druid_event - On update item positions callback +
@@ -464,42 +526,197 @@
- - Fields + + on_remove_item
- Component fields + On item remove callback(self, index) + + +
    +
  • on_remove_item + druid_event + +
  • +
+ + + + + +
+
+ + on_change_items +
+
+ On item add or remove callback(self, index) + + +
    +
  • on_change_items + druid_event + +
  • +
+ + + + + +
+
+ + on_clear +
+
+ On grid clear callback(self) + + +
    +
  • on_clear + druid_event + +
  • +
+ + + + + +
+
+ + on_update_positions +
+
+ On update item positions callback(self) + + +
    +
  • on_update_positions + druid_event + +
  • +
+ + + + + +
+
+ + parent +
+
+ Parent gui node -

Fields:

  • parent node - Parent gui node +
  • +
+ + + + + +
+
+ + nodes +
+
+ List of all grid nodes + + +
  • nodes node[] - List of all grid nodes +
  • +
+ + + + + +
+
+ + first_index +
+
+ The first index of node in grid + + +
  • first_index number - The first index of node in grid +
  • +
+ + + + + +
+
+ + last_index +
+
+ The last index of node in grid + + +
  • last_index number - The last index of node in grid +
  • +
+ + + + + +
+
+ + anchor +
+
+ Item anchor + + +
  • anchor vector3 - Item anchor +
  • +
+ + + + + +
+
+ + node_size +
+
+ Item size + + +
  • node_size vector3 - Item size -
  • -
  • border - vector4 - The size of item content +
@@ -515,7 +732,7 @@
generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 +Last updated 2020-10-12 00:44:30
diff --git a/docs/modules/druid.swipe.html b/docs/modules/Swipe.html similarity index 52% rename from docs/modules/druid.swipe.html rename to docs/modules/Swipe.html index eb364c5..4957031 100644 --- a/docs/modules/druid.swipe.html +++ b/docs/modules/Swipe.html @@ -34,83 +34,77 @@

Modules

-

Topics

-
-

Module druid.swipe

+

Module Swipe

Component to handle swipe gestures on node.

-

Swipe will be triggered, if swipe was started and +

+ Swipe will be triggered, if swipe was started and ended on one node

Functions

- + - +
init(node, on_swipe_callback)init(self, node, on_swipe_callback) Component init function
set_click_zone(zone)set_click_zone(self, zone) Strict swipe click area.

Tables

- - - - - - - - - +
FieldsComponents fields
EventsComponent events
Stylestyle Component style params.
+

Fields

+ + + + + + + + + +
nodeSwipe node
click_zoneRestriction zone


@@ -121,7 +115,7 @@
- init(node, on_swipe_callback) + init(self, node, on_swipe_callback)
Component init function @@ -129,13 +123,17 @@

Parameters:

    +
  • self + Swipe + +
  • node - node + node Gui node
  • on_swipe_callback function - Swipe callback for onswipeend event + Swipe callback for on_swipe_end event
@@ -146,7 +144,7 @@
- set_click_zone(zone) + set_click_zone(self, zone)
Strict swipe click area. Useful for @@ -155,8 +153,12 @@

Parameters:

    +
  • self + Swipe + +
  • zone - node + node Gui node
@@ -171,55 +173,8 @@
- - Fields -
-
- Components fields - - -

Fields:

-
    -
  • node - node - Swipe node -
  • -
  • click_zone - node - Restriction zone - (optional) -
  • -
- - - - - -
-
- - Events -
-
- Component events - - -

Fields:

-
    -
  • on_swipe - druid_event - Trigger on swipe event -
  • -
- - - - - -
-
- - Style + + style
Component style params. @@ -250,6 +205,51 @@ +
+
+

Fields

+ +
+
+ + node +
+
+ Swipe node + + +
    +
  • node + node + +
  • +
+ + + + + +
+
+ + click_zone +
+
+ Restriction zone + + +
    +
  • click_zone + node + + (optional) +
  • +
+ + + + +
@@ -258,7 +258,7 @@
generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 +Last updated 2020-10-12 00:44:30
diff --git a/docs/modules/druid.text.html b/docs/modules/Text.html similarity index 50% rename from docs/modules/druid.text.html rename to docs/modules/Text.html index b3b2feb..87fc999 100644 --- a/docs/modules/druid.text.html +++ b/docs/modules/Text.html @@ -33,102 +33,124 @@

Contents

Modules

-

Topics

-
-

Module druid.text

+

Module Text

Component to handle all GUI texts.

-

Druid text can adjust itself for text node size +

+ Druid text can adjust itself for text node size Text will never will be outside of his text size (even multiline)

Functions

- + - + - + - + - + - + - + - +
init(node[, value[, no_adjust]])init(self, node[, value[, no_adjust]]) Component init function
get_text_width([text])get_text_width(self[, text]) Calculate text width with font with respect to trailing space
set_to(set_to)set_to(self, set_to) Set text to text field
set_color(color)set_color(self, color) Set color
set_alpha(alpha)set_alpha(self, alpha) Set alpha
set_scale(scale)set_scale(self, scale) Set scale
set_pivot(pivot)set_pivot(self, pivot) Set text pivot.
is_multiline()is_multiline(self) Return true, if text with line break
-

Tables

+

Fields

- - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
EventsComponent eventson_set_textOn set text callback(self, text)
FieldsComponent fieldson_update_text_scaleOn adjust text size callback(self, new_scale)
on_set_pivotOn change pivot callback(self, pivot)
nodeText node
posCurrent text position
start_scaleInitial text node scale
scaleCurrent text node scale
start_sizeInitial text node size
text_areaCurrent text node available are
is_no_adjustCurrent text size adjust settings
@@ -141,7 +163,7 @@
- init(node[, value[, no_adjust]]) + init(self, node[, value[, no_adjust]])
Component init function @@ -149,8 +171,12 @@

Parameters:

    +
  • self + Text + +
  • node - node + node Gui text node
  • value @@ -172,7 +198,7 @@
- get_text_width([text]) + get_text_width(self[, text])
Calculate text width with font with respect to trailing space @@ -180,11 +206,13 @@

Parameters:

    +
  • self + Text + +
  • text string - - (optional)
@@ -196,7 +224,7 @@
- set_to(set_to) + set_to(self, set_to)
Set text to text field @@ -204,6 +232,10 @@

Parameters:

    +
  • self + Text + +
  • set_to string Text for node @@ -217,7 +249,7 @@
- set_color(color) + set_color(self, color)
Set color @@ -225,6 +257,10 @@

Parameters:

    +
  • self + Text + +
  • color vector4 Color for node @@ -238,7 +274,7 @@
- set_alpha(alpha) + set_alpha(self, alpha)
Set alpha @@ -246,6 +282,10 @@

Parameters:

    +
  • self + Text + +
  • alpha number Alpha for node @@ -259,7 +299,7 @@
- set_scale(scale) + set_scale(self, scale)
Set scale @@ -267,6 +307,10 @@

Parameters:

    +
  • self + Text + +
  • scale vector3 Scale for node @@ -280,7 +324,7 @@
- set_pivot(pivot) + set_pivot(self, pivot)
Set text pivot. Text will re-anchor inside @@ -289,6 +333,10 @@

Parameters:

    +
  • self + Text + +
  • pivot gui.pivot Gui pivot constant @@ -302,12 +350,19 @@
- is_multiline() + is_multiline(self)
Return true, if text with line break +

Parameters:

+
    +
  • self + Text + +
  • +

Returns:

    @@ -321,30 +376,21 @@
-

Tables

+

Fields

- - Events + + on_set_text
- Component events + On set text callback(self, text) -

Fields:

  • on_set_text druid_event - On set text callback -
  • -
  • on_update_text_scale - druid_event - On adjust text size callback -
  • -
  • on_set_pivot - druid_event - On change pivot callback +
@@ -354,46 +400,177 @@
- - Fields + + on_update_text_scale
- Component fields + On adjust text size callback(self, new_scale) + + +
    +
  • on_update_text_scale + druid_event + +
  • +
+ + + + + +
+
+ + on_set_pivot +
+
+ On change pivot callback(self, pivot) + + +
    +
  • on_set_pivot + druid_event + +
  • +
+ + + + + +
+
+ + node +
+
+ Text node -

Fields:

  • node - node - Text node + node +
  • +
+ + + + + +
+
+ + pos +
+
+ Current text position + + +
  • pos vector3 - Current text position +
  • +
+ + + + + +
+
+ + start_scale +
+
+ Initial text node scale + + +
  • start_scale vector3 - Initial text node scale +
  • +
+ + + + + +
+
+ + scale +
+
+ Current text node scale + + +
  • scale vector3 - Current text node scale +
  • +
+ + + + + +
+
+ + start_size +
+
+ Initial text node size + + +
  • start_size vector3 - Initial text node size +
  • +
+ + + + + +
+
+ + text_area +
+
+ Current text node available are + + +
  • text_area vector3 - Current text node available are +
  • +
+ + + + + +
+
+ + is_no_adjust +
+
+ Current text size adjust settings + + +
  • is_no_adjust bool - Current text size adjust settings -
  • -
  • color - vector3 - Current text color +
@@ -409,7 +586,7 @@
generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 +Last updated 2020-10-12 00:44:30
diff --git a/docs/modules/druid.timer.html b/docs/modules/Timer.html similarity index 51% rename from docs/modules/druid.timer.html rename to docs/modules/Timer.html index 8468527..39a50b4 100644 --- a/docs/modules/druid.timer.html +++ b/docs/modules/Timer.html @@ -33,86 +33,92 @@

Contents

Modules

-

Topics

-
-

Module druid.timer

+

Module Timer

Component to handle GUI timers.

-

Timer updating by game delta time. If game is not focused - +

+ Timer updating by game delta time. If game is not focused - timer will be not updated.

Functions

- + - + - + - +
init(node, seconds_from[, seconds_to=0[, callback]])init(self, node, seconds_from[, seconds_to=0[, callback]]) Component init function
set_to(set_to)set_to(self, set_to) Set text to text field
set_state(is_on)set_state(self, is_on) Called when update
set_interval(from, to)set_interval(self, from, to) Set time interval
-

Tables

+

Fields

- - + + - - + + + + + + + + + + + + + + + + + +
EventsComponent eventson_tickOn timer tick.
FieldsComponent fieldson_set_enabledOn timer change enabled state callback(self, is_enabled)
on_timer_endOn timer end callback
nodeTrigger node
fromInitial timer value
targetTarget timer value
@@ -125,7 +131,7 @@
- init(node, seconds_from[, seconds_to=0[, callback]]) + init(self, node, seconds_from[, seconds_to=0[, callback]])
Component init function @@ -133,8 +139,12 @@

Parameters:

    +
  • self + Timer + +
  • node - node + node Gui text node
  • seconds_from @@ -160,7 +170,7 @@
- set_to(set_to) + set_to(self, set_to)
Set text to text field @@ -168,6 +178,10 @@

Parameters:

    +
  • self + Timer + +
  • set_to number Value in seconds @@ -181,7 +195,7 @@
- set_state(is_on) + set_state(self, is_on)
Called when update @@ -189,6 +203,10 @@

Parameters:

    +
  • self + Timer + +
  • is_on bool Timer enable state @@ -202,7 +220,7 @@
- set_interval(from, to) + set_interval(self, from, to)
Set time interval @@ -210,6 +228,10 @@

Parameters:

    +
  • self + Timer + +
  • from number Start time in seconds @@ -226,30 +248,21 @@
-

Tables

+

Fields

- - Events + + on_tick
- Component events + On timer tick. Fire every second callback(self, value) -

Fields:

  • on_tick druid_event - On timer tick callback. Fire every second -
  • -
  • on_set_enabled - druid_event - On timer change enabled state callback -
  • -
  • on_timer_end - druid_event - On timer end callback +
@@ -259,30 +272,97 @@
- - Fields + + on_set_enabled
- Component fields + On timer change enabled state callback(self, is_enabled) + + +
    +
  • on_set_enabled + druid_event + +
  • +
+ + + + + +
+
+ + on_timer_end +
+
+ On timer end callback + + +
    +
  • on_timer_end + druid_event + (self, Timer) +
  • +
+ + + + + +
+
+ + node +
+
+ Trigger node -

Fields:

  • node - node - Trigger node + node +
  • +
+ + + + + +
+
+ + from +
+
+ Initial timer value + + +
  • from number - Initial timer value +
  • +
+ + + + + +
+
+ + target +
+
+ Target timer value + + +
  • target number - Target timer value -
  • -
  • value - number - Current timer value +
@@ -298,7 +378,7 @@
generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 +Last updated 2020-10-12 00:44:30
diff --git a/docs/modules/component.html b/docs/modules/component.html deleted file mode 100644 index 597d4c2..0000000 --- a/docs/modules/component.html +++ /dev/null @@ -1,601 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module component

-

Basic class for all Druid components.

-

To create you component, use component.create

- - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
set_style(style)Set current component style table.
set_template(template)Set current component template name
set_nodes(nodes)Set current component nodes
get_context()Get current component context
increase_input_priority()Increase input priority in current input stack
reset_input_priority()Reset input priority in current input stack
get_node(node_or_name)Get node for component by name.
get_druid()Return druid with context of calling component.
get_name()Return component name
set_input_enabled(state)Set component input state.
get_parent_component()Return the parent for current component
setup_component(table, table, table)Setup component context and his style table
__set_context(context)Set current component context
__get_interests()Get current component interests
__get_template()Get current component template name
__get_nodes()Get current component nodes
__add_children(children)Add child to component children list
__remove_children(children)Remove child from component children list
Component.create(name[, interest={}])Create new component.
- -
-
- - -

Functions

- -
-
- - set_style(style) -
-
- Set current component style table. - Invoke on_style_change on component, if exist. Component should handle - their style changing and store all style params - - -

Parameters:

-
    -
  • style - table - Druid style module -
  • -
- - - - - -
-
- - set_template(template) -
-
- Set current component template name - - -

Parameters:

-
    -
  • template - string - Component template name -
  • -
- - - - - -
-
- - set_nodes(nodes) -
-
- Set current component nodes - - -

Parameters:

-
    -
  • nodes - table - Component nodes table -
  • -
- - - - - -
-
- - get_context() -
-
- Get current component context - - - -

Returns:

-
    - - table - Component context -
- - - - -
-
- - increase_input_priority() -
-
- Increase input priority in current input stack - - - - - - - -
-
- - reset_input_priority() -
-
- Reset input priority in current input stack - - - - - - - -
-
- - get_node(node_or_name) -
-
- Get node for component by name. - If component has nodes, nodeorname should be string - It auto pick node by template name or from nodes by clonetree - if they was setup via component:setnodes, component:set_template - - -

Parameters:

-
    -
  • node_or_name - string or node - Node name or node itself -
  • -
- -

Returns:

-
    - - node - Gui node -
- - - - -
-
- - get_druid() -
-
- Return druid with context of calling component. - Use it to create component inside of other components. - - - -

Returns:

-
    - - Druid - Druid instance with component context -
- - - - -
-
- - get_name() -
-
- Return component name - - - -

Returns:

-
    - - string - The component name -
- - - - -
-
- - set_input_enabled(state) -
-
- Set component input state. By default it enabled - You can disable any input of component by this function - - -

Parameters:

-
    -
  • state - bool - The component input state -
  • -
- -

Returns:

-
    - - Component - Component itself -
- - - - -
-
- - get_parent_component() -
-
- Return the parent for current component - - - -

Returns:

-
    - - Component or nil - The druid component instance or nil -
- - - - -
-
- - setup_component(table, table, table) -
-
- Setup component context and his style table - - -

Parameters:

-
    -
  • table - style - Druid style module -
  • -
  • table - style - Druid style module -
  • -
  • table - style - Druid style module -
  • -
- -

Returns:

-
    - - component - Component itself -
- - - - -
-
- - __set_context(context) -
-
- Set current component context - - -

Parameters:

-
    -
  • context - table - Druid context. Usually it is self of script -
  • -
- - - - - -
-
- - __get_interests() -
-
- Get current component interests - - - -

Returns:

-
    - - table - List of component interests -
- - - - -
-
- - __get_template() -
-
- Get current component template name - - - -

Returns:

-
    - - string - Component template name -
- - - - -
-
- - __get_nodes() -
-
- Get current component nodes - - - -

Returns:

-
    - - table - Component nodes table -
- - - - -
-
- - __add_children(children) -
-
- Add child to component children list - - -

Parameters:

-
    -
  • children - component - The druid component instance -
  • -
- - - - - -
-
- - __remove_children(children) -
-
- Remove child from component children list - - -

Parameters:

-
    -
  • children - component - The druid component instance -
  • -
- - - - - -
-
- - Component.create(name[, interest={}]) -
-
- Create new component. It will inheritance from basic - druid component. - - -

Parameters:

-
    -
  • name - string - Component name -
  • -
  • interest - table - List of component's interest - (default {}) -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 -
-
- - diff --git a/docs/modules/druid.back_handler.html b/docs/modules/druid.back_handler.html deleted file mode 100644 index 5971afb..0000000 --- a/docs/modules/druid.back_handler.html +++ /dev/null @@ -1,227 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module druid.back_handler

-

Component to handle back key (android, backspace)

-

- -

- - -

Functions

- - - - - - - - - -
init(callback[, Callback])Component init function
on_input(action_id, action)Input handler for component
-

Tables

- - - - - - - - - -
EventsComponent events
FieldsComponent fields
- -
-
- - -

Functions

- -
-
- - init(callback[, Callback]) -
-
- Component init function - - -

Parameters:

-
    -
  • callback - callback - On back button -
  • -
  • Callback - params - argument - (optional) -
  • -
- - - - - -
-
- - on_input(action_id, action) -
-
- Input handler for component - - -

Parameters:

-
    -
  • action_id - string - on_input action id -
  • -
  • action - table - on_input action -
  • -
- - - - - -
-
-

Tables

- -
-
- - Events -
-
- Component events - - -

Fields:

-
    -
  • on_back - druid_event - On back handler callback -
  • -
- - - - - -
-
- - Fields -
-
- Component fields - - -

Fields:

-
    -
  • params - any - Params to click callbacks -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 -
-
- - diff --git a/docs/modules/druid.blocker.html b/docs/modules/druid.blocker.html deleted file mode 100644 index 2d25873..0000000 --- a/docs/modules/druid.blocker.html +++ /dev/null @@ -1,246 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module druid.blocker

-

Component to block input on specify zone by node

-

- -

- - -

Functions

- - - - - - - - - - - - - -
init(node)Component init function
set_enabled(state)Set enabled blocker component state
is_enabled()Return blocked enabled state
-

Tables

- - - - - - - - - -
EventsComponent events
FieldsComponent fields
- -
-
- - -

Functions

- -
-
- - init(node) -
-
- Component init function - - -

Parameters:

-
    -
  • node - node - Gui node -
  • -
- - - - - -
-
- - set_enabled(state) -
-
- Set enabled blocker component state - - -

Parameters:

-
    -
  • state - bool - Enabled state -
  • -
- - - - - -
-
- - is_enabled() -
-
- Return blocked enabled state - - - -

Returns:

-
    - - bool - True, if blocker is enabled -
- - - - -
-
-

Tables

- -
-
- - Events -
-
- Component events - - -

Fields:

-
    -
  • on_click - druid_event - On release button callback -
  • -
  • on_enable_change - druid_event - On enable/disable callback -
  • -
- - - - - -
-
- - Fields -
-
- Component fields - - -

Fields:

-
    -
  • node - node - Trigger node -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 -
-
- - diff --git a/docs/modules/druid.checkbox_group.html b/docs/modules/druid.checkbox_group.html deleted file mode 100644 index f2aba40..0000000 --- a/docs/modules/druid.checkbox_group.html +++ /dev/null @@ -1,251 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module druid.checkbox_group

-

Checkbox group module

-

- -

- - -

Functions

- - - - - - - - - - - - - -
init(node, callback[, click=node])Component init function
set_state(indexes)Set checkbox group state
get_state()Return checkbox group state
-

Tables

- - - - - - - - - -
EventsComponent events
FieldsComponent fields
- -
-
- - -

Functions

- -
-
- - init(node, callback[, click=node]) -
-
- Component init function - - -

Parameters:

-
    -
  • node - node[] - Array of gui node -
  • -
  • callback - function - Checkbox callback -
  • -
  • click - node[] - node Array of trigger nodes, by default equals to nodes - (default node) -
  • -
- - - - - -
-
- - set_state(indexes) -
-
- Set checkbox group state - - -

Parameters:

-
    -
  • indexes - bool[] - Array of checkbox state -
  • -
- - - - - -
-
- - get_state() -
-
- Return checkbox group state - - - -

Returns:

-
    - - bool[] - Array if checkboxes state -
- - - - -
-
-

Tables

- -
-
- - Events -
-
- Component events - - -

Fields:

-
    -
  • on_checkbox_click - druid_event - On any checkbox click -
  • -
- - - - - -
-
- - Fields -
-
- Component fields - - -

Fields:

-
    -
  • checkboxes - table - Array of checkbox components -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 -
-
- - diff --git a/docs/modules/druid.drag.html b/docs/modules/druid.drag.html deleted file mode 100644 index d71152b..0000000 --- a/docs/modules/druid.drag.html +++ /dev/null @@ -1,291 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module druid.drag

-

Component to handle drag action on node.

-

Drag have correct handling for multitouch and swap - touched while dragging. Drag will be processed even - the cursor is outside of node, if drag is already started

- - -

Functions

- - - - - - - - - -
init(node, on_drag_callback)Drag component constructor
set_click_zone(zone)Strict drag click area.
-

Tables

- - - - - - - - - - - - - -
EventsComponent events
FieldsComponents fields
StyleComponent style params.
- -
-
- - -

Functions

- -
-
- - init(node, on_drag_callback) -
-
- Drag component constructor - - -

Parameters:

-
    -
  • node - node - GUI node to detect dragging -
  • -
  • on_drag_callback - function - Callback for ondragevent(self, dx, dy) -
  • -
- - - - - -
-
- - set_click_zone(zone) -
-
- Strict drag click area. Useful for - restrict events outside stencil node - - -

Parameters:

-
    -
  • zone - node - Gui node -
  • -
- - - - - -
-
-

Tables

- -
-
- - Events -
-
- Component events - - -

Fields:

-
    -
  • on_touch_start - druid_event - (self) Event on touch start -
  • -
  • on_touch_end - druid_event - (self) Event on touch end -
  • -
  • on_drag_start - druid_event - (self) Event on drag start -
  • -
  • on_drag - druid_event - (self, dx, dy) Event on drag progress -
  • -
  • on_drag_end - druid_event - (self) Event on drag end -
  • -
- - - - - -
-
- - Fields -
-
- Components fields - - -

Fields:

-
    -
  • is_touch - bool - Is component now touching -
  • -
  • is_drag - bool - Is component now dragging -
  • -
  • can_x - bool - Is drag component process vertical dragging. Default - true -
  • -
  • can_y - bool - Is drag component process horizontal. Default - true -
  • -
  • x - number - Current touch x position -
  • -
  • y - number - Current touch y position -
  • -
  • touch_start_pos - vector3 - Touch start position -
  • -
- - - - - -
-
- - Style -
-
- Component style params. - You can override this component styles params in druid styles table - or create your own style - - -

Fields:

-
    -
  • DRAG_DEADZONE - number - Distance in pixels to start dragging - (default 10) -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 -
-
- - diff --git a/docs/modules/druid.grid.html b/docs/modules/druid.grid.html deleted file mode 100644 index 9982cc3..0000000 --- a/docs/modules/druid.grid.html +++ /dev/null @@ -1,381 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module druid.grid

-

Component to handle placing components by row and columns.

-

Grid can anchor your elements, get content size and other

- - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
init(parent, element[, in_row=1])Component init function
set_offset(offset)Set grid items offset, the distance between items
set_anchor(acnhor)Set grid anchor
add(item[, index])Add new item to the grid
get_size()Return grid content size
get_all_pos()Return array of all node positions
clear()Clear grid nodes array.
-

Tables

- - - - - - - - - -
EventsComponent events
FieldsComponent fields
- -
-
- - -

Functions

- -
-
- - init(parent, element[, in_row=1]) -
-
- Component init function - - -

Parameters:

-
    -
  • parent - node - The gui node parent, where items will be placed -
  • -
  • element - node - Element prefab. Need to get it size -
  • -
  • in_row - number - How many nodes in row can be placed - (default 1) -
  • -
- - - - - -
-
- - set_offset(offset) -
-
- Set grid items offset, the distance between items - - -

Parameters:

-
    -
  • offset - vector3 - Offset -
  • -
- - - - - -
-
- - set_anchor(acnhor) -
-
- Set grid anchor - - -

Parameters:

-
    -
  • acnhor - vector3 - Anchor -
  • -
- - - - - -
-
- - add(item[, index]) -
-
- Add new item to the grid - - -

Parameters:

-
    -
  • item - node - Gui node -
  • -
  • index - number - The item position. By default add as last item - (optional) -
  • -
- - - - - -
-
- - get_size() -
-
- Return grid content size - - - -

Returns:

-
    - - vector3 - The grid content size -
- - - - -
-
- - get_all_pos() -
-
- Return array of all node positions - - - -

Returns:

-
    - - vector3[] - All grid node positions -
- - - - -
-
- - clear() -
-
- Clear grid nodes array. GUI nodes will be not deleted! - If you want to delete GUI nodes, use grid.nodes array before grid:clear - - - - - - - -
-
-

Tables

- -
-
- - Events -
-
- Component events - - -

Fields:

-
    -
  • on_add_item - druid_event - On item add callback -
  • -
  • on_remove_item - druid_event - On item remove callback -
  • -
  • on_clear - druid_event - On grid clear callback -
  • -
  • on_update_positions - druid_event - On update item positions callback -
  • -
- - - - - -
-
- - Fields -
-
- Component fields - - -

Fields:

-
    -
  • parent - node - Parent gui node -
  • -
  • nodes - node[] - List of all grid nodes -
  • -
  • offset - vector3 - Item distance between each other items -
  • -
  • anchor - vector3 - Item anchor -
  • -
  • node_size - vector3 - Item size -
  • -
  • border - vector4 - The size of item content -
  • -
  • border_offer - vector3 - The border offset for correct anchor calculations -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-06-14 20:13:02 -
-
- - diff --git a/docs/modules/druid.helper.html b/docs/modules/druid.helper.html index 6986acf..f239731 100644 --- a/docs/modules/druid.helper.html +++ b/docs/modules/druid.helper.html @@ -38,40 +38,29 @@

Modules

-

Topics

- @@ -80,9 +69,7 @@

Module druid.helper

Text node or icon node can be nil

-

- -

+

Functions

@@ -325,7 +312,7 @@
generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 +Last updated 2020-10-12 00:44:30
diff --git a/docs/modules/druid.html b/docs/modules/druid.html index 85bca7f..ccca1a7 100644 --- a/docs/modules/druid.html +++ b/docs/modules/druid.html @@ -38,40 +38,29 @@

Modules

-

Topics

- @@ -81,23 +70,16 @@

Module druid

Druid UI Library.

- -

Powerful Defold component based UI library. Use standart + Powerful Defold component based UI library. Use standart components or make your own game-specific components to - make amazing GUI in your games.

- + make amazing GUI in your games.

Contains the several basic components and examples to how to do your custom complex components to - separate UI game logic to small files

- - -
-require("druid.druid")
-function init(self)
-    self.druid = druid.new(self)
-end
-
- + separate UI game logic to small files +

require("druid.druid") + function init(self) + self.druid = druid.new(self) + end

@@ -153,7 +135,7 @@
Register external druid component. After register you can create the component with - druidinstance:new{name}. For example druid:new_button(...) + druid_instance:new_{name}. For example `druid:new_button(...)`

Parameters:

@@ -233,7 +215,7 @@
Set text function Druid locale component will call this function - to get translated text. After settextfuntion + to get translated text. After set_text_funtion all existing locale component will be updated @@ -279,7 +261,7 @@
Callback on global window event. - Used to trigger onfocuslost and onfocusgain + Used to trigger on_focus_lost and on_focus_gain

Parameters:

@@ -331,7 +313,7 @@
generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 +Last updated 2020-10-12 00:44:30
diff --git a/docs/modules/druid.radio_group.html b/docs/modules/druid.radio_group.html deleted file mode 100644 index fe429d0..0000000 --- a/docs/modules/druid.radio_group.html +++ /dev/null @@ -1,251 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module druid.radio_group

-

Radio group module

-

- -

- - -

Functions

- - - - - - - - - - - - - -
init(node, callback[, click=node])Component init function
set_state(index)Set radio group state
get_state()Return radio group state
-

Tables

- - - - - - - - - -
EventsComponent events
FieldsComponent fields
- -
-
- - -

Functions

- -
-
- - init(node, callback[, click=node]) -
-
- Component init function - - -

Parameters:

-
    -
  • node - node[] - Array of gui node -
  • -
  • callback - function - Radio callback -
  • -
  • click - node[] - node Array of trigger nodes, by default equals to nodes - (default node) -
  • -
- - - - - -
-
- - set_state(index) -
-
- Set radio group state - - -

Parameters:

-
    -
  • index - number - Index in radio group -
  • -
- - - - - -
-
- - get_state() -
-
- Return radio group state - - - -

Returns:

-
    - - number - Index in radio group -
- - - - -
-
-

Tables

- -
-
- - Events -
-
- Component events - - -

Fields:

-
    -
  • on_radio_click - druid_event - On any checkbox click -
  • -
- - - - - -
-
- - Fields -
-
- Component fields - - -

Fields:

-
    -
  • checkboxes - table - Array of checkbox components -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 -
-
- - diff --git a/docs/modules/druid_instance.html b/docs/modules/druid_instance.html deleted file mode 100644 index c0865a3..0000000 --- a/docs/modules/druid_instance.html +++ /dev/null @@ -1,997 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module druid_instance

-

Instance of Druid.

-

Make one instance per gui_script with next code:

- - -
-local druid = require("druid.druid")
-function init(self)
-    self.druid = druid.new(self)
-    local button = self.druid:new_button(...)
-end
-
- -

Learn Druid instance function here

-

See also:

- - - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
druid:initialize(table, table)Druid class constructor
druid:create(component, ...)Create new druid component
druid:final()Call on final function on gui_script.
druid:remove(component)Remove component from druid instance.
druid:update(dt)Druid update function
druid:on_input(action_id, action)Druid on_input function
druid:on_message(message_id, message, sender)Druid on_message function
druid:on_focus_lost()Druid on focus lost interest function.
druid:on_focus_gained()Druid on focus gained interest function.
druid:on_layout_change()Druid on layout change function.
druid.on_language_change()Druid on language change.
druid:new_button(...)Create button basic component
druid:new_blocker(...)Create blocker basic component
druid:new_back_handler(...)Create back_handler basic component
druid:new_hover(...)Create hover basic component
druid:new_text(...)Create text basic component
druid:new_grid(...)Create grid basic component - Deprecated
druid:new_static_grid(...)Create static grid basic component
druid:new_scroll(...)Create scroll basic component
druid:new_swipe(...)Create swipe basic component
druid:new_drag(...)Create drag basic component
druid:new_dynamic_grid(...)Create dynamic grid component
druid:new_lang_text(...)Create lang_text component
druid:new_slider(...)Create slider component
druid:new_checkbox(...)Create checkbox component
druid:new_input(...)Create input component
druid:new_checkbox_group(...)Create checkbox_group component
druid:new_radio_group(...)Create radio_group component
druid:new_timer(...)Create timer component
druid:new_progress(...)Create progress component
- -
-
- - -

Functions

- -
-
- - druid:initialize(table, table) -
-
- Druid class constructor - - -

Parameters:

-
    -
  • table - style - Druid style module -
  • -
  • table - style - Druid style module -
  • -
- - - - - -
-
- - druid:create(component, ...) -
-
- Create new druid component - - -

Parameters:

-
    -
  • component - Component - Component module -
  • -
  • ... - args - Other component params to pass it to component:init function -
  • -
- - - - - -
-
- - druid:final() -
-
- Call on final function on guiscript. It will call onremove - on all druid components - - - - - - - -
-
- - druid:remove(component) -
-
- Remove component from druid instance. - Component on_remove function will be invoked, if exist. - - -

Parameters:

-
    -
  • component - Component - Component instance -
  • -
- - - - - -
-
- - druid:update(dt) -
-
- Druid update function - - -

Parameters:

-
    -
  • dt - number - Delta time -
  • -
- - - - - -
-
- - druid:on_input(action_id, action) -
-
- Druid on_input function - - -

Parameters:

-
    -
  • action_id - hash - Actionid from oninput -
  • -
  • action - table - Action from on_input -
  • -
- - - - - -
-
- - druid:on_message(message_id, message, sender) -
-
- Druid on_message function - - -

Parameters:

-
    -
  • message_id - hash - Messageid from onmessage -
  • -
  • message - table - Message from on_message -
  • -
  • sender - hash - Sender from on_message -
  • -
- - - - - -
-
- - druid:on_focus_lost() -
-
- Druid on focus lost interest function. - This one called by onwindowcallback by global window listener - - - - - - - -
-
- - druid:on_focus_gained() -
-
- Druid on focus gained interest function. - This one called by onwindowcallback by global window listener - - - - - - - -
-
- - druid:on_layout_change() -
-
- Druid on layout change function. - Called on update gui layout - - - - - - - -
-
- - druid.on_language_change() -
-
- Druid on language change. - This one called by global gruid.onlanguagechange, but can be - call manualy to update all translations - - - - - - - -
-
- - druid:new_button(...) -
-
- Create button basic component - - -

Parameters:

-
    -
  • ... - args - button init args -
  • -
- -

Returns:

-
    - - Component - button component -
- - - - -
-
- - druid:new_blocker(...) -
-
- Create blocker basic component - - -

Parameters:

-
    -
  • ... - args - blocker init args -
  • -
- -

Returns:

-
    - - Component - blocker component -
- - - - -
-
- - druid:new_back_handler(...) -
-
- Create back_handler basic component - - -

Parameters:

-
    -
  • ... - args - back_handler init args -
  • -
- -

Returns:

-
    - - Component - back_handler component -
- - - - -
-
- - druid:new_hover(...) -
-
- Create hover basic component - - -

Parameters:

-
    -
  • ... - args - hover init args -
  • -
- -

Returns:

-
    - - Component - hover component -
- - - - -
-
- - druid:new_text(...) -
-
- Create text basic component - - -

Parameters:

-
    -
  • ... - args - text init args -
  • -
- -

Returns:

-
    - - Component - text component -
- - - - -
-
- - druid:new_grid(...) -
-
- Create grid basic component - Deprecated - - -

Parameters:

-
    -
  • ... - args - grid init args -
  • -
- -

Returns:

-
    - - Component - grid component -
- - - - -
-
- - druid:new_static_grid(...) -
-
- Create static grid basic component - - -

Parameters:

-
    -
  • ... - args - grid init args -
  • -
- -

Returns:

-
    - - Component - grid component -
- - - - -
-
- - druid:new_scroll(...) -
-
- Create scroll basic component - - -

Parameters:

-
    -
  • ... - args - scroll init args -
  • -
- -

Returns:

-
    - - Component - scroll component -
- - - - -
-
- - druid:new_swipe(...) -
-
- Create swipe basic component - - -

Parameters:

-
    -
  • ... - args - swipe init args -
  • -
- -

Returns:

-
    - - Component - swipe component -
- - - - -
-
- - druid:new_drag(...) -
-
- Create drag basic component - - -

Parameters:

-
    -
  • ... - args - drag init args -
  • -
- -

Returns:

-
    - - Componetn - drag component -
- - - - -
-
- - druid:new_dynamic_grid(...) -
-
- Create dynamic grid component - - -

Parameters:

-
    -
  • ... - args - grid init args -
  • -
- -

Returns:

-
    - - Component - grid component -
- - - - -
-
- - druid:new_lang_text(...) -
-
- Create lang_text component - - -

Parameters:

-
    -
  • ... - args - lang_text init args -
  • -
- -

Returns:

-
    - - Component - lang_text component -
- - - - -
-
- - druid:new_slider(...) -
-
- Create slider component - - -

Parameters:

-
    -
  • ... - args - slider init args -
  • -
- -

Returns:

-
    - - Component - slider component -
- - - - -
-
- - druid:new_checkbox(...) -
-
- Create checkbox component - - -

Parameters:

-
    -
  • ... - args - checkbox init args -
  • -
- -

Returns:

-
    - - Component - checkbox component -
- - - - -
-
- - druid:new_input(...) -
-
- Create input component - - -

Parameters:

-
    -
  • ... - args - input init args -
  • -
- -

Returns:

-
    - - Component - input component -
- - - - -
-
- - druid:new_checkbox_group(...) -
-
- Create checkbox_group component - - -

Parameters:

-
    -
  • ... - args - checkbox_group init args -
  • -
- -

Returns:

-
    - - Component - checkbox_group component -
- - - - -
-
- - druid:new_radio_group(...) -
-
- Create radio_group component - - -

Parameters:

-
    -
  • ... - args - radio_group init args -
  • -
- -

Returns:

-
    - - Component - radio_group component -
- - - - -
-
- - druid:new_timer(...) -
-
- Create timer component - - -

Parameters:

-
    -
  • ... - args - timer init args -
  • -
- -

Returns:

-
    - - Component - timer component -
- - - - -
-
- - druid:new_progress(...) -
-
- Create progress component - - -

Parameters:

-
    -
  • ... - args - progress init args -
  • -
- -

Returns:

-
    - - Component - progress component -
- - - - -
-
- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 -
-
- - diff --git a/docs/topics/01-components.md.html b/docs/topics/01-components.md.html deleted file mode 100644 index e470172..0000000 --- a/docs/topics/01-components.md.html +++ /dev/null @@ -1,513 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- - - - -

Druid components

- - -

-

Button

-

Button API here

- -

Overview

-

Basic Druid input component. Handle input on node and provide different callbacks on touch events.

- -

Setup

-

Create button with druid: button = druid:new_button(node_name, callback, [params], [animation_node]) -Where node name is name of node from GUI scene. You can use node_name as input trigger zone and point another node for animation via animation_node

- -

Usecase

-

fill example usecases

- -

Notes

-

- Button callback have next params: (self, params, button_instance)

- -
-- **self** - Druid self context
-- **params** - Additional params, specified on button creating
-- **button_instance** - button itself
-
- -

- You can set params on button callback on button creating: druid:new_button("node_name", callback, params). This params will pass in callback as second argument -- Button have next events:

- -
-- **on_click** - basic button callback
-- **on_repeated_click** - repeated click callback, while holding the button, don't trigger if callback is empty
-- **on_long_click** - callback on long button tap, don't trigger if callback is empty
-- **on_hold_click** - hold callback, before long_click trigger, don't trigger if callback is empty
-- **on_double_click** - different callback, if tap button 2+ in row, don't trigger if callback is empty
-
- -

- Click event will not trigger, if between pressed and released state cursor was outside of node zone -- If button have double click event and it is triggered, usual callback will be not invoked -- If you have stencil on buttons and you don't want trigger them outside of stencil node, you can use button:set_click_zone to restrict button click zone -- Button can have key trigger to use then by key: button:set_key_trigger -- Animation node can be used for example to animate small icon on big panel. Node name of trigger zone will be big panel and animation node will be small icon

- - -

-

Text

-

Text API here

- -

Overview

-

Basic Druid text component. Text components by default have the text size adjusting.

- -

Setup

-

Create text node with druid: text = druid:new_text(node_name, [initial_value], [is_disable_size_adjust])

- -

Notes

-

- Text component by default have auto adjust text sizing. Text never will be bigger, than text node size, which you can setup in GUI scene. It can be disabled on component creating by settings argument is_no_adjust to true

- -

- -
    -
  • Text pivot can be changed with text:set_pivot, and text will save their position inside their text size box:
  • -
- -

- - -

-

Blocker

-

Blocker API here

- -

Overview

-

Druid component for block input. Use it to block input in special zone.

- -

Setup

-

Create blocker component with druid: druid:new_blocker(node_name)

- -

Notes

-

Explanation: -

- -

Blue zone is button with close_window callback

- -

Yellow zone is blocker with window content

- -

So you can do the safe zones, when you have the big buttons

- - -

-

Back Handler

-

Back handler API here

- -

Overview

-

Component to handle back button. It handle Android back button and Backspace key. Key triggers in input.binding should be setup for correct working.

- -

Setup

-

Setup callback with druid:new_back_handler(callback)

- -

Notes

- - -

-

Lang text

-

Lang text API here

- -

Overview

-

Wrap on Text component to handle localization. It uses druid gettextfunction to set text by it's id

- -

Setup

-

Create lang text component with druid text = druid:new_lang_text(node_name, locale_id)

- -

Notes

- - -

-

Scroll

-

Scroll API here

- -

Overview

-

Basic Druid scroll component. Handle all scrolling stuff in druid GUI

- -

Setup

-

Create scroll component with druid: scroll = druid:new_scroll(view_node, content_node).

- -

Viewnode_ - is static part. It capturing user input and recognize scrolling touches

- -

Contentnode_ - is dynamic part. This node will change position by scroll system

- -

Initial scroll size will be equal to contentnode_ node size. The initial view box will be equal to viewnode_ node size

- -

Usually, Place viewnode_ and as children add contentnode_: - -

- -

*Here contentnode below viewnode, in game content_node be able to scroll left until end*

- -

Notes

-

- Scroll by default style have inertion and extra size for strecthing effect. It can be adjust via scroll style settings -- You can setup "points of interest". Scroll always will be centered on closes point of interest. It is able to create slider without inertion and points of interest on each scroll element. -- Scroll have next events:

- -
-- *on_scroll* (self, position) On scroll move callback
-- *on_scroll_to* (self, position, is_instant) On scroll_to function callback
-- *on_point_scroll* (self, item_index, position) On scroll_to_index function callback
-
- -

- You can adjust scroll content size by scroll:set_size(node_size). It will setup new size to content node -- You can enabled or disable inertion mode via scroll:set_intert(state) -- You can adjust extra stretch size via scroll:set_extra_stretch_size -- Multitouch is required for scroll. Scroll is correctly handling touch_id swap while dragging scroll

- - -

-

Progress

-

Progress API here

- -

Overview

-

Basic Druid progress bar component

- -

Setup

-

Create progress bar component with druid: progress = druid:new_progress(node_name, key, init_value)

- -

Node name should have maximum node size, so in GUI scene, node_name should be fully filled. -Key is value from druid const: const.SIDE.X (or just "x") or const.SIDE.Y (or just "y")

- -

Notes

-

- Progress correct working with 9slice nodes, it trying to set size by setsize_ first, if it is not possible, it set up sizing via setscale_ -- Progress bar can fill only by vertical or horizontal size. If you want make diagonal progress bar, just rotate node in GUI scene -- If you have glitchy or dark texture bug with progress bar, try to disable mipmaps in your texture profiles

- - -

-

Slider

-

Slider API here

- -

Overview

-

Basic Druid slider component

- -

Setup

-

Create slider component with druid: slider = druid:new_slider(node_name, end_pos, callback)

- -

Pin node (node_name in params) should be placed in zero position (initial). It will be available to mode Pin node between start pos and end pos.

- -

Notes

-

- You can setup points of interests on slider via slider:set_steps. If steps are exist, slider values will be only from this steps (notched slider) -- For now, start pos and end pos should be on vertical or horizontal line (their x or y value should be equal)

- - -

-

Input

-

Input API here

- -

Overview

-

Basic Druid text input component

- -

Setup

-

Create input component with druid: input = druid:new_input(button_node_name, text_node_name, keyboard_type)

- -

Notes

-

- Input component handle user text input. Input contains from button and text components. Button needed for selecting/unselecting input field -- Long click on input field for clear and select input field (clearing can be disable via styles) -- Click outside of button to unselect input field -- On focus lost (game minimized) input field will be unselected -- You can setup max length of the text -- You can setup allowed characters. On add not allowed characters on_input_wrong will be called. By default it cause simple shake animation -- The keyboard for input will not show on mobile HTML5. So input field in mobile HTML5 is not working now -- To make work different keyboard type, make sure value in game.project Android:InputMethod set to HidderInputField (https://defold.com/manuals/project-settings/#input-method)

- - -

-

Checkbox

-

Checkbox API here

- -

Overview

-

Basic Druid checkbox component.

- -

Setup

-

Create checkbox component with druid: checkbox = druid:new_checkbox(node, callback)

- -

Notes

-

- Checkbox uses button to handle click -- You can setup another node to handle input with click_node arg in component init: druid:new_checkbox(node, callback, [click_node])

- - -

-

Checkbox group

-

Checkbox group API here

- -

Overview

-

Several checkboxes in one group

- -

Setup

-

Create checkbox_group component with druid: group = druid:new_checkbox_group(nodes[], callback)

- -

Notes

-

- Callback arguments: function(self, checkbox_index). Index is equals in nodes[] array in component constructor -- You can get/set checkbox_group state with group:set_state() and group:get_state()

- - -

-

Radio group

-

Radio group API here

- -

Overview

-

Several checkboxes in one group with single choice

- -

Setup

-

Create radio_group component with druid: group = druid:new_radio_group(nodes[], callback)

- -

Notes

-

- Callback arguments: function(self, checkbox_index). Index is equals in nodes[] array in component constructor -- You can get/set radio_group state with group:set_state() and group:get_state() -- Only different from checkbox_group: on click another checkboxes in this group will be unchecked

- - -

-

Timer

-

Timer API here

- -

Overview

-

Handle timer work on gui text node

- -

Setup

-

Create timer component with druid: timer = druid:new_timer(text_node, from_seconds, to_seconds, callback)

- -

Notes

-

- Timer fires callback, when timer value equals to toseconds_ -- Timer will setup text node with current timer value -- Timer uses update function to handle time

- - -

-

Static Grid

-

Static Grid API here

- -

Overview

-

Component for manage node positions. -Static grid have constant node size, so it possible to calculate node positions before placement. Nodes can be placed with gaps. -Static grid can shift elements on add/remove functions.

- -

Setup

-

Create component with druid: grid = druid:new_static_grid(parent_node, prefab_node, max_in_row_elements)

- -

Notes

-

- On add node grid will set node parent to parentnode_ -- You can get array of position of every element for setup points of interest in scroll component -- You can get size of all elements for setup size in scroll component -- You can also bind the grid to the scroll component for auto resize scroll content size -- Pivot of parent_node matter for node placement -- Prefab node used to get node size and anchor -- You can point *position_function* for animations with staticgrid:setpositionfunction(node, pos)_ callback. Default - *gui.set_position()*

- - -

-

Dynamic Grid

-

Dynamic Grid API here

- -

Overview

-

Component for manage node positions with different node sizes. -Unlike Static Grid, Dynamic Grid can place nodes only in one row or in one column. -Dynamic Grid can't have gaps between elements - you will get error, if try spawn element far away from others. -Dynamic Grid should have West, East, South or North pivot (vertical or horizontal element placement)

- -

Setup

-

Create component with druid: grid = druid:new_dynamic_grid(parent_node)

- -

Check the parentnode_ have correct pivot point. You will get the error otherwise.

- -

Notes

-

- On add node grid will set node parent to parentnode_ -- You can get array of position of every element for setup points of interest in scroll component -- You can get size of all elements for setup size in scroll component -- You can also bind the grid to the scroll component for auto resize scroll content size -- Pivot of parentnode matter for node placement -- You can point *positionfunction* for animations with staticgrid:setpositionfunction(node, pos)_ callback. Default - *gui.set_position()* -- First node placed at Grid pivot point. Other nodes placed nearby of other nodes. -- On add/remove nodes always shifted. You can point the shift side in this functions (*isshiftleft* boolean argument)

- -

-

Hover

-

Hover API here

- -

Overview

-

System Druid component, handle hover node state.

- -

Setup

-

Create hover component with druid: hover = druid:new_hover(node, callback)

- -

Notes

-

- By default, hover handles hover event with pressed touch action_id. So it's mean, what mouse or touch have to be pressed -- On desktop platforms there is onmousehover event. It's event on mouse hover without any action id -- By default, assume what node is on not hovered state (both hover and mousehover_)

- - -

-

Swipe

-

Swipe API here

- -

Overview

-

System Druid component, handle swipe actions on node

- -

Setup

-

Create swipe component with druid: hover = druid:new_swipe(node, swipe_callback)

- -

Notes

-

- Swipe callback have next params: (self, swipe_side, distance, time)

- -
-- **self** - Druid self context
-- **swipe_side**: *string* - values from ["up", "down", "left", "right"]
-- **distance**: *number* - in pixels, distance of swipe
-- **time**: *number* - in seconds, time of swiping
-
- -

- Swipe trigger only, if all input actions was on swipe node. If action will be outside of node, swipe status will be reseted -- In swipe style table you can adjust minimal distance and maximum time to trigg- Hover state trigger only with touch on mobile devices or button mouse holding. Just mouse over swipe -- In swipe style table you can toggle type of swipe triggering. if SWIPETRIGGERON_MOVE setup to true - swipe will trigger as swipe can be triggered. If setup to false - swipe will trigger only on released action -- If you have stencil on swipe node and you don't want trigger it outside of stencil node, you can use swipe:set_click_zone to restrict swipe zonethout buttons is now not allowed.

- - -

-

Drag

-

Drag API here

- -

Overview

-

System Druid component, handle drag actions on node

- -

Setup

-

Create drag component with druid: hover = druid:new_drag(node, drag_callback)

- -

Notes

-

- Drag callback have next params: (self, swipe_side, distance, time)

- -
-- **self**: Druid self context
-- **dx**: *number* - delta x position
-- **dy**: *number* - delta y position
-
- -

- In styles, you can point the drag start deadzone. Default value is 10 pixels -- Drag correctly process multitouch. You can switch touch_id, while dragging on node with correct dx and dy values (made for correct scrolling) -- You can restrict horizontal or vertical dragging by setting drag.can_x or drag.can_y to false value -- You can get info about current drag state:

- -
-- _is_touch_ - Is currently node touching
-- _is_drag_ - Is currently node is dragging
-- _x_ and _y_ - Current touch position
-- _touch_start_pos_ - Touch stat positions
-
- -

- Drag have next events:

- -
-- _on_touch_start_ (self) - Event on touch start
-- _on_touch_end_ (self) - Event on touch end
-- _on_drag_start_ (self) - Event on drag start
-- _on_drag_ (self, dx, dy) - Event on drag process
-- _on_drag_end_ (self) - Event on drag end
-
- -

- Drag node zone can be restricted via drag:set_click_zone(node)

- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 -
-
- - diff --git a/docs/topics/02-creating_custom_components.md.html b/docs/topics/02-creating_custom_components.md.html deleted file mode 100644 index 48f3bd6..0000000 --- a/docs/topics/02-creating_custom_components.md.html +++ /dev/null @@ -1,254 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- - -

Creating custom components

- -

-

Overview

- -

Druid allows you to create your custom components from druid basic components or other custom components.

- -

Every component is the children of Basic Druid component. Read the [basic component API here].(https://insality.github.io/druid/modules/component.html), Methods of basic components you can call via self:{method_name}

- - -

-

Custom components

- -

Basic custom component template looks like this:

- -
-local const = require("druid.const")
-local component = require("druid.component")
-
-local M = component.create("my_component")
-
--- Component constructor
-function M.init(self, ...)
-end
-
--- Call only if exist interest: const.ON_UPDATE
-function M.update(self, dt)
-end
-
--- Call only if exist interest: const.ON_INPUT or const.ON_INPUT_HIGH
-function M.on_input(self, action_id, action)
-end
-
--- Call on component creation and on component:set_style() function
-function M.on_style_change(self, style)
-end
-
--- Call only if exist interest: const.ON_MESSAGE
-function M.on_message(self, message_id, message, sender)
-end
-
--- Call only if component with ON_ANGUAGECHANinterest
-function M.on_anguagechanself)
-end
-
--- Call only if component with ON_LAYOUT_CHANGE interest
-function M.on_layout_change(self)
-end
-
--- Call, if input was capturing before this component
--- Example: scroll is start scrolling, so you need unhover button
-function M.on_input_interrupt(self)
-end
-
--- Call, if game lost focus. Need ON_FOCUS_LOST intereset
-function M.on_focus_lost(self)
-end
-
--- Call, if game gained focus. Need ON_FOCUS_GAINED intereset
-function M.on_focus_gained(self)
-end
-
--- Call on component remove or on druid:final
-function M.on_remove(self)
-end
-
-return M
-
- - - -

Add your custom component to druid via druid.register

- -
-local druid = require("druid.druid")
-local my_component = require("my.amazing.component")
-
-function init(self)
-    druid.register("my_component", my_component)
-end
-
- - -

Registering make new function with "new{componentname}". In our example it will be: druid:new_my_component().

- -

Or you can create component without registering with druid:create(my_component_module)

- -

As component registered, you can create your component with next code:

- -
-local druid = require("druid.druid")
-local my_component = require("my.amazing.component")
-
-function init(self)
-    self.druid = druid.new(self)
-
-    local my_component = self.druid:new_my_component(...)
-    -- or --
- local my_component = self.druid:create(my_component, ...)
-end
-
- - -

Interest

-

Interest - is a way to indicate what events your component will respond to. -There is next interests in druid: -- ON_MESSAGE - component will receive messages from on_message

- -
    -
  • ON_UPDATE - component will be updated from update

  • -
  • ONINPUTHIGH - component will receive input from oninput, before other components with ONINPUT

  • -
  • ON_INPUT - component will receive input from oninput, after other components with ONINPUT_HIGH

  • -
  • ONLANGUAGECHANGE - will call onlanguagechange function on language change trigger

  • -
  • ONLAYOUTCHANGE will call onlayoutchange function on layout change trigger

  • -
  • ONFOCUSLOST will call onfocustlost function in on focus lost event. You need to pass window_callback to global druid:on_window_callback

  • -
  • ONFOCUSGAINED will call onfocustgained function in on focus gained event. You need to pass window_callback to global druid:on_window_callback

  • -
- -

-

Best practice on custom components

-

On each component recommended describe component scheme in next way:

- - -
--- Component module
-local component = require("druid.component")
-
-local M = component.create("your_component")
-
-local SCHEME = {
-    ROOT = "root",
-    ITEM = "item",
-    TITLE = "title"
-}
-
-function M.init(self, template_name, node_table)
-    -- If component use template, setup it:
- self:set_template(template_name)
-
-    -- If component was cloned with gui.clone_tree, pass his nodes
- self:set_nodes(node_table)
-
-    -- helper can get node from gui/template/table
- local root = self:get_node(SCHEME.ROOT)
-
-    -- This component can spawn another druid components:
- local druid = self:get_druid()
-
-    -- Button self on callback is self of _this_ component
- local button = druid:new_button(...)
-end
-
- - - -

-

Power of using templates

- -

You can use one component, but creating and customizing templates for them. Templates only requires to match the component scheme.

- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 -
-
- - diff --git a/docs/topics/03-styles.md.html b/docs/topics/03-styles.md.html deleted file mode 100644 index b4d8cf0..0000000 --- a/docs/topics/03-styles.md.html +++ /dev/null @@ -1,164 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- - -

Styles

- -

-

Overview

-

Styles - set of functions and parameters for components to customize their behavior.

- -

Styles is a table, where key is name of component, and value is style table for this component.

- -

In component API documentation, you can find the style API for this component. Or just lookup for existing styles and modify them.

- -

-

Usage

-

Setup default druid style for all druid instances via druid.set_default_style -You can pass nil or emptytable_ to use default values for all components (no styles)

- -
-local druid = require("druid.druid")
-local my_style = require("my.amazing.style")
-
-local function init(self)
-    druid.set_default_style(my_style)
-end
-
- - -

Setup custom style to specific druid instance:

- -
-local druid = require("druid.druid")
-local my_style = require("my.amazing.style")
-
-local function init(self)
-    -- This druid instance will be use my_style as default
- self.druid = druid.new(self, my_style)
-end
-
- - -

Change component style with setstyle_ function

- -
-local druid = require("druid.druid")
-local my_style = require("my.amazing.style")
-
-local function init(self)
-    self.druid = druid.new(self)
-    self.button = self.druid:new_button(self, "node")
-    -- Setup custom style for specific component
- self.button:set_style(my_style)
-end
-
- - - -

-

Create your own styles

- -

The most components have their styles. You can explore it on Druid API in table style section (button example). Or you can see, what fields component uses in code in function on_style_change

- -

To create you style, create lua module, what return <componentname_, componentstyle_> table

- -

Example: default druid style

- -

Override all fields you want and set your style with one of next ways:

- -
    -
  • Set your style as global via druid.set_default_style
  • -
  • Set style for concrete druid instance via druid = druid.new(self, style)
  • -
  • Set style for concrete instance via component:set_style(style)
  • -
- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 -
-
- - diff --git a/docs/topics/04-druid_assets.md.html b/docs/topics/04-druid_assets.md.html deleted file mode 100644 index 8270e0e..0000000 --- a/docs/topics/04-druid_assets.md.html +++ /dev/null @@ -1,101 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- - -

Druid assets

- -

-

Overview

-

I've created druid-assets repository to make a marketplace with custom styles and components.

- -

Any of Druid users can push their own components and styles to share it with the other users

- -

Also, this marketplace is great example to how you can create your custom components

- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 -
-
- - diff --git a/docs/topics/05-examples.md.html b/docs/topics/05-examples.md.html deleted file mode 100644 index 140bf25..0000000 --- a/docs/topics/05-examples.md.html +++ /dev/null @@ -1,99 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- - -

Examples

- -

-

Overview

-

See the example folder for examples of how to use Druid

- -

Try the HTML5 version of the example app

- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 -
-
- - diff --git a/docs/topics/README.md.html b/docs/topics/README.md.html deleted file mode 100644 index 7c0a416..0000000 --- a/docs/topics/README.md.html +++ /dev/null @@ -1,358 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

- -

GitHub release (latest by date)

- -

Druid - powerful Defold component UI library. Use basic and extended Druid components or make your own game-specific components to make amazing GUI in your games.

- - -

-

Setup

- -

Dependency

- -

You can use the Druid extension in your own project by adding this project as a Defold library dependency. Open your game.project file and in the dependencies field under project add:

- -
-

https://github.com/Insality/druid/archive/master.zip

-
- -

Or point to the ZIP file of a specific release.

- -

Input bindings

- -

For Druid to work requires next input bindings:

- -
    -
  • Mouse trigger - Button 1 -> touch For basic input components
  • -
  • Key trigger - Backspace -> key_backspace For backhandler component, input component_
  • -
  • Key trigger - Back -> key_back For backhandler component, Android back button, input component_
  • -
  • Key trigger - Enter -> key_enter For input component, optional
  • -
  • Key trigger - Esc -> key_esc For input component, optional
  • -
  • Touch triggers - Touch multi -> multitouch For scroll component
  • -
- -

-

- - -

Input capturing [optional]

- -

By default, Druid will auto-capture input focus, if any input component will be created. So you don't need to call msg.post(".", "acquire_input_focus")

- -

If you not need this behaviour, you can disable it by settings druid.no_auto_input field in game.project:

-
 [druid]
- no_auto_input = 1
-
- - -

Code [optional]

- -

Adjust Druid settings, if needed:

- -
-local druid = require("druid.druid")
-
--- Used for button component and custom components
--- Callback should play sound by name
-druid.set_sound_function(callback)
-
--- Used for lang_text component
--- Callback should return localized string by locale id
-druid.set_text_function(callback)
-
--- Used for change default druid style
-druid.set_default_style(your_style)
-
--- Call this function on language changing in the game,
--- to retranslate all lang_text components:
-druid.on_language_change()
-
--- Call this function inside window.set_listener
--- to catch game focus lost/gained callbacks:
-druid.on_window_callback(event)
-
- - - -

-

Components

- -

Druid provides next basic components:

- -
    -
  • Button - Basic Druid button input component. Handles all types of interaction (tap, long-tap, hold-tap, double-tap, simple key triggers, etc)

  • -
  • Text - Basic Druid text component. Wrap on gui text node, handle text size adjusting.

  • -
  • Scroll - Basic Druid scroll component

  • -
  • Blocker - Block input in node zone component

  • -
  • Back Handler - Handle back button (Android back button, backspace key)

  • -
  • Static Grid - Component for manage node positions with equal sizes

  • -
  • Hover - System Druid component, handle hover node state

  • -
  • Swipe - System Druid component, handle swipe gestures on node

  • -
  • Drag - System Druid component, handle drag input on node

  • -
- -

Druid also provides next extended components:

- -

*Note: In future, to use extended components, you should register them first. It's required for make Druid modular - to exclude unused components from build*

- -
    -
  • Checkbox - Checkbox component

  • -
  • Checkbox group - Several checkboxes in one group

  • -
  • Dynamic Grid - Component for manage node positions with different sizes. Only in one row or column

  • -
  • Input - User text input component

  • -
  • Lang text - Wrap on Text component to handle localization

  • -
  • Progress - Progress bar component

  • -
  • Radio group - Several checkboxes in one group with single choice

  • -
  • Slider - Slider component

  • -
  • Timer - Handle timer work on gui text node

  • -
- -

Full info see on components.md

- - -

-

Basic usage

- -

For using Druid, first you should create Druid instance to spawn components. Pass to new Druid instance main engine functions: update, *onmessage* and *oninput*

- -

All Druid components as arguments can apply node name string, you can don't do gui.get_node() before

- -

All Druid and component methods calling with : like self.druid:new_button()

- - -
-local druid = require("druid.druid")
-
-local function button_callback(self)
-    print("Button was clicked!")
-end
-
-function init(self)
-    self.druid = druid.new(self)
-    self.druid:new_button("button_node_name", button_callback)
-end
-
-function final(self)
-    self.druid:final()
-end
-
-function on_input(self, action_id, action)
-    return self.druid:on_input(action_id, action)
-end
-
- - -

Learn Druid instance functions here)

- -

-

Druid Events

- -

Any Druid components as callbacks uses Druid Events. In component API (button example) pointed list of component events. You can manually subscribe on this events by next API:

- -
    -
  • event:subscribe(callback)

  • -
  • event:unsubscribe(callback)

  • -
  • event:clear()

  • -
- -

You can subscribe several callbacks on single event.

- -

-

Druid Lifecycle

- -

Here is full Druid lifecycle setup in your *.gui_script file:

- -
-local druid = require("druid.druid")
-
-function init(self)
-    self.druid = druid.new(self)
-end
-
-function final(self)
-    self.druid:final()
-end
-
-function update(self, dt)
-    self.druid:update(dt)
-end
-
-function on_input(self, action_id, action)
-    return self.druid:on_input(action_id, action)
-end
-
-function on_message(self, message_id, message, sender)
-    self.druid:on_message(message_id, message, sender)
-end
-
- - -
    -
  • final required function for correct Druid lifecycle
  • -
  • *on_input* used for almost all Druid components
  • -
  • update used for progress bar, scroll and timer base components
  • -
  • *on_message* used for specific Druid events, like language change or layout change
  • -
- -

Recommended is fully integrate all Druid lifecycles functions

- - -

-

Details

- -
    -
  • Druid input goes as stack. Last created button will checked first. So create your GUI from back
  • -
  • Don't forget about return in on_input: return self.druid:on_input(). It need, if you have more than 1 acquire inputs (several Druid, other input system, etc)
  • -
  • Druid by default do acquireinputfocus. So you don't need do it manually. Buy only if you have components, which requires oninput_
  • -
  • If you want to delete node with declared Druid component, don't forget to remove them via druid:remove(component)
  • -
- -

See full See FAQ here

- - -

-

Examples

- -

See the example folder for examples of how to use Druid

- -

See the druid-assets repository for examples of how to create custom components and styles

- -

Try the HTML5 version of the example app

- - -

-

Documentation

- -

To learn Druid better, read next documentation: -- Druid components -- Create custom components -- See FAQ article -- Druid styles -- Druid asset store

- -

Full Druid documentation you can find here: -https://insality.github.io/druid/

- - -

-

Games powered by Druid

- -

You published your game and you using Druid? Note me!

- - -

-

License

- - - -

MIT License

- - -

-

Issues and suggestions

- -

If you have any issues, questions or suggestions please create an issue or contact me: insality@gmail.com - -

-
-
-generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 -
-
- - diff --git a/docs/topics/changelog.md.html b/docs/topics/changelog.md.html deleted file mode 100644 index ac002f0..0000000 --- a/docs/topics/changelog.md.html +++ /dev/null @@ -1,252 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- - -

Druid 0.3.0:

- -
    -
  • Druid:final() now is important function for correct working

  • -
  • Add swipe basic component

    - -
    -- Swipe component handle simple swipe gestures on node. It has single callback with direction on swipe. You can adjust a several parameters of swipe in druid style.
    -- Swipe can be triggered on action.released or while user is make swiping (in process)
    -- Add swipe example at main Druid example. Try swipe left/right to switch example pages.
    -
    -
  • -
  • Add input basic component

    - -
    -- Input component handle user text input. Input contains from button and text components. Button needed for selecting/unselecting input field
    -- Long click on input field for clear and select input field (clearing can be disable via styles)
    -- Click outside of button to unselect input field
    -- On focus lost (game minimized) input field will be unselected
    -- You can setup max length of the text
    -- You can setup allowed characters. On add not allowed characters on_input_wrong will be called. By default it cause simple shake animation
    -- The keyboard for input will not show on mobile HTML5. So input field in mobile HTML5 is not working now
    -- To make work different keyboard type, make sure value in game.project Android:InputMethod set to HiddenInputField (https://defold.com/manuals/project-settings/#input-method)
    -
    -
  • -
  • Add two functions to basic component: increase_input_priority and reset_input_priority. It used to process component input first in current input stack (there is two input stacks now: INPUT and INPUT_HIGH). Example: on selecting input field, it increase input self priority until it be unselected

  • -
  • Add two new component interests: on_focus_gain and on_focus_lost

  • -
  • Add global druid events:

    - -
    -- on_window_callback: call druid.on_window_callback(event) for on_focus_gain/lost correct work
    -- on_language_change: call druid.on_language_change() (#38) for update all druid instances lang components
    -- on_layout_change: call druid.on_layout_change() (#37) for update all gui layouts (unimplemented now)
    -
    -
  • -
  • Add button on_click_outside event. You can subscribe on this event in button. Was needed for Input component (click outside to deselect input field)

  • -
  • Add startpos_ field to button component

  • -
  • Changed input binding settings. Add esc, enter, text and marked_text. Backspace now is different from android back button event. Check the README setup section

  • -
  • Renamed onchangelanguage -> onlanguagechange component interest

  • -
  • Add several examples to druid-assets respository (see live example here): https://insality.github.io/druid-assets/)

  • -
  • Known issues:

    - -
    -- Adjusting text size by height works wrong. Adjusting single line texting works fine
    -- Space is not working in HTML5
    -
    - -

    Druid 0.4.0:

  • -
  • Add Drag basic component

    - -
    -- Drag component allow you detect dragging on GUI node
    -- Drag will be processed even the cursor is outside of node, if drag is already started
    -- Drag provides correct handle of several touches. Drag can switch between them (no more scroll gliches with position)
    -- Drag have next events:
    -    - on_touch_start (self)
    -    - on_touch_end (self)
    -    - on_drag_start (self)
    -    - on_drag (self, dx, dy)
    -    - on_drag_end (self)
    -- You can restriction side of dragging by changing _drag.can_x_ and _drag.can_y_ fields
    -- You can setup drag deadzone to detect, when dragging is started (_by default 10 pixels_)
    -
    -
  • -
  • [Breaking changes] Druid Scroll component fully reworked. Input logic moved to Drag component

    - -
    -- Update scroll documentation
    -- Change constructor order params
    -- Change _scroll:set_border_ to _scroll:set_size_
    -- Scroll now contains from view and content node
    -    - _View node_ - static node, which size determine the "camera" zone
    -    - _Content node_ - dynamic node, moving by _Scroll_ component
    -- Scroll will be disabled only if content size equals to view size (by width or height separatly)
    -- You can adjust start scroll size via _.gui_ scene. Just setup correct node size
    -- Different anchoring is supported (for easier layouting)
    -- Function _scroll_to_ now accept position relative to _content node_. It's more easier for handling. _Example:_ if you have children node of _content_node_, you can pass this node position to scroll to this.
    -- **Resolve #52**: _Content node size_ now can be less than _view node size_. In this case, content will be scrolled only inside _view size_ (can be disabled via style field: _SMALL_CONTENT_SCROLL_)
    -- **Fix #50**: If style.SOFT_ZONE_SIZE equals to [0..1], scroll can be disappeared
    -
    -
  • -
  • Druid Grid Update

    - -
    -- Anchor by default equals to node pivot (so, more component settings in _.gui_ settings) (#51)
    -- Function grid:clear now don't delete any GUI nodes. Druid will not care about gui.delete_node logic anymore (#56)
    -
    -
  • -
  • Druid Hover component now have two hover events (#49):

    - -
    -- _on_hover_ is usual hover event. Trigger only if touch or mouse action_id pressed on node
    -- _on_mouse_hover_ action on node without action_id (desktop mouse over). Works only on desktop platform
    -
    -
  • -
  • Styles update:

    - -
    -- Styles table now can be empty, every component have their default style values
    -- Remove component:get_style function. Now you can only set styles
    -- To get style values in component, add component:on_style_change function. It's invoked on component:set_style function
    -- You can look up default values inside component:on_style_change function or style component API on [Druid API](https://insality.github.io/druid/index.html)
    -
    -
  • -
  • Druid update:

    - -
    -- Now function druid:remove remove instance and all instance children components. No more manual deleting child components (#41)
    -
    -
  • -
  • Fix: Blocker component bug (blocker had very high priority, so it's block even button components, created after blocker)

  • -
  • Fix #58: Bug, when druid instance should be always named druid (ex: self.druid = druid.new(self))

  • -
  • Fix #53: Bug with final Druid instance without any components

  • -
- - -

Druid 0.5.0:

- -

Besides a lot of fixes (thanks for feedback!) two components was add: StaticGrid and DynamicGrid instead of usual Grid component (it is deprecated now). -Add component:setinputenabled for basic component class. So you can enable/disable user input for any component. -Finaly implemented onlayoutchanged support. Druid components now will try keep their data between layout changing! You also can use this callback in your custom components. -Also check component.template.lua what you can use for your own custom components!

- -
    -
  • #77 Grid update: - -
    -- The _grid_ component now is __deprecated__. Use _static_grid_ instead. Druid will show you deprecated message, if you still using _grid_ component
    -- __[BREAKING]__ Remove the _grid:set_offset_ grid functions. To adjust the distance between nodes inside grid - setup correct node sizes
    -- Add _static_grid_ component
    -    - The behaviour like previous _grid_ component
    -    - Have constant element size, so have ability to precalculate positions, indexes and size of content
    -    - By default, not shifting elements on removing element. Add _is_shift_ flag to _static_grid:remove_ function
    -    - This grid can spawn elements with several rows and columns
    -- Add _dynamic_grid_ component
    -    - Can have different element size. So have no ability to precalculate stuff like _static_grid_
    -    - This grid can't have gaps between elements. You will get the error, if spawn element far away from other elements
    -    - The grid can spawn elements only in row or in column
    -    - The grid node should have __West__, __East__, __South__ or __North__ pivot (vertical or horizontal element placement)
    -    - Able to shift nodes left or right on _grid:add_ / _grid:remove_ functions
    -
    -
  • -
  • Scroll update: - -
    -- Add _scroll:set_vertical_scroll_ and _scroll:set_horizontal_scroll_ for disable scroll sides
    -- Add _scroll:bind_grid_ function. Now is possible to bind Druid Grid component (Static or Dynamic) to the scroll for auto refresh the scroll size on grid nodes changing
    -
    -
  • -
  • #37 Add onlayoutchange support. Druid will keep and restore GUI component data between changing game layout. Override function onlayoutchange in your custom components to do stuff you need.
  • -
  • #85 Move several components from base folder to extended. In future to use them, you have to register them manually. This is done for decrease build size by excluding unused components
  • -
  • Fix #61: Button component: fix button animation node creation
  • -
  • Fix #64: Hover component: wrong mouse_hover default state
  • -
  • Fix #71: Blocker: blocker now correct block mouse hover event
  • -
  • Fix #72: Fix return nil in some on_input functions
  • -
  • Fix #74: [BREAKING] Fix typo: strech -> stretch. Scroll function set_extra_stretch_size renamed
  • -
  • Fix #76: Add params for lang text localization component
  • -
  • Fix #79: Fix druid:remove inside on_input callback
  • -
  • Fix #80: Fix hover:setenable_ typo function call
  • -
  • Fix #88: Add component:setinputenabled function to enable/disable input for druid component. Now you can disable input of any druid component, even complex (with other components inside)
  • -
  • Add component.template.lua as template for Druid custom component
  • -
  • Update the example app
  • -
- - - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 -
-
- - diff --git a/docs/topics/components.md.html b/docs/topics/components.md.html deleted file mode 100644 index a8c9c0a..0000000 --- a/docs/topics/components.md.html +++ /dev/null @@ -1,162 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- - -

Druid components

- -

-

Button

-

Basic game button

- -

-

Text

-

Wrap on text node with text size adjusting

- -

-

Blocker

-

Block input in node zone

- -

-

Back Handler

-

Handle back button (Android, backspace)

- -

-

Locale

-

Text component with handle localization system

- -

-

Timer

-

Run timer on text node

- -

-

Progress

-

Basic progress bar

- -

-

Scroll

-

Basic scroll component

- -

-

Grid

-

Component for manage node positions

- -

-

Slider

-

Basic slider component

- -

-

Checkbox

-

Basic checkbox component

- -

-

Checkbox group

-

Several checkboxes in one group

- -

-

Radio group

-

Several checkboxes in one group with single choice

- -

-

Hover

-

Trigger component for check node hover state

- -

-

Input

-

Component to process user text input

- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-03-21 22:59:46 -
-
- - diff --git a/docs/topics/create_custom_components.md.html b/docs/topics/create_custom_components.md.html deleted file mode 100644 index 758f9c9..0000000 --- a/docs/topics/create_custom_components.md.html +++ /dev/null @@ -1,172 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- - -

Custom components

- -

Add your custom components via druid.register

- -
-local druid = require("druid.druid")
-local my_component = require("my.amazing.component")
-
-local function init(self)
-    druid.register("my_component", my_component)
-end
-
- - -

Basic custom component template looks like this:

- -
-local const = require("druid.const")
-
-local M = {}
-M.interest = { const.ON_INPUT }
-
-function M.init(self, ...)
-    -- Component constructor
-end
-
--- Call only if exist interest: const.ON_UPDATE
-function M.update(self, dt)
-
-end
-
--- Call only if exist interest: const.ON_INPUT or const.ON_SWIPE
-function M.on_input(self, action_id, action)
-
-end
-
--- Call only if exist interest: const.ON_MESSAGE
-function M.on_message(self, message_id, message, sender)
-
-end
-
--- Call only if swipe was started on another component (ex. scroll)
-function M.on_swipe(self)
-
-end
-
-return M
-
- - - -

Best practice on custom components

-

On each component recomended describe component schema in next way:

- - -
--- Component module
-local helper = require("druid.helper")
-
-local M = {}
-
-local SCHEME = {
-    ROOT = "/root",
-    ITEM = "/item",
-    TITLE = "/title"
-}
-
--- TODO: Rework self.template/self.nodes
--- Make self._inner_data? { component_name, template, nodes }
-function M.init(self, template_name, node_table)
-    -- If component use template, setup it:
- self.template = template_name
-
-    -- If component was cloned with gui.clone_tree, pass his nodes
- self.nodes = node_table
-
-    -- helper can get node from gui/template/table
- local root = helper.node(self, SCHEME.ROOT)
-
-    -- This component can spawn another druid components:
- local druid = helper.get_druid(self)
-    -- Button self on callback is self of _this_ component
- local button = druid:new_button(...)
-
-    -- helper can return you the component style
- local my_style = helper.get_style(self, "component_name")
-end
-
- - - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-03-21 22:00:04 -
-
- - diff --git a/docs/topics/creating_custom_components.md.html b/docs/topics/creating_custom_components.md.html deleted file mode 100644 index 67d997b..0000000 --- a/docs/topics/creating_custom_components.md.html +++ /dev/null @@ -1,200 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- - -

Creating custom components

- -

-

Overview

-

Druid allows you to create your custom components from druid basic components or other custom components

- - -

-

Custom components

-

Basic custom component template looks like this:

- -
-local const = require("druid.const")
-local component = require("druid.component")
-
-local M = component.create("your_component")
-
--- Component constructor
-function M.init(self, ...)
-end
-
--- Call only if exist interest: const.ON_UPDATE
-function M.update(self, dt)
-end
-
--- Call only if exist interest: const.ON_INPUT or const.ON_INPUT_HIGH
-function M.on_input(self, action_id, action)
-end
-
--- Call only if exist interest: const.ON_MESSAGE
-function M.on_message(self, message_id, message, sender)
-end
-
--- Call only if component with ON_CHANGE_LANGUAGE interest
-function M.on_change_language(self)
-end
-
--- Call only if component with ON_LAYOUT_CHANGE interest
-function M.on_layout_change(self)
-end
-
-return M
-
- - - -

Add your custom component to druid via druid.register

- -
-local druid = require("druid.druid")
-local my_component = require("my.amazing.component")
-
-local function init(self)
-    druid.register("my_component", my_component)
-end
-
- - -

Interest

-

Interest - is a way to indicate what events your component will respond to. -There is next interests in druid: -- ON_MESSAGE - component will receive messages from on_message

- -
    -
  • ON_UPDATE - component will be updated from update

  • -
  • ONINPUTHIGH - component will receive input from oninput, before other components with ONINPUT

  • -
  • ON_INPUT - component will receive input from oninput, after other components with ONINPUT_HIGH

  • -
  • ONCHANGELANGUAGE - will call onchangelanguage function on language change trigger

  • -
  • ONLAYOUTCHANGED will call onlayoutchange function on layout change trigger

  • -
- - -

-

Best practice on custom components

-

On each component recomended describe component scheme in next way:

- - -
--- Component module
-local component = require("druid.component")
-
-local M = component.create("your_component")
-
-local SCHEME = {
-    ROOT = "/root",
-    ITEM = "/item",
-    TITLE = "/title"
-}
-
-function M.init(self, template_name, node_table)
-    -- If component use template, setup it:
- self:set_template(template_name)
-
-    -- If component was cloned with gui.clone_tree, pass his nodes
- self:set_nodes(node_table)
-
-    -- helper can get node from gui/template/table
- local root = self:get_node(SCHEME.ROOT)
-
-    -- This component can spawn another druid components:
- local druid = self:get_druid()
-
-    -- Button self on callback is self of _this_ component
- local button = druid:new_button(...)
-
-    -- helper can return you the component style for current component
- -- It return by component name from
- local my_style = self:get_style()
-end
-
- - - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-03-21 22:59:46 -
-
- - diff --git a/docs/topics/druid_assets.md.html b/docs/topics/druid_assets.md.html deleted file mode 100644 index b45f35a..0000000 --- a/docs/topics/druid_assets.md.html +++ /dev/null @@ -1,96 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- - -

Druid assets

- -

-

Overview

-

I've created druid-assets repository to make a marketplace with custom styles and components.

- -

Any of druid users can push their own components and styles to share it with the other users

- -

Also, this marketplace is great example to how you can create your custom components

- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-03-21 22:59:46 -
-
- - diff --git a/docs/topics/examples.md.html b/docs/topics/examples.md.html deleted file mode 100644 index dafc08b..0000000 --- a/docs/topics/examples.md.html +++ /dev/null @@ -1,94 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- - -

Examples

- -

-

Overview

-

See the example folder for examples of how to use Druid

- -

Try the HTML5 version of the example app

- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-03-21 22:59:46 -
-
- - diff --git a/docs/topics/faq.md.html b/docs/topics/faq.md.html deleted file mode 100644 index c2e535f..0000000 --- a/docs/topics/faq.md.html +++ /dev/null @@ -1,161 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- - - -

Druid FAQ

- -
-

Have questions about Druid? Ask me! - Here is questions you might have

-
- -

Q: Why I want use Druid?

-

A: ---

- - -

Q: How to remove the Druid component instance?

-

A: Any created Druid component can be removed with druid:remove. API reference link.

- - -

Q: How to make scroll work?

-

A: ---

- - -

Q: How the input is processing?

-

A: -SImply: the Druid has a LIFO queue to check input. Last added buttons have more priority than first. Placing your buttons from behind to the front is correct in most cases.

- - -

Q: For what purpose Blocker component is exist?

-

A: Component explanation here. -With Blocker you can block input in some zone. It is useful for make unclickable zone in buttons or kind of buttons panel on other big button (ex. close windows on window background click)

- - -

Q: Which stuff can I do with custom components?

-

A: Any of you can imagine! There is a lot of examples, but in general: custom components allow you place component and some game logic separately from other stuff. It will be reusable, easier for testing and developing.

- -

For example it can be element in scroll with buttons, your custom GUI widget or even component with your game logic. Usually custom components going with templates. You can do several templates for single component module (for different visuals!)

- -

Some examples of custom components you can find here.

- - -

Q: How *self:get_node()* is working?

-

A: The node can be placed in gui directly or can be cloned via *gui.clone_tree()*. Also nodes can be placed as templates, so full node id will be composed from template name and node name (in cloned nodes too).

- -

Druid component *self:getnode()* trying to search in all of this places. Use *self:settemplate()* and *self:setcomponentnodes()* for correct setup component nodes before any call of *self:get_node()*.

- -

Remember, usually you should pass string name of the node, not gui node itself. It's better and more druid-way.

- - -

Q: My button in scroll is clickable outside the stencil node

-

A: Since Druid checking click node with gui.picknode_, stencil is not prevent this. You can setup additional click zone on your buttons with button:setclickzone.

- -

The usual Druid way after add button to the scroll do:

- -
--- Scroll view node usually is stencil node
-button:set_click_zone(scroll.view_node)
-
- - - -

Q: How to use EmmyLua annotations? (from Druid 0.6.0)

-

A: Since the dependencies can't be processed by external editors, for use generated EmmyLua annotations you should copy the annotations.lua to your project. For EmmyLua it will be enough. Remember you can restart emmylua server for refresh the changes, if something goes wrong. -After the annotations is processed, you should point the type of druid in requires:

- -
----@type druid
-local druid = require("druid.druid")
-
--- Now the autocomplete is working
-
- - - -

Q: When I should use *onlayoutchange*?

-

A: ---

- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-09-29 23:46:16 -
-
- - diff --git a/docs/topics/online_example.md.html b/docs/topics/online_example.md.html deleted file mode 100644 index b057b31..0000000 --- a/docs/topics/online_example.md.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- - -

Online example

- -

Check druid --here-- (link)

- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-03-21 22:00:04 -
-
- - diff --git a/docs/topics/styles.md.html b/docs/topics/styles.md.html deleted file mode 100644 index 9c680d6..0000000 --- a/docs/topics/styles.md.html +++ /dev/null @@ -1,145 +0,0 @@ - - - - - Defold Druid UI Library - - - - -
- -
- -
-
-
- - -
- - - - - - -
- - -

Styles

- -

-

Overview

-

Styles - set of functions and parameters for components to customize their behavior.

- -

Styles is a table, where key is name of component, and value is style table for this component.

- -

In component API documentation, you can find the style API for this component. Or just lookup for existing styles and modify them.

- -

-

Usage

-

Setup default druid style for all druid instances via druid.set_default_style

- -
-local druid = require("druid.druid")
-local my_style = require("my.amazing.style")
-
-local function init(self)
-    druid.set_default_style(my_style)
-end
-
- - -

Setup custom style to specific druid instance:

- -
-local druid = require("druid.druid")
-local my_style = require("my.amazing.style")
-
-local function init(self)
-    -- This druid instance will be use my_style as default
- self.druid = druid.new(self, my_style)
-end
-
- - -

Change component style with setstyle_ function

- -
-local druid = require("druid.druid")
-local my_style = require("my.amazing.style")
-
-local function init(self)
-    self.druid = druid.new(self)
-    self.button = self.druid:new_button(self, "node")
-    -- Setup custom style for specific component
- self.button:set_style(my_style)
-end
-
- - -

-

Create custom components

-

Styles is just lua table, so it can be described in just one single file -TODO

- - -
-
-
-generated by LDoc 1.4.6 -Last updated 2020-03-21 22:59:46 -
-
- - diff --git a/docs_md/01-components.md b/docs_md/01-components.md index 11322f7..384edcc 100644 --- a/docs_md/01-components.md +++ b/docs_md/01-components.md @@ -240,7 +240,7 @@ Create timer component with druid: `timer = druid:new_timer(text_node, from_seco ### Notes - Timer fires callback, when timer value equals to _to_seconds_ -- Timer will setup text node with current timer value +- Timer will set text node with current timer value - Timer uses update function to handle time @@ -256,7 +256,7 @@ Static grid can shift elements on add/remove functions. Create component with druid: `grid = druid:new_static_grid(parent_node, prefab_node, max_in_row_elements)` ### Notes -- On _add node_ grid will set node parent to _parent_node_ +- On _add node_ grid will set nodeup parent to _parent_node_ - You can get array of position of every element for setup points of interest in scroll component - You can get size of all elements for setup size in scroll component - You can also bind the grid to the scroll component for auto resize scroll content size @@ -271,7 +271,8 @@ Create component with druid: `grid = druid:new_static_grid(parent_node, prefab_ ### Overview Component for manage node positions with different node sizes. Unlike Static Grid, Dynamic Grid can place nodes only in one row or in one column. -Dynamic Grid can't have gaps between elements - you will get error, if try spawn element far away from others. +Dynamic Grid can't have gaps between elements +- you will get error, if try spawn element far away from others. Dynamic Grid should have __West__, __East__, __South__ or __North__ pivot (vertical or horizontal element placement) ### Setup @@ -287,7 +288,7 @@ Check the _parent_node_ have correct pivot point. You will get the error otherwi - Pivot of parent_node matter for node placement - You can point *position_function* for animations with _static_grid:set_position_function(node, pos)_ callback. Default - *gui.set_position()* - First node placed at Grid pivot point. Other nodes placed nearby of other nodes. -- On *add/remove* nodes always shifted. You can point the shift side in this functions (*is_shift_left* boolean argument) +- On *add/remove* nodes always shifted. You can point the shift side in this functions (*is_shift_left* boolean argumentp ## Hover [Hover API here](https://insality.github.io/druid/modules/druid.hover.html) diff --git a/druid/base/back_handler.lua b/druid/base/back_handler.lua index daabd9a..d6711df 100644 --- a/druid/base/back_handler.lua +++ b/druid/base/back_handler.lua @@ -1,13 +1,14 @@ --- Component to handle back key (android, backspace) --- @module druid.back_handler +-- @module BackHandler +-- @within BaseComponent +-- @alias druid.back_handler ---- Component events --- @table Events --- @tfield druid_event on_back On back handler callback +--- On back handler callback(self, params) +-- @tfield druid_event on_back + +--- Params to back callback +-- @tfield any params ---- Component fields --- @table Fields --- @tfield any params Params to click callbacks local Event = require("druid.event") local const = require("druid.const") @@ -17,21 +18,20 @@ local BackHandler = component.create("back_handler", { const.ON_INPUT }) --- Component init function --- @function back_handler:init +-- @tparam BackHandler self -- @tparam callback callback On back button --- @tparam[opt] params Callback argument -function BackHandler:init(callback, params) +-- @tparam[opt] any params Callback argument +function BackHandler.init(self, callback, params) self.params = params - self.on_back = Event(callback) end --- Input handler for component --- @function back_handler:on_input +-- @tparam BackHandler self -- @tparam string action_id on_input action id -- @tparam table action on_input action -function BackHandler:on_input(action_id, action) +function BackHandler.on_input(self, action_id, action) if not action[const.RELEASED] then return false end diff --git a/druid/base/blocker.lua b/druid/base/blocker.lua index 4f36ae8..1017db9 100644 --- a/druid/base/blocker.lua +++ b/druid/base/blocker.lua @@ -1,16 +1,12 @@ --- Component to block input on specify zone by node --- @module druid.blocker +-- @module Blocker +-- @within BaseComponent +-- @alias druid.blocker ---- Component events --- @table Events --- @tfield druid_event on_click On release button callback --- @tfield druid_event on_enable_change On enable/disable callback +---Trigger node +-- @tfield node node ---- Component fields --- @table Fields --- @tfield node node Trigger node -local Event = require("druid.event") local const = require("druid.const") local component = require("druid.component") @@ -18,17 +14,14 @@ local Blocker = component.create("blocker", { const.ON_INPUT }) --- Component init function --- @function blocker:init +-- @tparam Blocker self -- @tparam node node Gui node -function Blocker:init(node) +function Blocker.init(self, node) self.node = self:get_node(node) - - self.on_click = Event() - self.on_enable_change = Event() end -function Blocker:on_input(action_id, action) +function Blocker.on_input(self, action_id, action) if action_id ~= const.ACTION_TOUCH and action_id ~= const.ACTION_MULTITOUCH and action_id ~= nil then @@ -48,17 +41,17 @@ end --- Set enabled blocker component state --- @function blocker:set_enabled +-- @tparam Blocker self -- @tparam bool state Enabled state -function Blocker:set_enabled(state) +function Blocker.set_enabled(self, state) gui.set_enabled(self.node, state) end --- Return blocked enabled state --- @function blocker:is_enabled +-- @tparam Blocker self -- @treturn bool True, if blocker is enabled -function Blocker:is_enabled(state) +function Blocker.is_enabled(self) return gui.is_enabled(self.node) end diff --git a/druid/base/button.lua b/druid/base/button.lua index e1ac309..3f25c4e 100644 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -1,25 +1,50 @@ --- Component to handle basic GUI button --- @module druid.button +-- @module Button +-- @within BaseComponent +-- @alias druid.button ---- Component events --- @table Events --- @tfield druid_event on_click (self, params, button_instance) On release button callback --- @tfield druid_event on_repeated_click (self, params, button_instance, click_amount) On repeated action button callback --- @tfield druid_event on_long_click (self, params, button_instance, time) On long tap button callback --- @tfield druid_event on_double_click (self, params, button_instance, click_amount) On double tap button callback --- @tfield druid_event on_hold_callback (self, params, button_instance, time) On button hold before long_click callback --- @tfield druid_event on_click_outside (self, params, button_instance) On click outside of button +--- On release button callback(self, params, button_instance) +-- @tfield druid_event on_click + +--- On repeated action button callback(self, params, button_instance, click_amount) +-- @tfield druid_event on_repeated_click + +---On long tap button callback(self, params, button_instance, time) +-- @tfield druid_event on_long_click + +---On double tap button callback(self, params, button_instance, click_amount) +-- @tfield druid_event on_double_click + +---On button hold before long_click callback(self, params, button_instance, time) +-- @tfield druid_event on_hold_callback + +---On click outside of button(self, params, button_instance) +-- @tfield druid_event on_click_outside + +---Trigger node +-- @tfield node node + +---Animation node +-- @tfield[opt=node] node anim_node + +---Initial scale of anim_node +-- @tfield vector3 start_scale + +---Initial pos of anim_node +-- @tfield vector3 start_pos + +---Initial pos of anim_node +-- @tfield vector3 pos + +---Params to click callbacks +-- @tfield any params + +---Druid hover logic component +-- @tfield druid.hover hover + +---Restriction zone +-- @tfield[opt] node click_zone ---- Component fields --- @table Fields --- @tfield node node Trigger node --- @tfield[opt=node] node anim_node Animation node --- @tfield vector3 start_scale Initial scale of anim_node --- @tfield vector3 start_pos Initial pos of anim_node --- @tfield vector3 pos Initial pos of anim_node --- @tfield any params Params to click callbacks --- @tfield druid.hover hover Druid hover logic component --- @tfield[opt] node click_zone Restriction zone local Event = require("druid.event") local const = require("druid.const") @@ -132,7 +157,7 @@ end --- Component style params. -- You can override this component styles params in druid styles table -- or create your own style --- @table Style +-- @table style -- @tfield[opt=0.4] number LONGTAP_TIME Minimum time to trigger on_hold_callback -- @tfield[opt=0.8] number AUTOHOLD_TRIGGER Maximum hold time to trigger button release while holding -- @tfield[opt=0.4] number DOUBLETAP_TIME Time between double taps @@ -141,7 +166,7 @@ end -- @tfield function on_hover (self, node, hover_state) -- @tfield function on_mouse_hover (self, node, hover_state) -- @tfield function on_set_enabled (self, node, enabled_state) -function Button:on_style_change(style) +function Button.on_style_change(self, style) self.style = {} self.style.LONGTAP_TIME = style.LONGTAP_TIME or 0.4 self.style.AUTOHOLD_TRIGGER = style.AUTOHOLD_TRIGGER or 0.8 @@ -156,12 +181,12 @@ end --- Component init function --- @function button:init +-- @tparam Button self -- @tparam node node Gui node -- @tparam function callback Button callback -- @tparam[opt] table params Button callback params -- @tparam[opt] node anim_node Button anim node (node, if not provided) -function Button:init(node, callback, params, anim_node) +function Button.init(self, node, callback, params, anim_node) self.druid = self:get_druid() self.node = self:get_node(node) @@ -188,7 +213,7 @@ function Button:init(node, callback, params, anim_node) end -function Button:on_input(action_id, action) +function Button.on_input(self, action_id, action) if not is_input_match(self, action_id) then return false end @@ -257,16 +282,16 @@ function Button:on_input(action_id, action) end -function Button:on_input_interrupt() +function Button.on_input_interrupt(self) self.can_action = false end --- Set enabled button component state --- @function button:set_enabled +-- @tparam Button self -- @tparam bool state Enabled state --- @treturn druid.button Current button instance -function Button:set_enabled(state) +-- @treturn Button Current button instance +function Button.set_enabled(self, state) self.disabled = not state self.hover:set_enabled(state) self.style.on_set_enabled(self, self.node, state) @@ -276,19 +301,19 @@ end --- Return button enabled state --- @function button:is_enabled +-- @tparam Button self -- @treturn bool True, if button is enabled -function Button:is_enabled() +function Button.is_enabled(self) return not self.disabled end --- Strict button click area. Useful for -- no click events outside stencil node --- @function button:set_click_zone +-- @tparam Button self -- @tparam node zone Gui node --- @treturn druid.button Current button instance -function Button:set_click_zone(zone) +-- @treturn Button Current button instance +function Button.set_click_zone(self, zone) self.click_zone = self:get_node(zone) self.hover:set_click_zone(zone) @@ -297,10 +322,10 @@ end --- Set key-code to trigger this button --- @function button:set_key_trigger +-- @tparam Button self -- @tparam hash key The action_id of the key --- @treturn druid.button Current button instance -function Button:set_key_trigger(key) +-- @treturn Button Current button instance +function Button.set_key_trigger(self, key) self.key_trigger = hash(key) return self @@ -308,9 +333,9 @@ end --- Get key-code to trigger this button --- @function button:get_key_trigger +-- @tparam Button self -- @treturn hash The action_id of the key -function Button:get_key_trigger() +function Button.get_key_trigger(self) return self.key_trigger end diff --git a/druid/base/drag.lua b/druid/base/drag.lua index bef0b7a..2eef901 100644 --- a/druid/base/drag.lua +++ b/druid/base/drag.lua @@ -2,25 +2,46 @@ -- Drag have correct handling for multitouch and swap -- touched while dragging. Drag will be processed even -- the cursor is outside of node, if drag is already started --- @module druid.drag +-- @module Drag +-- @within BaseComponent +-- @alias druid.drag ---- Component events --- @table Events --- @tfield druid_event on_touch_start (self) Event on touch start --- @tfield druid_event on_touch_end (self) Event on touch end --- @tfield druid_event on_drag_start (self) Event on drag start --- @tfield druid_event on_drag (self, dx, dy) Event on drag progress --- @tfield druid_event on_drag_end (self) Event on drag end +--- Event on touch start callback(self) +-- @tfield druid_event on_touch_start + +--- Event on touch end callback(self) +-- @tfield druid_event on_touch_end + +--- Event on drag start callback(self) +-- @tfield druid_event on_drag_start + +--- on drag progress callback(self, dx, dy) +-- @tfield druid_event on_drag Event + +--- Event on drag end callback(self) +-- @tfield druid_event on_drag_end + +--- Is component now touching +-- @tfield bool is_touch + +--- Is component now dragging +-- @tfield bool is_drag + +--- Is drag component process vertical dragging. Default - true +-- @tfield bool can_x + +--- Is drag component process horizontal. Default - true +-- @tfield bool can_y + +--- Current touch x position +-- @tfield number x + +--- Current touch y position +-- @tfield number y + +--- Touch start position +-- @tfield vector3 touch_start_pos ---- Components fields --- @table Fields --- @tfield bool is_touch Is component now touching --- @tfield bool is_drag Is component now dragging --- @tfield bool can_x Is drag component process vertical dragging. Default - true --- @tfield bool can_y Is drag component process horizontal. Default - true --- @tfield number x Current touch x position --- @tfield number y Current touch y position --- @tfield vector3 touch_start_pos Touch start position local Event = require("druid.event") local const = require("druid.const") @@ -127,19 +148,19 @@ end --- Component style params. -- You can override this component styles params in druid styles table -- or create your own style --- @table Style +-- @table style -- @tfield[opt=10] number DRAG_DEADZONE Distance in pixels to start dragging -function Drag:on_style_change(style) +function Drag.on_style_change(self, style) self.style = {} self.style.DRAG_DEADZONE = style.DRAG_DEADZONE or 10 end --- Drag component constructor +-- @tparam Drag self -- @tparam node node GUI node to detect dragging -- @tparam function on_drag_callback Callback for on_drag_event(self, dx, dy) --- @function drag:init -function Drag:init(node, on_drag_callback) +function Drag.init(self, node, on_drag_callback) self.node = self:get_node(node) self.dx = 0 @@ -163,14 +184,14 @@ function Drag:init(node, on_drag_callback) end -function Drag:on_input_interrupt() +function Drag.on_input_interrupt(self) if self.is_drag or self.is_touch then end_touch(self) end end -function Drag:on_input(action_id, action) +function Drag.on_input(self, action_id, action) if action_id ~= const.ACTION_TOUCH and action_id ~= const.ACTION_MULTITOUCH then return false end @@ -241,9 +262,9 @@ end --- Strict drag click area. Useful for -- restrict events outside stencil node --- @function drag:set_click_zone +-- @tparam Drag self -- @tparam node zone Gui node -function Drag:set_click_zone(zone) +function Drag.set_click_zone(self, zone) self.click_zone = self:get_node(zone) end diff --git a/druid/base/hover.lua b/druid/base/hover.lua index 221c7b6..4d61461 100644 --- a/druid/base/hover.lua +++ b/druid/base/hover.lua @@ -1,10 +1,14 @@ --- Component to handle hover node interaction --- @module druid.hover +-- @module Hover +-- @within BaseComponent +-- @alias druid.hover + +--- On hover callback(self, state) +-- @tfield druid_event on_hover + +--- On mouse hover callback(self, state) +-- @tfield druid_event on_mouse_hover ---- Component events --- @table Events --- @tfield druid_event on_hover On hover callback (Touch pressed) --- @tfield druid_event on_mouse_hover On mouse hover callback (Touch over without action_id) local Event = require("druid.event") local const = require("druid.const") @@ -15,10 +19,10 @@ local Hover = component.create("hover", { const.ON_INPUT }) --- Component init function --- @function hover:init +-- @tparam Hover self -- @tparam node node Gui node -- @tparam function on_hover_callback Hover callback -function Hover:init(node, on_hover_callback) +function Hover.init(self, node, on_hover_callback) self.node = self:get_node(node) self._is_hovered = false @@ -31,7 +35,7 @@ function Hover:init(node, on_hover_callback) end -function Hover:on_input(action_id, action) +function Hover.on_input(self, action_id, action) if action_id ~= const.ACTION_TOUCH and action_id ~= nil then return false end @@ -64,15 +68,15 @@ function Hover:on_input(action_id, action) end -function Hover:on_input_interrupt() +function Hover.on_input_interrupt(self) self:set_hover(false) end --- Set hover state --- @function hover:set_hover +-- @tparam Hover self -- @tparam bool state The hover state -function Hover:set_hover(state) +function Hover.set_hover(self, state) if self._is_hovered ~= state then self._is_hovered = state self.on_hover:trigger(self:get_context(), state) @@ -80,9 +84,9 @@ function Hover:set_hover(state) end --- Set mouse hover state --- @function hover:set_mouse_hover +-- @tparam Hover self -- @tparam bool state The mouse hover state -function Hover:set_mouse_hover(state) +function Hover.set_mouse_hover(self, state) if self._is_mouse_hovered ~= state then self._is_mouse_hovered = state self.on_mouse_hover:trigger(self:get_context(), state) @@ -92,9 +96,9 @@ end --- Strict hover click area. Useful for -- no click events outside stencil node --- @function hover:set_click_zone +-- @tparam Hover self -- @tparam node zone Gui node -function Hover:set_click_zone(zone) +function Hover.set_click_zone(self, zone) self.click_zone = self:get_node(zone) end @@ -102,9 +106,9 @@ end --- Set enable state of hover component. -- If hover is not enabled, it will not generate -- any hover events --- @function hover:set_enabled +-- @tparam Hover self -- @tparam bool state The hover enabled state -function Hover:set_enabled(state) +function Hover.set_enabled(self, state) self._is_enabled = state if not state then @@ -119,9 +123,9 @@ end --- Return current hover enabled state --- @function hover:is_enabled +-- @tparam Hover self -- @treturn bool The hover enabled state -function Hover:is_enabled() +function Hover.is_enabled(self) return self._is_enabled end diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index bd7139a..7f76bb6 100644 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -5,27 +5,53 @@ -- Setup initial scroll size by changing scroll parent size. If scroll parent -- size will be less than scroll_input size, no scroll is available. For scroll -- parent size should be more than input size --- @module druid.scroll +-- @module Scroll +-- @within BaseComponent +-- @alias druid.scroll ---- Component events --- @table Events --- @tfield druid_event on_scroll On scroll move callback --- @tfield druid_event on_scroll_to On scroll_to function callback --- @tfield druid_event on_point_scroll On scroll_to_index function callback ---- Component fields --- @table Fields --- @tfield node view_node Scroll view node --- @tfield node content_node Scroll content node --- @tfield bool is_inert Flag, if scroll now moving by inertion --- @tfield vector3 inertion Current inert speed --- @tfield vector3 position Current scroll posisition --- @tfield vector3 target_position Current scroll target position --- @tfield vector4 available_pos Available position for content node: (min_x, max_y, max_x, min_y) --- @tfield vector3 available_size Size of available positions: (width, height, 0) --- @tfield druid.drag drag Drag component --- @tfield[opt] selected Current index of points of interests --- @tfield bool is_animate Flag, if scroll now animating by gui.animate +--- On scroll move callback(self, position) +-- @tfield druid_event on_scroll + +--- On scroll_to function callback(self, target, is_instant) +-- @tfield druid_event on_scroll_to + +--- On scroll_to_index function callback(self, index, point) +-- @tfield druid_event on_point_scroll + +--- Scroll view node +-- @tfield node view_node + +--- Scroll content node +-- @tfield node content_node + +--- Flag, if scroll now moving by inertion +-- @tfield bool is_inert + +--- Current inert speed +-- @tfield vector3 inertion + +--- Current scroll posisition +-- @tfield vector3 position + +--- Current scroll target position +-- @tfield vector3 target_position + +--- Available position for content node: (min_x, max_y, max_x, min_y) +-- @tfield vector4 available_pos + +--- Size of available positions: (width, height, 0) +-- @tfield vector3 available_size + +--- Drag Druid component +-- @tfield Drag drag + +--- Current index of points of interests +-- @tfield[opt] number selected + +--- Flag, if scroll now animating by gui.animate +-- @tfield bool is_animate + local Event = require("druid.event") local const = require("druid.const") @@ -64,7 +90,7 @@ end --- Component style params. -- You can override this component styles params in druid styles table -- or create your own style --- @table Style +-- @table style -- @tfield[opt=0] number FRICT Multiplier for free inertion -- @tfield[opt=0] number FRICT_HOLD Multiplier for inertion, while touching -- @tfield[opt=3] number INERT_THRESHOLD Scroll speed to stop inertion @@ -74,7 +100,7 @@ end -- @tfield[opt=0.2] number ANIM_SPEED Scroll gui.animation speed for scroll_to function -- @tfield[opt=0] number EXTRA_STRETCH_SIZE extra size in pixels outside of scroll (stretch effect) -- @tfield[opt=false] bool SMALL_CONTENT_SCROLL If true, content node with size less than view node size can be scrolled -function Scroll:on_style_change(style) +function Scroll.on_style_change(self, style) self.style = {} self.style.EXTRA_STRETCH_SIZE = style.EXTRA_STRETCH_SIZE or 0 self.style.ANIM_SPEED = style.ANIM_SPEED or 0.2 @@ -94,11 +120,11 @@ function Scroll:on_style_change(style) end ---- Scroll constructor. --- @function scroll:init +--- Scroll constructor +-- @tparam Scroll self -- @tparam node view_node GUI view scroll node -- @tparam node content_node GUI content scroll node -function Scroll:init(view_node, content_node) +function Scroll.init(self, view_node, content_node) self.druid = self:get_druid() self.view_node = self:get_node(view_node) @@ -128,12 +154,12 @@ function Scroll:init(view_node, content_node) end -function Scroll:on_layout_change() +function Scroll.on_layout_change(self) gui.set_position(self.content_node, self.position) end -function Scroll:update(dt) +function Scroll.update(self, dt) if self.drag.is_drag then self:_update_hand_scroll(dt) else @@ -142,18 +168,18 @@ function Scroll:update(dt) end -function Scroll:on_remove() +function Scroll.on_remove(self) self:bind_grid(nil) end --- Start scroll to target point. --- @function scroll:scroll_to --- @tparam point vector3 Target point +-- @tparam Scroll self +-- @tparam vector3 point Target point -- @tparam[opt] bool is_instant Instant scroll flag -- @usage scroll:scroll_to(vmath.vector3(0, 50, 0)) -- @usage scroll:scroll_to(vmath.vector3(0), true) -function Scroll:scroll_to(point, is_instant) +function Scroll.scroll_to(self, point, is_instant) local b = self.available_pos local target = vmath.vector3(-point.x, -point.y, 0) target.x = helper.clamp(target.x, b.x, b.z) @@ -179,10 +205,10 @@ end --- Scroll to item in scroll by point index. --- @function scroll:scroll_to_index +-- @tparam Scroll self -- @tparam number index Point index -- @tparam[opt] bool skip_cb If true, skip the point callback -function Scroll:scroll_to_index(index, skip_cb) +function Scroll.scroll_to_index(self, index, skip_cb) if not self.points then return end @@ -202,11 +228,11 @@ end --- Start scroll to target scroll percent --- @function scroll:scroll_to_percent --- @tparam point vector3 target percent +-- @tparam Scroll self +-- @tparam vector3 percent target percent -- @tparam[opt] bool is_instant instant scroll flag -- @usage scroll:scroll_to_percent(vmath.vector3(0.5, 0, 0)) -function Scroll:scroll_to_percent(percent, is_instant) +function Scroll.scroll_to_percent(self, percent, is_instant) local border = self.available_pos local pos = vmath.vector3( @@ -221,9 +247,9 @@ end --- Return current scroll progress status. -- Values will be in [0..1] interval --- @function scroll:get_percent +-- @tparam Scroll self -- @treturn vector3 New vector with scroll progress values -function Scroll:get_percent() +function Scroll.get_percent(self) local x_perc = 1 - inverse_lerp(self.available_pos.x, self.available_pos.z, self.position.x) local y_perc = inverse_lerp(self.available_pos.w, self.available_pos.y, self.position.y) @@ -233,10 +259,10 @@ end --- Set scroll content size. -- It will change content gui node size --- @function scroll:set_size +-- @tparam Scroll self -- @tparam vector3 size The new size for content node -- @treturn druid.scroll Current scroll instance -function Scroll:set_size(size) +function Scroll.set_size(self, size) gui.set_size(self.content_node, size) self:_update_size() @@ -247,10 +273,10 @@ end --- Enable or disable scroll inert. -- If disabled, scroll through points (if exist) -- If no points, just simple drag without inertion --- @function scroll:set_inert +-- @tparam Scroll self -- @tparam bool state Inert scroll state -- @treturn druid.scroll Current scroll instance -function Scroll:set_inert(state) +function Scroll.set_inert(self, state) self._is_inert = state return self @@ -258,19 +284,19 @@ end --- Return if scroll have inertion. --- @function scroll:is_inert +-- @tparam Scroll self -- @treturn bool If scroll have inertion -function Scroll:is_inert() +function Scroll.is_inert(self) return self._is_inert end --- Set extra size for scroll stretching. -- Set 0 to disable stretching effect --- @function scroll:set_extra_stretch_size +-- @tparam Scroll self -- @tparam[opt=0] number stretch_size Size in pixels of additional scroll area -- @treturn druid.scroll Current scroll instance -function Scroll:set_extra_stretch_size(stretch_size) +function Scroll.set_extra_stretch_size(self, stretch_size) self.style.EXTRA_STRETCH_SIZE = stretch_size or 0 self:_update_size() @@ -279,19 +305,19 @@ end --- Return vector of scroll size with width and height. --- @function scroll:get_scroll_size +-- @tparam Scroll self -- @treturn vector3 Available scroll size -function Scroll:get_scroll_size() +function Scroll.get_scroll_size(self) return self.available_size end --- Set points of interest. -- Scroll will always centered on closer points --- @function scroll:set_points +-- @tparam Scroll self -- @tparam table points Array of vector3 points -- @treturn druid.scroll Current scroll instance -function Scroll:set_points(points) +function Scroll.set_points(self, points) self.points = points table.sort(self.points, function(a, b) @@ -305,10 +331,10 @@ end --- Lock or unlock horizontal scroll --- @function scroll:set_horizontal_scroll +-- @tparam Scroll self -- @tparam bool state True, if horizontal scroll is enabled -- @treturn druid.scroll Current scroll instance -function Scroll:set_horizontal_scroll(state) +function Scroll.set_horizontal_scroll(self, state) self._is_horizontal_scroll = state self.drag.can_x = self.available_size.x > 0 and state return self @@ -316,10 +342,10 @@ end --- Lock or unlock vertical scroll --- @function scroll:set_vertical_scroll +-- @tparam Scroll self -- @tparam bool state True, if vertical scroll is enabled -- @treturn druid.scroll Current scroll instance -function Scroll:set_vertical_scroll(state) +function Scroll.set_vertical_scroll(self, state) self._is_vertical_scroll = state self.drag.can_y = self.available_size.y > 0 and state return self @@ -329,10 +355,10 @@ end --- Bind the grid component (Static or Dynamic) to recalculate -- scroll size on grid changes --- @function scroll:bind_grid --- @tparam druid.static_grid|druid.dynamic_grid Druid grid component +-- @tparam Scroll self +-- @tparam StaticGrid|DynamicGrid grid Druid grid component -- @treturn druid.scroll Current scroll instance -function Scroll:bind_grid(grid) +function Scroll.bind_grid(self, grid) if self._grid_on_change then self._grid_on_change:unsubscribe(self._grid_on_change_callback) @@ -354,7 +380,7 @@ function Scroll:bind_grid(grid) end -function Scroll:_on_scroll_drag(dx, dy) +function Scroll._on_scroll_drag(self, dx, dy) local t = self.target_position local b = self.available_pos local eb = self.available_pos_extra @@ -395,7 +421,7 @@ function Scroll:_on_scroll_drag(dx, dy) end -function Scroll:_check_soft_zone() +function Scroll._check_soft_zone(self) local target = self.target_position local border = self.available_pos local speed = self.style.BACK_SPEED @@ -420,7 +446,7 @@ end --- Cancel animation on other animation or input touch -function Scroll:_cancel_animate() +function Scroll._cancel_animate(self) if self.is_animate then self.target_position = gui.get_position(self.content_node) self.position.x = self.target_position.x @@ -431,7 +457,7 @@ function Scroll:_cancel_animate() end -function Scroll:_set_scroll_position(position) +function Scroll._set_scroll_position(self, position) local available_extra = self.available_pos_extra position.x = helper.clamp(position.x, available_extra.x, available_extra.z) position.y = helper.clamp(position.y, available_extra.w, available_extra.y) @@ -450,7 +476,7 @@ end -- if no inert, scroll to next point by scroll direction -- if inert, find next point by scroll director -- @local -function Scroll:_check_points() +function Scroll._check_points(self) if not self.points then return end @@ -502,7 +528,7 @@ function Scroll:_check_points() end -function Scroll:_check_threshold() +function Scroll._check_threshold(self) local is_stopped = false if self.inertion.x ~= 0 and math.abs(self.inertion.x) < self.style.INERT_THRESHOLD then @@ -520,7 +546,7 @@ function Scroll:_check_threshold() end -function Scroll:_update_free_scroll(dt) +function Scroll._update_free_scroll(self, dt) local target = self.target_position if self._is_inert and (self.inertion.x ~= 0 or self.inertion.y ~= 0) then @@ -541,7 +567,7 @@ function Scroll:_update_free_scroll(dt) end -function Scroll:_update_hand_scroll(dt) +function Scroll._update_hand_scroll(self, dt) local dx = self.target_position.x - self.position.x local dy = self.target_position.y - self.position.y @@ -552,7 +578,7 @@ function Scroll:_update_hand_scroll(dt) end -function Scroll:_on_touch_start() +function Scroll._on_touch_start(self) self.inertion.x = 0 self.inertion.y = 0 self.target_position.x = self.position.x @@ -560,12 +586,12 @@ function Scroll:_on_touch_start() end -function Scroll:_on_touch_end() +function Scroll._on_touch_end(self) self:_check_threshold() end -function Scroll:_update_size() +function Scroll._update_size(self) local view_border = helper.get_border(self.view_node) local view_size = vmath.mul_per_elem(gui.get_size(self.view_node), gui.get_scale(self.view_node)) diff --git a/druid/base/static_grid.lua b/druid/base/static_grid.lua index 2dd9a42..7e2e7dd 100644 --- a/druid/base/static_grid.lua +++ b/druid/base/static_grid.lua @@ -1,24 +1,45 @@ --- Component to handle placing components by row and columns. -- Grid can anchor your elements, get content size and other --- @module druid.static_grid +-- @module StaticGrid +-- @within BaseComponent +-- @alias druid.static_grid ---- Component events --- @table Events --- @tfield druid_event on_add_item On item add callback --- @tfield druid_event on_remove_item On item remove callback --- @tfield druid_event on_change_items On item add or remove callback --- @tfield druid_event on_clear On grid clear callback --- @tfield druid_event on_update_positions On update item positions callback +--- On item add callback(self, node, index) +-- @tfield druid_event on_add_item + +--- On item remove callback(self, index) +-- @tfield druid_event on_remove_item + +--- On item add or remove callback(self, index) +-- @tfield druid_event on_change_items + +--- On grid clear callback(self) +-- @tfield druid_event on_clear + +--- On update item positions callback(self) +-- @tfield druid_event on_update_positions + +--- Parent gui node +-- @tfield node parent + +--- List of all grid nodes +-- @tfield node[] nodes + +--- The first index of node in grid +-- @tfield number first_index + +--- The last index of node in grid +-- @tfield number last_index + +--- Item anchor +-- @tfield vector3 anchor + +--- Item size +-- @tfield vector3 node_size + +--- The size of item content +-- @tfield vector4 border ---- Component fields --- @table Fields --- @tfield node parent Parent gui node --- @tfield node[] nodes List of all grid nodes --- @tfield number first_index The first index of node in grid --- @tfield number last_index The last index of node in grid --- @tfield vector3 anchor Item anchor --- @tfield vector3 node_size Item size --- @tfield vector4 border The size of item content local const = require("druid.const") local Event = require("druid.event") @@ -29,11 +50,11 @@ local StaticGrid = component.create("static_grid", { const.ON_LAYOUT_CHANGE }) --- Component init function --- @function static_grid:init +-- @tparam StaticGrid self -- @tparam node parent The gui node parent, where items will be placed -- @tparam node element Element prefab. Need to get it size -- @tparam[opt=1] number in_row How many nodes in row can be placed -function StaticGrid:init(parent, element, in_row) +function StaticGrid.init(self, parent, element, in_row) self.parent = self:get_node(parent) self.nodes = {} @@ -60,10 +81,10 @@ end local _temp_pos = vmath.vector3(0) --- Return pos for grid node index --- @function static_grid:get_pos +-- @tparam StaticGrid self -- @tparam number index The grid element index -- @treturn vector3 Node position -function StaticGrid:get_pos(index) +function StaticGrid.get_pos(self, index) local row = math.ceil(index / self.in_row) - 1 local col = (index - row * self.in_row) - 1 @@ -76,10 +97,10 @@ end --- Return index for grid pos --- @function static_grid:get_index +-- @tparam StaticGrid self -- @tparam vector3 pos The node position in the grid -- @treturn number The node index -function StaticGrid:get_index(pos) +function StaticGrid.get_index(self, pos) local col = pos.x / self.node_size.x + 1 local row = -pos.y / self.node_size.y @@ -92,10 +113,10 @@ end --- Return grid index by node --- @function static_grid:get_index_by_node +-- @tparam StaticGrid self -- @tparam node node The gui node in the grid -- @treturn number The node index -function StaticGrid:get_index_by_node(node) +function StaticGrid.get_index_by_node(self, node) for index, grid_node in pairs(self.nodes) do if node == grid_node then return index @@ -106,25 +127,25 @@ function StaticGrid:get_index_by_node(node) end -function StaticGrid:on_layout_change() +function StaticGrid.on_layout_change(self) self:_update(true) end --- Set grid anchor. Default anchor is equal to anchor of grid parent node --- @function static_grid:set_anchor +-- @tparam StaticGrid self -- @tparam vector3 anchor Anchor -function StaticGrid:set_anchor(anchor) +function StaticGrid.set_anchor(self, anchor) self.anchor = anchor self:_update() end --- Add new item to the grid --- @function static_grid:add +-- @tparam StaticGrid self -- @tparam node item Gui node -- @tparam[opt] number index The item position. By default add as last item -function StaticGrid:add(item, index) +function StaticGrid.add(self, item, index) index = index or ((self.last_index or 0) + 1) if self.nodes[index] then @@ -152,10 +173,10 @@ end --- Remove the item from the grid. Note that gui node will be not deleted --- @function static_grid:remove +-- @tparam StaticGrid self -- @tparam number index The grid node index to remove -- @tparam bool is_shift_nodes If true, will shift nodes left after index -function StaticGrid:remove(index, is_shift_nodes) +function StaticGrid.remove(self, index, is_shift_nodes) assert(self.nodes[index], "No grid item at given index " .. index) self.nodes[index] = nil @@ -168,15 +189,15 @@ function StaticGrid:remove(index, is_shift_nodes) self:_update() - self.on_add_item:trigger(self:get_context(), index) + self.on_remove_item:trigger(self:get_context(), index) self.on_change_items:trigger(self:get_context(), index) end --- Return grid content size --- @function static_grid:get_size +-- @tparam StaticGrid self -- @treturn vector3 The grid content size -function StaticGrid:get_size() +function StaticGrid.get_size(self) return vmath.vector3( self.border.z - self.border.x, self.border.y - self.border.w, @@ -185,9 +206,9 @@ end --- Return array of all node positions --- @function static_grid:get_all_pos +-- @tparam StaticGrid self -- @treturn vector3[] All grid node positions -function StaticGrid:get_all_pos() +function StaticGrid.get_all_pos(self) local result = {} for i, node in pairs(self.nodes) do table.insert(result, gui.get_position(node)) @@ -199,10 +220,10 @@ end --- Change set position function for grid nodes. It will call on -- update poses on grid elements. Default: gui.set_position --- @function static_grid:set_position_function +-- @tparam StaticGrid self -- @tparam function callback Function on node set position -- @treturn druid.static_grid Current grid instance -function StaticGrid:set_position_function(callback) +function StaticGrid.set_position_function(self, callback) self._set_position_function = callback or gui.set_position return self @@ -211,9 +232,9 @@ end --- Clear grid nodes array. GUI nodes will be not deleted! -- If you want to delete GUI nodes, use static_grid.nodes array before grid:clear --- @function static_grid:clear +-- @tparam StaticGrid self -- @treturn druid.static_grid Current grid instance -function StaticGrid:clear() +function StaticGrid.clear(self) self.border.x = 0 self.border.y = 0 self.border.w = 0 @@ -222,16 +243,18 @@ function StaticGrid:clear() self.nodes = {} self:_update() + self.on_clear:trigger(self:get_context()) + return self end --- Return elements offset for correct posing nodes. Correct posing at -- parent pivot node (0:0) with adjusting of node sizes and anchoring --- @function static_grid:_get_zero_offset +-- @tparam StaticGrid self -- @treturn vector3 The offset vector -- @local -function StaticGrid:_get_zero_offset() +function StaticGrid._get_zero_offset(self) -- zero offset: center pos - border size * anchor return vmath.vector3( -((self.border.x + self.border.z)/2 + (self.border.z - self.border.x) * self.pivot.x), @@ -242,10 +265,10 @@ end --- Update grid inner state --- @function static_grid:_update +-- @tparam StaticGrid self -- @tparam bool is_instant If true, node position update instantly, otherwise with set_position_function callback -- @local -function StaticGrid:_update(is_instant) +function StaticGrid._update(self, is_instant) self:_update_indexes() self:_update_borders() self:_update_pos(is_instant) @@ -253,9 +276,9 @@ end --- Update first and last indexes of grid nodes --- @function static_grid:_update_indexes +-- @tparam StaticGrid self -- @local -function StaticGrid:_update_indexes() +function StaticGrid._update_indexes(self) self.first_index = nil self.last_index = nil for index in pairs(self.nodes) do @@ -269,9 +292,9 @@ end --- Update grid content borders, recalculate min and max values --- @function static_grid:_update_borders +-- @tparam StaticGrid self -- @local -function StaticGrid:_update_borders() +function StaticGrid._update_borders(self) if not self.first_index then self.border = vmath.vector4(0) return @@ -298,10 +321,10 @@ end --- Update grid nodes position --- @function static_grid:_update_indexes +-- @tparam StaticGrid self -- @tparam bool is_instant If true, node position update instantly, otherwise with set_position_function callback -- @local -function StaticGrid:_update_pos(is_instant) +function StaticGrid._update_pos(self, is_instant) local zero_offset = self:_get_zero_offset() for i, node in pairs(self.nodes) do diff --git a/druid/base/swipe.lua b/druid/base/swipe.lua index 09a9eae..f248e64 100644 --- a/druid/base/swipe.lua +++ b/druid/base/swipe.lua @@ -1,16 +1,19 @@ --- Component to handle swipe gestures on node. -- Swipe will be triggered, if swipe was started and -- ended on one node --- @module druid.swipe +-- @module Swipe +-- @within BaseComponent +-- @alias druid.swipe ---- Components fields --- @table Fields --- @tparam node node Swipe node --- @tparam[opt] node click_zone Restriction zone +--- Swipe node +-- @tparam node node + +--- Restriction zone +-- @tparam[opt] node click_zone + +--- Trigger on swipe event(self, swipe_side, dist, delta_time +-- @tfield druid_event on_swipe) ---- Component events --- @table Events --- @tfield druid_event on_swipe Trigger on swipe event local Event = require("druid.event") local const = require("druid.const") @@ -65,11 +68,11 @@ end --- Component style params. -- You can override this component styles params in druid styles table -- or create your own style --- @table Style +-- @table style -- @tfield[opt=0.4] number SWIPE_TIME Maximum time for swipe trigger -- @tfield[opt=50] number SWIPE_THRESHOLD Minimum distance for swipe trigger -- @tfield[opt=false] bool SWIPE_TRIGGER_ON_MOVE If true, trigger on swipe moving, not only release action -function Swipe:on_style_change(style) +function Swipe.on_style_change(self, style) self.style = {} self.style.SWIPE_TIME = style.SWIPE_TIME or 0.4 self.style.SWIPE_THRESHOLD = style.SWIPE_THRESHOLD or 50 @@ -78,10 +81,10 @@ end --- Component init function --- @function swipe:init +-- @tparam Swipe self -- @tparam node node Gui node -- @tparam function on_swipe_callback Swipe callback for on_swipe_end event -function Swipe:init(node, on_swipe_callback) +function Swipe.init(self, node, on_swipe_callback) self._trigger_on_move = self.style.SWIPE_TRIGGER_ON_MOVE self.node = self:get_node(node) @@ -93,7 +96,7 @@ function Swipe:init(node, on_swipe_callback) end -function Swipe:on_input(action_id, action) +function Swipe.on_input(self, action_id, action) if action_id ~= const.ACTION_TOUCH then return false end @@ -126,16 +129,16 @@ function Swipe:on_input(action_id, action) end -function Swipe:on_input_interrupt() +function Swipe.on_input_interrupt(self) reset_swipe(self) end --- Strict swipe click area. Useful for -- restrict events outside stencil node --- @function swipe:set_click_zone +-- @tparam Swipe self -- @tparam node zone Gui node -function Swipe:set_click_zone(zone) +function Swipe.set_click_zone(self, zone) self.click_zone = self:get_node(zone) end diff --git a/druid/base/text.lua b/druid/base/text.lua index c5018cd..ff29f19 100644 --- a/druid/base/text.lua +++ b/druid/base/text.lua @@ -1,24 +1,43 @@ --- Component to handle all GUI texts. -- Druid text can adjust itself for text node size -- Text will never will be outside of his text size (even multiline) --- @module druid.text +-- @module Text +-- @within BaseComponent +-- @alias druid.text ---- Component events --- @table Events --- @tfield druid_event on_set_text On set text callback --- @tfield druid_event on_update_text_scale On adjust text size callback --- @tfield druid_event on_set_pivot On change pivot callback +--- On set text callback(self, text) +-- @tfield druid_event on_set_text + +--- On adjust text size callback(self, new_scale) +-- @tfield druid_event on_update_text_scale + +--- On change pivot callback(self, pivot) +-- @tfield druid_event on_set_pivot + +--- Text node +-- @tfield node node + +--- Current text position +-- @tfield vector3 pos + +--- Initial text node scale +-- @tfield vector3 start_scale + +--- Current text node scale +-- @tfield vector3 scale + +--- Initial text node size +-- @tfield vector3 start_size + +--- Current text node available are +-- @tfield vector3 text_area + +--- Current text size adjust settings +-- @tfield bool is_no_adjust + +--- Current text color +-- @tfield vector3 color ---- Component fields --- @table Fields --- @tfield node node Text node --- @tfield vector3 pos Current text position --- @tfield vector3 start_scale Initial text node scale --- @tfield vector3 scale Current text node scale --- @tfield vector3 start_size Initial text node size --- @tfield vector3 text_area Current text node available are --- @tfield bool is_no_adjust Current text size adjust settings --- @tfield vector3 color Current text color local Event = require("druid.event") local const = require("druid.const") @@ -77,11 +96,11 @@ end --- Component init function --- @function text:init +-- @tparam Text self -- @tparam node node Gui text node -- @tparam[opt] string value Initial text. Default value is node text from GUI scene. -- @tparam[opt] bool no_adjust If true, text will be not auto-adjust size -function Text:init(node, value, no_adjust) +function Text.init(self, node, value, no_adjust) self.node = self:get_node(node) self.pos = gui.get_position(self.node) @@ -107,15 +126,15 @@ function Text:init(node, value, no_adjust) end -function Text:on_layout_change() +function Text.on_layout_change(self) self:set_to(self.last_value) end --- Calculate text width with font with respect to trailing space --- @function text:get_text_width +-- @tparam Text self -- @tparam[opt] string text -function Text:get_text_width(text) +function Text.get_text_width(self, text) text = text or self.last_value local font = gui.get_font(self.node) local scale = gui.get_scale(self.node) @@ -134,9 +153,9 @@ end --- Set text to text field --- @function text:set_to +-- @tparam Text self -- @tparam string set_to Text for node -function Text:set_to(set_to) +function Text.set_to(self, set_to) self.last_value = set_to gui.set_text(self.node, set_to) @@ -149,27 +168,27 @@ end --- Set color --- @function text:set_color +-- @tparam Text self -- @tparam vector4 color Color for node -function Text:set_color(color) +function Text.set_color(self, color) self.color = color gui.set_color(self.node, color) end --- Set alpha --- @function text:set_alpha +-- @tparam Text self -- @tparam number alpha Alpha for node -function Text:set_alpha(alpha) +function Text.set_alpha(self, alpha) self.color.w = alpha gui.set_color(self.node, self.color) end --- Set scale --- @function text:set_scale +-- @tparam Text self -- @tparam vector3 scale Scale for node -function Text:set_scale(scale) +function Text.set_scale(self, scale) self.last_scale = scale gui.set_scale(self.node, scale) end @@ -177,9 +196,9 @@ end --- Set text pivot. Text will re-anchor inside -- his text area --- @function text:set_pivot +-- @tparam Text self -- @tparam gui.pivot pivot Gui pivot constant -function Text:set_pivot(pivot) +function Text.set_pivot(self, pivot) local prev_pivot = gui.get_pivot(self.node) local prev_offset = const.PIVOTS[prev_pivot] @@ -200,9 +219,9 @@ end --- Return true, if text with line break --- @function text:is_multiline +-- @tparam Text self -- @treturn bool Is text node with line break -function Text:is_multiline() +function Text.is_multiline(self) return gui.get_line_break(self.node) end diff --git a/druid/component.lua b/druid/component.lua index c58d0c4..f735edf 100644 --- a/druid/component.lua +++ b/druid/component.lua @@ -1,20 +1,20 @@ --- Basic class for all Druid components. -- To create you component, use `component.create` --- @module component +-- @module BaseComponent +-- @alias druid.base_component local const = require("druid.const") local class = require("druid.system.middleclass") --- @classmod Component -local Component = class("druid.component") +local BaseComponent = class("druid.component") --- Set current component style table. --- Invoke `on_style_change` on component, if exist. Component should handle +-- Invoke `on_style_change` on component, if exist. BaseComponent should handle -- their style changing and store all style params --- @function component:set_style --- @tparam table style Druid style module -function Component:set_style(druid_style) +-- @tparam BaseComponent self +-- @tparam table druid_style Druid style module +function BaseComponent.set_style(self, druid_style) self._meta.style = druid_style or const.EMPTY_TABLE local component_style = self._meta.style[self._component.name] or const.EMPTY_TABLE @@ -25,39 +25,39 @@ end --- Set current component template name --- @function component:set_template --- @tparam string template Component template name -function Component:set_template(template) +-- @tparam BaseComponent self +-- @tparam string template BaseComponent template name +function BaseComponent.set_template(self, template) self._meta.template = template end --- Set current component nodes --- @function component:set_nodes --- @tparam table nodes Component nodes table -function Component:set_nodes(nodes) +-- @tparam BaseComponent self +-- @tparam table nodes BaseComponent nodes table +function BaseComponent.set_nodes(self, nodes) self._meta.nodes = nodes end --- Get current component context --- @function component:get_context --- @treturn table Component context -function Component:get_context(context) +-- @tparam BaseComponent self +-- @treturn table BaseComponent context +function BaseComponent.get_context(self) return self._meta.context end --- Increase input priority in current input stack --- @function component:increase_input_priority -function Component:increase_input_priority() +-- @tparam BaseComponent self +function BaseComponent.increase_input_priority(self) self._meta.increased_input_priority = true end --- Reset input priority in current input stack --- @function component:reset_input_priority -function Component:reset_input_priority() +-- @tparam BaseComponent self +function BaseComponent.reset_input_priority(self) self._meta.increased_input_priority = false end @@ -66,10 +66,10 @@ end -- If component has nodes, node_or_name should be string -- It auto pick node by template name or from nodes by clone_tree -- if they was setup via component:set_nodes, component:set_template --- @function component:get_node +-- @tparam BaseComponent self -- @tparam string|node node_or_name Node name or node itself -- @treturn node Gui node -function Component:get_node(node_or_name) +function BaseComponent.get_node(self, node_or_name) local template_name = self:__get_template() or const.EMPTY_STRING local nodes = self:__get_nodes() @@ -94,28 +94,28 @@ end --- Return druid with context of calling component. -- Use it to create component inside of other components. --- @function component:get_druid +-- @tparam BaseComponent self -- @treturn Druid Druid instance with component context -function Component:get_druid() +function BaseComponent.get_druid(self) local context = { _context = self } return setmetatable(context, { __index = self._meta.druid }) end --- Return component name --- @function component:get_name +-- @tparam BaseComponent self -- @treturn string The component name -function Component:get_name() +function BaseComponent.get_name(self) return self._component.name end --- Set component input state. By default it enabled -- You can disable any input of component by this function --- @function component:set_input_enabled +-- @tparam BaseComponent self -- @tparam bool state The component input state --- @treturn Component Component itself -function Component:set_input_enabled(state) +-- @treturn BaseComponent BaseComponent itself +function BaseComponent.set_input_enabled(self, state) self._meta.input_enabled = state for index = 1, #self._meta.children do @@ -127,12 +127,12 @@ end --- Return the parent for current component --- @function component:get_parent_component --- @treturn Component|nil The druid component instance or nil -function Component:get_parent_component() +-- @tparam BaseComponent self +-- @treturn druid.base_component|nil The druid component instance or nil +function BaseComponent.get_parent_component(self) local context = self:get_context() - if context.isInstanceOf and context:isInstanceOf(Component) then + if context.isInstanceOf and context:isInstanceOf(BaseComponent) then return context end @@ -141,12 +141,12 @@ end --- Setup component context and his style table --- @function component:setup_component --- @tparam druid_instance table The parent druid instance --- @tparam context table Druid context. Usually it is self of script --- @tparam style table Druid style module --- @treturn component Component itself -function Component:setup_component(druid_instance, context, style) +-- @tparam BaseComponent self +-- @tparam table druid_instance The parent druid instance +-- @tparam table context Druid context. Usually it is self of script +-- @tparam table style Druid style module +-- @treturn component BaseComponent itself +function BaseComponent.setup_component(self, druid_instance, context, style) self._meta = { template = nil, context = nil, @@ -171,12 +171,12 @@ end --- Basic constructor of component. It will call automaticaly --- by `Component.static.create` --- @function component:initialize --- @tparam string name Component name +-- by `BaseComponent.static.create` +-- @tparam BaseComponent self +-- @tparam string name BaseComponent name -- @tparam[opt={}] table interest List of component's interest -- @local -function Component:initialize(name, interest) +function BaseComponent.initialize(self, name, interest) interest = interest or {} self._component = { @@ -186,55 +186,61 @@ function Component:initialize(name, interest) end -function Component:__tostring() +function BaseComponent.__tostring(self) return self._component.name end --- Set current component context --- @function component:__set_context +-- @tparam BaseComponent self -- @tparam table context Druid context. Usually it is self of script -function Component:__set_context(context) +-- @local +function BaseComponent.__set_context(self, context) self._meta.context = context end --- Get current component interests --- @function component:__get_interests +-- @tparam BaseComponent self -- @treturn table List of component interests -function Component:__get_interests() +-- @local +function BaseComponent.__get_interests(self) return self._component.interest end --- Get current component template name --- @function component:__get_template --- @treturn string Component template name -function Component:__get_template() +-- @tparam BaseComponent self +-- @treturn string BaseComponent template name +-- @local +function BaseComponent.__get_template(self) return self._meta.template end --- Get current component nodes --- @function component:__get_nodes --- @treturn table Component nodes table -function Component:__get_nodes() +-- @tparam BaseComponent self +-- @treturn table BaseComponent nodes table +-- @local +function BaseComponent.__get_nodes(self) return self._meta.nodes end --- Add child to component children list --- @function component:__add_children +-- @tparam BaseComponent self -- @tparam component children The druid component instance -function Component:__add_children(children) +-- @local +function BaseComponent.__add_children(self, children) table.insert(self._meta.children, children) end --- Remove child from component children list --- @function component:__remove_children +-- @tparam BaseComponent self -- @tparam component children The druid component instance -function Component:__remove_children(children) +-- @local +function BaseComponent.__remove_children(self, children) for i = #self._meta.children, 1, -1 do if self._meta.children[i] == children then table.remove(self._meta.children, i) @@ -245,19 +251,19 @@ end --- Create new component. It will inheritance from basic -- druid component. --- @function Component.create --- @tparam string name Component name +-- @tparam string name BaseComponent name -- @tparam[opt={}] table interest List of component's interest -function Component.static.create(name, interest) +-- @local +function BaseComponent.static.create(name, interest) -- Yea, inheritance here - local new_class = class(name, Component) + local new_class = class(name, BaseComponent) new_class.initialize = function(self) - Component.initialize(self, name, interest) + BaseComponent.initialize(self, name, interest) end return new_class end -return Component +return BaseComponent diff --git a/druid/const.lua b/druid/const.lua index 3437fe4..a16499e 100644 --- a/druid/const.lua +++ b/druid/const.lua @@ -1,6 +1,7 @@ --- Druid constants -- @local --- @module const +-- @module DruidConst +-- @alias druid_const local M = {} diff --git a/druid/event.lua b/druid/event.lua index a8ada46..0e9f624 100644 --- a/druid/event.lua +++ b/druid/event.lua @@ -1,16 +1,16 @@ --- Lua event small library --- @module druid_event +-- @module DruidEvent +-- @alias druid_event local class = require("druid.system.middleclass") --- @class DruidEvent -local Event = class("druid.event") +local DruidEvent = class("druid.event") --- Event constructur --- @function Event +-- @tparam DruidEvent self -- @tparam function initial_callback Subscribe the callback on new event, if callback exist -function Event:initialize(initial_callback) +function DruidEvent.initialize(self, initial_callback) self._callbacks = {} if initial_callback then @@ -20,9 +20,9 @@ end --- Subscribe callback on event --- @function event:subscribe +-- @tparam DruidEvent self -- @tparam function callback Callback itself -function Event:subscribe(callback) +function DruidEvent.subscribe(self, callback) assert(type(self) == "table", "You should subscribe to event with : syntax") assert(type(callback) == "function", "Callback should be function") @@ -33,9 +33,9 @@ end --- Unsubscribe callback on event --- @function event:unsubscribe +-- @tparam DruidEvent self -- @tparam function callback Callback itself -function Event:unsubscribe(callback) +function DruidEvent.unsubscribe(self, callback) for i = 1, #self._callbacks do if self._callbacks[i] == callback then table.remove(self._callbacks, i) @@ -46,28 +46,28 @@ end --- Return true, if event have at lease one handler --- @function event:is_exist +-- @tparam DruidEvent self -- @treturn bool True if event have handlers -function Event:is_exist() +function DruidEvent.is_exist(self) return #self._callbacks > 0 end --- Clear the all event handlers --- @function event:clear -function Event:clear() +-- @tparam DruidEvent self +function DruidEvent.clear(self) self._callbacks = {} end --- Trigger the event and call all subscribed callbacks --- @function event:trigger --- @param ... All event params -function Event:trigger(...) +-- @tparam DruidEvent self +-- @tparam any ... All event params +function DruidEvent.trigger(self, ...) for i = 1, #self._callbacks do self._callbacks[i](...) end end -return Event +return DruidEvent diff --git a/druid/extended/checkbox.lua b/druid/extended/checkbox.lua index bfe7c6e..24b5e56 100644 --- a/druid/extended/checkbox.lua +++ b/druid/extended/checkbox.lua @@ -1,15 +1,20 @@ --- Druid checkbox component --- @module druid.checkbox +-- @module Checkbox +-- @within BaseComponent +-- @alias druid.checkbox ---- Component events --- @table Events --- @tfield druid_event on_change_state On change state callback +--- On change state callback(self, state) +-- @tfield druid_event on_change_state + +--- Visual node +-- @tfield node node + +--- Button trigger node +-- @tfield[opt=node] node click_node + +--- Button component from click_node +-- @tfield Button button ---- Component fields --- @table Fields --- @tfield node node Visual node --- @tfield[opt=node] node click_node Button trigger node --- @tfield druid.button button Button component from click_node local const = require("druid.const") local Event = require("druid.event") @@ -26,9 +31,9 @@ end --- Component style params. -- You can override this component styles params in druid styles table -- or create your own style --- @table Style +-- @table style -- @tfield function on_change_state (self, node, state) -function Checkbox:on_style_change(style) +function Checkbox.on_style_change(self, style) self.style = {} self.style.on_change_state = style.on_change_state or function(_, node, state) @@ -38,11 +43,11 @@ end --- Component init function --- @function checkbox:init +-- @tparam Checkbox self -- @tparam node node Gui node -- @tparam function callback Checkbox callback --- @tparam[opt=node] node click node Trigger node, by default equals to node -function Checkbox:init(node, callback, click_node) +-- @tparam[opt=node] node click_node Trigger node, by default equals to node +function Checkbox.init(self, node, callback, click_node) self.druid = self:get_druid() self.node = self:get_node(node) self.click_node = self:get_node(click_node) @@ -54,16 +59,16 @@ function Checkbox:init(node, callback, click_node) end -function Checkbox:on_layout_change() +function Checkbox.on_layout_change(self) self:set_state(self.state, true) end --- Set checkbox state --- @function checkbox:set_state +-- @tparam Checkbox self -- @tparam bool state Checkbox state -- @tparam bool is_silent Don't trigger on_change_state if true -function Checkbox:set_state(state, is_silent) +function Checkbox.set_state(self, state, is_silent) self.state = state self.style.on_change_state(self, self.node, state) @@ -74,9 +79,9 @@ end --- Return checkbox state --- @function checkbox:get_state +-- @tparam Checkbox self -- @treturn bool Checkbox state -function Checkbox:get_state() +function Checkbox.get_state(self) return self.state end diff --git a/druid/extended/checkbox_group.lua b/druid/extended/checkbox_group.lua index 376c712..a801a89 100644 --- a/druid/extended/checkbox_group.lua +++ b/druid/extended/checkbox_group.lua @@ -1,13 +1,14 @@ --- Checkbox group module --- @module druid.checkbox_group +-- @module CheckboxGroup +-- @within BaseComponent +-- @alias druid.checkbox_group ---- Component events --- @table Events --- @tfield druid_event on_checkbox_click On any checkbox click +--- On any checkbox click callback(self, index) +-- @tfield druid_event on_checkbox_click + +--- Array of checkbox components +-- @tfield table checkboxes ---- Component fields --- @table Fields --- @tfield table checkboxes Array of checkbox components local Event = require("druid.event") local component = require("druid.component") @@ -16,11 +17,11 @@ local CheckboxGroup = component.create("checkbox_group") --- Component init function --- @function checkbox_group:init --- @tparam node[] node Array of gui node +-- @tparam CheckboxGroup self +-- @tparam node[] nodes Array of gui node -- @tparam function callback Checkbox callback --- @tparam[opt=node] node[] click node Array of trigger nodes, by default equals to nodes -function CheckboxGroup:init(nodes, callback, click_nodes) +-- @tparam[opt=node] node[] click_nodes Array of trigger nodes, by default equals to nodes +function CheckboxGroup.init(self, nodes, callback, click_nodes) self.druid = self:get_druid() self.checkboxes = {} @@ -38,9 +39,9 @@ end --- Set checkbox group state --- @function checkbox_group:set_state +-- @tparam CheckboxGroup self -- @tparam bool[] indexes Array of checkbox state -function CheckboxGroup:set_state(indexes) +function CheckboxGroup.set_state(self, indexes) for i = 1, #indexes do if self.checkboxes[i] then self.checkboxes[i]:set_state(indexes[i], true) @@ -50,9 +51,9 @@ end --- Return checkbox group state --- @function checkbox_group:get_state +-- @tparam CheckboxGroup self -- @treturn bool[] Array if checkboxes state -function CheckboxGroup:get_state() +function CheckboxGroup.get_state(self) local result = {} for i = 1, #self.checkboxes do diff --git a/druid/extended/dynamic_grid.lua b/druid/extended/dynamic_grid.lua index e009459..efa6f0a 100644 --- a/druid/extended/dynamic_grid.lua +++ b/druid/extended/dynamic_grid.lua @@ -1,22 +1,41 @@ --- Component to handle placing components in row --- @module druid.dynamic_grid +-- @module DynamicGrid +-- @within BaseComponent +-- @alias druid.dynamic_grid ---- Component events --- @table Events --- @tfield druid_event on_add_item On item add callback --- @tfield druid_event on_remove_item On item remove callback --- @tfield druid_event on_change_items On item add or remove callback --- @tfield druid_event on_clear On grid clear callback --- @tfield druid_event on_update_positions On update item positions callback +--- On item add callback(self, node, index) +-- @tfield druid_event on_add_item + +--- On item remove callback(self, index) +-- @tfield druid_event on_remove_item + +--- On item add or remove callback(self, index) +-- @tfield druid_event on_change_items + +--- On grid clear callback(self) +-- @tfield druid_event on_clear + +--- On update item positions callback(self) +-- @tfield druid_event on_update_positions + +--- Parent gui node +-- @tfield node parent + +--- List of all grid nodes +-- @tfield node[] nodes + +--- The first index of node in grid +-- @tfield number first_index + +--- The last index of node in grid +-- @tfield number last_index + +--- Item size +-- @tfield vector3 node_size + +--- The size of item content +-- @tfield vector4 border ---- Component fields --- @table Fields --- @tfield node parent Parent gui node --- @tfield node[] nodes List of all grid nodes --- @tfield number first_index The first index of node in grid --- @tfield number last_index The last index of node in grid --- @tfield vector3 node_size Item size --- @tfield vector4 border The size of item content local const = require("druid.const") local Event = require("druid.event") @@ -42,9 +61,9 @@ local AVAILABLE_PIVOTS = { --- Component init function --- @function dynamic_grid:init +-- @tparam DynamicGrid self -- @tparam node parent The gui node parent, where items will be placed -function DynamicGrid:init(parent) +function DynamicGrid.init(self, parent) self.parent = self:get_node(parent) local parent_pivot = gui.get_pivot(self.parent) @@ -67,17 +86,18 @@ function DynamicGrid:init(parent) end -function DynamicGrid:on_layout_change() +function DynamicGrid.on_layout_change(self) self:_update(true) end --- Return pos for grid node index --- @function dynamic_grid:get_pos +-- @tparam DynamicGrid self -- @tparam number index The grid element index -- @tparam node node The node to be placed +-- @tparam[opt] number origin_index Index of nearby node -- @treturn vector3 Node position -function DynamicGrid:get_pos(index, node, origin_index) +function DynamicGrid.get_pos(self, index, node, origin_index) local origin_node = self.nodes[origin_index] -- If anchor node is not exist, check around nodes @@ -113,11 +133,11 @@ end --- Add new node to the grid --- @function dynamic_grid:add +-- @tparam DynamicGrid self -- @tparam node node Gui node -- @tparam[opt] number index The node position. By default add as last node -- @tparam[opt=false] bool is_shift_left If true, shift all nodes to the left, otherwise shift nodes to the right -function DynamicGrid:add(node, index, is_shift_left) +function DynamicGrid.add(self, node, index, is_shift_left) local delta = is_shift_left and -1 or 1 -- By default add node at end @@ -155,10 +175,10 @@ end --- Remove the item from the grid. Note that gui node will be not deleted --- @function dynamic_grid:remove +-- @tparam DynamicGrid self -- @tparam number index The grid node index to remove -- @tparam[opt=false] bool is_shift_left If true, shift all nodes to the left, otherwise shift nodes to the right -function DynamicGrid:remove(index, is_shift_left) +function DynamicGrid.remove(self, index, is_shift_left) local delta = is_shift_left and -1 or 1 assert(self.nodes[index], "No grid item at given index " .. index) @@ -178,15 +198,16 @@ function DynamicGrid:remove(index, is_shift_left) -- Sync grid data self:_update() - self.on_add_item:trigger(self:get_context(), index) + self.on_remove_item:trigger(self:get_context(), index) self.on_change_items:trigger(self:get_context(), index) end --- Return grid content size --- @function dynamic_grid:get_size +-- @tparam DynamicGrid self +-- @tparam vector3 border -- @treturn vector3 The grid content size -function DynamicGrid:get_size(border) +function DynamicGrid.get_size(self, border) border = border or self.border return vmath.vector3( border.z - border.x, @@ -196,10 +217,10 @@ end --- Return grid index by node --- @function dynamic_grid:get_index_by_node +-- @tparam DynamicGrid self -- @tparam node node The gui node in the grid -- @treturn number The node index -function DynamicGrid:get_index_by_node(node) +function DynamicGrid.get_index_by_node(self, node) for index, node_info in pairs(self.nodes) do if node == node_info.node then return index @@ -211,9 +232,9 @@ end --- Return array of all node positions --- @function dynamic_grid:get_all_pos +-- @tparam DynamicGrid self -- @treturn vector3[] All grid node positions -function DynamicGrid:get_all_pos() +function DynamicGrid.get_all_pos(self) local result = {} for i, node in pairs(self.nodes) do table.insert(result, gui.get_position(node)) @@ -225,10 +246,10 @@ end --- Change set position function for grid nodes. It will call on -- update poses on grid elements. Default: gui.set_position --- @function dynamic_grid:set_position_function +-- @tparam DynamicGrid self -- @tparam function callback Function on node set position -- @treturn druid.dynamic_grid Current grid instance -function DynamicGrid:set_position_function(callback) +function DynamicGrid.set_position_function(self, callback) self._set_position_function = callback or gui.set_position return self end @@ -236,16 +257,19 @@ end --- Clear grid nodes array. GUI nodes will be not deleted! -- If you want to delete GUI nodes, use dynamic_grid.nodes array before grid:clear --- @function dynamic_grid:clear +-- @tparam DynamicGrid self -- @treturn druid.dynamic_grid Current grid instance -function DynamicGrid:clear() +function DynamicGrid.clear(self) self.nodes = {} self:_update() + + self.on_clear:trigger(self:get_context()) + return self end -function DynamicGrid:_add_node(node, index, origin_index) +function DynamicGrid._add_node(self, node, index, origin_index) self.nodes[index] = { node = node, pos = self:get_pos(index, node, origin_index), @@ -260,10 +284,10 @@ end --- Update grid inner state --- @function dynamic_grid:_update +-- @tparam DynamicGrid self -- @tparam bool is_instant If true, node position update instantly, otherwise with set_position_function callback -- @local -function DynamicGrid:_update(is_instant) +function DynamicGrid._update(self, is_instant) self:_update_indexes() self:_update_borders() self:_update_pos(is_instant) @@ -271,9 +295,9 @@ end --- Update first and last indexes of grid nodes --- @function dynamic_grid:_update_indexes +-- @tparam DynamicGrid self -- @local -function DynamicGrid:_update_indexes() +function DynamicGrid._update_indexes(self) self.first_index = nil self.last_index = nil for index in pairs(self.nodes) do @@ -287,9 +311,9 @@ end --- Update grid content borders, recalculate min and max values --- @function dynamic_grid:_update_borders +-- @tparam DynamicGrid self -- @local -function DynamicGrid:_update_borders() +function DynamicGrid._update_borders(self) if not self.first_index then self.border = vmath.vector4(0) return @@ -316,10 +340,10 @@ end --- Update grid nodes position --- @function dynamic_grid:_update_indexes +-- @tparam DynamicGrid self -- @tparam bool is_instant If true, node position update instantly, otherwise with set_position_function callback -- @local -function DynamicGrid:_update_pos(is_instant) +function DynamicGrid._update_pos(self, is_instant) local offset = self:_get_zero_offset() for index, node in pairs(self.nodes) do @@ -334,7 +358,7 @@ function DynamicGrid:_update_pos(is_instant) end -function DynamicGrid:_get_next_node_pos(origin_node_index, new_node, place_side) +function DynamicGrid._get_next_node_pos(self, origin_node_index, new_node, place_side) local node = self.nodes[origin_node_index] local new_node_size = self:_get_node_size(new_node) @@ -353,17 +377,17 @@ function DynamicGrid:_get_next_node_pos(origin_node_index, new_node, place_side) end -function DynamicGrid:_get_node_size(node) +function DynamicGrid._get_node_size(self, node) return vmath.mul_per_elem(gui.get_size(node), gui.get_scale(node)) end --- Return elements offset for correct posing nodes. Correct posing at -- parent pivot node (0:0) with adjusting of node sizes and anchoring --- @function dynamic_grid:_get_zero_offset +-- @tparam DynamicGrid self -- @treturn vector3 The offset vector -- @local -function DynamicGrid:_get_zero_offset() +function DynamicGrid._get_zero_offset(self) -- zero offset: center pos - border size * anchor return vmath.vector3( -((self.border.x + self.border.z)/2 + (self.border.z - self.border.x) * self.pivot.x), @@ -373,7 +397,7 @@ end --- Return side vector to correct node shifting -function DynamicGrid:_get_side_vector(side, is_forward) +function DynamicGrid._get_side_vector(self, side, is_forward) if side == const.SIDE.X then return is_forward and SIDE_VECTORS.RIGHT or SIDE_VECTORS.LEFT end diff --git a/druid/extended/input.lua b/druid/extended/input.lua index b70608c..0ea8db5 100644 --- a/druid/extended/input.lua +++ b/druid/extended/input.lua @@ -1,26 +1,49 @@ --- Druid input text component. -- Carry on user text input -- @author Part of code from Britzl gooey input component --- @module druid.input +-- @module Input +-- @within BaseComponent +-- @alias druid.input ---- Component events --- @table Events --- @tfield druid_event on_input_select (self, button_node) On input field select callback --- @tfield druid_event on_input_unselect (self, button_node) On input field unselect callback --- @tfield druid_event on_input_text (self, input_text) On input field text change callback --- @tfield druid_event on_input_empty (self, input_text) On input field text change to empty string callback --- @tfield druid_event on_input_full (self, input_text) On input field text change to max length string callback --- @tfield druid_event on_input_wrong (self, params, button_instance) On trying user input with not allowed character callback +--- On input field select callback(self, button_node) +-- @tfield druid_event on_input_select + +--- On input field unselect callback(self, button_node) +-- @tfield druid_event on_input_unselect + +--- On input field text change callback(self, input_text) +-- @tfield druid_event on_input_text + +--- On input field text change to empty string callback(self, input_text) +-- @tfield druid_event on_input_empty + +--- On input field text change to max length string callback(self, input_text) +-- @tfield druid_event on_input_full + +--- On trying user input with not allowed character callback(self, params, button_instance) +-- @tfield druid_event on_input_wrong + +--- Text component +-- @tfield druid.text text + +--- Button component +-- @tfield druid.button button + +--- Is current input selected now +-- @tfield bool is_selected + +--- Is current input is empty now +-- @tfield bool is_empty + +--- Max length for input text +-- @tfield[opt] number max_length + +--- Pattern matching for user input +-- @tfield[opt] string allowerd_characters + +--- Gui keyboard type for input field +-- @tfield number keyboard_type ---- Component fields --- @table Fields --- @tfield druid.text text Text component --- @tfield druid.button button Button component --- @tfield bool is_selected Is current input selected now --- @tfield bool is_empty Is current input is empty now --- @tfield[opt] number max_length Max length for input text --- @tfield[opt] string allowerd_characters Pattern matching for user input --- @tfield number keyboard_type Gui keyboard type for input field local Event = require("druid.event") local const = require("druid.const") @@ -90,14 +113,14 @@ end --- Component style params. -- You can override this component styles params in druid styles table -- or create your own style --- @table Style +-- @table style -- @tfield[opt=false] bool IS_LONGTAP_ERASE Is long tap will erase current input data -- @tfield[opt=*] string MASK_DEFAULT_CHAR Default character mask for password input -- @tfield function on_select (self, button_node) Callback on input field selecting -- @tfield function on_unselect (self, button_node) Callback on input field unselecting -- @tfield function on_input_wrong (self, button_node) Callback on wrong user input -- @tfield table button_style Custom button style for input node -function Input:on_style_change(style) +function Input.on_style_change(self, style) self.style = {} self.style.IS_LONGTAP_ERASE = style.IS_LONGTAP_ERASE or false @@ -115,7 +138,7 @@ function Input:on_style_change(style) end -function Input:init(click_node, text_node, keyboard_type) +function Input.init(self, click_node, text_node, keyboard_type) self.druid = self:get_druid(self) self.text = self.druid:new_text(text_node) @@ -149,7 +172,7 @@ function Input:init(click_node, text_node, keyboard_type) end -function Input:on_input(action_id, action) +function Input.on_input(self, action_id, action) if self.selected then local input_text = nil if action_id == const.ACTION_TEXT then @@ -213,20 +236,20 @@ function Input:on_input(action_id, action) end -function Input:on_focus_lost() +function Input.on_focus_lost(self) unselect(self) end -function Input:on_input_interrupt() +function Input.on_input_interrupt(self) -- unselect(self) end --- Set text for input field --- @function input:set_text +-- @tparam Input self -- @tparam string input_text The string to apply for input field -function Input:set_text(input_text) +function Input.set_text(self, input_text) -- Case when update with marked text if input_text then self.value = input_text @@ -271,19 +294,19 @@ end --- Return current input field text --- @function input:get_text +-- @tparam Input self -- @treturn string The current input field text -function Input:get_text() +function Input.get_text(self) return self.value .. self.marked_value end --- Set maximum length for input field. -- Pass nil to make input field unliminted (by default) --- @function input:set_max_length +-- @tparam Input self -- @tparam number max_length Maximum length for input text field -- @treturn druid.input Current input instance -function Input:set_max_length(max_length) +function Input.set_max_length(self, max_length) self.max_length = max_length return self end @@ -292,18 +315,18 @@ end --- Set allowed charaters for input field. -- See: https://defold.com/ref/stable/string/ -- ex: [%a%d] for alpha and numeric --- @function input:set_allowerd_characters +-- @tparam Input self -- @tparam string characters Regulax exp. for validate user input -- @treturn druid.input Current input instance -function Input:set_allowed_characters(characters) +function Input.set_allowed_characters(self, characters) self.allowed_characters = characters return self end --- Reset current input selection and return previous value --- @function input:reset_changes -function Input:reset_changes() +-- @tparam Input self +function Input.reset_changes(self) self:set_text(self.previous_value) unselect(self) end diff --git a/druid/extended/lang_text.lua b/druid/extended/lang_text.lua index 61d345f..b51992c 100644 --- a/druid/extended/lang_text.lua +++ b/druid/extended/lang_text.lua @@ -1,14 +1,15 @@ --- Component to handle all GUI texts -- Good working with localization system --- @module druid.lang_text +-- @module LangText +-- @within BaseComponent +-- @alias druid.lang_text ---- Component events --- @table Events --- @tfield druid_event on_change On change text callback +--- On change text callback +-- @tfield druid_event on_change + +--- The text component +-- @tfield Text text ---- Component fields --- @table Fields --- @tfield druid.text text The text component local Event = require("druid.event") local const = require("druid.const") @@ -19,11 +20,11 @@ local LangText = component.create("lang_text", { const.ON_LANGUAGE_CHANGE }) --- Component init function --- @function lang_text:init +-- @tparam LangText self -- @tparam node node The text node -- @tparam string locale_id Default locale id -- @tparam bool no_adjust If true, will not correct text size -function LangText:init(node, locale_id, no_adjust) +function LangText.init(self, node, locale_id, no_adjust) self.druid = self:get_druid() self.text = self.druid:new_text(node, locale_id, no_adjust) self.last_locale_args = {} @@ -36,7 +37,7 @@ function LangText:init(node, locale_id, no_adjust) end -function LangText:on_language_change() +function LangText.on_language_change(self) if self.last_locale then self:translate(self.last_locale, unpack(self.last_locale_args)) end @@ -44,9 +45,9 @@ end --- Setup raw text to lang_text component --- @function lang_text:set_to +-- @tparam LangText self -- @tparam string text Text for text node -function LangText:set_to(text) +function LangText.set_to(self, text) self.last_locale = false self.text:set_to(text) self.on_change:trigger() @@ -54,9 +55,9 @@ end --- Translate the text by locale_id --- @function lang_text:translate +-- @tparam LangText self -- @tparam string locale_id Locale id -function LangText:translate(locale_id, ...) +function LangText.translate(self, locale_id, ...) self.last_locale_args = {...} self.last_locale = locale_id or self.last_locale self.text:set_to(settings.get_text(self.last_locale, ...)) diff --git a/druid/extended/progress.lua b/druid/extended/progress.lua index 2a343ba..fb257e1 100644 --- a/druid/extended/progress.lua +++ b/druid/extended/progress.lua @@ -1,19 +1,30 @@ --- Basic progress bar component. -- For correct progress bar init it should be in max size from gui --- @module druid.progress +-- @module Progress +-- @within BaseComponent +-- @alias druid.progress ---- Component events --- @table Events --- @tfield druid_event on_change On progress bar change callback +--- On progress bar change callback(self, new_value) +-- @tfield druid_event on_change + +--- Progress bar fill node +-- @tfield node node + +--- The progress bar direction +-- @tfield string key + +--- Current progress bar scale +-- @tfield vector3 scale + +--- Current progress bar size +-- @tfield vector3 size + +--- Maximum size of progress bar +-- @tfield number max_size + +--- Progress bar slice9 settings +-- @tfield vector4 slice ---- Component fields --- @table Fields --- @tfield node node Progress bar fill node --- @tfield string key The progress bar direction --- @tfield vector3 scale Current progress bar scale --- @tfield vector3 size Current progress bar size --- @tfield number max_size Maximum size of progress bar --- @tfield vector4 slice Progress bar slice9 settings local Event = require("druid.event") local const = require("druid.const") @@ -68,10 +79,10 @@ end --- Component style params. -- You can override this component styles params in druid styles table -- or create your own style --- @table Style +-- @table style -- @tfield[opt=5] number SPEED Progress bas fill rate. More -> faster -- @tfield[opt=0.005] number MIN_DELTA Minimum step to fill progress bar -function Progress:on_style_change(style) +function Progress.on_style_change(self, style) self.style = {} self.style.SPEED = style.SPEED or 5 self.style.MIN_DELTA = style.MIN_DELTA or 0.005 @@ -79,11 +90,11 @@ end --- Component init function --- @function progress:init +-- @tparam Progress self -- @tparam string|node node Progress bar fill node or node name -- @tparam string key Progress bar direction: const.SIDE.X or const.SIDE.Y -- @tparam[opt=1] number init_value Initial value of progress bar -function Progress:init(node, key, init_value) +function Progress.init(self, node, key, init_value) assert(key == const.SIDE.X or const.SIDE.Y, "Progress bar key should be 'x' or 'y'") self.prop = hash("scale."..key) @@ -106,12 +117,12 @@ function Progress:init(node, key, init_value) end -function Progress:on_layout_change() +function Progress.on_layout_change(self) self:set_to(self.last_value) end -function Progress:update(dt) +function Progress.update(self, dt) if self.target then local prev_value = self.last_value local step = math.abs(self.last_value - self.target) * (self.style.SPEED*dt) @@ -132,50 +143,50 @@ end --- Fill a progress bar and stop progress animation --- @function progress:fill -function Progress:fill() +-- @tparam Progress self +function Progress.fill(self) set_bar_to(self, 1, true) end --- Empty a progress bar --- @function progress:empty -function Progress:empty() +-- @tparam Progress self +function Progress.empty(self) set_bar_to(self, 0, true) end --- Instant fill progress bar to value --- @function progress:set_to +-- @tparam Progress self -- @tparam number to Progress bar value, from 0 to 1 -function Progress:set_to(to) +function Progress.set_to(self, to) set_bar_to(self, to) end --- Return current progress bar value --- @function progress:get -function Progress:get() +-- @tparam Progress self +function Progress.get(self) return self.last_value end --- Set points on progress bar to fire the callback --- @function progress:set_steps +-- @tparam Progress self -- @tparam number[] steps Array of progress bar values -- @tparam function callback Callback on intersect step value -- @usage progress:set_steps({0, 0.3, 0.6, 1}, function(self, step) end) -function Progress:set_steps(steps, callback) +function Progress.set_steps(self, steps, callback) self.steps = steps self.step_callback = callback end --- Start animation of a progress bar --- @function progress:to +-- @tparam Progress self -- @tparam number to value between 0..1 -- @tparam[opt] function callback Callback on animation ends -function Progress:to(to, callback) +function Progress.to(self, to, callback) to = helper.clamp(to, 0, 1) -- cause of float error local value = helper.round(to, 5) diff --git a/druid/extended/radio_group.lua b/druid/extended/radio_group.lua index 75be888..9bdbd9c 100644 --- a/druid/extended/radio_group.lua +++ b/druid/extended/radio_group.lua @@ -1,13 +1,14 @@ --- Radio group module --- @module druid.radio_group +-- @module RadioGroup +-- @within BaseComponent +-- @alias druid.radio_group ---- Component events --- @table Events --- @tfield druid_event on_radio_click On any checkbox click +--- On any checkbox click +-- @tfield druid_event on_radio_click + +--- Array of checkbox components +-- @tfield Checkbox[] checkboxes ---- Component fields --- @table Fields --- @tfield table checkboxes Array of checkbox components local Event = require("druid.event") local component = require("druid.component") @@ -25,11 +26,11 @@ end --- Component init function --- @function radio_group:init --- @tparam node[] node Array of gui node +-- @tparam RadioGroup self +-- @tparam node[] nodes Array of gui node -- @tparam function callback Radio callback --- @tparam[opt=node] node[] click node Array of trigger nodes, by default equals to nodes -function RadioGroup:init(nodes, callback, click_nodes) +-- @tparam[opt=node] node[] click_nodes Array of trigger nodes, by default equals to nodes +function RadioGroup.init(self, nodes, callback, click_nodes) self.druid = self:get_druid() self.checkboxes = {} @@ -47,17 +48,17 @@ end --- Set radio group state --- @function radio_group:set_state +-- @tparam RadioGroup self -- @tparam number index Index in radio group -function RadioGroup:set_state(index) +function RadioGroup.set_state(self, index) on_checkbox_click(self, index) end --- Return radio group state --- @function radio_group:get_state +-- @tparam RadioGroup self -- @treturn number Index in radio group -function RadioGroup:get_state() +function RadioGroup.get_state(self) local result = -1 for i = 1, #self.checkboxes do diff --git a/druid/extended/slider.lua b/druid/extended/slider.lua index 2661927..97b306b 100644 --- a/druid/extended/slider.lua +++ b/druid/extended/slider.lua @@ -1,20 +1,35 @@ --- Druid slider component --- @module druid.slider +-- @module Slider +-- @within BaseComponent +-- @alias druid.slider ---- Component events --- @table Events --- @tfield druid_event on_change_value On change value callback +--- On change value callback(self, value) +-- @tfield druid_event on_change_value + +--- Slider pin node +-- @tfield node node + +--- Start pin node position +-- @tfield vector3 start_pos + +--- Current pin node position +-- @tfield vector3 pos + +--- Targer pin node position +-- @tfield vector3 target_pos + +--- End pin node position +-- @tfield vector3 end_pos + +--- Length between start and end position +-- @tfield number dist + +--- Current drag state +-- @tfield bool is_drag + +--- Current slider value +-- @tfield number value ---- Component fields --- @table Fields --- @tfield node node Slider pin node --- @tfield vector3 start_pos Start pin node position --- @tfield vector3 pos Current pin node position --- @tfield vector3 target_pos Targer pin node position --- @tfield vector3 end_pos End pin node position --- @tfield number dist Length between start and end position --- @tfield bool is_drag Current drag state --- @tfield number value Current slider value local Event = require("druid.event") @@ -37,11 +52,11 @@ end --- Component init function --- @function slider:init +-- @tparam Slider self -- @tparam node node Gui pin node -- @tparam vector3 end_pos The end position of slider -- @tparam[opt] function callback On slider change callback -function Slider:init(node, end_pos, callback) +function Slider.init(self, node, end_pos, callback) self.node = self:get_node(node) self.start_pos = gui.get_position(self.node) @@ -59,12 +74,12 @@ function Slider:init(node, end_pos, callback) end -function Slider:on_layout_change() +function Slider.on_layout_change(self) self:set(self.value, true) end -function Slider:on_input(action_id, action) +function Slider.on_input(self, action_id, action) if action_id ~= const.ACTION_TOUCH then return false end @@ -130,10 +145,10 @@ end --- Set value for slider --- @function slider:set +-- @tparam Slider self -- @tparam number value Value from 0 to 1 -- @tparam[opt] bool is_silent Don't trigger event if true -function Slider:set(value, is_silent) +function Slider.set(self, value, is_silent) value = helper.clamp(value, 0, 1) set_position(self, value) self.value = value @@ -145,10 +160,10 @@ end --- Set slider steps. Pin node will -- apply closest step position --- @function slider:set_steps +-- @tparam Slider self -- @tparam number[] steps Array of steps -- @usage slider:set_steps({0, 0.2, 0.6, 1}) -function Slider:set_steps(steps) +function Slider.set_steps(self, steps) self.steps = steps end diff --git a/druid/extended/timer.lua b/druid/extended/timer.lua index 34b6b98..5ae1ba8 100644 --- a/druid/extended/timer.lua +++ b/druid/extended/timer.lua @@ -1,20 +1,31 @@ --- Component to handle GUI timers. -- Timer updating by game delta time. If game is not focused - -- timer will be not updated. --- @module druid.timer +-- @module Timer +-- @within BaseComponent +-- @alias druid.timer ---- Component events --- @table Events --- @tfield druid_event on_tick On timer tick callback. Fire every second --- @tfield druid_event on_set_enabled On timer change enabled state callback --- @tfield druid_event on_timer_end On timer end callback +--- On timer tick. Fire every second callback(self, value) +-- @tfield druid_event on_tick + +--- On timer change enabled state callback(self, is_enabled) +-- @tfield druid_event on_set_enabled + +--- On timer end callback +-- @tfield druid_event on_timer_end(self, Timer) + +--- Trigger node +-- @tfield node node + +--- Initial timer value +-- @tfield number from + +--- Target timer value +-- @tfield number target + +--- Current timer value +-- @tfield number value ---- Component fields --- @table Fields --- @tfield node node Trigger node --- @tfield number from Initial timer value --- @tfield number target Target timer value --- @tfield number value Current timer value local Event = require("druid.event") local const = require("druid.const") @@ -26,12 +37,12 @@ local Timer = component.create("timer", { const.ON_UPDATE }) --- Component init function --- @function timer:init +-- @tparam Timer self -- @tparam node node Gui text node -- @tparam number seconds_from Start timer value in seconds -- @tparam[opt=0] number seconds_to End timer value in seconds -- @tparam[opt] function callback Function on timer end -function Timer:init(node, seconds_from, seconds_to, callback) +function Timer.init(self, node, seconds_from, seconds_to, callback) self.node = self:get_node(node) seconds_from = math.max(seconds_from, 0) seconds_to = math.max(seconds_to or 0, 0) @@ -52,7 +63,7 @@ function Timer:init(node, seconds_from, seconds_to, callback) end -function Timer:update(dt) +function Timer.update(self, dt) if not self.is_on then return end @@ -75,18 +86,18 @@ function Timer:update(dt) end --- Set text to text field --- @function timer:set_to +-- @tparam Timer self -- @tparam number set_to Value in seconds -function Timer:set_to(set_to) +function Timer.set_to(self, set_to) self.last_value = set_to gui.set_text(self.node, formats.second_string_min(set_to)) end --- Called when update --- @function timer:set_state +-- @tparam Timer self -- @tparam bool is_on Timer enable state -function Timer:set_state(is_on) +function Timer.set_state(self, is_on) self.is_on = is_on self.on_set_enabled:trigger(self:get_context(), is_on) @@ -94,10 +105,10 @@ end --- Set time interval --- @function timer:set_interval +-- @tparam Timer self -- @tparam number from Start time in seconds -- @tparam number to Target time in seconds -function Timer:set_interval(from, to) +function Timer.set_interval(self, from, to) self.from = from self.value = from self.temp = 0 diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index e8f4cd9..fba35bf 100644 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -7,24 +7,26 @@ -- end -- -- Learn Druid instance function here --- @module druid_instance --- @see druid.button --- @see druid.blocker --- @see druid.back_handler --- @see druid.input --- @see druid.text --- @see druid.lang_text --- @see druid.timer --- @see druid.progress --- @see druid.static_grid --- @see druid.dynamic_grid --- @see druid.scroll --- @see druid.slider --- @see druid.checkbox --- @see druid.checkbox_group --- @see druid.radio_group --- @see druid.swipe --- @see druid.drag +-- @module DruidInstance +-- @alias druid_instance +-- @see Button +-- @see Blocker +-- @see BackHandler +-- @see Input +-- @see Text +-- @see LangText +-- @see Timer +-- @see Progress +-- @see StaticGrid +-- @see DynamicGrid +-- @see Scroll +-- @see Slider +-- @see Checkbox +-- @see CheckboxGroup +-- @see RadioGroup +-- @see Swipe +-- @see Drag +-- @see Hover local const = require("druid.const") local helper = require("druid.helper") @@ -52,8 +54,8 @@ local radio_group = require("druid.extended.radio_group") local slider = require("druid.extended.slider") local timer = require("druid.extended.timer") --- @classmod Druid -local Druid = class("druid.druid_instance") + +local DruidInstance = class("druid.druid_instance") local function input_init(self) @@ -141,10 +143,10 @@ end --- Druid class constructor --- @function druid:initialize --- @tparam context table Druid context. Usually it is self of script --- @tparam style table Druid style module -function Druid:initialize(context, style) +-- @tparam DruidInstance self +-- @tparam table context Druid context. Usually it is self of script +-- @tparam table style Druid style module +function DruidInstance.initialize(self, context, style) self._context = context self._style = style or settings.default_style self._deleted = false @@ -160,10 +162,10 @@ end --- Create new druid component --- @function druid:create +-- @tparam DruidInstance self -- @tparam Component component Component module -- @tparam args ... Other component params to pass it to component:init function -function Druid:create(component, ...) +function DruidInstance.create(self, component, ...) local instance = create(self, component) if instance.init then @@ -176,8 +178,8 @@ end --- Call on final function on gui_script. It will call on_remove -- on all druid components --- @function druid:final -function Druid:final() +-- @tparam DruidInstance self +function DruidInstance.final(self) local components = self.components[const.ALL] for i = #components, 1, -1 do @@ -194,9 +196,9 @@ end --- Remove component from druid instance. -- Component `on_remove` function will be invoked, if exist. --- @function druid:remove +-- @tparam DruidInstance self -- @tparam Component component Component instance -function Druid:remove(component) +function DruidInstance.remove(self, component) if self._is_input_processing then table.insert(self._late_remove, component) return @@ -237,9 +239,9 @@ end --- Druid update function --- @function druid:update +-- @tparam DruidInstance self -- @tparam number dt Delta time -function Druid:update(dt) +function DruidInstance.update(self, dt) local components = self.components[const.ON_UPDATE] for i = 1, #components do components[i]:update(dt) @@ -248,10 +250,10 @@ end --- Druid on_input function --- @function druid:on_input +-- @tparam DruidInstance self -- @tparam hash action_id Action_id from on_input -- @tparam table action Action from on_input -function Druid:on_input(action_id, action) +function DruidInstance.on_input(self, action_id, action) self._is_input_processing = true local is_input_consumed = false @@ -276,11 +278,11 @@ end --- Druid on_message function --- @function druid:on_message +-- @tparam DruidInstance self -- @tparam hash message_id Message_id from on_message -- @tparam table message Message from on_message -- @tparam hash sender Sender from on_message -function Druid:on_message(message_id, message, sender) +function DruidInstance.on_message(self, message_id, message, sender) local specific_ui_message = const.SPECIFIC_UI_MESSAGES[message_id] if specific_ui_message then @@ -302,8 +304,8 @@ end --- Druid on focus lost interest function. -- This one called by on_window_callback by global window listener --- @function druid:on_focus_lost -function Druid:on_focus_lost() +-- @tparam DruidInstance self +function DruidInstance.on_focus_lost(self) local components = self.components[const.ON_FOCUS_LOST] for i = 1, #components do components[i]:on_focus_lost() @@ -313,8 +315,8 @@ end --- Druid on focus gained interest function. -- This one called by on_window_callback by global window listener --- @function druid:on_focus_gained -function Druid:on_focus_gained() +-- @tparam DruidInstance self +function DruidInstance.on_focus_gained(self) local components = self.components[const.ON_FOCUS_GAINED] for i = 1, #components do components[i]:on_focus_gained() @@ -324,8 +326,8 @@ end --- Druid on layout change function. -- Called on update gui layout --- @function druid:on_layout_change -function Druid:on_layout_change() +-- @tparam DruidInstance self +function DruidInstance.on_layout_change(self) local components = self.components[const.ON_LAYOUT_CHANGE] for i = 1, #components do components[i]:on_layout_change() @@ -337,7 +339,7 @@ end -- This one called by global gruid.on_language_change, but can be -- call manualy to update all translations -- @function druid.on_language_change -function Druid:on_language_change() +function DruidInstance.on_language_change(self) local components = self.components[const.ON_LANGUAGE_CHANGE] for i = 1, #components do components[i]:on_language_change() @@ -346,185 +348,185 @@ end --- Create button basic component --- @function druid:new_button +-- @tparam DruidInstance self -- @tparam args ... button init args --- @treturn Component button component -function Druid:new_button(...) - return Druid.create(self, button, ...) +-- @treturn Button button component +function DruidInstance.new_button(self, ...) + return DruidInstance.create(self, button, ...) end --- Create blocker basic component --- @function druid:new_blocker +-- @tparam DruidInstance self -- @tparam args ... blocker init args --- @treturn Component blocker component -function Druid:new_blocker(...) - return Druid.create(self, blocker, ...) +-- @treturn Blocker blocker component +function DruidInstance.new_blocker(self, ...) + return DruidInstance.create(self, blocker, ...) end --- Create back_handler basic component --- @function druid:new_back_handler +-- @tparam DruidInstance self -- @tparam args ... back_handler init args --- @treturn Component back_handler component -function Druid:new_back_handler(...) - return Druid.create(self, back_handler, ...) +-- @treturn BackHandler back_handler component +function DruidInstance.new_back_handler(self, ...) + return DruidInstance.create(self, back_handler, ...) end --- Create hover basic component --- @function druid:new_hover +-- @tparam DruidInstance self -- @tparam args ... hover init args --- @treturn Component hover component -function Druid:new_hover(...) - return Druid.create(self, hover, ...) +-- @treturn Hover hover component +function DruidInstance.new_hover(self, ...) + return DruidInstance.create(self, hover, ...) end --- Create text basic component --- @function druid:new_text +-- @tparam DruidInstance self -- @tparam args ... text init args --- @treturn Component text component -function Druid:new_text(...) - return Druid.create(self, text, ...) +-- @treturn Tet text component +function DruidInstance.new_text(self, ...) + return DruidInstance.create(self, text, ...) end --- Create grid basic component -- Deprecated --- @function druid:new_grid +-- @tparam DruidInstance self -- @tparam args ... grid init args --- @treturn Component grid component -function Druid:new_grid(...) +-- @treturn StaticGrid grid component +function DruidInstance.new_grid(self, ...) helper.deprecated("The druid:new_grid is deprecated. Please use druid:new_static_grid instead") - return Druid.create(self, static_grid, ...) + return DruidInstance.create(self, static_grid, ...) end --- Create static grid basic component --- @function druid:new_static_grid +-- @tparam DruidInstance self -- @tparam args ... grid init args --- @treturn Component grid component -function Druid:new_static_grid(...) - return Druid.create(self, static_grid, ...) +-- @treturn StaticGrid grid component +function DruidInstance.new_static_grid(self, ...) + return DruidInstance.create(self, static_grid, ...) end --- Create scroll basic component --- @function druid:new_scroll +-- @tparam DruidInstance self -- @tparam args ... scroll init args --- @treturn Component scroll component -function Druid:new_scroll(...) - return Druid.create(self, scroll, ...) +-- @treturn Scroll scroll component +function DruidInstance.new_scroll(self, ...) + return DruidInstance.create(self, scroll, ...) end --- Create swipe basic component --- @function druid:new_swipe +-- @tparam DruidInstance self -- @tparam args ... swipe init args --- @treturn Component swipe component -function Druid:new_swipe(...) - return Druid.create(self, swipe, ...) +-- @treturn Swipe swipe component +function DruidInstance.new_swipe(self, ...) + return DruidInstance.create(self, swipe, ...) end --- Create drag basic component --- @function druid:new_drag +-- @tparam DruidInstance self -- @tparam args ... drag init args --- @treturn Componetn drag component -function Druid:new_drag(...) - return Druid.create(self, drag, ...) +-- @treturn Drag drag component +function DruidInstance.new_drag(self, ...) + return DruidInstance.create(self, drag, ...) end --- Create dynamic grid component --- @function druid:new_dynamic_grid +-- @tparam DruidInstance self -- @tparam args ... grid init args --- @treturn Component grid component -function Druid:new_dynamic_grid(...) +-- @treturn DynamicGrid grid component +function DruidInstance.new_dynamic_grid(self, ...) -- return helper.extended_component("dynamic_grid") - return Druid.create(self, dynamic_grid, ...) + return DruidInstance.create(self, dynamic_grid, ...) end --- Create lang_text component --- @function druid:new_lang_text +-- @tparam DruidInstance self -- @tparam args ... lang_text init args --- @treturn Component lang_text component -function Druid:new_lang_text(...) +-- @treturn LangText lang_text component +function DruidInstance.new_lang_text(self, ...) -- return helper.extended_component("lang_text") - return Druid.create(self, lang_text, ...) + return DruidInstance.create(self, lang_text, ...) end --- Create slider component --- @function druid:new_slider +-- @tparam DruidInstance self -- @tparam args ... slider init args --- @treturn Component slider component -function Druid:new_slider(...) +-- @treturn Slider slider component +function DruidInstance.new_slider(self, ...) -- return helper.extended_component("slider") - return Druid.create(self, slider, ...) + return DruidInstance.create(self, slider, ...) end --- Create checkbox component --- @function druid:new_checkbox +-- @tparam DruidInstance self -- @tparam args ... checkbox init args --- @treturn Component checkbox component -function Druid:new_checkbox(...) +-- @treturn Checkbox checkbox component +function DruidInstance.new_checkbox(self, ...) -- return helper.extended_component("checkbox") - return Druid.create(self, checkbox, ...) + return DruidInstance.create(self, checkbox, ...) end --- Create input component --- @function druid:new_input +-- @tparam DruidInstance self -- @tparam args ... input init args --- @treturn Component input component -function Druid:new_input(...) +-- @treturn Input input component +function DruidInstance.new_input(self, ...) -- return helper.extended_component("input") - return Druid.create(self, input, ...) + return DruidInstance.create(self, input, ...) end --- Create checkbox_group component --- @function druid:new_checkbox_group +-- @tparam DruidInstance self -- @tparam args ... checkbox_group init args --- @treturn Component checkbox_group component -function Druid:new_checkbox_group(...) +-- @treturn CheckboxGroup checkbox_group component +function DruidInstance.new_checkbox_group(self, ...) -- return helper.extended_component("checkbox_group") - return Druid.create(self, checkbox_group, ...) + return DruidInstance.create(self, checkbox_group, ...) end --- Create radio_group component --- @function druid:new_radio_group +-- @tparam DruidInstance self -- @tparam args ... radio_group init args --- @treturn Component radio_group component -function Druid:new_radio_group(...) +-- @treturn RadioGroup radio_group component +function DruidInstance.new_radio_group(self, ...) -- return helper.extended_component("radio_group") - return Druid.create(self, radio_group, ...) + return DruidInstance.create(self, radio_group, ...) end --- Create timer component --- @function druid:new_timer +-- @tparam DruidInstance self -- @tparam args ... timer init args --- @treturn Component timer component -function Druid:new_timer(...) +-- @treturn Timer timer component +function DruidInstance.new_timer(self, ...) -- return helper.extended_component("timer") - return Druid.create(self, timer, ...) + return DruidInstance.create(self, timer, ...) end --- Create progress component --- @function druid:new_progress +-- @tparam DruidInstance self -- @tparam args ... progress init args --- @treturn Component progress component -function Druid:new_progress(...) +-- @treturn Progress progress component +function DruidInstance.new_progress(self, ...) -- return helper.extended_component("progress") - return Druid.create(self, progress, ...) + return DruidInstance.create(self, progress, ...) end -return Druid +return DruidInstance diff --git a/example/gui/main/main.gui_script b/example/gui/main/main.gui_script index 8973264..aee9b03 100644 --- a/example/gui/main/main.gui_script +++ b/example/gui/main/main.gui_script @@ -1,3 +1,4 @@ +---@type druid local druid = require("druid.druid") local empty_style = require("druid.styles.empty.style") diff --git a/settings_deployer b/settings_deployer index de288e7..91665ba 100644 --- a/settings_deployer +++ b/settings_deployer @@ -1,2 +1,4 @@ #!/bin/bash use_latest_bob=false +enable_incremental_version=true +bob_sha="173:fe2b689302e79b7cf8c0bc7d934f23587b268c8a" diff --git a/update_docs.sh b/update_docs.sh new file mode 100755 index 0000000..5aaf1e3 --- /dev/null +++ b/update_docs.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +## I am using Ldoc and my own Ldoc -> emmylua generator: +## https://github.com/Insality/emmylua-from-ldoc-annotations + +emmylua_generator_path=~/code/lua/emmylua-from-ldoc-annotations + +echo "Update Ldoc" +ldoc . + +echo "" +echo "Update EmmyLua annotations" +original_path=$(pwd) +bash $emmylua_generator_path/export.sh $original_path +mv $emmylua_generator_path/annotations.lua $original_path/annotations.lua