lay out buttons based on device dimensions
Dependencies
- [2]
GAKJROFZahh, got the background color sliders working - [3]
GWLETNMWMike's suggested button layout - [4]
RK2ASPN7add lots of buttons to the toolbar - [5]
I52S4E5Frunning `print` now appends to output editor - [6]
PRE6XPRNresponsively increase/decrease font height - [7]
FPSPT5TMshow current pane number - [8]
JV27LDDKsliders for font size and color settings - [9]
WR2WMEPEimplement 'Run' button - [10]
5RUFNRJOstart of the visual skeleton - [11]
VAVXKWZVaggregate global state inside a 'pane' object - [*]
R5QXEHUIsomebody stop me - [*]
ZM7NOBRMnew fork: carousel shell
Change contents
- file addition: 0110-maybe_draw_overflow_button[13.2]
maybe_draw_overflow_button = function(x, y, w, r, final_button)if Overflow_button then return x, y endlocal after = x+w+10if not final_button thenlocal w2 = App.width('>>')+10-- only draw a button if there's going to be at least space for the overflow button afterwardsafter = after+w2+10endif after > r thenx, y = overflow_button(x, y)Overflow_button = Global_state.button_handlers[#Global_state.button_handlers]return x, yelsereturn x, yendend - file addition: 0109-overflow_button[13.2]
overflow_button = function(x, y)local w = App.width('>>')+10button(Global_state, 'overflow', {x=x, y=y, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},icon = function(p)App.color(Normal_color)love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)love.graphics.print('>>', p.x+5,p.y+2)end,onpress1 = function()Show_overflow = not Show_overflowend,})return x+w+10, y+Line_heightend - file addition: 0108-Overflow_button[13.2]
Overflow_button = nil -- location and dimensions of the overflow button if it's been drawn this frame - file addition: 0107-Show_overflow[13.2]
-- True if the overflow menu has been opened and we want to render buttons within it.Show_overflow = false - replacement in 0106-stop_button at line 1
stop_button = function(x)stop_button = function(x, y) - replacement in 0106-stop_button at line 3
button(Global_state, 'stop', {x=x, y=Menu_top+5, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},button(Global_state, 'stop', {x=x, y=y, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6}, - replacement in 0106-stop_button at line 11
return x+w+10return x+w+10, y - replacement in 0076-delete_pane_button at line 1
delete_pane_button = function(x)delete_pane_button = function(x, y, r) - replacement in 0076-delete_pane_button at line 3
button(Global_state, 'delete', {x=x, y=Menu_top+5, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},local x2, y2 = maybe_draw_overflow_button(x, y, w, r, --[[final button]] true)if Overflow_button then-- overflowif Show_overflow theny = y2elsereturn x, yendendbutton(Global_state, 'delete', {x=x, y=y, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6}, - replacement in 0076-delete_pane_button at line 29
return x+w+10if Overflow_button thenreturn x, y+Line_heightelsereturn x+w+10, yend - replacement in 0074-clear_pane_button at line 1
clear_pane_button = function(x)clear_pane_button = function(x, y, r) - replacement in 0074-clear_pane_button at line 3
button(Global_state, 'clear', {x=x, y=Menu_top+5, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},local x2, y2 = maybe_draw_overflow_button(x, y, w, r)if Overflow_button then-- overflowif not Show_overflow thenreturn x, yelsey = y2endendbutton(Global_state, 'clear', {x=x, y=y, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6}, - replacement in 0074-clear_pane_button at line 20
return x+w+10if Overflow_button thenreturn x, y+Line_heightelsereturn x+w+10, yend - replacement in 0067-paste_button at line 1
paste_button = function(x)paste_button = function(x, y, r) - replacement in 0067-paste_button at line 3
button(Global_state, 'paste', {x=x, y=Menu_top+5, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},local x2, y2 = maybe_draw_overflow_button(x, y, w, r)if Overflow_button then-- overflowif not Show_overflow thenreturn x, yelsey = y2endendbutton(Global_state, 'paste', {x=x, y=y, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6}, - replacement in 0067-paste_button at line 23
return x+w+10if Overflow_button then-- we're past the overflow button; start drawing downwardreturn x, y+Line_heightelsereturn x+w+10, yend - replacement in 0066-copy_button at line 1
copy_button = function(x)copy_button = function(x, y, r) - replacement in 0066-copy_button at line 3
button(Global_state, 'copy', {x=x, y=Menu_top+5, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},local x2, y2 = maybe_draw_overflow_button(x, y, w, r)if Overflow_button then-- overflowif not Show_overflow thenreturn x, yendendbutton(Global_state, 'copy', {x=x, y=y, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6}, - replacement in 0066-copy_button at line 21
return x+w+10if Overflow_button thenreturn x, y+Line_heightelsereturn x+w+10, yend - replacement in 0065-hide_code_button at line 1
hide_code_button = function(x)hide_code_button = function(x, y, r) - replacement in 0065-hide_code_button at line 3
button(Global_state, 'hide', {x=x, y=Menu_top+5, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},local x2, y2 = maybe_draw_overflow_button(x, y, w, r)if Overflow_button then-- overflowif not Show_overflow thenreturn x, yendendbutton(Global_state, 'hide', {x=x, y=y, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6}, - replacement in 0065-hide_code_button at line 20
return x+w+10if Overflow_button thenreturn x, y+Line_heightelsereturn x+w+10, yend - replacement in 0064-show_code_button at line 1
show_code_button = function(x)show_code_button = function(x, y) - replacement in 0064-show_code_button at line 3
button(Global_state, 'show', {x=x, y=Menu_top+5, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},button(Global_state, 'show', {x=x, y=y, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6}, - replacement in 0064-show_code_button at line 13
return x+w+10return x+w+10, y+Line_height - replacement in 0061-new_pane_button at line 1
new_pane_button = function(x)new_pane_button = function(x, y, r) - replacement in 0061-new_pane_button at line 3
button(Global_state, 'new', {x=x, y=Menu_top+5, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},local x2, y2 = maybe_draw_overflow_button(x, y, w, r)if Overflow_button then-- overflowif not Show_overflow thenreturn x, yelsey = y2endendbutton(Global_state, 'new', {x=x, y=y, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6}, - replacement in 0061-new_pane_button at line 24
return x+w+10if Overflow_button thenreturn x, y+Line_heightelsereturn x+w+10, yend - replacement in 0051-run_button at line 1
run_button = function(x)run_button = function(x, y) - replacement in 0051-run_button at line 3
button(Global_state, 'run', {x=x, y=Menu_top+5, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},button(Global_state, 'run', {x=x, y=y, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6}, - replacement in 0051-run_button at line 36
return x+w+10return x+w+10, y - replacement in 0021-draw_menu at line 4
local x = Menu_left+5-- settings button on rightlocal w = App.width('settings')local r = Safe_width-w-10-5settings_button(r, w)local x, y = Menu_left+5, Menu_top+5-- main menu on left - replacement in 0021-draw_menu at line 14[4.378]→[4.746:763](∅→∅),[4.7837]→[4.746:763](∅→∅),[4.825]→[4.746:763](∅→∅),[4.763]→[4.379:398](∅→∅),[4.398]→[3.481:501](∅→∅)
-- main buttonsx = run_button(x)x = stop_button(x)x = run_button(x, y, r)x = stop_button(x, y, r) - replacement in 0021-draw_menu at line 17
love.graphics.print('code', x, Menu_top+5)love.graphics.print('code', x, y) - edit in 0021-draw_menu at line 19
-- assume screen will always be wide enough to print this far without overflow - replacement in 0021-draw_menu at line 21
x = hide_code_button(x)x, y = hide_code_button(x, y, r) - replacement in 0021-draw_menu at line 23
x = show_code_button(x)x, y = show_code_button(x, y, r) - replacement in 0021-draw_menu at line 25[4.7920]→[4.7920:7961](∅→∅),[4.8015]→[4.8015:8041](∅→∅),[4.8041]→[3.606:738](∅→∅),[3.738]→[4.8041:8068](∅→∅),[4.8041]→[4.8041:8068](∅→∅),[4.398]→[4.957:1019](∅→∅),[4.1679]→[4.957:1019](∅→∅),[4.8068]→[4.957:1019](∅→∅),[4.957]→[4.957:1019](∅→∅),[4.1019]→[4.8069:8108](∅→∅)
x = copy_button(x)x = paste_button(x)x = clear_pane_button(x)App.color{r=0.5, g=0.5, b=0.5}love.graphics.print('screen', x, Menu_top+5)x = x+App.width('screen')+10x = new_pane_button(x)x = delete_pane_button(x)-- settings button on rightlocal w = App.width('settings')settings_button(Safe_width-w-10-5, w)x, y = copy_button(x, y, r)x, y = paste_button(x, y, r)x, y = clear_pane_button(x, y, r)if not Overflow_button thenlocal w = App.width('screen')+10local w2 = App.width('>>')+10if x+w+10+w2+10 < r thenApp.color{r=0.5, g=0.5, b=0.5}love.graphics.print('screen', x, y)x = x+App.width('screen')+10endendx, y = new_pane_button(x, y, r)x, y = delete_pane_button(x, y, r) - edit in 0016-on.mouse_press at line 5
Show_overflow = false - edit in 0012-on.draw at line 3
Overflow_button = nil