From 2970fabeb11e090c28c989333a0c0b21724e9080 Mon Sep 17 00:00:00 2001 From: Piotr Grabowski Date: Sat, 10 Aug 2024 12:48:37 +0200 Subject: [PATCH] refactor(ui): move some ui logic out of config code --- config.go | 20 ++------------------ ui.go | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/config.go b/config.go index 537c8c1..990676a 100644 --- a/config.go +++ b/config.go @@ -194,29 +194,13 @@ func (app *App) setVFlip(vflip bool) { func (app *App) setFullscreen(fullscreen bool) { app.Config.Fullscreen = fullscreen - - if fullscreen { - app.W.MainWindow.Fullscreen() - } else { - app.W.MainWindow.Unfullscreen() - } - + app.toggleFullscreen(fullscreen) app.W.MenuItemFullscreen.SetActive(fullscreen) } func (app *App) setHideUI(hideUI bool) { app.Config.HideUI = hideUI - - if hideUI { - app.W.Menubar.Hide() - app.W.Toolbar.Hide() - app.W.Statusbar.Hide() - } else { - app.W.Menubar.Show() - app.W.Toolbar.Show() - app.W.Statusbar.Show() - } - + app.toggleHideUI(hideUI) app.W.MenuItemHideUI.SetActive(hideUI) } diff --git a/ui.go b/ui.go index 696cc19..f3dc8d3 100644 --- a/ui.go +++ b/ui.go @@ -119,3 +119,23 @@ func (app *App) syncWidgetsToConfig() { app.W.KamitePortContainer.SetSensitive(app.Config.KamiteEnabled) app.W.KamitePortEntry.SetText(fmt.Sprint(app.Config.KamitePort)) } + +func (app *App) toggleHideUI(hideUI bool) { + if hideUI { + app.W.Menubar.Hide() + app.W.Toolbar.Hide() + app.W.Statusbar.Hide() + } else { + app.W.Menubar.Show() + app.W.Toolbar.Show() + app.W.Statusbar.Show() + } +} + +func (app *App) toggleFullscreen(fullscreen bool) { + if fullscreen { + app.W.MainWindow.Fullscreen() + } else { + app.W.MainWindow.Unfullscreen() + } +}