mirror of
https://github.com/Insality/druid
synced 2025-11-26 19:00:52 +01:00
Update
This commit is contained in:
@@ -182,21 +182,13 @@ end
|
||||
---@param v2 number|nil Max value If nil, value will be clamped to negative infinity
|
||||
---@return number value Clamped value
|
||||
function M.clamp(value, v1, v2)
|
||||
if v1 and v2 then
|
||||
if v1 > v2 then
|
||||
v1, v2 = v2, v1
|
||||
end
|
||||
v1 = v1 or -math.huge
|
||||
v2 = v2 or math.huge
|
||||
if v1 > v2 then
|
||||
v1, v2 = v2, v1
|
||||
end
|
||||
|
||||
if v1 and value < v1 then
|
||||
return v1
|
||||
end
|
||||
|
||||
if v2 and value > v2 then
|
||||
return v2
|
||||
end
|
||||
|
||||
return value
|
||||
return math.max(v1, math.min(value, v2))
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ local COLOR_REFRESH_ACTIVE = "#8BD092"
|
||||
|
||||
function M:init()
|
||||
self.root = self:get_node("root")
|
||||
self.scale_root = gui.get_scale(self.root)
|
||||
self.content = self:get_node("content")
|
||||
|
||||
self.container = self.druid:new_container(self.root)
|
||||
@@ -118,7 +119,7 @@ end
|
||||
|
||||
function M:on_drag_widget(dx, dy)
|
||||
local position = self.container:get_position()
|
||||
self.container:set_position(position.x + dx, position.y + dy)
|
||||
self.container:set_position(position.x + dx * self.scale_root.x, position.y + dy * self.scale_root.y)
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user