lay out buttons based on device dimensions

akkartik
Nov 22, 2023, 8:38 PM
5MEJ7XNHNFG2BIX3TFU6PDJHSJOS2Z45L25QAZKFGRW7ZNOFEUKAC

Dependencies

  • [2] GAKJROFZ ahh, got the background color sliders working
  • [3] GWLETNMW Mike's suggested button layout
  • [4] RK2ASPN7 add lots of buttons to the toolbar
  • [5] I52S4E5F running `print` now appends to output editor
  • [6] PRE6XPRN responsively increase/decrease font height
  • [7] FPSPT5TM show current pane number
  • [8] JV27LDDK sliders for font size and color settings
  • [9] WR2WMEPE implement 'Run' button
  • [10] 5RUFNRJO start of the visual skeleton
  • [11] VAVXKWZV aggregate global state inside a 'pane' object
  • [*] R5QXEHUI somebody stop me
  • [*] ZM7NOBRM new 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 end
    local after = x+w+10
    if not final_button then
    local w2 = App.width('>>')+10
    -- only draw a button if there's going to be at least space for the overflow button afterwards
    after = after+w2+10
    end
    if after > r then
    x, y = overflow_button(x, y)
    Overflow_button = Global_state.button_handlers[#Global_state.button_handlers]
    return x, y
    else
    return x, y
    end
    end
  • file addition: 0109-overflow_button (----------)
    [13.2]
    overflow_button = function(x, y)
    local w = App.width('>>')+10
    button(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_overflow
    end,
    })
    return x+w+10, y+Line_height
    end
  • 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
    [3.41][3.42:68]()
    stop_button = function(x)
    [3.41]
    [3.68]
    stop_button = function(x, y)
  • replacement in 0106-stop_button at line 3
    [3.100][3.100:196]()
    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},
    [3.100]
    [3.196]
    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
    [3.386][3.386:401]()
    return x+w+10
    [3.386]
    [3.401]
    return x+w+10, y
  • replacement in 0076-delete_pane_button at line 1
    [4.1][4.2:35]()
    delete_pane_button = function(x)
    [4.1]
    [4.35]
    delete_pane_button = function(x, y, r)
  • replacement in 0076-delete_pane_button at line 3
    [4.69][4.69:167]()
    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},
    [4.69]
    [4.167]
    local x2, y2 = maybe_draw_overflow_button(x, y, w, r, --[[final button]] true)
    if Overflow_button then
    -- overflow
    if Show_overflow then
    y = y2
    else
    return x, y
    end
    end
    button(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
    [4.606][4.606:621]()
    return x+w+10
    [4.606]
    [4.621]
    if Overflow_button then
    return x, y+Line_height
    else
    return x+w+10, y
    end
  • replacement in 0074-clear_pane_button at line 1
    [4.945][4.946:978]()
    clear_pane_button = function(x)
    [4.945]
    [4.978]
    clear_pane_button = function(x, y, r)
  • replacement in 0074-clear_pane_button at line 3
    [4.1011][4.1011:1108]()
    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},
    [4.1011]
    [4.1108]
    local x2, y2 = maybe_draw_overflow_button(x, y, w, r)
    if Overflow_button then
    -- overflow
    if not Show_overflow then
    return x, y
    else
    y = y2
    end
    end
    button(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
    [4.1295][4.1295:1310]()
    return x+w+10
    [4.1295]
    [4.1310]
    if Overflow_button then
    return x, y+Line_height
    else
    return x+w+10, y
    end
  • replacement in 0067-paste_button at line 1
    [4.3731][4.3732:3759]()
    paste_button = function(x)
    [4.3731]
    [4.3759]
    paste_button = function(x, y, r)
  • replacement in 0067-paste_button at line 3
    [4.3792][4.3792:3889]()
    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},
    [4.3792]
    [4.3889]
    local x2, y2 = maybe_draw_overflow_button(x, y, w, r)
    if Overflow_button then
    -- overflow
    if not Show_overflow then
    return x, y
    else
    y = y2
    end
    end
    button(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
    [4.4165][4.4165:4180]()
    return x+w+10
    [4.4165]
    [4.4180]
    if Overflow_button then
    -- we're past the overflow button; start drawing downward
    return x, y+Line_height
    else
    return x+w+10, y
    end
  • replacement in 0066-copy_button at line 1
    [4.4227][4.4228:4254]()
    copy_button = function(x)
    [4.4227]
    [4.4254]
    copy_button = function(x, y, r)
  • replacement in 0066-copy_button at line 3
    [4.4286][4.4286:4382]()
    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},
    [4.4286]
    [4.4382]
    local x2, y2 = maybe_draw_overflow_button(x, y, w, r)
    if Overflow_button then
    -- overflow
    if not Show_overflow then
    return x, y
    end
    end
    button(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
    [4.4667][4.4667:4682]()
    return x+w+10
    [4.4667]
    [4.4682]
    if Overflow_button then
    return x, y+Line_height
    else
    return x+w+10, y
    end
  • replacement in 0065-hide_code_button at line 1
    [4.4728][4.4729:4760]()
    hide_code_button = function(x)
    [4.4728]
    [4.4760]
    hide_code_button = function(x, y, r)
  • replacement in 0065-hide_code_button at line 3
    [4.4792][4.4792:4888]()
    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},
    [4.4792]
    [4.4888]
    local x2, y2 = maybe_draw_overflow_button(x, y, w, r)
    if Overflow_button then
    -- overflow
    if not Show_overflow then
    return x, y
    end
    end
    button(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
    [4.5101][4.5101:5116]()
    return x+w+10
    [4.5101]
    [4.5116]
    if Overflow_button then
    return x, y+Line_height
    else
    return x+w+10, y
    end
  • replacement in 0064-show_code_button at line 1
    [4.5167][4.5168:5199]()
    show_code_button = function(x)
    [4.5167]
    [4.5199]
    show_code_button = function(x, y)
  • replacement in 0064-show_code_button at line 3
    [4.5231][4.5231:5327]()
    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},
    [4.5231]
    [4.5327]
    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
    [4.5539][4.5539:5554]()
    return x+w+10
    [4.5539]
    [4.5554]
    return x+w+10, y+Line_height
  • replacement in 0061-new_pane_button at line 1
    [4.5663][4.5664:5694]()
    new_pane_button = function(x)
    [4.5663]
    [4.5694]
    new_pane_button = function(x, y, r)
  • replacement in 0061-new_pane_button at line 3
    [4.5725][4.5725:5820]()
    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},
    [4.5725]
    [4.5820]
    local x2, y2 = maybe_draw_overflow_button(x, y, w, r)
    if Overflow_button then
    -- overflow
    if not Show_overflow then
    return x, y
    else
    y = y2
    end
    end
    button(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
    [4.6155][4.6155:6170]()
    return x+w+10
    [4.6155]
    [4.6170]
    if Overflow_button then
    return x, y+Line_height
    else
    return x+w+10, y
    end
  • replacement in 0051-run_button at line 1
    [4.1][4.31:56]()
    run_button = function(x)
    [4.1]
    [3.405]
    run_button = function(x, y)
  • replacement in 0051-run_button at line 3
    [3.436][4.87:182](),[4.87][4.87:182]()
    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},
    [3.436]
    [4.149]
    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
    [4.1365][4.7565:7580]()
    return x+w+10
    [4.1365]
    [4.1365]
    return x+w+10, y
  • replacement in 0021-draw_menu at line 4
    [4.246][4.246:269]()
    local x = Menu_left+5
    [4.825]
    [4.5699]
    -- settings button on right
    local w = App.width('settings')
    local r = Safe_width-w-10-5
    settings_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 buttons
    x = run_button(x)
    x = stop_button(x)
    [4.7837]
    [3.501]
    x = run_button(x, y, r)
    x = stop_button(x, y, r)
  • replacement in 0021-draw_menu at line 17
    [3.533][3.533:577]()
    love.graphics.print('code', x, Menu_top+5)
    [3.533]
    [3.577]
    love.graphics.print('code', x, y)
  • edit in 0021-draw_menu at line 19
    [3.605]
    [4.7838]
    -- assume screen will always be wide enough to print this far without overflow
  • replacement in 0021-draw_menu at line 21
    [4.7857][4.7857:7883]()
    x = hide_code_button(x)
    [4.7857]
    [4.7883]
    x, y = hide_code_button(x, y, r)
  • replacement in 0021-draw_menu at line 23
    [4.7889][4.7889:7915]()
    x = show_code_button(x)
    [4.7889]
    [4.7915]
    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')+10
    x = new_pane_button(x)
    x = delete_pane_button(x)
    -- settings button on right
    local w = App.width('settings')
    settings_button(Safe_width-w-10-5, w)
    [4.7920]
    [4.1344]
    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 then
    local w = App.width('screen')+10
    local w2 = App.width('>>')+10
    if x+w+10+w2+10 < r then
    App.color{r=0.5, g=0.5, b=0.5}
    love.graphics.print('screen', x, y)
    x = x+App.width('screen')+10
    end
    end
    x, y = new_pane_button(x, y, r)
    x, y = delete_pane_button(x, y, r)
  • edit in 0016-on.mouse_press at line 5
    [4.5838]
    [4.5838]
    Show_overflow = false
  • edit in 0012-on.draw at line 3
    [4.4113]
    [2.44]
    Overflow_button = nil