only add padding to the node being moved
This keeps the surface more stable as we move things around.
This commit is contained in:
parent
a7b9c3c808
commit
99035b22f9
|
@ -25,7 +25,7 @@ on.mouse_press = function(x,y, mouse_button)
|
|||
local node = on_handle(x,y)
|
||||
if node then
|
||||
-- move node
|
||||
prepare_to_move()
|
||||
prepare_to_move(node)
|
||||
Move = {xoff=App.mouse_x()-vx(node.x), yoff=App.mouse_y()-vy(node.y), node=node}
|
||||
return
|
||||
end
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
prepare_to_move = function()
|
||||
-- pad out one node fully, and all other nodes just enough to keep them from overlapping.
|
||||
-- We don't want cascading movements to get too chaotic.
|
||||
prepare_to_move = function(target)
|
||||
for _,def in pairs(Definitions) do
|
||||
assert(def.w)
|
||||
assert(def.h)
|
||||
if def.pos == nil then def.pos = {} end
|
||||
if def.hs == nil then def.hs = {} end
|
||||
def.hs.x = def.w/2 + 50
|
||||
def.hs.y = def.h/2 + math.max(60, math.min(def.h/3, 200))
|
||||
def.hs.x = def.w/2
|
||||
def.hs.y = def.h/2 + 30
|
||||
if def == target then
|
||||
def.hs.x = def.hs.x + 50
|
||||
def.hs.y = def.hs.y + math.max(30, math.min(def.h/3, 200))
|
||||
end
|
||||
def.pos.x = def.x + def.hs.x
|
||||
def.pos.y = def.y + def.hs.y
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue