add some padding, and avoid infinite recursion
This commit is contained in:
parent
b7b45ff969
commit
a7b9c3c808
|
@ -23,8 +23,8 @@ on.update = function(dt)
|
|||
-- quantize the x axis to discrete columns
|
||||
Move.node.x = round(Move.node.x/100)*100
|
||||
A1(Move.node.key)
|
||||
Move.node.pos.x = Move.node.x+Move.node.w/2
|
||||
Move.node.pos.y = Move.node.y+Move.node.h/2
|
||||
Move.node.pos.x = Move.node.x+Move.node.hs.x
|
||||
Move.node.pos.y = Move.node.y+Move.node.hs.y
|
||||
move_others(Move.node)
|
||||
return
|
||||
end
|
||||
|
|
|
@ -23,6 +23,7 @@ on.draw = function()
|
|||
if obj.w == nil then
|
||||
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
|
||||
else
|
||||
-- hack: toss in a move affordance for every bit of text
|
||||
love.graphics.setColor(0.5,0.5,0.5)
|
||||
love.graphics.rectangle('fill', vx(obj.x),vy(obj.y-30), scale(obj.w/2-5), scale(20))
|
||||
edit.draw(obj.editor, obj.fg, not obj.show_cursor)
|
||||
|
|
|
@ -8,7 +8,7 @@ collide = function(a, b)
|
|||
if abs_amount.x > 0 and abs_amount.y > 0 then
|
||||
if abs_amount.x <= abs_amount.y then
|
||||
return {x=abs_amount.x*sign(delta.x), y=0}
|
||||
else
|
||||
else
|
||||
return {x=0, y=abs_amount.y*sign(delta.y)}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
-- move any colliding Rects to make room for `a`
|
||||
move_others = function(a)
|
||||
move_others = function(a, depth)
|
||||
if depth == nil then depth = 0 end
|
||||
if depth > 10 then return end
|
||||
-- print('move others', a.key)
|
||||
for _,d in pairs(Definitions) do
|
||||
if d ~= a then
|
||||
local msv = collide(a, d)
|
||||
if msv then
|
||||
move(d, msv)
|
||||
A1(d.key)
|
||||
move_others(d)
|
||||
move_others(d, depth+1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,9 +4,9 @@ prepare_to_move = function()
|
|||
assert(def.h)
|
||||
if def.pos == nil then def.pos = {} end
|
||||
if def.hs == nil then def.hs = {} end
|
||||
def.pos.x = def.x + def.w/2
|
||||
def.pos.y = def.y + def.h/2
|
||||
def.hs.x = def.w/2
|
||||
def.hs.y = def.h/2
|
||||
def.hs.x = def.w/2 + 50
|
||||
def.hs.y = def.h/2 + math.max(60, math.min(def.h/3, 200))
|
||||
def.pos.x = def.x + def.hs.x
|
||||
def.pos.y = def.y + def.hs.y
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue