sokoban.love/0020-draw_editor_border

40 lines
1.3 KiB
Plaintext

draw_editor_border = function()
App.color(Border_color)
local x1 = Current_pane.editor_state.left-5-Line_number_padding
local y1 = Current_pane.editor_state.top-5
local x2 = Current_pane.editor_state.right+5
local y2 = Current_pane.editor_state.bottom+5
-- upper border
if Current_pane.filename then
-- title in between if it exists
local old_font = love.graphics.getFont()
if Title_font == nil then
Title_font = love.graphics.newFont(15) -- 20 pixels between menu and upper border - 5
end
love.graphics.setFont(Title_font)
local tx1 = Current_pane.editor_state.left
local filename = Current_pane.filename
if Current_pane.editor_state.next_save then
filename = filename..' *'
end
local tx2 = tx1 + App.width(filename)
if Current_pane.is_stash then
App.color(Stash_color)
elseif has_local_modifications(Current_pane.filename) then
App.color(Local_modifications_color)
end
love.graphics.print(filename, tx1, y1-15+5)
App.color(Border_color)
love.graphics.setFont(old_font)
love.graphics.line(x1,y1, tx1-5,y1)
love.graphics.line(math.min(tx2+5,x2), y1, x2,y1)
else
love.graphics.line(x1,y1, x2,y1)
end
love.graphics.line(x1,y1, x1,y1+10)
love.graphics.line(x2,y1, x2,y1+10)
-- lower border
love.graphics.line(x1,y2, x2,y2)
love.graphics.line(x1,y2, x1,y2-10)
love.graphics.line(x2,y2, x2,y2-10)
end