feat(ui): allow temporarily revealing the UI with the alt button if hidden

This commit is contained in:
Piotr Grabowski 2024-08-10 14:58:13 +02:00
parent 3f1ac02fe7
commit 784bb77d91
3 changed files with 13 additions and 0 deletions

6
app.go
View file

@ -70,6 +70,7 @@ type State struct {
RecentManager *gtk.RecentManager RecentManager *gtk.RecentManager
BackgroundColorCssProvider *gtk.CssProvider BackgroundColorCssProvider *gtk.CssProvider
PageCacheTrimTimeoutHandle *glib.SourceHandle PageCacheTrimTimeoutHandle *glib.SourceHandle
UITemporarilyRevealed bool
} }
//go:embed about.jpg //go:embed about.jpg
@ -236,6 +237,11 @@ func (app *App) handleKeyPress(key uint, shift bool, ctrl bool) {
} else { } else {
app.W.MenuItemNextPage.Activate() app.W.MenuItemNextPage.Activate()
} }
case gdk.KEY_Alt_L:
if app.Config.HideUI {
app.S.UITemporarilyRevealed = !app.S.UITemporarilyRevealed
app.toggleHideUI(!app.S.UITemporarilyRevealed)
}
} }
} }

View file

@ -202,6 +202,7 @@ func (app *App) setHideUI(hideUI bool) {
app.Config.HideUI = hideUI app.Config.HideUI = hideUI
app.toggleHideUI(hideUI) app.toggleHideUI(hideUI)
app.W.MenuItemHideUI.SetActive(hideUI) app.W.MenuItemHideUI.SetActive(hideUI)
app.S.UITemporarilyRevealed = false
} }
func (app *App) setShrink(shrink bool) { func (app *App) setShrink(shrink bool) {

View file

@ -35,6 +35,12 @@ func (app *App) imageAreaInit() {
}) })
app.W.ScrolledWindow.Connect("button-press-event", func(self *gtk.ScrolledWindow, event *gdk.Event) bool { app.W.ScrolledWindow.Connect("button-press-event", func(self *gtk.ScrolledWindow, event *gdk.Event) bool {
if app.S.UITemporarilyRevealed {
app.S.UITemporarilyRevealed = false
app.toggleHideUI(true)
return true
}
be := &gdk.EventButton{Event: event} be := &gdk.EventButton{Event: event}
switch be.Button() { switch be.Button() {
case 1: case 1: