diff --git a/druid/base/checkbox.lua b/druid/base/checkbox.lua index 7725082..d7406be 100644 --- a/druid/base/checkbox.lua +++ b/druid/base/checkbox.lua @@ -6,19 +6,15 @@ local helper = require("druid.helper") local M = {} -local function state_animate(node, state) - local target = state and 1 or 0 - gui.animate(node, "color.w", target, gui.EASING_OUTSINE, 0.1) -end - - function M.set_state(self, state, is_silence) if self.state == state then return end self.state = state - state_animate(self.node, state) + if self.style.on_change_state then + self.style.on_change_state(self, self.node, state) + end if not is_silence and self.callback then self.callback(self.context, state) @@ -37,6 +33,7 @@ end function M.init(self, node, callback, click_node) + self.style = helper.get_style(self, "CHECKBOX") self.druid = helper.get_druid(self) self.node = helper.node(node) self.click_node = helper.node(click_node) diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index 798d326..fa5d169 100644 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -215,6 +215,7 @@ local function add_delta(self, dx, dy) local t = self.target local b = self.border local soft = self.soft_size + -- TODO: Can we calc it more easier? -- A lot of calculations for every side of border diff --git a/druid/styles/bounce/style.lua b/druid/styles/bounce/style.lua index add520f..2acd7e9 100644 --- a/druid/styles/bounce/style.lua +++ b/druid/styles/bounce/style.lua @@ -54,13 +54,24 @@ M.SCROLL = { ANIM_SPEED = 0.3, -- gui.animation speed to point } + M.PROGRESS = { SPEED = 5, -- progress bar fill rate, more faster MIN_DELTA = 0.005 } + M.PROGRESS_RICH = { DELAY = 1, -- delay in seconds before main fill } + +M.CHECKBOX = { + on_change_state = function(self, node, state) + local target = state and 1 or 0 + gui.animate(node, "color.w", target, gui.EASING_OUTSINE, 0.1) + end +} + + return M diff --git a/druid/styles/empty/style.lua b/druid/styles/empty/style.lua new file mode 100644 index 0000000..10f627d --- /dev/null +++ b/druid/styles/empty/style.lua @@ -0,0 +1,43 @@ +local M = {} + + +M.BUTTON = { + BTN_SOUND = "click", + BTN_SOUND_DISABLED = "click", + DISABLED_COLOR = vmath.vector4(0, 0, 0, 1), + ENABLED_COLOR = vmath.vector4(1), + IS_HOVER = false, +} + + +M.SCROLL = { + FRICT_HOLD = 0, -- mult. for inert, while touching + FRICT = 0, -- mult for free inert + INERT_THRESHOLD = 2, -- speed to stop inertion + INERT_SPEED = 0, -- koef. of inert speed + DEADZONE = 6, -- in px + SOFT_ZONE_SIZE = 20, -- size of outside zone (back move) + BACK_SPEED = 0, -- lerp speed + ANIM_SPEED = 0, -- gui.animation speed to point +} + + +M.PROGRESS = { + SPEED = 5, -- progress bar fill rate, more faster + MIN_DELTA = 1 +} + + +M.PROGRESS_RICH = { + DELAY = 0, -- delay in seconds before main fill +} + + +M.CHECKBOX = { + on_change_state = function(self, node, state) + gui.set_enabled(node, state) + end +} + + +return M diff --git a/example/kenney/gui/main/main.gui_script b/example/kenney/gui/main/main.gui_script index 949418b..c0b923b 100644 --- a/example/kenney/gui/main/main.gui_script +++ b/example/kenney/gui/main/main.gui_script @@ -1,5 +1,6 @@ local druid = require("druid.druid") local bounce_style = require("druid.styles.bounce.style") +local empty_style = require("druid.styles.empty.style") local main_page = require("example.kenney.page.main") @@ -16,7 +17,7 @@ end function init(self) - druid.set_default_style(bounce_style) + druid.set_default_style(empty_style) self.druid = druid.new(self) init_top_panel(self)