Also much fiddling as I noodle on the big picture of pensieve.love and figure out how to implement panning between mouse and keyboard.
S4QPRGGMVRDOB5FINBVTWSXMSOX4HA2GPRFQ5UIXRHTIHUUGZIZQC
{"vx":5,"Viewport":233,"initialize_editor":74,"vy":8,"compute_layout":235,"scale":7,"on.mouse_pressed":179,"on.mouse_released":178,"on.textinput":177,"on.update":14,"font":228,"on.keychord_pressed":200,"to_text":180,"Page":202,"parent":234,"on":1,"Surface":196,"box_height":44,"on.code_changed":212,"on.draw":234,"Cursor_node":172}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
-- leaf node containing raw text
node.x = x
node.y = y
-- render background if necessary
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
-- render contents
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.w = 0
for _,s in ipairs(node.data) do
local text = love.graphics.newText(font(scaled_fontsize), node.data)
local width = text:getWidth()
if node.w < width then node.w = width end
end
end
initialize_editor(node)
node.h = box_height(node)
table.insert(nodes_to_render, node)
if node_to_render then
node_to_render.w = node.w
node_to_render.h = node.h
end
elseif node.type == 'rows' then
node.x = x
node.y = y
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
end
return x+node.w,y+node.h
end
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
love.graphics.setFont(font(scaled_fontsize))
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"vx":5,"Viewport":233,"initialize_editor":74,"vy":8,"compute_layout":229,"scale":7,"on.mouse_pressed":179,"on.mouse_released":178,"on.textinput":177,"on.update":14,"font":228,"on.keychord_pressed":200,"to_text":180,"Page":202,"parent":233,"on":1,"Surface":196,"box_height":44,"on.code_changed":212,"on.draw":234,"Cursor_node":172}
{"vx":5,"Viewport":233,"initialize_editor":74,"vy":8,"compute_layout":229,"scale":7,"on.mouse_pressed":179,"on.mouse_released":178,"on.textinput":177,"on.update":14,"font":228,"on.keychord_pressed":200,"to_text":180,"Page":202,"parent":232,"on":1,"Surface":196,"box_height":44,"on.code_changed":212,"on.draw":225,"Cursor_node":172}
Viewport = {x=-50, y=-50, w=800,h=600, zoom=1.2}
{"vx":5,"Viewport":232,"initialize_editor":74,"vy":8,"compute_layout":229,"scale":7,"on.mouse_pressed":179,"on.mouse_released":178,"on.textinput":177,"on.update":14,"font":228,"on.keychord_pressed":200,"to_text":180,"Page":202,"parent":231,"on":1,"Surface":196,"box_height":44,"on.code_changed":212,"on.draw":225,"Cursor_node":172}
Viewport = {x=-50, y=-50, w=800,h=600, zoom=1.5}
{"vx":5,"Viewport":231,"initialize_editor":74,"vy":8,"compute_layout":229,"scale":7,"on.mouse_pressed":179,"on.mouse_released":178,"on.textinput":177,"on.update":14,"font":228,"on.keychord_pressed":200,"to_text":180,"Page":202,"parent":230,"on":1,"Surface":196,"box_height":44,"on.code_changed":212,"on.draw":225,"Cursor_node":172}
Viewport = {x=-50, y=-50, w=800,h=600, zoom=1.2}
{"vx":5,"Viewport":230,"initialize_editor":74,"vy":8,"compute_layout":229,"scale":7,"on.mouse_pressed":179,"on.mouse_released":178,"on.textinput":177,"on.update":14,"font":228,"on.keychord_pressed":200,"to_text":180,"Page":202,"parent":229,"on":1,"Surface":196,"box_height":44,"on.code_changed":212,"on.draw":225,"Cursor_node":172}
Viewport = {x=-50, y=-50, w=800,h=600, zoom=1.5}
{"on.draw":225,"compute_layout":229,"vx":5,"font":228,"Cursor_node":172,"vy":8,"on.code_changed":212,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":228,"scale":7,"Viewport":227,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
-- leaf node containing raw text
print(x,y, node.data[1])
node.x = x
node.y = y
-- render background if necessary
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
-- render contents
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.w = 0
for _,s in ipairs(node.data) do
local text = love.graphics.newText(font(scaled_fontsize), node.data)
local width = text:getWidth()
if node.w < width then node.w = width end
end
end
initialize_editor(node)
node.h = box_height(node)
table.insert(nodes_to_render, node)
if node_to_render then
node_to_render.w = node.w
node_to_render.h = node.h
end
elseif node.type == 'rows' then
node.x = x
node.y = y
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
end
return x+node.w,y+node.h
end
{"on.draw":225,"compute_layout":205,"vx":5,"font":228,"Cursor_node":172,"vy":8,"on.code_changed":212,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":227,"scale":7,"Viewport":227,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
font = function(fontsize)
if Font == nil then Font = {} end
if Font[fontsize] == nil then
print(fontsize)
Font[fontsize] = love.graphics.newFont(fontsize)
end
return Font[fontsize]
end
{"on.draw":225,"compute_layout":205,"vx":5,"font":224,"Cursor_node":172,"vy":8,"on.code_changed":212,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":226,"scale":7,"Viewport":227,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
Viewport = {x=-50, y=-50, w=800,h=600, zoom=1.4}
{"on.draw":225,"compute_layout":205,"vx":5,"font":224,"Cursor_node":172,"vy":8,"on.code_changed":212,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":225,"scale":7,"Viewport":226,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
Viewport = {x=-50, y=-50, w=800,h=600, zoom=1.5}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
print('Creating text of size', scaled_fontsize)
love.graphics.setFont(font(scaled_fontsize))
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
print('aaaa', obj.text)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"on.draw":225,"compute_layout":205,"vx":5,"font":224,"Cursor_node":172,"vy":8,"on.code_changed":212,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":224,"scale":7,"Viewport":221,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
{"on.draw":223,"compute_layout":205,"vx":5,"font":224,"Cursor_node":172,"vy":8,"on.code_changed":212,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":223,"scale":7,"Viewport":221,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
font = function(fontsize)
if Font == nil then Font = {} end
if Font[fontsize] == nil then
Font[fontsize] = love.graphics.newFont(fontsize)
end
return Font[fontsize]
end
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
print('Creating text of size', scaled_fontsize)
love.graphics.setFont(scaled_fontsize)
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
print('aaaa', obj.text)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"on.draw":223,"compute_layout":205,"vx":5,"font":104,"Cursor_node":172,"vy":8,"on.code_changed":212,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":222,"scale":7,"Viewport":221,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
print('Creating text of size', scaled_fontsize)
love.graphics.setFont(scaled_fontsize)
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
print(obj.text)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"on.draw":222,"compute_layout":205,"vx":5,"font":104,"Cursor_node":172,"vy":8,"on.code_changed":212,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":221,"scale":7,"Viewport":221,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
{"on.draw":220,"compute_layout":205,"vx":5,"font":104,"Cursor_node":172,"vy":8,"on.code_changed":212,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":220,"scale":7,"Viewport":221,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
Viewport = {x=-50, y=-50, w=800,h=600, zoom=1.5}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
print('creating text of size', scaled_fontsize)
love.graphics.setFont(scaled_fontsize)
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
print(obj.text)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"on.draw":220,"compute_layout":205,"vx":5,"font":104,"Cursor_node":172,"vy":8,"on.code_changed":212,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":219,"scale":7,"Viewport":217,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
print('creating text of size', scaled_fontsize)
love.graphics.setFont(scaled_fontsize)
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"on.draw":219,"compute_layout":205,"vx":5,"font":104,"Cursor_node":172,"vy":8,"on.code_changed":212,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":218,"scale":7,"Viewport":217,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
print('creating text of size', scaled_fontsize)
love.graphics.setFont(scaled_fontsize)
obj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"on.draw":218,"compute_layout":205,"vx":5,"font":104,"Cursor_node":172,"vy":8,"on.code_changed":212,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":217,"scale":7,"Viewport":217,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
{"on.draw":216,"compute_layout":205,"vx":5,"font":104,"Cursor_node":172,"vy":8,"on.code_changed":212,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":216,"scale":7,"Viewport":217,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
Viewport = {x=-50, y=-50, w=800,h=600, zoom=1.4}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
print('creating text of size', scaled_fontsize)
-- love.graphics.setFont(scaled_fontsize)
obj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"on.draw":216,"compute_layout":205,"vx":5,"font":104,"Cursor_node":172,"vy":8,"on.code_changed":212,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":215,"scale":7,"Viewport":215,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
{"on.draw":211,"compute_layout":205,"vx":5,"font":104,"Cursor_node":172,"vy":8,"on.code_changed":212,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":214,"scale":7,"Viewport":215,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
Viewport = {x=-50, y=-50, w=800,h=600, zoom=1.5}
{"on.draw":211,"compute_layout":205,"vx":5,"font":104,"Cursor_node":172,"vy":8,"on.code_changed":212,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":213,"scale":7,"Viewport":214,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
Viewport = {x=-50, y=-50, w=800,h=600, zoom=1.4}
{"on.draw":211,"compute_layout":205,"vx":5,"font":104,"Cursor_node":172,"vy":8,"on.code_changed":212,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":212,"scale":7,"Viewport":213,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
Viewport = {x=-50, y=-50, w=800,h=600, zoom=1.5}
on.code_changed = function()
while #Surface > 3 do
table.remove(Surface)
end
print('code changed', Page.x,Page.y)
compute_layout(Page, Page.x,Page.y, Surface)
end
{"on.draw":211,"compute_layout":205,"vx":5,"font":104,"Cursor_node":172,"vy":8,"on.code_changed":212,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":211,"scale":7,"Viewport":204,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
print('creating text of size', scaled_fontsize)
love.graphics.setFont(scaled_fontsize)
obj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"on.draw":211,"compute_layout":205,"vx":5,"font":104,"Cursor_node":172,"vy":8,"on.code_changed":201,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":210,"scale":7,"Viewport":204,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
print('creating text of size', scaled_fontsize)
love.graphics.setFont(font(obj, scaled_fontsize))
obj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"on.draw":210,"compute_layout":205,"vx":5,"font":104,"Cursor_node":172,"vy":8,"on.code_changed":201,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":209,"scale":7,"Viewport":204,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
print('creating text of size', scaled_fontsize)
love.graphics.setFont(font(obj, scaled_fontsize))
obj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"on.draw":209,"compute_layout":205,"vx":5,"font":104,"Cursor_node":172,"vy":8,"on.code_changed":201,"on.textinput":177,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":200,"Page":202,"parent":208,"scale":7,"Viewport":204,"on":1,"to_text":180,"Surface":196,"initialize_editor":74,"box_height":44}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
print('creating text of size', scaled_fontsize)
love.graphics.setFont(font(obj, scaled_fontsize))
-- obj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"Cursor_node":172,"font":104,"Surface":196,"on.draw":208,"vx":5,"Viewport":204,"vy":8,"initialize_editor":74,"on":1,"on.code_changed":201,"on.mouse_pressed":179,"to_text":180,"on.mouse_released":178,"parent":207,"on.update":14,"box_height":44,"on.keychord_pressed":200,"scale":7,"compute_layout":205,"on.textinput":177,"Page":202}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
print('creating text of size', scaled_fontsize)
obj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"Cursor_node":172,"font":104,"Surface":196,"on.draw":207,"vx":5,"Viewport":204,"vy":8,"initialize_editor":74,"on":1,"on.code_changed":201,"on.mouse_pressed":179,"to_text":180,"on.mouse_released":178,"parent":206,"on.update":14,"box_height":44,"on.keychord_pressed":200,"scale":7,"compute_layout":205,"on.textinput":177,"Page":202}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
obj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"Cursor_node":172,"font":104,"Surface":196,"on.draw":206,"vx":5,"Viewport":204,"vy":8,"initialize_editor":74,"on":1,"on.code_changed":201,"on.mouse_pressed":179,"to_text":180,"on.mouse_released":178,"parent":205,"on.update":14,"box_height":44,"on.keychord_pressed":200,"scale":7,"compute_layout":205,"on.textinput":177,"Page":202}
{"Cursor_node":172,"font":104,"Surface":196,"on.draw":195,"vx":5,"Viewport":204,"vy":8,"initialize_editor":74,"on":1,"on.code_changed":201,"on.mouse_pressed":179,"to_text":180,"on.mouse_released":178,"parent":204,"on.update":14,"box_height":44,"on.keychord_pressed":200,"scale":7,"compute_layout":205,"on.textinput":177,"Page":202}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
-- leaf node containing raw text
print(x,y, node.data[1])
node.x = x
node.y = y
-- render background if necessary
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
-- render contents
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.w = 0
for _,s in ipairs(node.data) do
local text = love.graphics.newText(font(node, scaled_fontsize), node.data)
local width = text:getWidth()
if node.w < width then node.w = width end
end
end
initialize_editor(node)
node.h = box_height(node)
table.insert(nodes_to_render, node)
if node_to_render then
node_to_render.w = node.w
node_to_render.h = node.h
end
elseif node.type == 'rows' then
node.x = x
node.y = y
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
end
return x+node.w,y+node.h
end
{"Cursor_node":172,"font":104,"Surface":196,"on.draw":195,"vx":5,"Viewport":204,"vy":8,"initialize_editor":74,"on":1,"on.code_changed":201,"on.mouse_pressed":179,"to_text":180,"on.mouse_released":178,"parent":203,"on.update":14,"box_height":44,"on.keychord_pressed":200,"scale":7,"compute_layout":194,"on.textinput":177,"Page":202}
Viewport = {x=-50, y=-50, w=800,h=600, zoom=1.5}
{"Cursor_node":172,"font":104,"Surface":196,"on.draw":195,"vx":5,"Viewport":203,"vy":8,"initialize_editor":74,"on":1,"on.code_changed":201,"on.mouse_pressed":179,"to_text":180,"on.mouse_released":178,"parent":202,"on.update":14,"box_height":44,"on.keychord_pressed":200,"scale":7,"compute_layout":194,"on.textinput":177,"Page":202}
Viewport = {x=-50, y=-50, w=800,h=600, zoom=1.5}
{"Cursor_node":172,"font":104,"Surface":196,"on.draw":195,"vx":5,"Viewport":29,"vy":8,"initialize_editor":74,"on":1,"on.code_changed":201,"on.mouse_pressed":179,"to_text":180,"on.mouse_released":178,"parent":201,"on.update":14,"box_height":44,"on.keychord_pressed":200,"scale":7,"compute_layout":194,"on.textinput":177,"Page":202}
Page = {
-- page
type='cols', x=0, y=20,
width=800, data={
-- editor covering left side
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- a table on the right
{ type='rows', name='searches', margin=50, data={
{ type='text', data={''},},
{ type='cols', data={
{ type='text', data={'search:'},},
{ type='text', name='search', bg={r=0.8,g=0.8,b=0.8}, data={''}, width=90,},
}},
{ type='text', data={'table:'},},
{ type='cols', bg={r=0.8,g=0.8,b=0.8}, data={
{ type='rows', width=90, data={
{type='text', data={'abc'},},
{type='text', data={'abc'},},
}},
{ type='rows', width=90, data={
{type='text', data={'def'},},
{type='text', data={'def'},},
}},
}},
}},
},
}
on.code_changed = function()
while #Surface > 3 do
table.remove(Surface)
end
print('code changed', Page.x,Page.y)
compute_layout(Page, Page.x,Page.y, Surface)
end
{"Cursor_node":172,"font":104,"Surface":196,"on.draw":195,"vx":5,"Viewport":29,"vy":8,"initialize_editor":74,"on":1,"on.code_changed":201,"on.mouse_pressed":179,"to_text":180,"on.mouse_released":178,"parent":200,"on.update":14,"box_height":44,"on.keychord_pressed":200,"scale":7,"compute_layout":194,"on.textinput":177,"Page":197}
on.keychord_pressed = function(chord, key)
if chord == 'C-=' then
-- zoom in
Viewport.zoom = Viewport.zoom+0.1
elseif chord == 'C--' then
-- zoom out
Viewport.zoom = Viewport.zoom-0.1
elseif chord == 'C-0' then
-- reset zoom
Viewport.zoom = 1.0
elseif Cursor_node then
edit.keychord_pressed(Cursor_node.editor, chord, key)
end
end
{"Cursor_node":172,"font":104,"Surface":196,"on.draw":195,"vx":5,"Viewport":29,"vy":8,"initialize_editor":74,"on":1,"on.code_changed":199,"on.mouse_pressed":179,"to_text":180,"on.mouse_released":178,"parent":199,"on.update":14,"box_height":44,"on.keychord_pressed":200,"scale":7,"compute_layout":194,"on.textinput":177,"Page":197}
on.code_changed = function()
while #Surface > 3 do
table.remove(Surface)
end
print('code changed', Page.x,Page.y)
compute_layout(
Page,
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
Page.x,Page.y,
Surface)
end
{"Cursor_node":172,"font":104,"Surface":196,"on.draw":195,"vx":5,"Viewport":29,"vy":8,"initialize_editor":74,"on":1,"on.code_changed":199,"on.mouse_pressed":179,"to_text":180,"on.mouse_released":178,"parent":198,"on.update":14,"box_height":44,"on.keychord_pressed":176,"scale":7,"compute_layout":194,"on.textinput":177,"Page":197}
on.code_changed = function()
while #Surface > 3 do
table.remove(Surface)
end
print('code changed', Page.x,Page.y)
compute_layout(
Page,
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
Page.x,Page.y,
Surface)
end
{"Cursor_node":172,"font":104,"Surface":196,"on.draw":195,"vx":5,"Viewport":29,"vy":8,"initialize_editor":74,"on":1,"on.code_changed":198,"on.mouse_pressed":179,"to_text":180,"on.mouse_released":178,"parent":197,"on.update":14,"box_height":44,"on.keychord_pressed":176,"scale":7,"compute_layout":194,"on.textinput":177,"Page":197}
{"on.mouse_released":178,"on.update":14,"box_height":44,"font":104,"compute_layout":194,"Page":197,"on.code_changed":190,"on.textinput":177,"Surface":196,"on":1,"on.draw":195,"vx":5,"scale":7,"Viewport":29,"Cursor_node":172,"vy":8,"parent":196,"to_text":180,"initialize_editor":74,"on.keychord_pressed":176,"on.mouse_pressed":179}
Page = {
-- page
type='cols', x=0, y=20,
width=800, data={
-- editor covering left side
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- a table on the right
{ type='rows', name='searches', margin=50, data={
{ type='text', data={''},},
{ type='cols', data={
{ type='text', data={'search:'},},
{ type='text', name='search', bg={r=0.8,g=0.8,b=0.8}, data={''}, width=90,},
}},
{ type='text', data={'table:'},},
{ type='cols', bg={r=0.8,g=0.8,b=0.8}, data={
{ type='rows', width=90, data={
{type='text', data={'abc'},},
{type='text', data={'abc'},},
}},
{ type='rows', width=90, data={
{type='text', data={'def'},},
{type='text', data={'def'},},
}},
}},
}},
},
}
{"on.mouse_released":178,"on.update":14,"box_height":44,"font":104,"compute_layout":194,"Page":192,"on.code_changed":190,"on.textinput":177,"Surface":196,"on":1,"on.draw":195,"vx":5,"scale":7,"Viewport":29,"Cursor_node":172,"vy":8,"parent":195,"to_text":180,"initialize_editor":74,"on.keychord_pressed":176,"on.mouse_pressed":179}
Surface = {
-- test data
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data={'0'}, x=-20,y=-20},
{type='rectangle', x=50,y=50, w=20,h=80, r=1,g=0,b=0},
{type='text', data={'abc', 'def'}, x=150, y=50, w=50,h=50, fg={r=0,g=0.4, b=0.9}},
{type='circle', x=300,y=200, radius=40, r=1,g=0,b=1},
{type='arc', x=0,y=0, radius=50, angle1=0, angle2=math.pi*2/3},
{type='ellipse', x=100,y=100, radiusx=10, radiusy=50},
{type='bezier', data={25,25, 25,125, 75,25, 125,25}},
}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 15)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
obj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"on.mouse_released":178,"on.update":14,"box_height":44,"font":104,"compute_layout":194,"Page":192,"on.code_changed":190,"on.textinput":177,"Surface":165,"on":1,"on.draw":195,"vx":5,"scale":7,"Viewport":29,"Cursor_node":172,"vy":8,"parent":194,"to_text":180,"initialize_editor":74,"on.keychord_pressed":176,"on.mouse_pressed":179}
{"on.mouse_released":178,"on.update":14,"box_height":44,"font":104,"compute_layout":194,"Page":192,"on.code_changed":190,"on.textinput":177,"Surface":165,"on":1,"on.draw":193,"vx":5,"scale":7,"Viewport":29,"Cursor_node":172,"vy":8,"parent":193,"to_text":180,"initialize_editor":74,"on.keychord_pressed":176,"on.mouse_pressed":179}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
-- leaf node containing raw text
print(x,y, node.data[1])
node.x = x
node.y = y
-- render background if necessary
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
-- render contents
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 15)
node.w = 0
for _,s in ipairs(node.data) do
local text = love.graphics.newText(font(node, scaled_fontsize), node.data)
local width = text:getWidth()
if node.w < width then node.w = width end
end
end
initialize_editor(node)
node.h = box_height(node)
table.insert(nodes_to_render, node)
if node_to_render then
node_to_render.w = node.w
node_to_render.h = node.h
end
elseif node.type == 'rows' then
node.x = x
node.y = y
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
end
return x+node.w,y+node.h
end
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 15)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
obj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"on.mouse_released":178,"on.update":14,"box_height":44,"font":104,"compute_layout":187,"Page":192,"on.code_changed":190,"on.textinput":177,"Surface":165,"on":1,"on.draw":193,"vx":5,"scale":7,"Viewport":29,"Cursor_node":172,"vy":8,"parent":192,"to_text":180,"initialize_editor":74,"on.keychord_pressed":176,"on.mouse_pressed":179}
{"on.mouse_released":178,"on.update":14,"box_height":44,"font":104,"compute_layout":187,"Page":192,"on.code_changed":190,"on.textinput":177,"Surface":165,"on":1,"on.draw":162,"vx":5,"scale":7,"Viewport":29,"Cursor_node":172,"vy":8,"parent":191,"to_text":180,"initialize_editor":74,"on.keychord_pressed":176,"on.mouse_pressed":179}
Page = {
-- page
type='cols', x=0, y=0,
width=800, data={
-- editor covering left side
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- a table on the right
{ type='rows', name='searches', margin=50, data={
{ type='text', data={''},},
{ type='cols', data={
{ type='text', data={'search:'},},
{ type='text', name='search', bg={r=0.8,g=0.8,b=0.8}, data={''}, width=90,},
}},
{ type='text', data={'table:'},},
{ type='cols', bg={r=0.8,g=0.8,b=0.8}, data={
{ type='rows', width=90, data={
{type='text', data={'abc'},},
{type='text', data={'abc'},},
}},
{ type='rows', width=90, data={
{type='text', data={'def'},},
{type='text', data={'def'},},
}},
}},
}},
},
}
{"on.mouse_released":178,"on.update":14,"box_height":44,"font":104,"compute_layout":187,"Page":191,"on.code_changed":190,"on.textinput":177,"Surface":165,"on":1,"on.draw":162,"vx":5,"scale":7,"Viewport":29,"Cursor_node":172,"vy":8,"parent":190,"to_text":180,"initialize_editor":74,"on.keychord_pressed":176,"on.mouse_pressed":179}
Page = {
-- page
type='cols', x=0, y=200,
width=800, data={
-- editor covering left side
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- a table on the right
{ type='rows', name='searches', margin=50, data={
{ type='text', data={''},},
{ type='cols', data={
{ type='text', data={'search:'},},
{ type='text', name='search', bg={r=0.8,g=0.8,b=0.8}, data={''}, width=90,},
}},
{ type='text', data={'table:'},},
{ type='cols', bg={r=0.8,g=0.8,b=0.8}, data={
{ type='rows', width=90, data={
{type='text', data={'abc'},},
{type='text', data={'abc'},},
}},
{ type='rows', width=90, data={
{type='text', data={'def'},},
{type='text', data={'def'},},
}},
}},
}},
},
}
on.code_changed = function()
while #Surface > 3 do
table.remove(Surface)
end
print('code changed', Page.x,Page.y)
compute_layout(
Page,
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
Page.x,Page.y,
Surface)
end
{"on.draw":162,"to_text":180,"vx":5,"Viewport":29,"vy":8,"Cursor_node":172,"font":104,"on.mouse_released":178,"on.textinput":177,"initialize_editor":74,"box_height":44,"on.keychord_pressed":176,"compute_layout":187,"Page":189,"on.update":14,"scale":7,"on":1,"on.code_changed":190,"parent":189,"on.mouse_pressed":179,"Surface":165}
{"on.draw":162,"to_text":180,"vx":5,"Viewport":29,"vy":8,"Cursor_node":172,"font":104,"on.mouse_released":178,"on.textinput":177,"initialize_editor":74,"box_height":44,"on.keychord_pressed":176,"compute_layout":187,"Page":189,"on.update":14,"scale":7,"on":1,"on.code_changed":188,"parent":188,"on.mouse_pressed":179,"Surface":165}
Page = {
-- page
type='cols', x=0, y=400,
width=800, data={
-- editor covering left side
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- a table on the right
{ type='rows', name='searches', margin=50, data={
{ type='text', data={''},},
{ type='cols', data={
{ type='text', data={'search:'},},
{ type='text', name='search', bg={r=0.8,g=0.8,b=0.8}, data={''}, width=90,},
}},
{ type='text', data={'table:'},},
{ type='cols', bg={r=0.8,g=0.8,b=0.8}, data={
{ type='rows', width=90, data={
{type='text', data={'abc'},},
{type='text', data={'abc'},},
}},
{ type='rows', width=90, data={
{type='text', data={'def'},},
{type='text', data={'def'},},
}},
}},
}},
},
}
on.code_changed = function()
while #Surface > 3 do
table.remove(Surface)
end
print('code changed', Page.x,Page.y)
compute_layout(
Page,
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
Page.x,Page.y,
Surface)
end
{"on.draw":162,"to_text":180,"vx":5,"Viewport":29,"vy":8,"Cursor_node":172,"font":104,"on.mouse_released":178,"on.textinput":177,"initialize_editor":74,"box_height":44,"on.keychord_pressed":176,"compute_layout":187,"Page":184,"on.update":14,"scale":7,"on":1,"on.code_changed":188,"parent":187,"on.mouse_pressed":179,"Surface":165}
{"on.draw":162,"to_text":180,"vx":5,"Viewport":29,"vy":8,"Cursor_node":172,"font":104,"on.mouse_released":178,"on.textinput":177,"initialize_editor":74,"box_height":44,"on.keychord_pressed":176,"compute_layout":187,"Page":184,"on.update":14,"scale":7,"on":1,"on.code_changed":185,"parent":186,"on.mouse_pressed":179,"Surface":165}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
-- leaf node containing raw text
print(x,y, node.data[1])
node.x = x
node.y = y
-- render background if necessary
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
-- render contents
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.w = 0
for _,s in ipairs(node.data) do
local text = love.graphics.newText(font(node, scaled_fontsize), node.data)
local width = text:getWidth()
if node.w < width then node.w = width end
end
end
initialize_editor(node)
node.h = box_height(node)
table.insert(nodes_to_render, node)
if node_to_render then
node_to_render.w = node.w
node_to_render.h = node.h
end
elseif node.type == 'rows' then
node.x = x
node.y = y
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
end
return x+node.w,y+node.h
end
{"on.draw":162,"to_text":180,"vx":5,"Viewport":29,"vy":8,"Cursor_node":172,"font":104,"on.mouse_released":178,"on.textinput":177,"initialize_editor":74,"box_height":44,"on.keychord_pressed":176,"compute_layout":186,"Page":184,"on.update":14,"scale":7,"on":1,"on.code_changed":185,"parent":185,"on.mouse_pressed":179,"Surface":165}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
-- leaf node containing raw text
print(node.data[1])
node.x = x
node.y = y
-- render background if necessary
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
-- render contents
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.w = 0
for _,s in ipairs(node.data) do
local text = love.graphics.newText(font(node, scaled_fontsize), node.data)
local width = text:getWidth()
if node.w < width then node.w = width end
end
end
initialize_editor(node)
node.h = box_height(node)
table.insert(nodes_to_render, node)
if node_to_render then
node_to_render.w = node.w
node_to_render.h = node.h
end
elseif node.type == 'rows' then
node.x = x
node.y = y
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
end
return x+node.w,y+node.h
end
on.code_changed = function()
print('code changed')
while #Surface > 3 do
table.remove(Surface)
end
compute_layout(
Page,
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
Page.x,Page.y,
Surface)
end
{"on.draw":162,"to_text":180,"vx":5,"Viewport":29,"vy":8,"Cursor_node":172,"font":104,"on.mouse_released":178,"on.textinput":177,"initialize_editor":74,"box_height":44,"on.keychord_pressed":176,"compute_layout":157,"Page":184,"on.update":14,"scale":7,"on":1,"on.code_changed":185,"parent":184,"on.mouse_pressed":179,"Surface":165}
{"on.draw":162,"to_text":180,"vx":5,"Viewport":29,"vy":8,"Cursor_node":172,"font":104,"on.mouse_released":178,"on.textinput":177,"initialize_editor":74,"box_height":44,"on.keychord_pressed":176,"compute_layout":157,"Page":184,"on.update":14,"scale":7,"on":1,"on.code_changed":183,"parent":183,"on.mouse_pressed":179,"Surface":165}
Page = {
-- page
type='cols', x=0, y=400,
width=800, data={
-- editor covering left side
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- a table on the right
{ type='rows', name='searches', margin=50, data={
{ type='text', data={''},},
{ type='cols', data={
{ type='text', data={'search:'},},
{ type='text', name='search', bg={r=0.8,g=0.8,b=0.8}, data={''}, width=90,},
}},
{ type='text', data={'table:'},},
{ type='cols', bg={r=0.8,g=0.8,b=0.8}, data={
{ type='rows', width=90, data={
{type='text', data={'abc'},},
{type='text', data={'abc'},},
}},
{ type='rows', width=90, data={
{type='text', data={'def'},},
{type='text', data={'def'},},
}},
}},
}},
},
}
on.code_changed = function()
print('code changed')
while #Surface > 3 do
table.remove(Surface)
end
compute_layout(
Page,
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
0,0,
Surface)
end
{"on.draw":162,"to_text":180,"vx":5,"Viewport":29,"vy":8,"Cursor_node":172,"font":104,"on.mouse_released":178,"on.textinput":177,"initialize_editor":74,"box_height":44,"on.keychord_pressed":176,"compute_layout":157,"Page":181,"on.update":14,"scale":7,"on":1,"on.code_changed":183,"parent":182,"on.mouse_pressed":179,"Surface":165}
on.code_changed = function()
while #Surface > 3 do
table.remove(Surface)
end
compute_layout(
Page,
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
0,0,
Surface)
end
{"on.draw":162,"to_text":180,"vx":5,"Viewport":29,"vy":8,"Cursor_node":172,"font":104,"on.mouse_released":178,"on.textinput":177,"initialize_editor":74,"box_height":44,"on.keychord_pressed":176,"compute_layout":157,"Page":181,"on.update":14,"scale":7,"on":1,"on.code_changed":182,"parent":181,"on.mouse_pressed":179,"Surface":165}
{"on.draw":162,"to_text":180,"vx":5,"Viewport":29,"vy":8,"Cursor_node":172,"font":104,"on.mouse_released":178,"on.textinput":177,"initialize_editor":74,"box_height":44,"on.keychord_pressed":176,"compute_layout":157,"Page":181,"on.update":14,"scale":7,"on":1,"on.code_changed":140,"parent":180,"on.mouse_pressed":179,"Surface":165}
Page = {
-- page
type='cols', x=0, y=300,
width=800, data={
-- editor covering left side
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- a table on the right
{ type='rows', name='searches', margin=50, data={
{ type='text', data={''},},
{ type='cols', data={
{ type='text', data={'search:'},},
{ type='text', name='search', bg={r=0.8,g=0.8,b=0.8}, data={''}, width=90,},
}},
{ type='text', data={'table:'},},
{ type='cols', bg={r=0.8,g=0.8,b=0.8}, data={
{ type='rows', width=90, data={
{type='text', data={'abc'},},
{type='text', data={'abc'},},
}},
{ type='rows', width=90, data={
{type='text', data={'def'},},
{type='text', data={'def'},},
}},
}},
}},
},
}