extract a helper for buttons
Dependencies
- [2]
VQYLKEGDhandle still narrower screens on phones - [3]
6MQCFHXMremember when someone deletes an example - [4]
X2YWEIZSbugfix: missing variable in a button - [5]
YCPA257Vcopy entire buffer when there's no selection - [6]
5MEJ7XNHlay out buttons based on device dimensions - [7]
QGSOEM7Zbugfix: 'show' button layout - [8]
RK2ASPN7add lots of buttons to the toolbar - [*]
R5QXEHUIsomebody stop me
Change contents
- file addition: 0118-overflowable_button[10.2]
overflowable_button = function(name, x, y, r, onpress1)local w = App.width(name)+10local x2, y2 = maybe_draw_overflow_button(x, y, w, r)if Overflow_button then-- overflowif not Show_overflow thenreturn x, yelsey = y2endendbutton(Global_state, name, {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(name, p.x+5,p.y+2)end,onpress1 = onpress1,})if Overflow_button thenreturn x, y+Line_heightelsereturn x+w+10, yendend - replacement in 0076-delete_pane_button at line 2[6.1536]→[6.35:69](∅→∅),[6.35]→[6.35:69](∅→∅),[6.69]→[6.1537:1812](∅→∅),[6.1812]→[6.167:350](∅→∅),[6.167]→[6.167:350](∅→∅)
local w = App.width('delete')+10local 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},icon = function(p)App.color(Normal_color)love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)love.graphics.print('delete', p.x+5,p.y+2)end,onpress1 = function()return overflowable_button('delete', x, y, r,function() - replacement in 0076-delete_pane_button at line 15
end,})if Overflow_button thenreturn x, y+Line_heightelsereturn x+w+10, yendend) - replacement in 0074-clear_pane_button at line 2[6.1935]→[6.978:1011](∅→∅),[6.978]→[6.978:1011](∅→∅),[6.1011]→[6.1936:2189](∅→∅),[6.2189]→[6.1108:1295](∅→∅),[6.1108]→[6.1108:1295](∅→∅),[6.1295]→[6.2190:2271](∅→∅)
local w = App.width('clear')+10local 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},icon = function(p)App.color(Normal_color)love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)love.graphics.print('clear', p.x+5,p.y+2)end,onpress1 = clear_pane,})if Overflow_button thenreturn x, y+Line_heightelsereturn x+w+10, yendreturn overflowable_button('clear', x, y, r,clear_pane) - replacement in 0067-paste_button at line 2[6.2311]→[6.3759:3792](∅→∅),[6.3759]→[6.3759:3792](∅→∅),[6.3792]→[6.2312:2565](∅→∅),[6.2565]→[6.3889:4071](∅→∅),[6.3889]→[6.3889:4071](∅→∅)
local w = App.width('paste')+10local 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},icon = function(p)App.color(Normal_color)love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)love.graphics.print('paste', p.x+5,p.y+2)end,onpress1 = function()return overflowable_button('paste', x, y, r,function() - replacement in 0067-paste_button at line 6
end,})if Overflow_button then-- we're past the overflow button; start drawing downwardreturn x, y+Line_heightelsereturn x+w+10, yendend) - replacement in 0066-copy_button at line 2[6.2741]→[6.4254:4286](∅→∅),[6.4254]→[6.4254:4286](∅→∅),[6.4286]→[6.2742:2879](∅→∅),[6.2879]→[2.0:17](∅→∅),[2.17]→[6.2879:2977](∅→∅),[6.2879]→[6.2879:2977](∅→∅),[6.2977]→[6.4382:4563](∅→∅),[6.4382]→[6.4382:4563](∅→∅)
local w = App.width('copy')+10local x2, y2 = maybe_draw_overflow_button(x, y, w, r)if Overflow_button then-- overflowif not Show_overflow thenreturn x, yelsey = y2endendbutton(Global_state, 'copy', {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('copy', p.x+5,p.y+2)end,onpress1 = function()return overflowable_button('copy', x, y, r,function() - replacement in 0066-copy_button at line 14
end,})if Overflow_button thenreturn x, y+Line_heightelsereturn x+w+10, yendend) - replacement in 0065-hide_code_button at line 2[6.3098]→[6.4760:4792](∅→∅),[6.4760]→[6.4760:4792](∅→∅),[6.4792]→[6.3099:3236](∅→∅),[6.3236]→[2.18:35](∅→∅),[2.35]→[6.3236:3334](∅→∅),[6.3236]→[6.3236:3334](∅→∅),[6.3334]→[6.4888:5069](∅→∅),[6.4888]→[6.4888:5069](∅→∅)
local w = App.width('hide')+10local x2, y2 = maybe_draw_overflow_button(x, y, w, r)if Overflow_button then-- overflowif not Show_overflow thenreturn x, yelsey = y2endendbutton(Global_state, 'hide', {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('hide', p.x+5,p.y+2)end,onpress1 = function()return overflowable_button('hide', x, y, r,function() - replacement in 0065-hide_code_button at line 5
end,})if Overflow_button thenreturn x, y+Line_heightelsereturn x+w+10, yendend) - replacement in 0064-show_code_button at line 2[4.109]→[6.5199:5231](∅→∅),[6.3452]→[6.5199:5231](∅→∅),[6.5199]→[6.5199:5231](∅→∅),[6.5231]→[2.36:201](∅→∅),[2.201]→[6.3453:3540](∅→∅),[6.5231]→[6.3453:3540](∅→∅),[6.3540]→[6.5327:5508](∅→∅),[6.5327]→[6.5327:5508](∅→∅)
local w = App.width('show')+10local x2, y2 = maybe_draw_overflow_button(x, y, w, r)if Overflow_button then-- overflowif not Show_overflow thenreturn x, yelsey = y2endendbutton(Global_state, 'show', {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('show', p.x+5,p.y+2)end,onpress1 = function()return overflowable_button('show', x, y, r,function() - replacement in 0064-show_code_button at line 5
end,})if Overflow_button thenreturn x, y+Line_heightelsereturn x+w+10, yendend) - replacement in 0061-new_pane_button at line 2[6.3610]→[6.5694:5725](∅→∅),[6.5694]→[6.5694:5725](∅→∅),[6.5725]→[6.3611:3862](∅→∅),[6.3862]→[6.5820:6000](∅→∅),[6.5820]→[6.5820:6000](∅→∅)
local w = App.width('new')+10local 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},icon = function(p)App.color(Normal_color)love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)love.graphics.print('new', p.x+5,p.y+2)end,onpress1 = function()return overflowable_button('new', x, y, r,function() - replacement in 0061-new_pane_button at line 7
end,})if Overflow_button thenreturn x, y+Line_heightelsereturn x+w+10, yendend)