save peak meter window size
This commit is contained in:
@@ -124,6 +124,11 @@ type TranscodingConfig struct {
|
||||
ForceRawFile bool
|
||||
}
|
||||
|
||||
type PeakMeterConfig struct {
|
||||
WindowHeight int
|
||||
WindowWidth int
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Application AppConfig
|
||||
Servers []*ServerConfig
|
||||
@@ -141,6 +146,7 @@ type Config struct {
|
||||
ReplayGain ReplayGainConfig
|
||||
Transcoding TranscodingConfig
|
||||
Theme ThemeConfig
|
||||
PeakMeter PeakMeterConfig
|
||||
}
|
||||
|
||||
var SupportedStartupPages = []string{"Albums", "Favorites", "Playlists"}
|
||||
@@ -221,6 +227,10 @@ func DefaultConfig(appVersionTag string) *Config {
|
||||
Theme: ThemeConfig{
|
||||
Appearance: "Dark",
|
||||
},
|
||||
PeakMeter: PeakMeterConfig{
|
||||
WindowWidth: 375,
|
||||
WindowHeight: 100,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"github.com/dweymouth/supersonic/ui/util"
|
||||
"github.com/dweymouth/supersonic/ui/visualizations"
|
||||
)
|
||||
|
||||
@@ -35,7 +36,15 @@ func (c *Controller) ShowPeakMeter() {
|
||||
c.stopVisualizationAnim()
|
||||
c.peakMeter = nil
|
||||
win.Close()
|
||||
util.SaveWindowSize(win,
|
||||
&c.App.Config.PeakMeter.WindowWidth,
|
||||
&c.App.Config.PeakMeter.WindowHeight)
|
||||
})
|
||||
if c.App.Config.PeakMeter.WindowHeight > 0 {
|
||||
win.Resize(fyne.NewSize(
|
||||
float32(c.App.Config.PeakMeter.WindowWidth),
|
||||
float32(c.App.Config.PeakMeter.WindowHeight)))
|
||||
}
|
||||
c.peakMeter = visualizations.NewPeakMeter()
|
||||
win.SetContent(c.peakMeter)
|
||||
c.startVisualizationAnim()
|
||||
|
||||
+4
-5
@@ -3,7 +3,6 @@ package ui
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"math"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -16,6 +15,7 @@ import (
|
||||
"github.com/dweymouth/supersonic/ui/dialogs"
|
||||
"github.com/dweymouth/supersonic/ui/os"
|
||||
"github.com/dweymouth/supersonic/ui/theme"
|
||||
"github.com/dweymouth/supersonic/ui/util"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
@@ -432,8 +432,7 @@ func (m *MainWindow) Quit() {
|
||||
}
|
||||
|
||||
func (m *MainWindow) SaveWindowSize() {
|
||||
// round sizes to even to avoid Wayland issues with 2x scaling factor
|
||||
// https://github.com/dweymouth/supersonic/issues/212
|
||||
m.App.Config.Application.WindowHeight = int(math.RoundToEven(float64(m.Window.Canvas().Size().Height)))
|
||||
m.App.Config.Application.WindowWidth = int(math.RoundToEven(float64(m.Window.Canvas().Size().Width)))
|
||||
util.SaveWindowSize(m.Window,
|
||||
&m.App.Config.Application.WindowWidth,
|
||||
&m.App.Config.Application.WindowHeight)
|
||||
}
|
||||
|
||||
@@ -257,6 +257,13 @@ func NewTrailingAlignLabel() *widget.Label {
|
||||
return rt
|
||||
}
|
||||
|
||||
func SaveWindowSize(w fyne.Window, wPtr, hPtr *int) {
|
||||
// round sizes to even to avoid Wayland issues with 2x scaling factor
|
||||
// https://github.com/dweymouth/supersonic/issues/212
|
||||
*wPtr = int(math.RoundToEven(float64(w.Canvas().Size().Width)))
|
||||
*hPtr = int(math.RoundToEven(float64(w.Canvas().Size().Height)))
|
||||
}
|
||||
|
||||
type HSpace struct {
|
||||
widget.BaseWidget
|
||||
|
||||
|
||||
Reference in New Issue
Block a user