-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy paththeme.go
76 lines (67 loc) · 1.78 KB
/
theme.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// TODO: replace with go:embed
//go:generate fyne bundle -o bundled.go -package main ./resources/Mplus1-Regular.ttf
//go:generate fyne bundle -append -o bundled.go -package main ./resources/Mplus1-Bold.ttf
//go:generate fyne bundle -append -o bundled.go -package main ./resources/Mplus1Code-Regular.ttf
//go:generate fyne bundle -append -o bundled.go -package main ./resources/Mplus1Code-Bold.ttf
package main
import (
"image/color"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/theme"
)
type mytheme struct{}
func (m *mytheme) Color(n fyne.ThemeColorName, v fyne.ThemeVariant) color.Color {
defaultTheme := theme.DefaultTheme()
switch n {
default:
return defaultTheme.Color(n, v)
case theme.ColorNameDisabled:
return color.RGBA{R: 0xab, G: 0xab, B: 0xab, A: 0xff}
}
}
func (m *mytheme) Font(s fyne.TextStyle) fyne.Resource {
if s.Monospace {
return resourceMplus1CodeRegularTtf
}
if s.Bold {
return resourceMplus1BoldTtf
}
return resourceMplus1RegularTtf
}
func (m *mytheme) Icon(n fyne.ThemeIconName) fyne.Resource {
return theme.DefaultTheme().Icon(n)
}
func (m *mytheme) Size(n fyne.ThemeSizeName) float32 {
switch n {
default:
return theme.DefaultTheme().Size(n)
case theme.SizeNameSeparatorThickness:
return 1
case theme.SizeNameInlineIcon:
return 20
case theme.SizeNameInnerPadding:
return 8
case theme.SizeNameLineSpacing:
return 4
case theme.SizeNamePadding:
return 4
case theme.SizeNameScrollBar:
return 16
case theme.SizeNameScrollBarSmall:
return 3
case theme.SizeNameText:
return 10
case theme.SizeNameHeadingText:
return 24
case theme.SizeNameSubHeadingText:
return 18
case theme.SizeNameCaptionText:
return 11
case theme.SizeNameInputBorder:
return 1
case theme.SizeNameInputRadius:
return 5
case theme.SizeNameSelectionRadius:
return 3
}
}