mirror of
https://github.com/Insality/druid.git
synced 2025-09-28 02:22:18 +02:00
Add component instance with general methods. New component constructor
This commit is contained in:
@@ -4,7 +4,7 @@ local anims = require("druid.styles.bounce.anims")
|
||||
local M = {}
|
||||
|
||||
|
||||
M.BUTTON = {
|
||||
M["button"] = {
|
||||
HOVER_SCALE = vmath.vector3(-0.025, -0.025, 1),
|
||||
HOVER_TIME = 0.05,
|
||||
SCALE_CHANGE = vmath.vector3(-0.05, - 0.05, 1),
|
||||
@@ -16,34 +16,34 @@ M.BUTTON = {
|
||||
|
||||
on_hover = function(self, node, state)
|
||||
if self.hover_anim then
|
||||
local scale_to = self.scale_from + M.BUTTON.HOVER_SCALE
|
||||
local scale_to = self.scale_from + M.button.HOVER_SCALE
|
||||
|
||||
local target_scale = state and scale_to or self.scale_from
|
||||
anims.hover_scale(self, target_scale, M.BUTTON.HOVER_TIME)
|
||||
anims.hover_scale(self, target_scale, M.button.HOVER_TIME)
|
||||
end
|
||||
end,
|
||||
|
||||
on_click = function(self, node)
|
||||
local scale_to = self.scale_from + M.BUTTON.SCALE_CHANGE
|
||||
local scale_to = self.scale_from + M.button.SCALE_CHANGE
|
||||
anims.tap_scale_animation(self, node, scale_to)
|
||||
settings.play_sound(M.BUTTON.BTN_SOUND)
|
||||
settings.play_sound(M.button.BTN_SOUND)
|
||||
end,
|
||||
|
||||
on_click_disabled = function(self, node)
|
||||
settings.play_sound(M.BUTTON.BTN_SOUND_DISABLED)
|
||||
settings.play_sound(M.button.BTN_SOUND_DISABLED)
|
||||
end,
|
||||
|
||||
on_set_enabled = function(self, node, state)
|
||||
if state then
|
||||
gui.set_color(node, M.BUTTON.ENABLED_COLOR)
|
||||
gui.set_color(node, M.button.ENABLED_COLOR)
|
||||
else
|
||||
gui.set_color(node, M.BUTTON.DISABLED_COLOR)
|
||||
gui.set_color(node, M.button.DISABLED_COLOR)
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
M.SCROLL = {
|
||||
M["scroll"] = {
|
||||
FRICT_HOLD = 0.8, -- mult. for inert, while touching
|
||||
FRICT = 0.93, -- mult for free inert
|
||||
INERT_THRESHOLD = 2, -- speed to stop inertion
|
||||
@@ -55,18 +55,18 @@ M.SCROLL = {
|
||||
}
|
||||
|
||||
|
||||
M.PROGRESS = {
|
||||
M["progress"] = {
|
||||
SPEED = 5, -- progress bar fill rate, more faster
|
||||
MIN_DELTA = 0.005
|
||||
}
|
||||
|
||||
|
||||
M.PROGRESS_RICH = {
|
||||
M["progress_rich"] = {
|
||||
DELAY = 1, -- delay in seconds before main fill
|
||||
}
|
||||
|
||||
|
||||
M.CHECKBOX = {
|
||||
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)
|
||||
|
Reference in New Issue
Block a user