-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.go
51 lines (42 loc) · 1.51 KB
/
settings.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"fmt"
"strconv"
"fyne.io/fyne/v2"
appearance "fyne.io/fyne/v2/cmd/fyne_settings/settings"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
)
func showSettings(a fyne.App) {
w := a.NewWindow("Settings")
srEntry := NewNumEntry()
srEntry.SetText(fmt.Sprint(a.Preferences().IntWithFallback("OutputSampleRate", 48000)))
srEntry.OnChanged = func(s string) {
sr, _ := strconv.Atoi(s)
a.Preferences().SetInt("OutputSampleRate", sr)
}
dpsrEntry := NewNumEntry()
dpsrEntry.SetText(fmt.Sprint(a.Preferences().IntWithFallback("DefaultProjectSampleRate", 8000)))
dpsrEntry.OnChanged = func(s string) {
sr, _ := strconv.Atoi(s)
a.Preferences().SetInt("DefaultProjectSampleRate", sr)
}
rqEntry := NewNumEntry()
rqEntry.SetText(fmt.Sprint(a.Preferences().IntWithFallback("ResampleQuality", 1)))
rqEntry.OnChanged = func(s string) {
sr, _ := strconv.Atoi(s)
a.Preferences().SetInt("ResampleQuality", sr)
}
w.SetContent(container.NewAppTabs(
container.NewTabItem("Audio", container.NewVScroll(container.NewVBox(
container.NewGridWithColumns(2, newBoldLabel("Output Sample Rate"), srEntry),
container.NewGridWithColumns(2, newBoldLabel("Default Project Sample Rate"), dpsrEntry),
container.NewGridWithColumns(2, newBoldLabel("Resample Quality"), rqEntry),
))),
container.NewTabItem("Appearance", appearance.NewSettings().LoadAppearanceScreen(w)),
))
w.Show()
}
func newBoldLabel(text string) *widget.Label {
return &widget.Label{Text: text, TextStyle: fyne.TextStyle{Bold: true}}
}