2023-11-15 15:04:34 +00:00
|
|
|
draw_menu = function()
|
|
|
|
App.color(Menu_background)
|
|
|
|
love.graphics.rectangle('fill', 0,0, App.screen.width, Menu_bottom)
|
2023-11-15 17:02:22 +00:00
|
|
|
-- main buttons
|
2023-11-19 21:15:06 +00:00
|
|
|
button(Global_state, 'run', {x=Menu_left+5, y=Menu_top+5, w=App.width('Run')+10, h=Line_height, bg={r=0.6, g=0.8, b=0.6},
|
2023-11-15 15:04:34 +00:00
|
|
|
icon = function(p)
|
2023-11-15 21:07:01 +00:00
|
|
|
App.color(Normal_color)
|
2023-11-15 17:02:22 +00:00
|
|
|
love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
|
2023-11-15 15:04:34 +00:00
|
|
|
love.graphics.print('Run', p.x+5,p.y+2)
|
|
|
|
end,
|
|
|
|
onpress1 = function()
|
|
|
|
print('run')
|
2023-11-19 21:15:06 +00:00
|
|
|
local buf = table.concat(map(Current_pane.editor_state.lines, function(line) return line.data end), '\n')
|
|
|
|
Current_pane.canvas = love.graphics.newCanvas()
|
|
|
|
love.graphics.setCanvas(Current_pane.canvas)
|
2023-11-19 03:42:00 +00:00
|
|
|
love.graphics.push('all')
|
|
|
|
love.graphics.setBackgroundColor(1,1,1)
|
|
|
|
love.graphics.setColor(0,0,0)
|
|
|
|
local status, result = live.eval(buf)
|
2023-11-19 04:34:51 +00:00
|
|
|
print(status, result)
|
|
|
|
if result then
|
|
|
|
-- could be either output or error
|
2023-11-19 21:15:06 +00:00
|
|
|
Current_pane.output_editor_state.lines = {
|
2023-11-19 04:34:51 +00:00
|
|
|
{data=tostring(result)},
|
|
|
|
}
|
2023-11-19 21:15:06 +00:00
|
|
|
Text.redraw_all(Current_pane.output_editor_state)
|
2023-11-19 03:42:00 +00:00
|
|
|
end
|
|
|
|
love.graphics.pop()
|
|
|
|
love.graphics.setCanvas()
|
2023-11-15 15:04:34 +00:00
|
|
|
end,
|
|
|
|
})
|
2023-11-15 17:02:22 +00:00
|
|
|
-- settings button on right
|
|
|
|
local w = App.width('settings')
|
2023-11-19 21:15:06 +00:00
|
|
|
button(Global_state, 'settings', {x=Safe_width-w-10-5, y=Menu_top+5, w=w+10, h=Line_height, bg={r=0.6, g=0.8, b=0.6},
|
2023-11-15 17:02:22 +00:00
|
|
|
icon = function(p)
|
2023-11-15 21:07:01 +00:00
|
|
|
App.color(Normal_color)
|
2023-11-15 17:02:22 +00:00
|
|
|
love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
|
|
|
|
love.graphics.print('settings', p.x+5,p.y+2)
|
|
|
|
end,
|
|
|
|
onpress1 = function()
|
|
|
|
print('settings')
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
-- nav buttons along sides
|
2023-11-19 21:15:06 +00:00
|
|
|
button(Global_state, 'left', {x=0, y=Menu_bottom, w=Menu_left+30, h=App.screen.height, bg={r=0.5, g=0.5, b=0.5, a=0.2},
|
2023-11-15 17:02:22 +00:00
|
|
|
icon = function(p)
|
|
|
|
App.color{r=0.4,g=0.4,b=0.4}
|
|
|
|
love.graphics.polygon('fill', Menu_left+5, App.screen.height/2, Menu_left+25, App.screen.height/2-10, Menu_left+25, App.screen.height/2+10)
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
local r = Menu_left + Safe_width
|
2023-11-19 21:15:06 +00:00
|
|
|
button(Global_state, 'left', {x=r-30, y=Menu_bottom, w=100, h=App.screen.height, bg={r=0.5, g=0.5, b=0.5, a=0.2},
|
2023-11-15 17:02:22 +00:00
|
|
|
icon = function(p)
|
|
|
|
App.color{r=0.4,g=0.4,b=0.4}
|
|
|
|
love.graphics.polygon('fill', r-25, App.screen.height/2-10, r-25, App.screen.height/2+10, r-5, App.screen.height/2)
|
|
|
|
end,
|
|
|
|
})
|
2023-11-15 15:04:34 +00:00
|
|
|
end
|