resize handler seems to be working
This commit is contained in:
parent
d55ecf822b
commit
eb46a98742
|
@ -4,11 +4,24 @@ on.mouse_press = function(x,y, mouse_button)
|
|||
Cursor_node = nil
|
||||
end
|
||||
local sx, sy = sx(x), sy(y)
|
||||
local node = to_node(sx,sy)
|
||||
local node = on_node(sx,sy)
|
||||
if node then
|
||||
Cursor_node = node
|
||||
edit.mouse_press(node.editor, x,y, mouse_button)
|
||||
else
|
||||
return
|
||||
end
|
||||
node = on_move_bar(sx,sy)
|
||||
if node then
|
||||
Move_node = node
|
||||
Move = {x=sx, y=sy}
|
||||
return
|
||||
end
|
||||
node = on_resize(sx,sy)
|
||||
if node then
|
||||
Resize_node = node
|
||||
Resize = {x=x, y=y}
|
||||
return
|
||||
end
|
||||
-- default
|
||||
Pan = {x=sx,y=sy}
|
||||
end
|
||||
end
|
|
@ -1,6 +1,18 @@
|
|||
on.mouse_release = function(x,y, mouse_button)
|
||||
if Pan then
|
||||
Pan = nil
|
||||
elseif Resize_node then
|
||||
print('before', Resize_node.width)
|
||||
print('editor before', Resize_node.editor.width)
|
||||
Resize_node.width = Resize_node.width + (x - Resize.x)/Viewport.zoom
|
||||
print('after', Resize_node.width)
|
||||
A()
|
||||
print('editor after', Resize_node.editor.width)
|
||||
Resize_node = nil
|
||||
Resize = nil
|
||||
elseif Move_node then
|
||||
Move_node = nil
|
||||
Move = nil
|
||||
elseif Cursor_node then
|
||||
Cursor_node.show_cursor = true
|
||||
edit.mouse_release(Cursor_node.editor, x,y, mouse_button)
|
||||
|
|
|
@ -13,6 +13,7 @@ compute_layout = function(node, x,y, nodes_to_render, preserve_screen_top_of_cur
|
|||
local bounding_box = {type='rectangle', drawmode='line', r=0.5, g=0.5, b=0.5, x=node.x-10, y=node.y-10, corner_radius=5}
|
||||
table.insert(nodes_to_render, bounding_box)
|
||||
-- render contents
|
||||
print('node.width', node.width)
|
||||
if node.width then
|
||||
node.w = node.width
|
||||
else
|
||||
|
|
|
@ -11,6 +11,7 @@ update_editor_box = function(node, preserve_screen_top_of_cursor_node)
|
|||
end
|
||||
node.editor.left = math.floor(vx(node.x))
|
||||
node.editor.right = math.ceil(vx(node.x+node.w))
|
||||
node.editor.width = node.editor.right - node.editor.left
|
||||
edit.update_font_settings(node.editor, scale(20))
|
||||
Text.redraw_all(node.editor)
|
||||
end
|
|
@ -1,4 +1,4 @@
|
|||
to_node = function(sx,sy)
|
||||
on_node = function(sx,sy)
|
||||
for _,node in ipairs(Surface) do
|
||||
if node.type == 'text' then
|
||||
if sx >= node.x and sx < node.x + node.w then
|
Loading…
Reference in New Issue