refactor(ui): move some ui logic out of config code

This commit is contained in:
Piotr Grabowski 2024-08-10 12:48:37 +02:00
parent fb91eac669
commit 2970fabeb1
2 changed files with 22 additions and 18 deletions

View file

@ -194,29 +194,13 @@ func (app *App) setVFlip(vflip bool) {
func (app *App) setFullscreen(fullscreen bool) { func (app *App) setFullscreen(fullscreen bool) {
app.Config.Fullscreen = fullscreen app.Config.Fullscreen = fullscreen
app.toggleFullscreen(fullscreen)
if fullscreen {
app.W.MainWindow.Fullscreen()
} else {
app.W.MainWindow.Unfullscreen()
}
app.W.MenuItemFullscreen.SetActive(fullscreen) app.W.MenuItemFullscreen.SetActive(fullscreen)
} }
func (app *App) setHideUI(hideUI bool) { func (app *App) setHideUI(hideUI bool) {
app.Config.HideUI = hideUI app.Config.HideUI = hideUI
app.toggleHideUI(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.W.MenuItemHideUI.SetActive(hideUI) app.W.MenuItemHideUI.SetActive(hideUI)
} }

20
ui.go
View file

@ -119,3 +119,23 @@ func (app *App) syncWidgetsToConfig() {
app.W.KamitePortContainer.SetSensitive(app.Config.KamiteEnabled) app.W.KamitePortContainer.SetSensitive(app.Config.KamiteEnabled)
app.W.KamitePortEntry.SetText(fmt.Sprint(app.Config.KamitePort)) 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()
}
}