-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy paththeme.go
110 lines (98 loc) · 2.95 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package main
import (
"image/color"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/theme"
)
var (
errorColor = color.NRGBA{R: 0xf4, G: 0x43, B: 0x36, A: 0xff}
successColor = color.NRGBA{R: 0x43, G: 0xf4, B: 0x36, A: 0xff}
warningColor = color.NRGBA{R: 0xff, G: 0x98, B: 0x00, A: 0xff}
)
type MyTheme struct{}
var _ fyne.Theme = (*MyTheme)(nil)
func (m MyTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color {
switch name {
case theme.ColorNameBackground:
return color.NRGBA{R: 0x14, G: 0x14, B: 0x15, A: 0xff}
case theme.ColorNameButton:
return color.NRGBA{R: 0x28, G: 0x29, B: 0x2e, A: 0xff}
case theme.ColorNameDisabled:
return color.NRGBA{R: 0x39, G: 0x39, B: 0x3a, A: 0xff}
case theme.ColorNameDisabledButton:
return color.NRGBA{R: 0x28, G: 0x29, B: 0x2e, A: 0xff}
case theme.ColorNameError:
return errorColor
case theme.ColorNameForeground:
return color.NRGBA{R: 0xf3, G: 0xf3, B: 0xf3, A: 0xff}
case theme.ColorNameHover:
return color.NRGBA{R: 0xff, G: 0xff, B: 0xff, A: 0x0f}
case theme.ColorNameInputBackground:
return color.NRGBA{R: 0x20, G: 0x20, B: 0x23, A: 0xff}
case theme.ColorNameInputBorder:
return color.NRGBA{R: 0x39, G: 0x39, B: 0x3a, A: 0xff}
case theme.ColorNameMenuBackground:
return color.NRGBA{R: 0x28, G: 0x29, B: 0x2e, A: 0xff}
case theme.ColorNameOverlayBackground:
return color.NRGBA{R: 0x18, G: 0x1d, B: 0x25, A: 0xff}
case theme.ColorNamePlaceHolder:
return color.NRGBA{R: 0xb2, G: 0xb2, B: 0xb2, A: 0xff}
case theme.ColorNamePressed:
return color.NRGBA{R: 0xff, G: 0xff, B: 0xff, A: 0x66}
case theme.ColorNameScrollBar:
return color.NRGBA{R: 0xff, G: 0xff, B: 0xff, A: 0x99}
case theme.ColorNameSeparator:
return color.NRGBA{R: 0x0, G: 0x0, B: 0x0, A: 0xff}
case theme.ColorNameShadow:
return color.NRGBA{A: 0x66}
case theme.ColorNameSuccess:
return successColor
case theme.ColorNameWarning:
return warningColor
}
return theme.DefaultTheme().Color(name, variant)
}
/*
func (m MyTheme) Icon(name fyne.ThemeIconName) fyne.Resource {
if name == theme.IconNameHome {
fyne.NewStaticResource("myHome", assets.HkBytes)
}
return theme.DefaultTheme().Icon(name)
}
*/
func (m MyTheme) Icon(n fyne.ThemeIconName) fyne.Resource {
return theme.DefaultTheme().Icon(n)
}
func (m MyTheme) Font(style fyne.TextStyle) fyne.Resource {
return theme.DefaultTheme().Font(style)
}
func (m MyTheme) Size(name fyne.ThemeSizeName) float32 {
switch name {
case theme.SizeNameSeparatorThickness:
return 0
case theme.SizeNameInlineIcon:
return 20
case theme.SizeNameInnerPadding:
return 4
case theme.SizeNameLineSpacing:
return 2
case theme.SizeNamePadding:
return 6
case theme.SizeNameScrollBar:
return 16
case theme.SizeNameScrollBarSmall:
return 3
case theme.SizeNameText:
return 13
case theme.SizeNameHeadingText:
return 24
case theme.SizeNameSubHeadingText:
return 18
case theme.SizeNameCaptionText:
return 11
case theme.SizeNameInputBorder:
return 2
default:
return 2
}
}