Rename bounce -> default style, start make new example pages

This commit is contained in:
Insality
2020-02-24 00:03:29 +03:00
parent 822db35e84
commit a81d49de9d
25 changed files with 50 additions and 24 deletions

View File

@@ -0,0 +1,38 @@
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)
scale_to(self, node, target_scale)
end
function M.tap_scale_animation(self, node, target_scale)
scale_to(self, node, target_scale,
function()
M.back_scale_animation(self, node, self.scale_from)
end
)
end
function M.hover_scale(self, target, time)
gui.animate(self.anim_node, "scale", target, gui.EASING_OUTSINE, time)
end
return M

View File

@@ -0,0 +1,77 @@
local settings = require("druid.system.settings")
local anims = require("druid.styles.default.anims")
local M = {}
M["button"] = {
HOVER_SCALE = vmath.vector3(-0.025, -0.025, 1),
HOVER_TIME = 0.05,
SCALE_CHANGE = vmath.vector3(-0.05, - 0.05, 1),
BTN_SOUND = "click",
BTN_SOUND_DISABLED = "click",
DISABLED_COLOR = vmath.vector4(0, 0, 0, 1),
ENABLED_COLOR = vmath.vector4(1),
IS_HOVER = true,
on_hover = function(self, node, state)
if self.hover_anim then
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)
end
end,
on_click = function(self, node)
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)
end,
on_click_disabled = function(self, node)
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)
else
gui.set_color(node, M.button.DISABLED_COLOR)
end
end
}
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
INERT_SPEED = 25, -- koef. of inert speed
DEADZONE = 6, -- in px
SOFT_ZONE_SIZE = 160, -- size of outside zone (back move)
BACK_SPEED = 0.2, -- lerp speed
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