From 3b38992de8f090ba68d84c55e32e198515927a19 Mon Sep 17 00:00:00 2001 From: Insality Date: Thu, 6 Feb 2020 01:53:41 +0300 Subject: [PATCH] remove druid_animate, update docs --- docs/index.html | 14 +- docs/modules/component.html | 4 +- docs/modules/const.html | 4 +- docs/modules/druid.back_handler.html | 4 +- docs/modules/druid.blocker.html | 4 +- docs/modules/druid.button.html | 4 +- docs/modules/druid.checkbox.html | 4 +- docs/modules/druid.checkbox_group.html | 4 +- docs/modules/druid.grid.html | 4 +- docs/modules/druid.html | 4 +- docs/modules/druid.locale.html | 4 +- docs/modules/druid.progress.html | 4 +- docs/modules/druid.progress_rich.html | 4 +- docs/modules/druid.radio_group.html | 4 +- docs/modules/druid.scroll.html | 4 +- docs/modules/druid.slider.html | 4 +- docs/modules/druid.text.html | 4 +- docs/modules/druid.timer.html | 4 +- docs/modules/druid_instance.html | 4 +- docs/modules/helper.formats.html | 4 +- docs/modules/helper.html | 4 +- druid/base/button.lua | 1 + druid/base/timer.lua | 24 ++-- druid/helper/druid_animate.lua | 189 ------------------------- druid/styles/bounce/anims.lua | 24 +++- druid/system/component.lua | 169 ---------------------- druid/system/druid_instance.lua | 2 - 27 files changed, 79 insertions(+), 424 deletions(-) delete mode 100644 druid/helper/druid_animate.lua delete mode 100644 druid/system/component.lua diff --git a/docs/index.html b/docs/index.html index f04bfad..6e28364 100644 --- a/docs/index.html +++ b/docs/index.html @@ -44,12 +44,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -58,7 +58,7 @@
    -

    Documentation for Druid Library

    +

    Documentation for Druid UI Library

    Modules

    @@ -116,6 +116,10 @@ + + + + @@ -136,10 +140,6 @@ - - - - @@ -150,7 +150,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/docs/modules/component.html b/docs/modules/component.html index efdbf93..97bca4d 100644 --- a/docs/modules/component.html +++ b/docs/modules/component.html @@ -51,12 +51,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -398,7 +398,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/docs/modules/const.html b/docs/modules/const.html index a660ac7..67e8268 100644 --- a/docs/modules/const.html +++ b/docs/modules/const.html @@ -51,12 +51,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -105,7 +105,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/docs/modules/druid.back_handler.html b/docs/modules/druid.back_handler.html index 056ed7a..851b443 100644 --- a/docs/modules/druid.back_handler.html +++ b/docs/modules/druid.back_handler.html @@ -51,12 +51,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -150,7 +150,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/docs/modules/druid.blocker.html b/docs/modules/druid.blocker.html index 2bfeb01..2eac1e0 100644 --- a/docs/modules/druid.blocker.html +++ b/docs/modules/druid.blocker.html @@ -47,12 +47,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -76,7 +76,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/docs/modules/druid.button.html b/docs/modules/druid.button.html index 5550167..54a61db 100644 --- a/docs/modules/druid.button.html +++ b/docs/modules/druid.button.html @@ -51,12 +51,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -190,7 +190,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/docs/modules/druid.checkbox.html b/docs/modules/druid.checkbox.html index 69bf10e..4a55bba 100644 --- a/docs/modules/druid.checkbox.html +++ b/docs/modules/druid.checkbox.html @@ -47,12 +47,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -76,7 +76,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/docs/modules/druid.checkbox_group.html b/docs/modules/druid.checkbox_group.html index fd22518..b8824a0 100644 --- a/docs/modules/druid.checkbox_group.html +++ b/docs/modules/druid.checkbox_group.html @@ -47,12 +47,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -76,7 +76,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/docs/modules/druid.grid.html b/docs/modules/druid.grid.html index 2dc932e..3aeed3a 100644 --- a/docs/modules/druid.grid.html +++ b/docs/modules/druid.grid.html @@ -47,12 +47,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -77,7 +77,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/docs/modules/druid.html b/docs/modules/druid.html index e2407f7..51c19d0 100644 --- a/docs/modules/druid.html +++ b/docs/modules/druid.html @@ -51,12 +51,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -161,7 +161,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/docs/modules/druid.locale.html b/docs/modules/druid.locale.html index a815917..45da53f 100644 --- a/docs/modules/druid.locale.html +++ b/docs/modules/druid.locale.html @@ -51,12 +51,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -117,7 +117,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/docs/modules/druid.progress.html b/docs/modules/druid.progress.html index a51299f..5bb06b8 100644 --- a/docs/modules/druid.progress.html +++ b/docs/modules/druid.progress.html @@ -51,12 +51,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -295,7 +295,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/docs/modules/druid.progress_rich.html b/docs/modules/druid.progress_rich.html index f543b12..2cce401 100644 --- a/docs/modules/druid.progress_rich.html +++ b/docs/modules/druid.progress_rich.html @@ -51,12 +51,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -175,7 +175,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/docs/modules/druid.radio_group.html b/docs/modules/druid.radio_group.html index 37f9b24..b1bb0e0 100644 --- a/docs/modules/druid.radio_group.html +++ b/docs/modules/druid.radio_group.html @@ -47,12 +47,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -76,7 +76,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/docs/modules/druid.scroll.html b/docs/modules/druid.scroll.html index dc62222..2836be1 100644 --- a/docs/modules/druid.scroll.html +++ b/docs/modules/druid.scroll.html @@ -51,12 +51,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -275,7 +275,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/docs/modules/druid.slider.html b/docs/modules/druid.slider.html index bb12425..427bc7a 100644 --- a/docs/modules/druid.slider.html +++ b/docs/modules/druid.slider.html @@ -47,12 +47,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -76,7 +76,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/docs/modules/druid.text.html b/docs/modules/druid.text.html index d118b49..abb909d 100644 --- a/docs/modules/druid.text.html +++ b/docs/modules/druid.text.html @@ -51,12 +51,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -234,7 +234,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/docs/modules/druid.timer.html b/docs/modules/druid.timer.html index 23a625d..52c40e5 100644 --- a/docs/modules/druid.timer.html +++ b/docs/modules/druid.timer.html @@ -51,12 +51,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -178,7 +178,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/docs/modules/druid_instance.html b/docs/modules/druid_instance.html index f0be67e..93f898e 100644 --- a/docs/modules/druid_instance.html +++ b/docs/modules/druid_instance.html @@ -51,12 +51,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -709,7 +709,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/docs/modules/helper.formats.html b/docs/modules/helper.formats.html index 3f58d1e..f2f5a94 100644 --- a/docs/modules/helper.formats.html +++ b/docs/modules/helper.formats.html @@ -51,12 +51,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -185,7 +185,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/docs/modules/helper.html b/docs/modules/helper.html index d796afa..1b48bb9 100644 --- a/docs/modules/helper.html +++ b/docs/modules/helper.html @@ -51,12 +51,12 @@
  • druid.slider
  • druid.text
  • druid.timer
  • +
  • component
  • const
  • druid
  • helper
  • helper.formats
  • druid.progress_rich
  • -
  • component
  • druid_instance
  • @@ -147,7 +147,7 @@
    generated by LDoc 1.4.6 -Last updated 2020-02-05 02:43:10 +Last updated 2020-02-06 01:47:09
    diff --git a/druid/base/button.lua b/druid/base/button.lua index 5fb3a14..549c330 100644 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -4,6 +4,7 @@ -- TODO: Add button mode: -- Long tap -- Repeated tap +-- Double tap? local const = require("druid.const") local helper = require("druid.helper") diff --git a/druid/base/timer.lua b/druid/base/timer.lua index 62c3c41..b7f1adc 100644 --- a/druid/base/timer.lua +++ b/druid/base/timer.lua @@ -62,18 +62,20 @@ end function M.update(self, dt) - if self.is_on then - self.temp = self.temp + dt - local dist = math.min(1, math.abs(self.value - self.target)) + if not self.is_on then + return + end - if self.temp > dist then - self.temp = self.temp - dist - self.value = helper.step(self.value, self.target, 1) - M.set_to(self, self.value) - if self.value == self.target then - self:set_state(false) - self.callback(self:get_context(), self) - end + self.temp = self.temp + dt + local dist = math.min(1, math.abs(self.value - self.target)) + + if self.temp > dist then + self.temp = self.temp - dist + self.value = helper.step(self.value, self.target, 1) + M.set_to(self, self.value) + if self.value == self.target then + self:set_state(false) + self.callback(self:get_context(), self) end end end diff --git a/druid/helper/druid_animate.lua b/druid/helper/druid_animate.lua deleted file mode 100644 index 22ed827..0000000 --- a/druid/helper/druid_animate.lua +++ /dev/null @@ -1,189 +0,0 @@ --- Druid helper module for animating GUI nodes --- @module helper.animate - -local M = {} - -local PROP_SCALE = gui.PROP_SCALE -local PROP_POSITION = gui.PROP_POSITION -local PROP_COLOR = hash("color") -local PROP_SCALE_X = "scale.x" -local PROP_SCALE_Y = "scale.y" - -M.PROP_POS_X = hash("position.x") -M.PROP_POS_Y = hash("position.y") -M.PROP_ALPHA = hash("color.w") - -M.TINT_HIDE = vmath.vector4(1, 1, 1, 0) -M.TINT_SHOW = vmath.vector4(1, 1, 1, 1) - -M.V3_ONE = vmath.vector3(1, 1, 1) -M.V3_ZERO = vmath.vector3(0, 0, 1) - -M.SCALE_ANIMATION_TIME = 0.1 -M.BOUNCE_ANIMATION_TIME = 0.25 -M.ALPHA_ANIMATION_TIME = 0.25 - - -function M.alpha(self, node, alpha, callback, time, delay, easing, playback) - time = time or M.ALPHA_ANIMATION_TIME - delay = delay or 0 - easing = easing or gui.EASING_LINEAR - playback = playback or gui.PLAYBACK_ONCE_FORWARD - gui.animate(node, M.PROP_ALPHA, alpha, easing, time, delay, - function() - if callback then - callback(self, node) - end - end, - playback) -end - - -function M.color(self, node, color, callback, time, delay, easing, playback) - time = time or M.ALPHA_ANIMATION_TIME - delay = delay or 0 - easing = easing or gui.EASING_LINEAR - playback = playback or gui.PLAYBACK_ONCE_FORWARD - gui.animate(node, PROP_COLOR, color, easing, time, delay, - function() - if callback then - callback(self, node) - end - end, - playback) -end - - -function M.shake(self, node, callback, str, time) - str = str or - 30 - time = time or 0.25 - local pos = gui.get_position(node) - pos.x = pos.x + str - gui.animate(node, PROP_POSITION, pos, gui.EASING_INELASTIC, time, - 0, - function() - if callback then - callback(self) - end - end, - gui.PLAYBACK_ONCE_BACKWARD - ) -end - - -function M.bounce(self, node, change_to, callback, time, easing, playback, delaly) - time = time or M.BOUNCE_ANIMATION_TIME - delaly = delaly or 0 - easing = easing or gui.EASING_OUTSINE - playback = playback or gui.PLAYBACK_ONCE_PINGPONG - gui.animate(node, PROP_SCALE, change_to, easing, time, delaly, - function() - if callback then - callback(self) - end - end, - playback) -end - - -function M.fly_to(self, node, to_pos, speed, callback, delay, easing) - easing = easing or gui.EASING_OUTSINE - delay = delay or 0 - local time = vmath.length(to_pos - gui.get_position(node)) / 100 / speed - gui.animate(node, gui.PROP_POSITION, to_pos, easing, time, delay, - function() - if callback then - callback(self, node) - end - end) -end - - -function M.fly_by_x(self, node, to_x, time, callback, delay, easing, playback) - playback = playback or gui.PLAYBACK_ONCE_FORWARD - easing = easing or gui.EASING_OUTSINE - delay = delay or 0 - gui.animate(node, M.PROP_POS_X, to_x, easing, time, delay, - function() - if callback then - callback(self, node) - end - end, - playback) -end - - -function M.fly_by_y(self, node, to_y, time, callback, delay, easing, playback) - playback = playback or gui.PLAYBACK_ONCE_FORWARD - easing = easing or gui.EASING_OUTSINE - delay = delay or 0 - time = time or 0.25 - gui.animate(node, M.PROP_POS_Y, to_y, easing, time, delay, - function() - if callback then - callback(self, node) - end - end, - playback) -end - - -function M.scale_to(self, node, to, callback, time, delay, easing) - easing = easing or gui.EASING_INSINE - time = time or M.SCALE_ANIMATION_TIME - delay = delay or 0 - time = time or 0.25 - gui.animate(node, PROP_SCALE, to, easing, time, delay, - function() - if callback then - callback(self, node) - end - end - ) -end - - -function M.scale(self, node, to, time) - gui.animate(node, "scale", to, gui.EASING_OUTSINE, time) -end - - -function M.scale_x_from_to(self, node, from, to, callback, time, easing, delay, playback) - easing = easing or gui.EASING_INSINE - time = time or M.SCALE_ANIMATION_TIME - delay = delay or 0 - playback = playback or gui.PLAYBACK_ONCE_FORWARD - local scale = gui.get_scale(node) - scale.x = from - gui.set_scale(node, scale) - gui.animate(node, PROP_SCALE_X, to, easing, time, delay, - function() - if callback then - callback(self) - end - end, - playback - ) -end - - -function M.scale_y_from_to(self, node, from, to, callback, time, easing, delay, playback) - easing = easing or gui.EASING_INSINE - time = time or M.SCALE_ANIMATION_TIME - delay = delay or 0 - playback = playback or gui.PLAYBACK_ONCE_FORWARD - local scale = gui.get_scale(node) - scale.y = from - gui.set_scale(node, scale) - gui.animate(node, PROP_SCALE_Y, to, easing, time, delay, - function() - if callback then - callback(self) - end - end, - playback - ) -end - - -return M \ No newline at end of file diff --git a/druid/styles/bounce/anims.lua b/druid/styles/bounce/anims.lua index bb642a6..ae56a40 100644 --- a/druid/styles/bounce/anims.lua +++ b/druid/styles/bounce/anims.lua @@ -1,16 +1,28 @@ -local ui_animate = require("druid.helper.druid_animate") - - local M = {} +local function scale_to(self, node, to, callback, time, delay, easing) + easing = easing or gui.EASING_INSINE + time = time or M.SCALE_ANIMATION_TIME + delay = delay or 0 + time = time or 0.25 + gui.animate(node, gui.PROP_SCALE, to, easing, time, delay, + function() + if callback then + callback(self, node) + end + end + ) +end + + function M.back_scale_animation(self, node, target_scale) - ui_animate.scale_to(self, node, target_scale) + scale_to(self, node, target_scale) end function M.tap_scale_animation(self, node, target_scale) - ui_animate.scale_to(self, node, target_scale, + scale_to(self, node, target_scale, function() M.back_scale_animation(self, node, self.scale_from) end @@ -19,7 +31,7 @@ end function M.hover_scale(self, target, time) - ui_animate.scale(self, self.anim_node, target, time) + gui.animate(self.anim_node, "scale", target, gui.EASING_OUTSINE, time) end diff --git a/druid/system/component.lua b/druid/system/component.lua deleted file mode 100644 index 2013cda..0000000 --- a/druid/system/component.lua +++ /dev/null @@ -1,169 +0,0 @@ ---- Basic class for all Druid components. --- To create you component, use `component.create` --- @module component - -local const = require("druid.const") -local class = require("druid.system.middleclass") - --- @classmod Component -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 -function Component.get_style(self) - if not self._meta.style then - return const.EMPTY_TABLE - end - - return self._meta.style[self._component.name] or const.EMPTY_TABLE -end - - ---- Set current component style table --- @function component:set_style --- @tparam table style Druid style module -function Component.set_style(self, druid_style) - self._meta.style = druid_style -end - - ---- Get current component template name --- @function component:get_template --- @treturn string Component template name -function Component.get_template(self) - return self._meta.template -end - - ---- Set current component template name --- @function component:set_template --- @tparam string template Component template name -function Component.set_template(self, template) - self._meta.template = template -end - - ---- Get current component nodes --- @function component:get_nodes --- @treturn table Component nodes table -function Component.get_nodes(self) - return self._meta.nodes -end - - ---- Set current component nodes --- @function component:set_nodes --- @tparam table nodes Component nodes table -function Component.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(self, context) - return self._meta.context -end - - ---- Set current component context --- @function component:set_context --- @tparam table context Druid context. Usually it is self of script -function Component.set_context(self, context) - self._meta.context = context -end - - ---- Get current component interests --- @function component:get_interests --- @treturn table List of component interests -function Component.get_interests(self) - return self._component.interest -end - - --- TODO: Определиться с get_node и node --- get_node - берет ноду по ноде или строке --- node - может брать ноду у компонента по схеме (если есть --- template или таблица нод после gui.clone_tree) -function Component.get_node(self, node_or_name) - local template_name = self:get_template() or const.EMPTY_STRING - local nodes = self:get_nodes() - - if nodes then - return nodes[template_name .. node_or_name] - else - if type(node_or_name) == const.STRING then - return gui.get_node(template_name .. node_or_name) - else - return node_or_name - end - end -end - - ---- Return druid with context of calling component. --- Use it to create component inside of other components. --- @function component:get_druid --- @treturn Druid Druid instance with component context -function Component.get_druid(self) - local context = { _context = self } - return setmetatable(context, { __index = self:get_context().druid }) -end - - ---- Basic constructor of component. It will call automaticaly --- by `Component.static.create` --- @function component:initialize --- @tparam string name Component name --- @tparam table interest List of component's interest --- @local -function Component.initialize(self, name, interest) - self._component = { - name = name, - interest = interest - } -end - - ---- Create new component. It will inheritance from basic --- druid component. --- @function Component.create --- @tparam string name Component name --- @tparam table interest List of component's interest -function Component.static.create(name, interest) - -- Yea, inheritance here - local new_class = class(name, Component) - - new_class.initialize = function(self) - Component.initialize(self, name, interest) - end - - return new_class -end - - -return Component diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index b76b652..4a524fe 100644 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -361,6 +361,4 @@ function Druid.new_progress_rich(self, ...) end - - return Druid
    druid.timer Component to handle GUI timers
    componentBasic class for all Druid components.
    const Druid constantsdruid.progress_rich Component for rich progress component
    componentBasic class for all Druid components.
    druid_instance Druid main class.