diff --git a/docs/index.html b/docs/index.html index 772268e..1b184f4 100644 --- a/docs/index.html +++ b/docs/index.html @@ -49,8 +49,10 @@
  • CheckboxGroup
  • DataList
  • DynamicGrid
  • +
  • Hotkey
  • Input
  • LangText
  • +
  • Layout
  • Progress
  • RadioGroup
  • Slider
  • @@ -140,6 +142,10 @@ DynamicGrid Component to handle placing components in row + + Hotkey + Druid hotkey component + Input Druid input text component. @@ -149,6 +155,10 @@ Component to handle all GUI texts Good working with localization system + + Layout + Layout management on node + Progress Basic progress bar component. diff --git a/docs/modules/BackHandler.html b/docs/modules/BackHandler.html index a6c768d..6d23e39 100644 --- a/docs/modules/BackHandler.html +++ b/docs/modules/BackHandler.html @@ -51,9 +51,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • diff --git a/docs/modules/BaseComponent.html b/docs/modules/BaseComponent.html index d920a1c..77841a8 100644 --- a/docs/modules/BaseComponent.html +++ b/docs/modules/BaseComponent.html @@ -51,9 +51,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • @@ -136,7 +138,7 @@ Set component input state. - set_input_priority(self, value) + set_input_priority(self, value, is_temporary) Set component input priority @@ -563,7 +565,7 @@
    - set_input_priority(self, value) + set_input_priority(self, value, is_temporary)
    Set component input priority @@ -579,6 +581,10 @@ number The new input priority value +
  • is_temporary + boolean + If true, the reset input priority will return to previous value +
  • Returns:

    diff --git a/docs/modules/Blocker.html b/docs/modules/Blocker.html index 0297f82..6e8651d 100644 --- a/docs/modules/Blocker.html +++ b/docs/modules/Blocker.html @@ -51,9 +51,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • diff --git a/docs/modules/Button.html b/docs/modules/Button.html index 4d3b310..f22eac1 100644 --- a/docs/modules/Button.html +++ b/docs/modules/Button.html @@ -52,9 +52,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • diff --git a/docs/modules/Checkbox.html b/docs/modules/Checkbox.html index 3cb13d5..3c9542f 100644 --- a/docs/modules/Checkbox.html +++ b/docs/modules/Checkbox.html @@ -52,9 +52,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • diff --git a/docs/modules/CheckboxGroup.html b/docs/modules/CheckboxGroup.html index 912993e..1f108e2 100644 --- a/docs/modules/CheckboxGroup.html +++ b/docs/modules/CheckboxGroup.html @@ -51,9 +51,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • diff --git a/docs/modules/DataList.html b/docs/modules/DataList.html index ede353d..88e0455 100644 --- a/docs/modules/DataList.html +++ b/docs/modules/DataList.html @@ -51,9 +51,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • diff --git a/docs/modules/Drag.html b/docs/modules/Drag.html index 09aee5c..42925c2 100644 --- a/docs/modules/Drag.html +++ b/docs/modules/Drag.html @@ -52,9 +52,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • @@ -87,9 +89,17 @@ Drag component constructor + is_enabled(self) + Check if Drag component is enabled + + set_click_zone(self, node) Strict drag click area. + + set_enabled(self, is_enabled) + Set Drag input enabled or disabled +

    Tables

    @@ -118,11 +128,11 @@ - + - + @@ -185,6 +195,33 @@ + +
    + + is_enabled(self) +
    +
    + Check if Drag component is enabled + + +

    Parameters:

    + + +

    Returns:

    +
      + + bool + +
    + + + +
    @@ -211,6 +248,31 @@ + +
    + + set_enabled(self, is_enabled) +
    +
    + Set Drag input enabled or disabled + + +

    Parameters:

    + + + + + +

    Tables

    @@ -329,7 +391,7 @@ on_drag
    - on drag progress callback(self, dx, dy) + on drag progress callback(self, dx, dy, total_x, total_y)
    + + + + @@ -167,6 +175,10 @@ + + + + @@ -658,6 +670,46 @@ + +
    + + new_hotkey(self, keys_array, callback[, params]) +
    +
    + Create hotkey component + + +

    Parameters:

    + + +

    Returns:

    +
      + + Hotkey + hotkey component +
    + + + +
    @@ -772,6 +824,41 @@ + +
    + + new_layout(self, node, mode) +
    +
    + Create layout component + + +

    Parameters:

    + + +

    Returns:

    +
      + + Layout + layout component +
    + + + +
    diff --git a/docs/modules/DynamicGrid.html b/docs/modules/DynamicGrid.html index 2879b8f..d4f1b92 100644 --- a/docs/modules/DynamicGrid.html +++ b/docs/modules/DynamicGrid.html @@ -51,9 +51,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • diff --git a/docs/modules/Helper.html b/docs/modules/Helper.html index 7550096..cdcb021 100644 --- a/docs/modules/Helper.html +++ b/docs/modules/Helper.html @@ -50,9 +50,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • diff --git a/docs/modules/Hotkey.html b/docs/modules/Hotkey.html new file mode 100644 index 0000000..8ea2ccd --- /dev/null +++ b/docs/modules/Hotkey.html @@ -0,0 +1,314 @@ + + + + + Defold Druid UI Library + + + + +
    + +
    + +
    +
    +
    + + +
    + + + + + + +
    + +

    Module Hotkey

    +

    Druid hotkey component

    +

    + + +

    Functions

    +
    on_dragon drag progress callback(self, dx, dy)on drag progress callback(self, dx, dy, total_x, total_y)
    on_drag_endEvent on drag end callback(self)Event on drag end callback(self, total_x, total_y)
    on_drag_start new_grid(self, parent, element[, in_row=1]) Create grid basic component Deprecated
    new_hotkey(self, keys_array, callback[, params])Create hotkey component
    new_hover(self, node, on_hover_callback)Create lang_text component
    new_layout(self, node, mode)Create layout component
    new_progress(self, node, key[, init_value=1]) Create progress component
    + + + + + + + + +
    add_hotkey(self, keys[, callback_argument])Add hotkey for component callback
    init(self, keys, callback[, callback_argument])Component init function
    +

    Tables

    + + + + + +
    styleComponent style params.
    +

    Fields

    + + + + + + + + + + + + + + + + + +
    buttonButton component from click_node
    click_nodeButton trigger node
    nodeVisual node
    on_change_stateOn change state callback(self, state)
    + +
    +
    + + +

    Functions

    + +
    +
    + + add_hotkey(self, keys[, callback_argument]) +
    +
    + Add hotkey for component callback + + +

    Parameters:

    +
      +
    • self + Hotkey + Hotkey +
    • +
    • keys + string[], hash[], string or hash + that have to be pressed before key pressed to activate +
    • +
    • callback_argument + value + The argument to pass into the callback function + (optional) +
    • +
    + + + + + +
    +
    + + init(self, keys, callback[, callback_argument]) +
    +
    + Component init function + + +

    Parameters:

    +
      +
    • self + Hotkey + Hotkey +
    • +
    • keys + string[] or string + The keys to be pressed for trigger callback. Should contains one key and any modificator keys +
    • +
    • callback + function + The callback function +
    • +
    • callback_argument + value + The argument to pass into the callback function + (optional) +
    • +
    + + + + + +
    +
    +

    Tables

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

    Fields:

    +
      +
    • MODIFICATORS + string[] + The list of action_id as hotkey modificators +
    • +
    + + + + + +
    +
    +

    Fields

    + +
    +
    + + button +
    +
    + Button component from click_node + + +
      +
    • button + Button + Button +
    • +
    + + + + + +
    +
    + + click_node +
    +
    + Button trigger node + + +
      +
    • click_node + node + + (default node) +
    • +
    + + + + + +
    +
    + + node +
    +
    + Visual node + + +
      +
    • node + node + +
    • +
    + + + + + +
    +
    + + on_change_state +
    +
    + On change state callback(self, state) + + + + + + + + +
    +
    + + + + +
    +generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
    + + + diff --git a/docs/modules/Hover.html b/docs/modules/Hover.html index e3b6d47..9172f9c 100644 --- a/docs/modules/Hover.html +++ b/docs/modules/Hover.html @@ -51,9 +51,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • diff --git a/docs/modules/Input.html b/docs/modules/Input.html index d247b11..ed576a0 100644 --- a/docs/modules/Input.html +++ b/docs/modules/Input.html @@ -52,9 +52,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • diff --git a/docs/modules/LangText.html b/docs/modules/LangText.html index ab9f8b8..7f524ba 100644 --- a/docs/modules/LangText.html +++ b/docs/modules/LangText.html @@ -51,9 +51,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • diff --git a/docs/modules/Layout.html b/docs/modules/Layout.html new file mode 100644 index 0000000..fa51dd2 --- /dev/null +++ b/docs/modules/Layout.html @@ -0,0 +1,91 @@ + + + + + Defold Druid UI Library + + + + +
    + +
    + +
    +
    +
    + + +
    + + + + + + +
    + +

    Module Layout

    +

    Layout management on node

    +

    + + + +
    +
    + + + + +
    +
    +
    +generated by LDoc TESTING +Last updated 2015-01-01 12:00:00 +
    +
    + + diff --git a/docs/modules/PinKnob.html b/docs/modules/PinKnob.html index 1fe3571..8a53914 100644 --- a/docs/modules/PinKnob.html +++ b/docs/modules/PinKnob.html @@ -51,9 +51,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • diff --git a/docs/modules/Progress.html b/docs/modules/Progress.html index 4494d3f..4ac940c 100644 --- a/docs/modules/Progress.html +++ b/docs/modules/Progress.html @@ -52,9 +52,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • @@ -97,6 +99,10 @@ Component init function + set_max_size(self, max_size) + Set progress bar max node size + + set_steps(self, steps, callback) Set points on progress bar to fire the callback @@ -251,6 +257,37 @@ +
    +
    + + set_max_size(self, max_size) +
    +
    + Set progress bar max node size + + +

    Parameters:

    + + +

    Returns:

    +
      + + Progress + Progress +
    + + + +
    diff --git a/docs/modules/RadioGroup.html b/docs/modules/RadioGroup.html index a451edd..8522b32 100644 --- a/docs/modules/RadioGroup.html +++ b/docs/modules/RadioGroup.html @@ -51,9 +51,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • diff --git a/docs/modules/RichInput.html b/docs/modules/RichInput.html index df5f87b..4d192af 100644 --- a/docs/modules/RichInput.html +++ b/docs/modules/RichInput.html @@ -51,9 +51,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • diff --git a/docs/modules/Scroll.html b/docs/modules/Scroll.html index 2781ee8..8098938 100644 --- a/docs/modules/Scroll.html +++ b/docs/modules/Scroll.html @@ -52,9 +52,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • diff --git a/docs/modules/Slider.html b/docs/modules/Slider.html index 6b7b70d..ccf9abd 100644 --- a/docs/modules/Slider.html +++ b/docs/modules/Slider.html @@ -51,9 +51,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • diff --git a/docs/modules/StaticGrid.html b/docs/modules/StaticGrid.html index a9a9c6c..5775504 100644 --- a/docs/modules/StaticGrid.html +++ b/docs/modules/StaticGrid.html @@ -52,9 +52,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • @@ -148,7 +150,7 @@ - + @@ -194,6 +196,10 @@ + + + +
    anchorItem anchorItem anchor [0..1]
    borderparent Parent gui node
    pivotItem pivot [-0.5..0.5]

    @@ -677,7 +683,7 @@ anchor
    - Item anchor + Item anchor [0..1]
    +
    + + pivot +
    +
    + Item pivot [-0.5..0.5] + + + + + + + +
    diff --git a/docs/modules/Swipe.html b/docs/modules/Swipe.html index 87fc435..de50f8c 100644 --- a/docs/modules/Swipe.html +++ b/docs/modules/Swipe.html @@ -52,9 +52,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • diff --git a/docs/modules/Text.html b/docs/modules/Text.html index 8fd4d8a..271b2d8 100644 --- a/docs/modules/Text.html +++ b/docs/modules/Text.html @@ -52,9 +52,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • diff --git a/docs/modules/Timer.html b/docs/modules/Timer.html index 61a3214..de1e335 100644 --- a/docs/modules/Timer.html +++ b/docs/modules/Timer.html @@ -51,9 +51,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • diff --git a/docs/modules/druid.html b/docs/modules/druid.html index 20b016c..3a2f78b 100644 --- a/docs/modules/druid.html +++ b/docs/modules/druid.html @@ -50,9 +50,11 @@
  • DruidInstance
  • DynamicGrid
  • Helper
  • +
  • Hotkey
  • Hover
  • Input
  • LangText
  • +
  • Layout
  • PinKnob
  • Progress
  • RadioGroup
  • diff --git a/docs_md/01-components.md b/docs_md/01-components.md index 5b9eb98..ed81422 100644 --- a/docs_md/01-components.md +++ b/docs_md/01-components.md @@ -147,7 +147,7 @@ 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. +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 @@ -165,7 +165,7 @@ 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. +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) @@ -277,7 +277,7 @@ 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 +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) @@ -301,7 +301,7 @@ Check the _parent_node_ have correct pivot point. You will get the error otherwi [Data List API here](https://insality.github.io/druid/modules/DataList.html) ### Overview -Component to manage data for huge dataset in scroll. DataList create elements only in scroll view. +Component to manage data for huge dataset in scroll. DataList create elements only in scroll view. It requires Druid Scroll and Druid Grid (Static or Dynamic) components @@ -368,10 +368,12 @@ System Druid component, handle drag actions on node Create drag component with druid: `hover = druid:new_drag(node, drag_callback)` ### Notes -- Drag callback have next params: (self, swipe_side, distance, time) +- Drag callback have next params: (self, dx, dy, total_x, total_y) - **self**: Druid self context - **dx**: *number* - delta x position - **dy**: *number* - delta y position + - **total_x**: *number* - total delta x position + - **total_y**: *number* - total 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 @@ -387,3 +389,56 @@ Create drag component with druid: `hover = druid:new_drag(node, drag_callback)` - _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)` + + +## Hotkey +[Hotkey API here](https://insality.github.io/druid/modules/Hotkey.html) + +### Overview +Druid component to handle keyboard hotkeys with key modificators + +### Setup +This is extended component. Before use it, you should register it: +``` +local druid = require("druid.druid") +local hotkey = require("druid.extended.hotkey") +druid.register("hotkey", hotkey) +``` +Create drag component with druid: `hotkey = druid:new_hotkey(keys_array, callback, [callback_argument])` + +### Notes +- Hotkey callback is similar with button callback: (self, callback_argument) + - **self**: Druid self context + - **callback_argument**: *value* - Any value passed at component constructor +- In styles, you can point the array of modificator keys. This keys should be pressed with main key to trigger the callback +- The keys_arrays should contains one action key and any amount of modificator keys +- You can add additional hotkeys to hotkey component with `hotkey:add_hotkey(keys_array, callback_argument)` + + +## Layout +[Layout API here](https://insality.github.io/druid/modules/Layout.html) + +### Overview +Component to handle node size depends on layout mode. Unlike from Defold Adjust modes, you able to select node stretch by one size or zoom by minimum or maximum side + +### Setup +This is extended component. Before use it, you should register it: +``` +local druid = require("druid.druid") +local layout = require("druid.extended.layout") +druid.register("layout", layout) +``` +Create drag component with druid: `layout = druid:new_layout(node, layout_mode, on_size_change_callback)` + + +### Notes +- Layout mode can be next: + - `const.LAYOUT_MODE.STRETCH_X` - Stretch node only by X + - `const.LAYOUT_MODE.STRETCH_Y` - Stretch node only by Y + - `const.LAYOUT_MODE.ZOOM_MIN` - Zoom node by minimal stretch multiplier + - `const.LAYOUT_MODE.ZOOM_MAX` - Zoom node by maximum stretch multiplier + - `const.LAYOUT_MODE.FIT` - Usual Defold Fit mode + - `const.LAYOUT_MODE.STRETCH` - Usual Defold Stretch Mode +- The Layout component will change the node size property. So it's able to increase size of 9patch nodes without scaling issue +- The Layout works even inside parent node with Fit adjust mode + diff --git a/docs_md/02-creating_custom_components.md b/docs_md/02-creating_custom_components.md index 64303d3..ad96efc 100644 --- a/docs_md/02-creating_custom_components.md +++ b/docs_md/02-creating_custom_components.md @@ -85,6 +85,9 @@ function Component:on_language_change() end -- [OPTIONAL] Call if game layout has changed and need to restore values in component function Component:on_layout_change() end +-- [OPTIONAL] Call if game window size is changed +function Component:on_window_resized() end + -- [OPTIONAL] Call, if input was capturing before this component -- Example: scroll is start scrolling, so you need unhover button function Component:on_input_interrupt() end diff --git a/druid/annotations.lua b/druid/annotations.lua index b286f87..9a716f2 100644 --- a/druid/annotations.lua +++ b/druid/annotations.lua @@ -149,8 +149,9 @@ function druid__base_component.set_input_enabled(self, state) end --- Set component input priority ---@param self druid.base_component @{BaseComponent} ---@param value number The new input priority value +---@param is_temporary boolean If true, the reset input priority will return to previous value ---@return number The component input priority -function druid__base_component.set_input_priority(self, value) end +function druid__base_component.set_input_priority(self, value, is_temporary) end --- Set current component nodes (protected) ---@protected @@ -387,8 +388,8 @@ function druid__data_list.set_data(self, data) end ---@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 druid.event on drag progress callback(self, dx, dy, total_x, total_y) +---@field on_drag_end druid.event Event on drag end callback(self, total_x, total_y) ---@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) @@ -404,12 +405,22 @@ local druid__drag = {} ---@param on_drag_callback function Callback for on_drag_event(self, dx, dy) function druid__drag.init(self, node, on_drag_callback) end +--- Check if Drag component is enabled +---@param self druid.drag @{Drag} +---@return bool +function druid__drag.is_enabled(self) end + --- Strict drag click area. --- Useful for restrict events outside stencil node ---@param self druid.drag @{Drag} ---@param node node Gui node function druid__drag.set_click_zone(self, node) end +--- Set Drag input enabled or disabled +---@param self druid.drag @{Drag} +---@param is_enabled bool +function druid__drag.set_enabled(self, is_enabled) end + ---@class druid.drag.style ---@field DRAG_DEADZONE field Distance in pixels to start dragging @@ -551,6 +562,33 @@ local druid__helper = {} function druid__helper.table_to_string(t) end +---@class druid.hotkey : druid.base_component +---@field button druid.button Button component from click_node +---@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.hotkey.style Component style params. +local druid__hotkey = {} + +--- Add hotkey for component callback +---@param self druid.hotkey @{Hotkey} +---@param keys string[]|hash[]|string|hash that have to be pressed before key pressed to activate +---@param callback_argument value The argument to pass into the callback function +function druid__hotkey.add_hotkey(self, keys, callback_argument) end + +--- Component init function +---@param self druid.hotkey @{Hotkey} +---@param keys string[]|string The keys to be pressed for trigger callback. Should contains one key and any modificator keys +---@param callback function The callback function +---@param callback_argument value The argument to pass into the callback function +function druid__hotkey.init(self, keys, callback, callback_argument) end + + +---@class druid.hotkey.style +---@field MODIFICATORS field The list of action_id as hotkey modificators +local druid__hotkey__style = {} + + ---@class druid.hover : druid.base_component ---@field on_hover druid.event On hover callback(self, state) ---@field on_mouse_hover druid.event On mouse hover callback(self, state) @@ -766,6 +804,12 @@ function druid__progress.get(self) end ---@param init_value number Initial value of progress bar function druid__progress.init(self, node, key, init_value) end +--- Set progress bar max node size +---@param self druid.progress @{Progress} +---@param max_size vector3 The new node maximum (full) size +---@return druid.progress @{Progress} +function druid__progress.set_max_size(self, max_size) end + --- Set points on progress bar to fire the callback ---@param self druid.progress @{Progress} ---@param steps number[] Array of progress bar values @@ -1009,7 +1053,7 @@ function druid__slider.set_steps(self, steps) end ---@class druid.static_grid : druid.base_component ----@field anchor vector3 Item anchor +---@field anchor vector3 Item anchor [0..1] ---@field border vector4 The size of item content ---@field first_index number The first index of node in grid ---@field last_index number The last index of node in grid @@ -1021,6 +1065,7 @@ function druid__slider.set_steps(self, steps) end ---@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 +---@field pivot vector3 Item pivot [-0.5..0.5] ---@field style druid.static_grid.style Component style params. local druid__static_grid = {} @@ -1365,6 +1410,14 @@ function druid_instance.new_dynamic_grid(self, parent) end ---@return druid.static_grid grid component function druid_instance.new_grid(self, parent, element, in_row) end +--- Create hotkey component +---@param self druid_instance +---@param keys_array string|string[] Keys for trigger action. Should contains one action key and any amount of modificator keys +---@param callback function Button callback +---@param params value Button callback params +---@return druid.hotkey hotkey component +function druid_instance.new_hotkey(self, keys_array, callback, params) end + --- Create hover basic component ---@param self druid_instance ---@param node node Gui node @@ -1388,6 +1441,13 @@ function druid_instance.new_input(self, click_node, text_node, keyboard_type) en ---@return druid.lang_text lang_text component function druid_instance.new_lang_text(self, node, locale_id, no_adjust) end +--- Create layout component +---@param self druid_instance +---@param node string|node Layout node +---@param mode string The layout mode +---@return druid.layout layout component +function druid_instance.new_layout(self, node, mode) end + --- Create progress component ---@param self druid_instance ---@param node string|node Progress bar fill node or node name diff --git a/druid/base/drag.lua b/druid/base/drag.lua index 249a664..cd0a50f 100644 --- a/druid/base/drag.lua +++ b/druid/base/drag.lua @@ -300,7 +300,7 @@ end --- Set Drag input enabled or disabled -- @tparam Drag self @{Drag} --- @tparam bool is enabled +-- @tparam bool is_enabled function Drag.set_enabled(self, is_enabled) self._is_disabled = not is_enabled end diff --git a/druid/extended/hotkey.lua b/druid/extended/hotkey.lua index 8e8be29..23ecd49 100644 --- a/druid/extended/hotkey.lua +++ b/druid/extended/hotkey.lua @@ -29,6 +29,7 @@ local Hotkey = component.create("hotkey") -- @tparam Hotkey self @{Hotkey} -- @tparam string[]|string keys The keys to be pressed for trigger callback. Should contains one key and any modificator keys -- @tparam function callback The callback function +-- @tparam[opt] value callback_argument The argument to pass into the callback function function Hotkey.init(self, keys, callback, callback_argument) self.druid = self:get_druid() @@ -59,7 +60,8 @@ end --- Add hotkey for component callback -- @tparam Hotkey self @{Hotkey} --- @tparam string[]|hash[]|string|hash Keys that have to be pressed before key pressed to activate +-- @tparam string[]|hash[]|string|hash keys that have to be pressed before key pressed to activate +-- @tparam[opt] value callback_argument The argument to pass into the callback function function Hotkey.add_hotkey(self, keys, callback_argument) keys = keys or {} if type(keys) == "string" then diff --git a/druid/extended/layout.lua b/druid/extended/layout.lua index eeaa77d..2a4a24f 100644 --- a/druid/extended/layout.lua +++ b/druid/extended/layout.lua @@ -13,7 +13,7 @@ local helper = require("druid.helper") local component = require("druid.component") local Event = require("druid.event") ----@class layout : druid.base_component + local Layout = component.create("layout") diff --git a/druid/extended/progress.lua b/druid/extended/progress.lua index 509e57b..aa2cd03 100644 --- a/druid/extended/progress.lua +++ b/druid/extended/progress.lua @@ -215,7 +215,7 @@ end -- @tparam Progress self @{Progress} -- @tparam vector3 max_size The new node maximum (full) size -- @treturn Progress @{Progress} -function Progress:set_max_size(max_size) +function Progress.set_max_size(self, max_size) self.max_size = max_size[self.key] self:set_to(self.last_value) return self diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index ee0d77b..192e684 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -752,10 +752,10 @@ end --- Create hotkey component -- @tparam DruidInstance self --- @tparam string|string[] string Keys for trigger action. Should contains one action key and any amount of modificator keys +-- @tparam string|string[] keys_array Keys for trigger action. Should contains one action key and any amount of modificator keys -- @tparam function callback Button callback -- @tparam[opt] value params Button callback params --- @treturn Layout layout component +-- @treturn Hotkey hotkey component function DruidInstance.new_hotkey(self, keys_array, callback, params) return helper.extended_component("hotkey") end