make space if needed when adding lines to a definition
This commit is contained in:
parent
c95a7e7184
commit
4492336866
|
@ -54,7 +54,10 @@ on.keychord_press = function(chord, key)
|
|||
maybe_update_key_in_definitions(old_definition_name, definition_name, Cursor_node)
|
||||
pan_viewport_to_contain_cursor(Cursor_node)
|
||||
if chord == 'return' then
|
||||
A()
|
||||
A1(Cursor_node.key)
|
||||
populate_collision_data()
|
||||
move_others(Cursor_node)
|
||||
A1(Cursor_node.key)
|
||||
else
|
||||
B()
|
||||
end
|
||||
|
|
|
@ -1,18 +1,8 @@
|
|||
-- 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
|
||||
def.hs.y = def.h/2 + 30
|
||||
def.pos.x = def.x + def.hs.x
|
||||
def.pos.y = def.y + def.hs.y
|
||||
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
|
||||
end
|
||||
populate_collision_data()
|
||||
-- give the target a little more buffer
|
||||
target.hs.x = target.hs.x + 50
|
||||
target.hs.y = target.hs.y + math.max(30, math.min(target.h/3, 200))
|
||||
end
|
|
@ -0,0 +1,12 @@
|
|||
populate_collision_data = function()
|
||||
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
|
||||
def.hs.y = def.h/2 + 30
|
||||
def.pos.x = def.x + def.hs.x
|
||||
def.pos.y = def.y + def.hs.y
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue