indicate local modifications in load/save dialog

This commit is contained in:
Kartik K. Agaram 2024-03-17 12:37:02 -07:00
parent 8508638582
commit ec7f0bbe6e
6 changed files with 15 additions and 9 deletions

View File

@ -19,7 +19,7 @@ draw_editor_border = function()
end
local tx2 = tx1 + App.width(filename)
if has_local_modifications(Current_pane.filename) then
App.color{r=0.8, g=0,b=0}
App.color(Local_modifications_color)
end
love.graphics.print(filename, tx1, y1-15+5)
App.color(Border_color)

View File

@ -1,6 +1,6 @@
-- draw a button in the menu if possible
-- if not, stash it behind an overflow ('>>') button
overflowable_button = function(name, x, y, r, onpress1, final_button, tooltip_text)
overflowable_button = function(name, x, y, r, onpress1, final_button, tooltip_text, fg)
local w = Font:getWidth(name)+10
local x2, y2 = maybe_draw_overflow_button(x, y, w, r, final_button)
if Overflow_button then
@ -11,7 +11,7 @@ overflowable_button = function(name, x, y, r, onpress1, final_button, tooltip_te
y = y2
end
end
styled_button(name, x,y, onpress1, tooltip_text)
styled_button(name, x,y, onpress1, tooltip_text, fg)
if Overflow_button then
return x, y+Line_height
else

View File

@ -43,10 +43,12 @@ draw_file_dialog = function()
end
end
styled_button(filename, x,y, function()
File_dialog_callback(filename)
reset_file_dialog_state()
end)
File_dialog_callback(filename)
reset_file_dialog_state()
end,
--[[tooltip text]] nil,
local_modifications_color(filename))
x = x+w+10
end
end
end
end

View File

@ -1,11 +1,11 @@
styled_button = function(name, x, y, onpress1, tooltip_text)
styled_button = function(name, x, y, onpress1, tooltip_text, fg)
local w = Font:getWidth(name)+10
button(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)
if Active_button and Active_button.name == name and Active_button.expire > Current_time then
App.color(Highlighted_button_color)
else
App.color(Normal_color)
App.color(fg or Normal_color)
end
love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
love.graphics.print(name, p.x+5,p.y+2)

View File

@ -0,0 +1 @@
Local_modifications_color = {r=0.8, g=0, b=0}

View File

@ -0,0 +1,3 @@
local_modifications_color = function(filename)
return has_local_modifications(filename) and Local_modifications_color
end