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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import { Theme } from "../theme.slint";
export component NeonToggle {
in property <string> label: "";
in-out property <bool> checked: false;
in property <bool> enabled: true;
in property <bool> has-focus: false;
callback toggled;
HorizontalLayout {
spacing: Theme.sp-2;
alignment: start;
if (root.label != "") : Text {
text: root.label;
color: root.enabled ? Theme.text-primary : Theme.text-dim;
font-size: Theme.font-base;
vertical-alignment: center;
}
Rectangle {
width: 32px; height: 18px;
border-radius: 9px;
background: !root.enabled ? Theme.border :
root.checked ? Theme.neon-cyan : Theme.border;
border-width: root.has-focus ? 1px : 0px;
border-color: root.has-focus ? Theme.border-focus : transparent;
opacity: root.enabled ? 1.0 : 0.4;
Rectangle {
width: 14px; height: 14px;
border-radius: 7px;
background: !root.enabled ? Theme.text-dim : Theme.text-inverse;
x: root.checked ? 16px : 2px;
y: 2px;
}
touch := TouchArea {
clicked => {
if (root.enabled) {
root.checked = !root.checked;
root.toggled();
}
}
enabled: root.enabled;
mouse-cursor: root.enabled ? MouseCursor.pointer : MouseCursor.default;
}
}
}
}
export component NeonCheckbox {
in property <string> label: "";
in-out property <bool> checked: false;
in property <bool> enabled: true;
in property <bool> has-focus: false;
callback toggled;
HorizontalLayout {
spacing: Theme.sp-2;
alignment: start;
Rectangle {
width: 16px; height: 16px;
border-radius: Theme.radius-sm;
border-width: 1px;
border-color: root.has-focus ? Theme.border-focus :
root.checked ? Theme.neon-cyan : Theme.border;
background: root.checked ? Theme.neon-cyan : transparent;
opacity: root.enabled ? 1.0 : 0.4;
Text {
text: "✓";
color: Theme.text-inverse;
font-size: 11px;
font-weight: 700;
horizontal-alignment: center;
vertical-alignment: center;
visible: root.checked;
}
touch := TouchArea {
clicked => {
if (root.enabled) {
root.checked = !root.checked;
root.toggled();
}
}
enabled: root.enabled;
mouse-cursor: root.enabled ? MouseCursor.pointer : MouseCursor.default;
}
}
if (root.label != "") : Text {
text: root.label;
color: root.enabled ? Theme.text-primary : Theme.text-dim;
font-size: Theme.font-base;
vertical-alignment: center;
}
}
}
export component NeonRadioGroup {
in property <[string]> items;
in-out property <int> selected-index: -1;
in property <bool> enabled: true;
callback index-changed(int);
VerticalLayout {
spacing: Theme.sp-2;
for item[idx] in root.items : HorizontalLayout {
spacing: Theme.sp-2;
alignment: start;
min-height: 28px;
Rectangle {
width: 16px; height: 16px;
border-radius: 8px;
border-width: 1px;
border-color: idx == root.selected-index ? Theme.neon-cyan : Theme.border;
opacity: root.enabled ? 1.0 : 0.4;
if (idx == root.selected-index) : Rectangle {
width: 8px; height: 8px;
border-radius: 4px;
background: root.enabled ? Theme.neon-cyan : Theme.text-dim;
x: 4px; y: 4px;
}
touch := TouchArea {
clicked => {
if (root.enabled) {
root.selected-index = idx;
root.index-changed(idx);
}
}
enabled: root.enabled;
mouse-cursor: root.enabled ? MouseCursor.pointer : MouseCursor.default;
}
}
Text {
text: item;
color: idx == root.selected-index ? (root.enabled ? Theme.neon-cyan : Theme.text-dim) : (root.enabled ? Theme.text-primary : Theme.text-dim);
font-size: Theme.font-base;
font-weight: idx == root.selected-index ? 600 : 400;
vertical-alignment: center;
}
}
}
}