From 822db35e84baf48e979cf11cc7868a7b6edf4bc0 Mon Sep 17 00:00:00 2001 From: Insality Date: Sun, 23 Feb 2020 22:57:44 +0300 Subject: [PATCH] Documentation experiments --- alpha_todo.txt | 6 +- config.ld | 2 +- docs/index.html | 2 +- docs/modules/component.html | 370 ++++++++--------- docs/modules/druid.back_handler.html | 8 +- docs/modules/druid.blocker.html | 8 +- docs/modules/druid.button.html | 249 ++++-------- docs/modules/druid.checkbox.html | 8 +- docs/modules/druid.checkbox_group.html | 8 +- docs/modules/druid.grid.html | 8 +- docs/modules/druid.helper.html | 112 +++--- docs/modules/druid.html | 70 ++-- docs/modules/druid.input.html | 68 ++-- docs/modules/druid.lang_text.html | 8 +- docs/modules/druid.progress.html | 176 ++++---- docs/modules/druid.radio_group.html | 8 +- docs/modules/druid.scroll.html | 166 ++++---- docs/modules/druid.slider.html | 8 +- docs/modules/druid.text.html | 58 +-- docs/modules/druid.timer.html | 44 +- docs/modules/druid_event.html | 93 ++++- docs/modules/druid_instance.html | 536 ++++++++++++------------- druid/base/button.lua | 62 ++- druid/component.lua | 40 +- druid/event.lua | 10 + 25 files changed, 1071 insertions(+), 1057 deletions(-) diff --git a/alpha_todo.txt b/alpha_todo.txt index 552c412..cff23aa 100644 --- a/alpha_todo.txt +++ b/alpha_todo.txt @@ -9,13 +9,15 @@ Simple to-do for Druid Alpha 0.2.0 + better name for slider component? Slider is ok + Druid store assets - separate repository with rich components (progress_rich migrate) + refactor on_swipe. To on_scroll? Add input priority -- separate custom data and predefined fields in components? ++ separate custom data and predefined fields in components? Every component have their fields and events - add init/remove stuff for every style in component. How to set custom sprites for button states? -- unify component api (get/set/to and other general stuff) - add druid settings (add auto_focus input and other stuff) + - button add key trigger - button polish, actions - button and hover click restriction zone? + +- unify component api (get/set/to and other general stuff) - better callbacks for every components - better scroll size management, check different cases. So implicit now - better grid + scroll management diff --git a/config.ld b/config.ld index b9a95cd..00b4508 100644 --- a/config.ld +++ b/config.ld @@ -3,7 +3,7 @@ title='Defold Druid UI Library' description='Documentation for Druid Library' file={"./druid"} package='druid' -sort=true +sort=false dir='./docs' style='!fixed' format='discount' diff --git a/docs/index.html b/docs/index.html index 45b2665..e865552 100644 --- a/docs/index.html +++ b/docs/index.html @@ -145,7 +145,7 @@
generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
diff --git a/docs/modules/component.html b/docs/modules/component.html index d0b3851..a05a234 100644 --- a/docs/modules/component.html +++ b/docs/modules/component.html @@ -38,15 +38,12 @@

Modules

@@ -70,54 +70,54 @@

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Component.create(name, interest)Create new component.
get_context()Get current component context
get_druid()Return druid with context of calling component.
get_interests()Get current component interests
get_nodes()Get current component nodes
get_style() Get current component style table
get_template()Get current component template name
set_context(context)Set current component context
set_nodes(nodes)Set current component nodes
set_style(style) Set current component style table
get_template()Get current component template name
set_template(template) Set current component template name
get_nodes()Get current component nodes
set_nodes(nodes)Set current component nodes
get_context()Get current component context
set_context(context)Set current component context
get_interests()Get current component interests
get_druid()Return druid with context of calling component.
setup_component(table, table) Setup component context and his style table
Component.create(name, interest)Create new component.

@@ -128,23 +128,120 @@
- - Component.create(name, interest) + + get_style()
- Create new component. It will inheritance from basic - druid component. + Get current component style table + + + +

Returns:

+
    + + table + Component style table +
+ + + + +
+
+ + set_style(style) +
+
+ Set current component style table

Parameters:

    -
  • name - string - Component name -
  • -
  • interest +
  • style table - List of component's interest + Druid style module +
  • +
+ + + + + +
+
+ + get_template() +
+
+ Get current component template name + + + +

Returns:

+
    + + string + Component template name +
+ + + + +
+
+ + set_template(template) +
+
+ Set current component template name + + +

Parameters:

+
    +
  • template + string + Component template name +
  • +
+ + + + + +
+
+ + get_nodes() +
+
+ Get current component nodes + + + +

Returns:

+
    + + table + Component nodes table +
+ + + + +
+
+ + set_nodes(nodes) +
+
+ Set current component nodes + + +

Parameters:

+
    +
  • nodes + table + Component nodes table
@@ -174,21 +271,21 @@
- - get_druid() + + set_context(context)
- Return druid with context of calling component. - Use it to create component inside of other components. + Set current component context +

Parameters:

+
    +
  • context + table + Druid context. Usually it is self of script +
  • +
-

Returns:

-
    - - Druid - Druid instance with component context -
@@ -215,148 +312,25 @@
- - get_nodes() + + get_druid()
- Get current component nodes + Return druid with context of calling component. + Use it to create component inside of other components.

Returns:

    - table - Component nodes table + Druid + Druid instance with component context
-
-
- - get_style() -
-
- Get current component style table - - - -

Returns:

-
    - - table - Component style table -
- - - - -
-
- - get_template() -
-
- Get current component template name - - - -

Returns:

-
    - - string - Component template name -
- - - - -
-
- - set_context(context) -
-
- Set current component context - - -

Parameters:

-
    -
  • context - table - Druid context. Usually it is self of script -
  • -
- - - - - -
-
- - set_nodes(nodes) -
-
- Set current component nodes - - -

Parameters:

-
    -
  • nodes - table - Component nodes table -
  • -
- - - - - -
-
- - set_style(style) -
-
- Set current component style table - - -

Parameters:

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

Parameters:

-
    -
  • template - string - Component template name -
  • -
- - - - -
@@ -388,6 +362,32 @@ + +
+ + 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 +
  • +
+ + + + +
@@ -396,7 +396,7 @@
generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
diff --git a/docs/modules/druid.back_handler.html b/docs/modules/druid.back_handler.html index 66881c1..66d587d 100644 --- a/docs/modules/druid.back_handler.html +++ b/docs/modules/druid.back_handler.html @@ -38,15 +38,12 @@

Modules

@@ -151,7 +151,7 @@
generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
diff --git a/docs/modules/druid.blocker.html b/docs/modules/druid.blocker.html index cd46818..46ce82d 100644 --- a/docs/modules/druid.blocker.html +++ b/docs/modules/druid.blocker.html @@ -34,15 +34,12 @@

Modules

@@ -77,7 +77,7 @@
generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
diff --git a/docs/modules/druid.button.html b/docs/modules/druid.button.html index 4108eb2..82fe0ef 100644 --- a/docs/modules/druid.button.html +++ b/docs/modules/druid.button.html @@ -39,15 +39,12 @@

Modules

@@ -73,49 +73,37 @@

Functions

- - - - - - - - - - + + - - - - - - - - - - + +
disable_animation(self)Disable all button animations
get_key_trigger(self)Get key-code to trigger this button
init(self, node, callback[, params[, anim_node[, event]]]) Component init function
set_callback(self, callback)Set usual button callbackdisable_animation(self)Disable all button animations
set_click_zone(self, zone) Strict button click area.
set_double_tap_callback(self, callback)Get doubletap callback on this button
set_hold_callback(self, callback)Repeat callback always, while holding button
set_long_tap_callback(self, callback)Single callbacka after long_tap.get_key_trigger(self)Get key-code to trigger this button

Tables

- + - + + + + +
eventsEvents Component events
fieldsFields Component fields
StyleComponent style params

@@ -125,49 +113,6 @@

Functions

-
- - disable_animation(self) -
-
- Disable all button animations - - -

Parameters:

-
    -
  • self - table - Component instance -
  • -
- - - - - -
-
- - get_key_trigger(self) -
-
- Get key-code to trigger this button - - -

Parameters:

-
    -
  • self - - - -
  • -
- - - - - -
init(self, node, callback[, params[, anim_node[, event]]]) @@ -213,24 +158,18 @@
- - set_callback(self, callback) + + disable_animation(self)
- Set usual button callback + Disable all button animations

Parameters:

  • self - - - -
  • -
  • callback - - - + table + Component instance
@@ -266,11 +205,11 @@
- - set_double_tap_callback(self, callback) + + get_key_trigger(self)
- Get doubletap callback on this button + Get key-code to trigger this button

Parameters:

@@ -279,65 +218,6 @@ - -
  • callback - - - -
  • - - - - - - -
    -
    - - set_hold_callback(self, callback) -
    -
    - Repeat callback always, while holding button - - -

    Parameters:

    -
      -
    • self - - - -
    • -
    • callback - - - -
    • -
    - - - - - -
    -
    - - set_long_tap_callback(self, callback) -
    -
    - Single callbacka after long_tap. No usual callback invoked - - -

    Parameters:

    -
      -
    • self - - - -
    • -
    • callback - - -
    @@ -351,8 +231,8 @@
    - - events + + Events
    Component events @@ -362,27 +242,19 @@
    • on_click druid_event - - - + On release button callback
    • -
    • on_hold_click +
    • on_repeated_click druid_event - - - + On repeated action button callback
    • on_long_click druid_event - - - + On long tap button callback
    • on_double_click druid_event - - - + On double tap button callback
    @@ -392,8 +264,8 @@
    - - fields + + Fields
    Component fields @@ -401,9 +273,64 @@

    Fields:

      -
    • Main +
    • node node - node + Trigger node +
    • +
    • anim_node + node + Animation node + (default node) +
    • +
    • scale_from + vector3 + Initial scale of anim_node +
    • +
    • pos + vector3 + Initial pos of anim_node +
    • +
    • params + any + Params to click callbacks +
    • +
    • hover_anim + boolean + Is hover anim enabled +
    • +
    • hover + druid.hover + Druid hover logic component +
    • +
    • click_zone + node + Restriction zone + (optional) +
    • +
    + + + + + +
    +
    + + Style +
    +
    + Component style params + + +

    Fields:

    +
      +
    • on_click + function + (self, node) +
    • +
    • on_hover + function + (self, node, hover_state)
    @@ -419,7 +346,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.checkbox.html b/docs/modules/druid.checkbox.html index e3b8461..bfe3b2a 100644 --- a/docs/modules/druid.checkbox.html +++ b/docs/modules/druid.checkbox.html @@ -34,15 +34,12 @@

    Modules

    @@ -77,7 +77,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.checkbox_group.html b/docs/modules/druid.checkbox_group.html index 6a20fe6..e492ef9 100644 --- a/docs/modules/druid.checkbox_group.html +++ b/docs/modules/druid.checkbox_group.html @@ -34,15 +34,12 @@

    Modules

    @@ -77,7 +77,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.grid.html b/docs/modules/druid.grid.html index ad0f258..6914a07 100644 --- a/docs/modules/druid.grid.html +++ b/docs/modules/druid.grid.html @@ -34,15 +34,12 @@

    Modules

    @@ -75,7 +75,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.helper.html b/docs/modules/druid.helper.html index 820aaec..ae45827 100644 --- a/docs/modules/druid.helper.html +++ b/docs/modules/druid.helper.html @@ -38,15 +38,12 @@

    Modules

    @@ -72,22 +72,22 @@

    Functions

    - - - - - - + + + + + +
    centrate_icon_with_text([icon_node[, text_node[, margin=0]]])Center two nodes.
    centrate_text_with_icon([text_node][, icon_node], margin) Center two nodes.
    get_pivot_offset(pivot)Get node offset for given gui pivotcentrate_icon_with_text([icon_node[, text_node[, margin=0]]])Center two nodes.
    is_enabled(node) Check if node is enabled in gui hierarchy.
    get_pivot_offset(pivot)Get node offset for given gui pivot

    @@ -97,6 +97,39 @@

    Functions

    +
    + + centrate_text_with_icon([text_node][, icon_node], margin) +
    +
    + Center two nodes. + Nodes will be center around 0 x position + text_node will be first (at left side) + + +

    Parameters:

    +
      +
    • text_node + text + Gui text node + (optional) +
    • +
    • icon_node + box + Gui box node + (optional) +
    • +
    • margin + number + Offset between nodes +
    • +
    + + + + + +
    centrate_icon_with_text([icon_node[, text_node[, margin=0]]]) @@ -132,33 +165,28 @@
    - - centrate_text_with_icon([text_node][, icon_node], margin) + + is_enabled(node)
    - Center two nodes. - Nodes will be center around 0 x position - text_node will be first (at left side) + Check if node is enabled in gui hierarchy. + Return false, if node or any his parent is disabled

    Parameters:

      -
    • text_node - text - Gui text node - (optional) -
    • -
    • icon_node - box - Gui box node - (optional) -
    • -
    • margin - number - Offset between nodes +
    • node + node + Gui node
    +

    Returns:

    +
      + + bool + Is enabled in hierarchy +
    @@ -190,34 +218,6 @@ -
    -
    - - is_enabled(node) -
    -
    - Check if node is enabled in gui hierarchy. - Return false, if node or any his parent is disabled - - -

    Parameters:

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

    Returns:

    -
      - - bool - Is enabled in hierarchy -
    - - - -
    @@ -226,7 +226,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.html b/docs/modules/druid.html index eef8815..66d2c54 100644 --- a/docs/modules/druid.html +++ b/docs/modules/druid.html @@ -38,15 +38,12 @@

    Modules

    @@ -88,14 +88,14 @@

    Functions

    - - - - + + + +
    new(context[, style])Create Druid instance.
    register(name, module) Register external druid component.
    new(context[, style])Create Druid instance.

    @@ -105,6 +105,33 @@

    Functions

    +
    + + register(name, module) +
    +
    + Register external druid component. + After register you can create the component with + druidinstance:new{name}. For example druid:new_button(...) + + +

    Parameters:

    +
      +
    • name + string + module name +
    • +
    • module + table + lua table with component +
    • +
    + + + + + +
    new(context[, style]) @@ -136,33 +163,6 @@ -
    -
    - - register(name, module) -
    -
    - Register external druid component. - After register you can create the component with - druidinstance:new{name}. For example druid:new_button(...) - - -

    Parameters:

    -
      -
    • name - string - module name -
    • -
    • module - table - lua table with component -
    • -
    - - - - -
    @@ -171,7 +171,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.input.html b/docs/modules/druid.input.html index 234ed47..3c37497 100644 --- a/docs/modules/druid.input.html +++ b/docs/modules/druid.input.html @@ -38,15 +38,12 @@

    Modules

    @@ -72,14 +72,14 @@

    Functions

    - - - - + + + +
    button:set_click_zone(self, zone)Strict button click area.
    hover:init(self, node, on_hover_callback) Component init function
    button:set_click_zone(self, zone)Strict button click area.

    @@ -89,32 +89,6 @@

    Functions

    -
    - - button:set_click_zone(self, zone) -
    -
    - Strict button click area. Useful for - no click events outside stencil node - - -

    Parameters:

    -
      -
    • self - table - Component instance -
    • -
    • zone - node - Gui node -
    • -
    - - - - - -
    hover:init(self, node, on_hover_callback) @@ -143,6 +117,32 @@ + +
    + + button:set_click_zone(self, zone) +
    +
    + Strict button click area. Useful for + no click events outside stencil node + + +

    Parameters:

    +
      +
    • self + table + Component instance +
    • +
    • zone + node + Gui node +
    • +
    + + + + +
    @@ -151,7 +151,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.lang_text.html b/docs/modules/druid.lang_text.html index 7eefddd..2c02a82 100644 --- a/docs/modules/druid.lang_text.html +++ b/docs/modules/druid.lang_text.html @@ -38,15 +38,12 @@

    Modules

    @@ -118,7 +118,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.progress.html b/docs/modules/druid.progress.html index a505c5a..2b0ede6 100644 --- a/docs/modules/druid.progress.html +++ b/docs/modules/druid.progress.html @@ -38,15 +38,12 @@

    Modules

    @@ -73,30 +73,30 @@

    Functions

    - - + + - - - - - - - - - - + + + + + + + + + + @@ -109,69 +109,6 @@

    Functions

    -
    - - empty(self) -
    -
    - Empty a progress bar - - -

    Parameters:

    -
      -
    • self - table - Component instance -
    • -
    - - - - - -
    -
    - - empty(self) -
    -
    - Fill a progress bar and stop progress animation - - -

    Parameters:

    -
      -
    • self - table - Component instance -
    • -
    - - - - - -
    -
    - - get(self) -
    -
    - Return current progress bar value - - -

    Parameters:

    -
      -
    • self - table - Component instance -
    • -
    - - - - - -
    init(self, node, key, init_value) @@ -206,11 +143,11 @@
    - - set_steps(self, steps, callback) + + empty(self)
    - Set points on progress bar to fire the callback + Fill a progress bar and stop progress animation

    Parameters:

    @@ -219,13 +156,26 @@ table Component instance -
  • steps + + + + + + +
  • +
    + + empty(self) +
    +
    + Empty a progress bar + + +

    Parameters:

    +
      +
    • self table - Array of progress bar values -
    • -
    • callback - function - Callback on intersect step value + Component instance
    @@ -258,6 +208,56 @@ +
    +
    + + get(self) +
    +
    + Return current progress bar value + + +

    Parameters:

    +
      +
    • self + table + Component instance +
    • +
    + + + + + +
    +
    + + set_steps(self, steps, callback) +
    +
    + Set points on progress bar to fire the callback + + +

    Parameters:

    +
      +
    • self + table + Component instance +
    • +
    • steps + table + Array of progress bar values +
    • +
    • callback + function + Callback on intersect step value +
    • +
    + + + + +
    @@ -296,7 +296,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.radio_group.html b/docs/modules/druid.radio_group.html index 95f1c32..082f70a 100644 --- a/docs/modules/druid.radio_group.html +++ b/docs/modules/druid.radio_group.html @@ -34,15 +34,12 @@

    Modules

    @@ -77,7 +77,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.scroll.html b/docs/modules/druid.scroll.html index c12e1aa..81b1019 100644 --- a/docs/modules/druid.scroll.html +++ b/docs/modules/druid.scroll.html @@ -38,15 +38,12 @@

    Modules

    @@ -72,29 +72,29 @@

    Functions

    empty(self)Empty a progress barinit(self, node, key, init_value)Component init function
    empty(self) Fill a progress bar and stop progress animation
    get(self)Return current progress bar value
    init(self, node, key, init_value)Component init function
    set_steps(self, steps, callback)Set points on progress bar to fire the callbackempty(self)Empty a progress bar
    set_to(self, to) Instant fill progress bar to value
    get(self)Return current progress bar value
    set_steps(self, steps, callback)Set points on progress bar to fire the callback
    to(self, to[, callback]) Start animation of a progress bar
    - - - - - - - - - - + + + + + + - - + + + + + +
    init(self, index[, skip_cb])Scroll to item in scroll by point index
    on_point_move(self, callback)Set the callback on scrolling to point (if exist)
    scroll_to(vector3[, is_instant]) Start scroll to target point
    set_border(self, border)Set the scroll possibly areainit(self, index[, skip_cb])Scroll to item in scroll by point index
    set_points(self, points)Set points of interest.
    set_inert(self, state) Enable or disable scroll inert.
    set_points(self, points)Set points of interest.on_point_move(self, callback)Set the callback on scrolling to point (if exist)
    set_border(self, border)Set the scroll possibly area
    @@ -105,61 +105,6 @@

    Functions

    -
    - - init(self, index[, skip_cb]) -
    -
    - Scroll to item in scroll by point index - - -

    Parameters:

    -
      -
    • self - table - Component instance -
    • -
    • index - number - Point index -
    • -
    • skip_cb - boolean - If true, skip the point callback - (optional) -
    • -
    - - - - - -
    -
    - - on_point_move(self, callback) -
    -
    - Set the callback on scrolling to point (if exist) - - -

    Parameters:

    -
      -
    • self - table - Component instance -
    • -
    • callback - function - Callback on scroll to point of interest -
    • -
    - - - - - -
    scroll_to(vector3[, is_instant]) @@ -192,11 +137,11 @@
    - - set_border(self, border) + + init(self, index[, skip_cb])
    - Set the scroll possibly area + Scroll to item in scroll by point index

    Parameters:

    @@ -205,9 +150,40 @@ table Component instance -
  • border - vmath.vector3 - Size of scrolling area +
  • index + number + Point index +
  • +
  • skip_cb + boolean + If true, skip the point callback + (optional) +
  • + + + + + + +
    +
    + + set_points(self, points) +
    +
    + Set points of interest. + Scroll will always centered on closer points + + +

    Parameters:

    +
      +
    • self + table + Component instance +
    • +
    • points + table + Array of vector3 points
    @@ -244,12 +220,11 @@
    - - set_points(self, points) + + on_point_move(self, callback)
    - Set points of interest. - Scroll will always centered on closer points + Set the callback on scrolling to point (if exist)

    Parameters:

    @@ -258,9 +233,34 @@ table Component instance -
  • points +
  • callback + function + Callback on scroll to point of interest +
  • + + + + + + +
    +
    + + set_border(self, border) +
    +
    + Set the scroll possibly area + + +

    Parameters:

    +
      +
    • self table - Array of vector3 points + Component instance +
    • +
    • border + vmath.vector3 + Size of scrolling area
    @@ -276,7 +276,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.slider.html b/docs/modules/druid.slider.html index fb5dc21..03e14f1 100644 --- a/docs/modules/druid.slider.html +++ b/docs/modules/druid.slider.html @@ -34,15 +34,12 @@

    Modules

    @@ -77,7 +77,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.text.html b/docs/modules/druid.text.html index a1ec437..41d09ef 100644 --- a/docs/modules/druid.text.html +++ b/docs/modules/druid.text.html @@ -38,15 +38,12 @@

    Modules

    @@ -74,24 +74,24 @@

    Functions

    - - + + - - + + - - + +
    set_alpha(self, alpha)Set alphaset_to(self, set_to)Set text to text field
    set_color(self, color) Set color
    set_pivot(self, pivot)Set text pivot.set_alpha(self, alpha)Set alpha
    set_scale(self, scale) Set scale
    set_to(self, set_to)Set text to text fieldset_pivot(self, pivot)Set text pivot.
    @@ -103,11 +103,11 @@
    - - set_alpha(self, alpha) + + set_to(self, set_to)
    - Set alpha + Set text to text field

    Parameters:

    @@ -116,9 +116,9 @@ table Component instance -
  • alpha - number - Alpha for node +
  • set_to + string + Text for node
  • @@ -153,12 +153,11 @@
    - - set_pivot(self, pivot) + + set_alpha(self, alpha)
    - Set text pivot. Text will re-anchor inside - his text area + Set alpha

    Parameters:

    @@ -167,9 +166,9 @@ table Component instance -
  • pivot - gui.pivot - Gui pivot constant +
  • alpha + number + Alpha for node
  • @@ -204,11 +203,12 @@
    - - set_to(self, set_to) + + set_pivot(self, pivot)
    - Set text to text field + Set text pivot. Text will re-anchor inside + his text area

    Parameters:

    @@ -217,9 +217,9 @@ table Component instance -
  • set_to - string - Text for node +
  • pivot + gui.pivot + Gui pivot constant
  • @@ -235,7 +235,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid.timer.html b/docs/modules/druid.timer.html index afa6a7a..242b9b2 100644 --- a/docs/modules/druid.timer.html +++ b/docs/modules/druid.timer.html @@ -38,15 +38,12 @@

    Modules

    @@ -73,16 +73,16 @@

    Functions

    - - + + - - + +
    set_interval(self, from, to)Set time intervalset_to(self, set_to)Set text to text field
    set_state(self, is_on) Called when update
    set_to(self, set_to)Set text to text fieldset_interval(self, from, to)Set time interval
    @@ -94,11 +94,11 @@
    - - set_interval(self, from, to) + + set_to(self, set_to)
    - Set time interval + Set text to text field

    Parameters:

    @@ -107,13 +107,9 @@ table Component instance -
  • from +
  • set_to number - Start time in seconds -
  • -
  • to - number - Target time in seconds + Value in seconds
  • @@ -148,11 +144,11 @@
    - - set_to(self, set_to) + + set_interval(self, from, to)
    - Set text to text field + Set time interval

    Parameters:

    @@ -161,9 +157,13 @@ table Component instance -
  • set_to +
  • from number - Value in seconds + Start time in seconds +
  • +
  • to + number + Target time in seconds
  • @@ -179,7 +179,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid_event.html b/docs/modules/druid_event.html index f6bda44..37e3a1c 100644 --- a/docs/modules/druid_event.html +++ b/docs/modules/druid_event.html @@ -30,19 +30,20 @@
  • Index
  • +

    Contents

    +

    Modules

    @@ -66,18 +70,99 @@

    +

    Functions

    + + + + + + + + + + + + + +
    event:subscribe(callback)Subscribe callback on event
    event:unsubscribe(callback)Unsubscribe callback on event
    event:trigger(...)Trigger the event and call all subscribed callbacks


    +

    Functions

    + +
    +
    + + event:subscribe(callback) +
    +
    + Subscribe callback on event + + +

    Parameters:

    +
      +
    • callback + function + Callback itself +
    • +
    + + + + + +
    +
    + + event:unsubscribe(callback) +
    +
    + Unsubscribe callback on event + + +

    Parameters:

    +
      +
    • callback + function + Callback itself +
    • +
    + + + + + +
    +
    + + event:trigger(...) +
    +
    + Trigger the event and call all subscribed callbacks + + +

    Parameters:

    +
      +
    • ... + All event params +
    • +
    + + + + + +
    +
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/docs/modules/druid_instance.html b/docs/modules/druid_instance.html index 719a0ca..f3df01a 100644 --- a/docs/modules/druid_instance.html +++ b/docs/modules/druid_instance.html @@ -38,15 +38,12 @@

    Modules

    @@ -88,73 +88,21 @@

    Functions

    - - - - - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -165,12 +113,64 @@ - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    druid:create(component, ...)Create new druid component
    druid:initialize(table, table) Druid class constructor
    druid:new_back_handler(...)Create back_handler basic componentdruid:create(component, ...)Create new druid component
    druid:new_blocker(...)Create blocker basic componentdruid:remove(component)Remove component from druid instance.
    druid:new_button(...)Create button basic component
    druid:new_checkbox(...)Create checkbox basic component
    druid:new_checkbox_group(...)Create checkbox_group basic component
    druid:new_grid(...)Create grid basic component
    druid:new_hover(...)Create hover basic component
    druid:new_input(...)Create input basic component
    druid:new_lang_text(...)Create lang_text basic component
    druid:new_progress(...)Create progress basic component
    druid:new_radio_group(...)Create radio_group basic component
    druid:new_scroll(...)Create scroll basic component
    druid:new_slider(...)Create slider basic component
    druid:new_text(...)Create text basic component
    druid:new_timer(...)Create timer basic componentdruid:update(dt)Druid update function
    druid:on_input(action_id, action)Druid on_message function
    druid:remove(component)Remove component from druid instance.druid:new_button(...)Create button basic component
    druid:update(dt)Druid update functiondruid: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_lang_text(...)Create lang_text basic component
    druid:new_timer(...)Create timer basic component
    druid:new_progress(...)Create progress basic component
    druid:new_grid(...)Create grid basic component
    druid:new_scroll(...)Create scroll basic component
    druid:new_slider(...)Create slider basic component
    druid:new_checkbox(...)Create checkbox basic component
    druid:new_input(...)Create input basic component
    druid:new_checkbox_group(...)Create checkbox_group basic component
    druid:new_radio_group(...)Create radio_group basic component
    @@ -181,31 +181,6 @@

    Functions

    -
    - - druid:create(component, ...) -
    -
    - Create new druid component - - -

    Parameters:

    -
      -
    • component - Component - Component module -
    • -
    • ... - args - Other component params to pass it to component:init function -
    • -
    - - - - - -
    druid:initialize(table, table) @@ -232,18 +207,140 @@
    - - druid:new_back_handler(...) + + druid:create(component, ...)
    - Create back_handler basic component + Create new druid component + + +

    Parameters:

    +
      +
    • component + Component + Component module +
    • +
    • ... + args + Other component params to pass it to component:init function +
    • +
    + + + + + +
    +
    + + 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:new_button(...) +
    +
    + Create button basic component

    Parameters:

    • ... args - back_handler init args + button init args
    @@ -251,7 +348,7 @@
      Component - back_handler component + button component
    @@ -286,18 +383,18 @@
    - - druid:new_button(...) + + druid:new_back_handler(...)
    - Create button basic component + Create back_handler basic component

    Parameters:

    • ... args - button init args + back_handler init args
    @@ -305,88 +402,7 @@
      Component - button component -
    - - - - -
    -
    - - druid:new_checkbox(...) -
    -
    - Create checkbox basic component - - -

    Parameters:

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

    Returns:

    -
      - - Component - checkbox component -
    - - - - -
    -
    - - druid:new_checkbox_group(...) -
    -
    - Create checkbox_group basic component - - -

    Parameters:

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

    Returns:

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

    Parameters:

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

    Returns:

    -
      - - Component - grid component + back_handler component
    @@ -421,18 +437,18 @@
    - - druid:new_input(...) + + druid:new_text(...)
    - Create input basic component + Create text basic component

    Parameters:

    • ... args - input init args + text init args
    @@ -440,7 +456,7 @@
      Component - input component + text component
    @@ -473,6 +489,33 @@ +
    +
    + + druid:new_timer(...) +
    +
    + Create timer basic component + + +

    Parameters:

    +
      +
    • ... + args + timer init args +
    • +
    + +

    Returns:

    +
      + + Component + timer component +
    + + + +
    @@ -502,18 +545,18 @@
    - - druid:new_radio_group(...) + + druid:new_grid(...)
    - Create radio_group basic component + Create grid basic component

    Parameters:

    • ... args - radio_group init args + grid init args
    @@ -521,7 +564,7 @@
      Component - radio_group component + grid component
    @@ -583,18 +626,18 @@
    - - druid:new_text(...) + + druid:new_checkbox(...)
    - Create text basic component + Create checkbox basic component

    Parameters:

    • ... args - text init args + checkbox init args
    @@ -602,7 +645,7 @@
      Component - text component + checkbox component
    @@ -610,18 +653,18 @@
    - - druid:new_timer(...) + + druid:new_input(...)
    - Create timer basic component + Create input basic component

    Parameters:

    • ... args - timer init args + input init args
    @@ -629,7 +672,7 @@
      Component - timer component + input component
    @@ -637,97 +680,54 @@
    - - druid:on_input(action_id, action) + + druid:new_checkbox_group(...)
    - Druid on_input function + Create checkbox_group basic component

    Parameters:

      -
    • action_id - hash - Actionid from oninput -
    • -
    • action - table - Action from on_input +
    • ... + args + checkbox_group init args
    +

    Returns:

    +
      + + Component + checkbox_group component +
    - - druid:on_message(message_id, message, sender) + + druid:new_radio_group(...)
    - Druid on_message function + Create radio_group basic component

    Parameters:

      -
    • message_id - hash - Messageid from onmessage -
    • -
    • message - table - Message from on_message -
    • -
    • sender - hash - Sender from on_message +
    • ... + args + radio_group init args
    +

    Returns:

    +
      - - - -
    -
    - - 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 -
    • -
    - + Component + radio_group component + @@ -740,7 +740,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-23 13:01:03 +Last updated 2020-02-23 22:54:59
    diff --git a/druid/base/button.lua b/druid/base/button.lua index 22f55b2..34f8f37 100644 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -2,15 +2,27 @@ -- @module druid.button --- Component events --- @tfield druid_event on_click --- @tfield druid_event on_hold_click --- @tfield druid_event on_long_click --- @tfield druid_event on_double_click --- @table events +-- @table Events +-- @tfield druid_event on_click On release button callback +-- @tfield druid_event on_repeated_click On repeated action button callback +-- @tfield druid_event on_long_click On long tap button callback +-- @tfield druid_event on_double_click On double tap button callback --- Component fields --- @tfield node Main node --- @table fields +-- @table Fields +-- @tfield node node Trigger node +-- @tfield[opt=node] node anim_node Animation node +-- @tfield vector3 scale_from Initial scale of anim_node +-- @tfield vector3 pos Initial pos of anim_node +-- @tfield any params Params to click callbacks +-- @tfield boolean hover_anim Is hover anim enabled +-- @tfield druid.hover hover Druid hover logic component +-- @tfield[opt] node click_zone Restriction zone + +--- Component style params +-- @table Style +-- @tfield function on_click (self, node) +-- @tfield function on_hover (self, node, hover_state) local Event = require("druid.event") local const = require("druid.const") @@ -36,7 +48,7 @@ local function on_button_release(self) if self.style.on_click then self.style.on_click(self, self.anim_node) end - self.callback(self:get_context(), self.params, self) + self.on_click:trigger(self:get_context(), self.params, self) end return true else @@ -66,19 +78,21 @@ function M.init(self, node, callback, params, anim_node, event) self.anim_node = anim_node and helper:get_node(anim_node) or self.node -- TODO: rename to start_scale self.scale_from = gui.get_scale(self.anim_node) - self.pos = gui.get_position(self.anim_node) - self.callback = callback self.params = params self.hover_anim = self.style.IS_HOVER self.hover = self.druid:new_hover(node, self, on_button_hover) + self.click_zone = nil -- Event stubs self.on_click = Event() - self.on_hold_click = Event() + self.on_repeated_click = Event() self.on_long_click = Event() self.on_double_click = Event() - self.click_zone = nil + if callback then + self.on_click:subscribe(callback) + end + end @@ -166,28 +180,4 @@ function M.get_key_trigger(self) end ---- Set usual button callback -function M.set_callback(self, callback) - -end - - ---- Repeat callback always, while holding button -function M.set_hold_callback(self, callback) - -end - - ---- Get doubletap callback on this button -function M.set_double_tap_callback(self, callback) - -end - - ---- Single callbacka after long_tap. No usual callback invoked -function M.set_long_tap_callback(self, callback) - -end - - return M diff --git a/druid/component.lua b/druid/component.lua index 8b9caf5..bc49060 100644 --- a/druid/component.lua +++ b/druid/component.lua @@ -9,26 +9,6 @@ local class = require("druid.system.middleclass") local Component = class("druid.component") ---- Setup component context and his style table --- @function component:setup_component --- @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(self, context, style) - self._meta = { - template = nil, - context = nil, - nodes = nil, - style = nil, - } - - self:set_context(context) - self:set_style(style) - - return self -end - - --- Get current component style table -- @function component:get_style -- @treturn table Component style table @@ -136,6 +116,26 @@ function Component.get_druid(self) end +--- Setup component context and his style table +-- @function component:setup_component +-- @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(self, context, style) + self._meta = { + template = nil, + context = nil, + nodes = nil, + style = nil, + } + + self:set_context(context) + self:set_style(style) + + return self +end + + --- Basic constructor of component. It will call automaticaly -- by `Component.static.create` -- @function component:initialize diff --git a/druid/event.lua b/druid/event.lua index baccb8e..8b3350e 100644 --- a/druid/event.lua +++ b/druid/event.lua @@ -12,13 +12,20 @@ function M.initialize(self) end +--- Subscribe callback on event +-- @function event:subscribe +-- @tparam function callback Callback itself function M.subscribe(self, callback) + assert(type(self) == "table", "You should subscribe to event with : syntax") assert(type(callback) == "function", "Callback should be function") table.insert(self._callbacks, callback) end +--- Unsubscribe callback on event +-- @function event:unsubscribe +-- @tparam function callback Callback itself function M.unsubscribe(self, callback) for i = 1, #self._callbacks do if self._callbacks[i] == callback then @@ -29,6 +36,9 @@ function M.unsubscribe(self, callback) end +--- Trigger the event and call all subscribed callbacks +-- @function event:trigger +-- @param ... All event params function M.trigger(self, ...) for i = 1, #self._callbacks do self._callbacks[i](...)