ok/cancel buttons in file dialog

This commit is contained in:
Kartik K. Agaram 2023-11-26 10:21:42 -08:00
parent d71e7fcfc8
commit 07b4fce750
4 changed files with 19 additions and 5 deletions

View File

@ -1,5 +1,5 @@
draw_file_dialog = function()
draw_file_dialog_input()
-- border
App.color{r=0.6, g=0.7, b=0.6}
love.graphics.rectangle('line',
Menu_left+5,
@ -7,6 +7,19 @@ draw_file_dialog = function()
Safe_width-Menu_left-10,
Safe_height-Menu_top-10,
5,5)
-- ok/cancel buttons (but with wider names)
local r = Safe_width-10
r = right_justified_button('cancel', r, Menu_top+5+3, function()
reset_file_dialog_state()
end)
r = right_justified_button('submit', r, Menu_top+5+3, function()
File_dialog_callback(File_dialog_input_text)
reset_file_dialog_state()
end)
File_dialog_input_right_margin = r
-- input
draw_file_dialog_input()
-- filtered files
App.color(Menu_background)
love.graphics.rectangle('fill',
Menu_left+5,

View File

@ -2,7 +2,7 @@ refresh_file_dialog_input_start = function()
local len = utf8.len(File_dialog_input_text)
for start=0,len do
local s = File_dialog_input_text:sub(start)
if App.width(s) < Safe_width-Menu_left-15-15 then
if App.width(s) < File_dialog_input_right_margin-15 then
File_dialog_input_draw_suffix = s
return
end

View File

@ -1,6 +1,6 @@
right_justified_button = function(name, x, y, callback)
local w = App.width('settings')
local w = App.width(name)
local x = x-5-w-5
styled_button('settings', x, y, callback)
return x
styled_button(name, x, y, callback)
return x-10
end

View File

@ -0,0 +1 @@
File_dialog_input_right_margin = 0