Merge luaML.love
This commit is contained in:
commit
7f418589fb
7
0002-vx
7
0002-vx
|
@ -1,3 +1,4 @@
|
|||
vx = function(x)
|
||||
return scale(x-Viewport.x)
|
||||
end
|
||||
vx = function(sx)
|
||||
-- turn surface coordinates into viewport coordinates
|
||||
return scale(sx-Viewport.x)
|
||||
end
|
||||
|
|
7
0004-vy
7
0004-vy
|
@ -1,3 +1,4 @@
|
|||
vy = function(y)
|
||||
return scale(y-Viewport.y)
|
||||
end
|
||||
vy = function(sy)
|
||||
-- turn surface coordinates into viewport coordinates
|
||||
return scale(sy-Viewport.y)
|
||||
end
|
||||
|
|
|
@ -3,7 +3,8 @@ on.mouse_press = function(x,y, mouse_button)
|
|||
if node_id then
|
||||
App.setClipboardText(Nodes[node_id].url)
|
||||
Cursor_node = Nodes[node_id]
|
||||
else
|
||||
Pan = {x=Viewport.x+x/Viewport.zoom, y=Viewport.y+y/Viewport.zoom}
|
||||
return
|
||||
end
|
||||
end
|
||||
-- pan surface
|
||||
Pan = {x=Viewport.x+x/Viewport.zoom,y=Viewport.y+y/Viewport.zoom}
|
||||
end
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
box_height = function(node)
|
||||
-- return the height of a node. The result is scaled.
|
||||
local y = 0
|
||||
for i=1,#node.editor.lines do
|
||||
local line = node.editor.lines[i]
|
||||
if node.editor.line_cache[i] == nil then
|
||||
node.editor.line_cache[i] = {}
|
||||
end
|
||||
node.editor.line_cache[i].fragments = nil
|
||||
node.editor.line_cache[i].screen_line_starting_pos = nil
|
||||
Text.populate_screen_line_starting_pos(node.editor, i)
|
||||
y = y + node.editor.line_height*#node.editor.line_cache[i].screen_line_starting_pos
|
||||
Text.clear_screen_line_cache(node.editor, i)
|
||||
end
|
||||
-- font size never changes in this app
|
||||
return y/Viewport.zoom
|
||||
-- return the height of a text editor node (explicit width). The result is unscaled.
|
||||
local y = 0
|
||||
for i=1,#node.editor.lines do
|
||||
local line = node.editor.lines[i]
|
||||
if node.editor.line_cache[i] == nil then
|
||||
node.editor.line_cache[i] = {}
|
||||
end
|
||||
node.editor.line_cache[i].fragments = nil
|
||||
node.editor.line_cache[i].screen_line_starting_pos = nil
|
||||
Text.populate_screen_line_starting_pos(node.editor, i)
|
||||
y = y + 20*1.3*#node.editor.line_cache[i].screen_line_starting_pos
|
||||
Text.clear_screen_line_cache(node.editor, i)
|
||||
end
|
||||
return y
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
on.mouse_release = function(x,y, mouse_button)
|
||||
if Pan then
|
||||
Pan = nil
|
||||
A()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,8 +17,7 @@ compute_layout = function(node, x,y, nodes_to_render, preserve_screen_top_of_cur
|
|||
else
|
||||
node.w = 0
|
||||
for i,s in ipairs(node.data) do
|
||||
local text = love.graphics.newText(font(20), node.data)
|
||||
local width = text:getWidth()
|
||||
local width = love.graphics.getFont():getWidth(s)
|
||||
if node.w < width then node.w = width end
|
||||
end
|
||||
end
|
||||
|
@ -95,4 +94,4 @@ compute_layout = function(node, x,y, nodes_to_render, preserve_screen_top_of_cur
|
|||
end
|
||||
end
|
||||
return x+node.w,y+node.h
|
||||
end
|
||||
end
|
||||
|
|
3
0028-A
3
0028-A
|
@ -1,9 +1,10 @@
|
|||
A = function(filename)
|
||||
if filename then
|
||||
love.graphics.setFont(love.graphics.newFont(scale(20))) -- editor objects implicitly depend on current font
|
||||
local f = io.open(filename)
|
||||
assert(f)
|
||||
local thread_data = json.decode(f:read('*a'))
|
||||
render_thread_to_surface(thread_data)
|
||||
end
|
||||
B()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,16 +1,21 @@
|
|||
update_editor_box = function(node, preserve_screen_top_of_cursor_node)
|
||||
if node.editor == nil then return end
|
||||
if node.y > Viewport.y then
|
||||
-- Compute screen_top1 in viewport coordinates because the editor's font takes scaling into account.
|
||||
if vy(node.y) > 0 then
|
||||
if not preserve_screen_top_of_cursor_node or node ~= Cursor_node then
|
||||
node.editor.screen_top1.line = 1
|
||||
node.editor.screen_top1.pos = 1
|
||||
end
|
||||
node.editor.top = vy(node.y)
|
||||
else
|
||||
node.editor.screen_top1, node.editor.top = schema1_of_y(node.editor, Viewport.y - node.y)
|
||||
node.editor.screen_top1, node.editor.top = schema1_of_y(node.editor, -vy(node.y))
|
||||
end
|
||||
if node.editor.font_height ~= scale(20) then
|
||||
edit.update_font_settings(node.editor, scale(20))
|
||||
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
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue