This commit is contained in:
Insality
2024-10-16 20:30:55 +03:00
parent 6e4490a3a7
commit aa6310db91
14 changed files with 60 additions and 47 deletions

View File

@@ -418,6 +418,8 @@ end
function Button.on_input_interrupt(self)
self.can_action = false
self.hover:set_hover(false)
self.hover:set_mouse_hover(false)
end

View File

@@ -108,13 +108,15 @@ end
-- @tparam Hover self @{Hover}
-- @tparam boolean|nil state The hover state
function Hover.set_hover(self, state)
if self._is_hovered ~= state then
self._is_hovered = state
self.on_hover:trigger(self:get_context(), state, self)
if self._is_hovered == state then
return
end
if defos and self.style.ON_HOVER_CURSOR then
self:_set_cursor(3, state and self.style.ON_HOVER_CURSOR or nil)
end
self._is_hovered = state
self.on_hover:trigger(self:get_context(), state, self)
if defos and self.style.ON_HOVER_CURSOR then
self:_set_cursor(3, state and self.style.ON_HOVER_CURSOR or nil)
end
end
@@ -131,13 +133,15 @@ end
-- @tparam Hover self @{Hover}
-- @tparam boolean|nil state The mouse hover state
function Hover.set_mouse_hover(self, state)
if self._is_mouse_hovered ~= state then
self._is_mouse_hovered = state
self.on_mouse_hover:trigger(self:get_context(), state, self)
if self._is_mouse_hovered == state then
return
end
if defos and self.style.ON_MOUSE_HOVER_CURSOR then
self:_set_cursor(2, state and self.style.ON_MOUSE_HOVER_CURSOR or nil)
end
self._is_mouse_hovered = state
self.on_mouse_hover:trigger(self:get_context(), state, self)
if defos and self.style.ON_MOUSE_HOVER_CURSOR then
self:_set_cursor(2, state and self.style.ON_MOUSE_HOVER_CURSOR or nil)
end
end

View File

@@ -24,7 +24,7 @@ local helper = require("druid.helper")
local BaseComponent = {}
local INTERESTS = {} -- Cache interests per component class in runtime
local IS_AUTO_TEMPLATE = not (sys.get_config_int("druid.no_auto_template", 0) == "1")
local IS_AUTO_TEMPLATE = not (sys.get_config_int("druid.no_auto_template", 0) == 1)
-- Component Interests
BaseComponent.ON_INPUT = const.ON_INPUT

View File

@@ -21,8 +21,9 @@ M.ACTION_LEFT = hash(sys.get_config_string("druid.input_key_left", "key_left"))
M.ACTION_RIGHT = hash(sys.get_config_string("druid.input_key_right", "key_right"))
M.ACTION_LSHIFT = hash(sys.get_config_string("druid.input_key_lshift", "key_lshift"))
M.ACTION_LCTRL = hash(sys.get_config_string("druid.input_key_lctrl", "key_lctrl"))
M.ACTION_LCMD = hash(sys.get_config_string("druid.input_key_lsuper", "key_lsuper"))
M.IS_STENCIL_CHECK = not (sys.get_config_string("druid.no_stencil_check") == "1")
M.IS_STENCIL_CHECK = not (sys.get_config_int("druid.no_stencil_check", 0) == 1)
M.ON_INPUT = "on_input"

View File

@@ -224,7 +224,7 @@ function RichInput.on_input(self, action_id, action)
end
end
if action_id == const.ACTION_LCTRL then
if action_id == const.ACTION_LCTRL or action_id == const.ACTION_LCMD then
if action.pressed then
self.is_lctrl = true
elseif action.released then

View File

@@ -71,9 +71,6 @@
--- The text prefab node
-- @tfield node text_prefab
--- The icon prefab node
-- @tfield node icon_prefab
--
local component = require("druid.component")

View File

@@ -26,7 +26,7 @@ end
function M.get_commands()
return {
{
label = "Assign layers",
label = "Assign Layers",
locations = {"Edit"},

View File

@@ -207,15 +207,20 @@ function M.refresh_layout(self)
end
if type == "vertical" then
position_x = current_x + row.width * (0.5 - pivot_offset.x)
position_y = current_y - node_height * (0.5 + pivot_offset.y)
local node_margin = margin.y
if is_justify then
node_margin = (max_height - rows_data.total_height) / (#rows - 1) + margin.y
end
current_x = -row.width * (0.5 + layout_pivot_offset.x)
position_x = current_x + row.width * (0.5 + pivot_offset.x)
position_y = current_y - node_height * (0.5 - pivot_offset.y)
current_y = current_y - node_height - node_margin
row_index = row_index + 1
row = rows[row_index]
end
if type == "horizontal_wrap" then

View File

@@ -36,7 +36,10 @@ M["button"] = {
on_click = function(self, node)
local scale_to = self.start_scale + M.button.SCALE_CHANGE
gui.set_scale(node, scale_to)
gui.animate(node, gui.PROP_SCALE, self.start_scale, gui.EASING_OUTBACK, 0.24)
local is_hover = self.hover:is_mouse_hovered()
local target_scale = is_hover and self.start_scale + M.button.HOVER_MOUSE_SCALE or self.start_scale
gui.animate(node, gui.PROP_SCALE, target_scale, gui.EASING_OUTBACK, 0.24)
settings.play_sound(M.button.BTN_SOUND)
end,