-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashTheme.go
More file actions
56 lines (46 loc) · 1.26 KB
/
HashTheme.go
File metadata and controls
56 lines (46 loc) · 1.26 KB
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
// Copyright (c) 2025 Neil Stephens. All rights reserved.
// Use of this source code is governed by an MIT license that can be
// found in the LICENSE file.
package main
import (
"image/color"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/theme"
)
// A custom theme that only overrides the text size, to make the output easier to read
type hashTheme struct {
fyne.Theme
scale float32
}
func NewHashTheme(scale float32) fyne.Theme {
return &hashTheme{
Theme: theme.DefaultTheme(),
scale: scale,
}
}
func (t *hashTheme) Size(name fyne.ThemeSizeName) float32 {
baseSize := t.Theme.Size(name)
// Only multiply text-related sizes
switch name {
case theme.SizeNameText:
return baseSize * t.scale
case theme.SizeNameHeadingText:
return baseSize * t.scale
case theme.SizeNameSubHeadingText:
return baseSize * t.scale
case theme.SizeNameCaptionText:
return baseSize * t.scale
default:
// Return original size for non-text elements
return baseSize
}
}
func (t *hashTheme) Font(style fyne.TextStyle) fyne.Resource {
return t.Theme.Font(style)
}
func (t *hashTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color {
return t.Theme.Color(name, variant)
}
func (t *hashTheme) Icon(name fyne.ThemeIconName) fyne.Resource {
return t.Theme.Icon(name)
}