Implement maximize/restore controls

Remove also resize from top and right of the window
This commit is contained in:
Francesco Abbate
2021-04-12 11:54:52 +02:00
parent 96a0ae802a
commit 46791aefe5
4 changed files with 48 additions and 6 deletions
+12 -2
View File
@@ -3,10 +3,18 @@ local common = require "core.common"
local style = require "core.style"
local View = require "core.view"
local restore_command = {
symbol = "w", action = function() system.set_window_mode("normal") end
}
local maximize_command = {
symbol = "W", action = function() system.set_window_mode("maximized") end
}
local title_commands = {
{symbol = "_", action = function() system.set_window_mode("minimized") end},
{symbol = "w", action = function() system.set_window_mode("maximized") end},
{symbol = "W", action = function() core.quit() end},
maximize_command,
{symbol = "X", action = function() core.quit() end},
}
local TitleView = View:extend()
@@ -28,6 +36,8 @@ function TitleView:update()
self.size.y = 0
end
TitleView.super.update(self)
local window_mode = system.get_window_mode()
title_commands[2] = window_mode == "maximized" and restore_command or maximize_command
local title_height = self.size.y
if core.window_borderless and title_height ~= core.hit_test_title_height then
local icon_w = style.icon_font:get_width("_")