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