-
Notifications
You must be signed in to change notification settings - Fork 158
Expand file tree
/
Copy pathstyle_drawtextwidget.v
More file actions
81 lines (72 loc) · 1.86 KB
/
style_drawtextwidget.v
File metadata and controls
81 lines (72 loc) · 1.86 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
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
module ui
import gg
// Embedded in most Widget Styles
pub struct WidgetTextStyle {
pub mut:
text_font_name string = 'system'
text_color gg.Color
text_size int = 16
text_align TextHorizontalAlign = .center
text_vertical_align TextVerticalAlign = .middle
}
@[params]
pub struct WidgetTextStyleParams {
pub mut:
// text_style TextStyle
text_font_name string
text_color gg.Color = no_color
text_size f64
text_align TextHorizontalAlign = .@none
text_vertical_align TextVerticalAlign = .@none
cursor_color gg.Color = no_color
}
// Style with Text
interface DrawTextWidgetStyle {
mut:
text_font_name string
text_color gg.Color
text_size int
text_align TextHorizontalAlign
text_vertical_align TextVerticalAlign
}
interface DrawTextWidgetStyleParams {
text_font_name string
text_color gg.Color
text_size f64
text_align TextHorizontalAlign
text_vertical_align TextVerticalAlign
}
pub fn (mut dtw DrawTextWidget) update_theme_style(ds DrawTextWidgetStyle) {
dtw.update_style(
font_name: ds.text_font_name
color: ds.text_color
size: ds.text_size
align: ds.text_align
vertical_align: ds.text_vertical_align
)
}
pub fn (mut dtw DrawTextWidget) update_theme_style_params(ds DrawTextWidgetStyleParams) {
if ds.text_size > 0 {
dtw.update_text_size(ds.text_size)
}
mut ts, mut ok := TextStyleParams{}, false
if ds.text_font_name != '' {
ok = true
ts.font_name = ds.text_font_name
}
if ds.text_color != no_color {
ok = true
ts.color = ds.text_color
}
if ds.text_align != .@none {
ok = true
ts.align = ds.text_align
}
if ds.text_vertical_align != .@none {
ok = true
ts.vertical_align = ds.text_vertical_align
}
if ok {
dtw.update_style(ts)
}
}