Many thanks Origedit for advocating for this change. It's much better now.
It's a little inefficient; overflow buttons get drawn twice per frame.
GO2QWWUIJZDJXLJ4O4MBYULDGNCQ5SYJP3ORNLZ4VFSY4BSRXWKAC
AZMYKWMHE3RTQ7Z7NTBK3H4YTZ46HQE2GHUY7WADMITC7UIVB5RQC
R5QXEHUIZLELJGGCZAE7ATNS3CLRJ7JFRENMGH4XXH24C5WABZDQC
SIJ5I4NZN5LFATNT5QIWUK75Z5W6P4B4AKNPVYFQ7IVRMOCVWR3AC
5MEJ7XNHNFG2BIX3TFU6PDJHSJOS2Z45L25QAZKFGRW7ZNOFEUKAC
PRE6XPRNICDCHMF7C45A6DRPVT47IPAIWW6Q7AHNGW3D2PBGOPNAC
5RUFNRJOK3PXQKJTPDEN5K5PI67MGB25QUA44WOCCH2O5KHXT45QC
JV27LDDKKY57IEBWGBFPSHEARMOEGLBYGBJD27PDPTNWWYXA4T6AC
find_overflow_button = function()
if Overflow_button == nil then return end
for i,button in ipairs(Global_state.button_handlers) do
if button == Overflow_button then
local max_width = 0
for j=i+1, #Global_state.button_handlers do
local b = Global_state.button_handlers[j]
max_width = math.max(max_width, b.w)
end
return i, max_width
end
end
end
redraw_overflow_buttons = function(y)
if Show_menu ~= 'overflow' then return end
local bottom = y + 10
App.color(Menu_background)
local overflow_button_index, overflow_width = find_overflow_button()
if overflow_button_index == nil then
error('overflow button not found')
end
love.graphics.rectangle('fill', Overflow_button.x-5, Menu_bottom, overflow_width+10, bottom - Menu_bottom)
for j=overflow_button_index+1, #Global_state.button_handlers do
local b = Global_state.button_handlers[j]
b.icon(b)
end
end