reactivate peak meter window if menu item selected again

This commit is contained in:
Drew Weymouth
2024-07-25 17:28:49 -07:00
parent e9946c0511
commit 0359d12e7d
+11 -8
View File
@@ -14,6 +14,7 @@ import (
// embedded in parent controller struct // embedded in parent controller struct
type visualizationData struct { type visualizationData struct {
peakMeter *visualizations.PeakMeter peakMeter *visualizations.PeakMeter
peakMeterWin fyne.Window
visualizationAnim *fyne.Animation visualizationAnim *fyne.Animation
} }
@@ -29,32 +30,34 @@ func (c *Controller) initVisualizations() {
} }
func (c *Controller) ShowPeakMeter() { func (c *Controller) ShowPeakMeter() {
if c.peakMeter != nil { if c.peakMeterWin != nil {
c.peakMeterWin.Show()
return return
} }
win := fyne.CurrentApp().NewWindow(lang.L("Peak Meter")) c.peakMeterWin = fyne.CurrentApp().NewWindow(lang.L("Peak Meter"))
win.SetCloseIntercept(func() { c.peakMeterWin.SetCloseIntercept(func() {
c.stopVisualizationAnim() c.stopVisualizationAnim()
c.peakMeter = nil c.peakMeter = nil
win.Close() util.SaveWindowSize(c.peakMeterWin,
util.SaveWindowSize(win,
&c.App.Config.PeakMeter.WindowWidth, &c.App.Config.PeakMeter.WindowWidth,
&c.App.Config.PeakMeter.WindowHeight) &c.App.Config.PeakMeter.WindowHeight)
c.peakMeterWin.Close()
c.peakMeterWin = nil
}) })
if c.App.Config.PeakMeter.WindowHeight > 0 { if c.App.Config.PeakMeter.WindowHeight > 0 {
win.Resize(fyne.NewSize( c.peakMeterWin.Resize(fyne.NewSize(
float32(c.App.Config.PeakMeter.WindowWidth), float32(c.App.Config.PeakMeter.WindowWidth),
float32(c.App.Config.PeakMeter.WindowHeight))) float32(c.App.Config.PeakMeter.WindowHeight)))
} }
c.peakMeter = visualizations.NewPeakMeter() c.peakMeter = visualizations.NewPeakMeter()
win.SetContent(c.peakMeter) c.peakMeterWin.SetContent(c.peakMeter)
if c.App.LocalPlayer.GetStatus().State == player.Playing { if c.App.LocalPlayer.GetStatus().State == player.Playing {
c.startVisualizationAnim() c.startVisualizationAnim()
} else { } else {
// TODO: why is this needed? // TODO: why is this needed?
c.peakMeter.Refresh() c.peakMeter.Refresh()
} }
win.Show() c.peakMeterWin.Show()
} }
func (c *Controller) stopVisualizationAnim() { func (c *Controller) stopVisualizationAnim() {