nomen-lang 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/System/Buffer.nm +32 -0
- package/core/System/ClassBuffer.nm +24 -0
- package/core/System/Controls/Alert.nm +326 -0
- package/core/System/Controls/App.nm +147 -0
- package/core/System/Controls/Button.nm +119 -1
- package/core/System/Controls/CheckBox.nm +24 -0
- package/core/System/Controls/ColorPicker.nm +307 -0
- package/core/System/Controls/ComboBox.nm +430 -0
- package/core/System/Controls/Container.nm +837 -9
- package/core/System/Controls/Control.nm +443 -0
- package/core/System/Controls/DatePicker.nm +288 -0
- package/core/System/Controls/Form.nm +70 -0
- package/core/System/Controls/GroupBox.nm +267 -0
- package/core/System/Controls/ImageView.nm +311 -0
- package/core/System/Controls/LevelIndicator.nm +305 -0
- package/core/System/Controls/ListView.nm +633 -0
- package/core/System/Controls/Menu.nm +428 -0
- package/core/System/Controls/NumberInput.nm +56 -0
- package/core/System/Controls/OtpInput.nm +50 -0
- package/core/System/Controls/OutlineView.nm +598 -0
- package/core/System/Controls/Pagination.nm +142 -0
- package/core/System/Controls/Popover.nm +296 -0
- package/core/System/Controls/Progress.nm +348 -0
- package/core/System/Controls/Radio.nm +292 -0
- package/core/System/Controls/Scrollable.nm +584 -0
- package/core/System/Controls/SearchField.nm +326 -0
- package/core/System/Controls/SecureField.nm +344 -0
- package/core/System/Controls/Segmented.nm +380 -0
- package/core/System/Controls/Select.nm +340 -0
- package/core/System/Controls/Separator.nm +198 -0
- package/core/System/Controls/Sheet.nm +329 -0
- package/core/System/Controls/Slider.nm +315 -0
- package/core/System/Controls/Spinner.nm +287 -0
- package/core/System/Controls/SplitView.nm +509 -0
- package/core/System/Controls/Stepper.nm +349 -0
- package/core/System/Controls/Switch.nm +259 -0
- package/core/System/Controls/Table.nm +833 -0
- package/core/System/Controls/Tabs.nm +500 -0
- package/core/System/Controls/Text.nm +108 -11
- package/core/System/Controls/TextBox.nm +112 -1
- package/core/System/Controls/TextView.nm +329 -0
- package/core/System/Controls/Toggle.nm +346 -0
- package/core/System/Controls/Toolbar.nm +501 -0
- package/core/System/Controls/Tooltip.nm +76 -0
- package/core/System/Controls/Window.nm +1549 -91
- package/core/System/List.nm +34 -0
- package/core/System/Map.nm +21 -4
- package/core/System/Set.nm +14 -0
- package/dist/index.mjs +3425 -710
- package/package.json +1 -1
|
@@ -6,9 +6,14 @@
|
|
|
6
6
|
* `#destroy` releases what the handle names. The constructor's `self` is
|
|
7
7
|
* the inline instance (the `.` accessor); methods keep the pointer form.
|
|
8
8
|
**/
|
|
9
|
-
pub mv struct Button
|
|
9
|
+
pub mv struct Button: Control {
|
|
10
10
|
var uint64 handle = 0
|
|
11
11
|
|
|
12
|
+
// The `#handle` hook synthesizes `NameHandle` — a copyable, non-owning
|
|
13
|
+
// twin (same public bare-self methods, no destroy) so closures can
|
|
14
|
+
// capture this control without moving it. See GUI.md, "Handles".
|
|
15
|
+
#handle = () {}
|
|
16
|
+
|
|
12
17
|
pub func #init = (self, Window window, string title) {
|
|
13
18
|
```
|
|
14
19
|
#arch: c
|
|
@@ -28,6 +33,8 @@ pub mv struct Button : Control {
|
|
|
28
33
|
((void(*)(id, SEL, id))objc_msgSend)(
|
|
29
34
|
contentView, sel_registerName("addSubview:"), btn);
|
|
30
35
|
self.handle = (uint64_t)btn;
|
|
36
|
+
extern void nomen_control_arm_clicks(unsigned long long);
|
|
37
|
+
nomen_control_arm_clicks((unsigned long long)btn);
|
|
31
38
|
```
|
|
32
39
|
```
|
|
33
40
|
#arch: aarch64_use_c
|
|
@@ -47,6 +54,8 @@ pub mv struct Button : Control {
|
|
|
47
54
|
((void(*)(id, SEL, id))objc_msgSend)(
|
|
48
55
|
contentView, sel_registerName("addSubview:"), btn);
|
|
49
56
|
self->handle = (uint64_t)btn;
|
|
57
|
+
extern void nomen_control_arm_clicks(unsigned long long) __asm__("nomen_control_arm_clicks");
|
|
58
|
+
nomen_control_arm_clicks((unsigned long long)btn);
|
|
50
59
|
```
|
|
51
60
|
```
|
|
52
61
|
#arch: c
|
|
@@ -158,6 +167,47 @@ pub mv struct Button : Control {
|
|
|
158
167
|
```
|
|
159
168
|
}
|
|
160
169
|
|
|
170
|
+
// The button's current title (a fresh own string — the heap copy is the
|
|
171
|
+
// returned nomen_string).
|
|
172
|
+
pub func get_title = (self, out string) {
|
|
173
|
+
```
|
|
174
|
+
#arch: c
|
|
175
|
+
#platform: macos
|
|
176
|
+
id str = ((id(*)(id, SEL))objc_msgSend)(
|
|
177
|
+
(id)self->handle, sel_registerName("title"));
|
|
178
|
+
const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
|
|
179
|
+
str, sel_registerName("UTF8String"));
|
|
180
|
+
return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
|
|
181
|
+
```
|
|
182
|
+
```
|
|
183
|
+
#arch: aarch64_use_c
|
|
184
|
+
#platform: macos
|
|
185
|
+
id str = ((id(*)(id, SEL))objc_msgSend)(
|
|
186
|
+
(id)self->handle, sel_registerName("title"));
|
|
187
|
+
const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
|
|
188
|
+
str, sel_registerName("UTF8String"));
|
|
189
|
+
return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
|
|
190
|
+
```
|
|
191
|
+
```
|
|
192
|
+
#arch: c
|
|
193
|
+
#platform: ios
|
|
194
|
+
id str = ((id(*)(id, SEL, unsigned long))objc_msgSend)(
|
|
195
|
+
(id)self->handle, sel_registerName("titleForState:"), 0UL); // UIControlStateNormal = 0
|
|
196
|
+
const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
|
|
197
|
+
str, sel_registerName("UTF8String"));
|
|
198
|
+
return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
|
|
199
|
+
```
|
|
200
|
+
```
|
|
201
|
+
#arch: aarch64_use_c
|
|
202
|
+
#platform: ios
|
|
203
|
+
id str = ((id(*)(id, SEL, unsigned long))objc_msgSend)(
|
|
204
|
+
(id)self->handle, sel_registerName("titleForState:"), 0UL); // UIControlStateNormal = 0
|
|
205
|
+
const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
|
|
206
|
+
str, sel_registerName("UTF8String"));
|
|
207
|
+
return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
|
|
208
|
+
```
|
|
209
|
+
}
|
|
210
|
+
|
|
161
211
|
// ── Control trait conformance ──
|
|
162
212
|
// A button sizes to its native intrinsic content size (title + chrome);
|
|
163
213
|
// `measure` clamps that to the box constraints. The native query goes
|
|
@@ -165,6 +215,74 @@ pub mv struct Button : Control {
|
|
|
165
215
|
// on both backends — a per-control raw block couldn't return a `Size` from
|
|
166
216
|
// the aarch64 companion (struct-name mangling) nor mutate a Nomen local.
|
|
167
217
|
|
|
218
|
+
pub func set_hidden = (self, bool hidden) {
|
|
219
|
+
```
|
|
220
|
+
#arch: c
|
|
221
|
+
#platform: macos
|
|
222
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(
|
|
223
|
+
(id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
|
|
224
|
+
```
|
|
225
|
+
```
|
|
226
|
+
#arch: aarch64_use_c
|
|
227
|
+
#platform: macos
|
|
228
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(
|
|
229
|
+
(id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
|
|
230
|
+
```
|
|
231
|
+
```
|
|
232
|
+
#arch: c
|
|
233
|
+
#platform: ios
|
|
234
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(
|
|
235
|
+
(id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
|
|
236
|
+
```
|
|
237
|
+
```
|
|
238
|
+
#arch: aarch64_use_c
|
|
239
|
+
#platform: ios
|
|
240
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(
|
|
241
|
+
(id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
|
|
242
|
+
```
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
pub func is_hidden = (self, out bool) {
|
|
246
|
+
```
|
|
247
|
+
#arch: c
|
|
248
|
+
#platform: macos
|
|
249
|
+
BOOL hidden = ((BOOL(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("isHidden"));
|
|
250
|
+
return hidden ? 1 : 0;
|
|
251
|
+
```
|
|
252
|
+
```
|
|
253
|
+
#arch: aarch64_use_c
|
|
254
|
+
#platform: macos
|
|
255
|
+
BOOL hidden = ((BOOL(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("isHidden"));
|
|
256
|
+
return hidden ? 1 : 0;
|
|
257
|
+
```
|
|
258
|
+
```
|
|
259
|
+
#arch: c
|
|
260
|
+
#platform: ios
|
|
261
|
+
BOOL hidden = ((BOOL(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("isHidden"));
|
|
262
|
+
return hidden ? 1 : 0;
|
|
263
|
+
```
|
|
264
|
+
```
|
|
265
|
+
#arch: aarch64_use_c
|
|
266
|
+
#platform: ios
|
|
267
|
+
BOOL hidden = ((BOOL(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("isHidden"));
|
|
268
|
+
return hidden ? 1 : 0;
|
|
269
|
+
```
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Arm the native click action at construction (the shared target —
|
|
273
|
+
// see Control.nm's nomen_control_arm_clicks) so `was_clicked` polls
|
|
274
|
+
// report clicks without any hit-testing.
|
|
275
|
+
pub func was_clicked = (self, out bool) {
|
|
276
|
+
return nomen_control_take_click(self.handle)
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// The on_click desugar's drain (docs/HANDLERS.md): the synthesized pump
|
|
280
|
+
// arm polls this per frame. Same edge as was_clicked — register one way
|
|
281
|
+
// or the other, never both (first consumer wins).
|
|
282
|
+
pub func take_click = (self, out bool) {
|
|
283
|
+
return nomen_control_take_click(self.handle)
|
|
284
|
+
}
|
|
285
|
+
|
|
168
286
|
pub func intrinsic_size = (self, out Size) {
|
|
169
287
|
var [w, h] = native_intrinsic(self.handle)
|
|
170
288
|
var s = Size()
|
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
pub mv struct CheckBox : Control {
|
|
10
10
|
var uint64 handle = 0
|
|
11
11
|
|
|
12
|
+
// The `#handle` hook synthesizes `NameHandle` — a copyable, non-owning
|
|
13
|
+
// twin (same public bare-self methods, no destroy) so closures can
|
|
14
|
+
// capture this control without moving it. See GUI.md, "Handles".
|
|
15
|
+
#handle = () {}
|
|
16
|
+
|
|
12
17
|
pub func #init = (self, Window window) {
|
|
13
18
|
```
|
|
14
19
|
#arch: c
|
|
@@ -26,6 +31,8 @@ pub mv struct CheckBox : Control {
|
|
|
26
31
|
((void(*)(id, SEL, id))objc_msgSend)(
|
|
27
32
|
contentView, sel_registerName("addSubview:"), cb);
|
|
28
33
|
self.handle = (uint64_t)cb;
|
|
34
|
+
extern void nomen_control_arm_clicks(unsigned long long);
|
|
35
|
+
nomen_control_arm_clicks((unsigned long long)cb);
|
|
29
36
|
```
|
|
30
37
|
```
|
|
31
38
|
#arch: aarch64_use_c
|
|
@@ -43,6 +50,8 @@ pub mv struct CheckBox : Control {
|
|
|
43
50
|
((void(*)(id, SEL, id))objc_msgSend)(
|
|
44
51
|
contentView, sel_registerName("addSubview:"), cb);
|
|
45
52
|
self->handle = (uint64_t)cb;
|
|
53
|
+
extern void nomen_control_arm_clicks(unsigned long long) __asm__("nomen_control_arm_clicks");
|
|
54
|
+
nomen_control_arm_clicks((unsigned long long)cb);
|
|
46
55
|
```
|
|
47
56
|
```
|
|
48
57
|
#arch: c
|
|
@@ -202,6 +211,21 @@ pub mv struct CheckBox : Control {
|
|
|
202
211
|
}
|
|
203
212
|
|
|
204
213
|
// ── Control trait conformance ──
|
|
214
|
+
// Edge-triggered click poll: true exactly once per click (the record
|
|
215
|
+
// is consumed). Backed by the native target/action queue —
|
|
216
|
+
// nomen_control_arm_clicks arms this control in the constructor — so
|
|
217
|
+
// no coordinates and no hit-testing, and it works inside Scrollables.
|
|
218
|
+
pub func was_clicked = (self, out bool) {
|
|
219
|
+
return nomen_control_take_click(self.handle)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// The on_click desugar's drain (docs/HANDLERS.md): the synthesized pump
|
|
223
|
+
// arm polls this per frame. Same edge as was_clicked — register one way
|
|
224
|
+
// or the other, never both (first consumer wins).
|
|
225
|
+
pub func take_click = (self, out bool) {
|
|
226
|
+
return nomen_control_take_click(self.handle)
|
|
227
|
+
}
|
|
228
|
+
|
|
205
229
|
pub func intrinsic_size = (self, out Size) {
|
|
206
230
|
var [w, h] = native_intrinsic(self.handle)
|
|
207
231
|
var s = Size()
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A picked color's 0-255 components (`ColorPicker.rgb`'s return value)
|
|
3
|
+
**/
|
|
4
|
+
pub struct Rgb {
|
|
5
|
+
pub var red = 0
|
|
6
|
+
pub var green = 0
|
|
7
|
+
pub var blue = 0
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A system color well (click to open the platform color panel)
|
|
12
|
+
*
|
|
13
|
+
* An OWNING STRUCT (STRUCT_PLAN_3 Phase R, tranche 4 — the shape menu): the
|
|
14
|
+
* single field is a platform handle, so the value is movable and its
|
|
15
|
+
* `#destroy` releases what the handle names. The constructor's `self` is
|
|
16
|
+
* the inline instance (the `.` accessor); methods keep the pointer form.
|
|
17
|
+
*
|
|
18
|
+
* Components travel as 0-255 ints; the platform stores 0-1 doubles, so the
|
|
19
|
+
* round trip is exact to ±1 (the getters round).
|
|
20
|
+
**/
|
|
21
|
+
pub mv struct ColorPicker : Control {
|
|
22
|
+
var uint64 handle = 0
|
|
23
|
+
|
|
24
|
+
pub func #init = (self, Window window) {
|
|
25
|
+
```
|
|
26
|
+
#arch: c
|
|
27
|
+
#platform: macos
|
|
28
|
+
id well = ((id(*)(id, SEL, CGRect))objc_msgSend)(
|
|
29
|
+
((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSColorWell"), sel_registerName("alloc")),
|
|
30
|
+
sel_registerName("initWithFrame:"),
|
|
31
|
+
((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 44, 24));
|
|
32
|
+
id contentView = ((id(*)(id, SEL))objc_msgSend)(
|
|
33
|
+
(id)window->handle, sel_registerName("contentView"));
|
|
34
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
35
|
+
contentView, sel_registerName("addSubview:"), well);
|
|
36
|
+
self.handle = (uint64_t)well;
|
|
37
|
+
```
|
|
38
|
+
```
|
|
39
|
+
#arch: aarch64_use_c
|
|
40
|
+
#platform: macos
|
|
41
|
+
id well = ((id(*)(id, SEL, CGRect))objc_msgSend)(
|
|
42
|
+
((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSColorWell"), sel_registerName("alloc")),
|
|
43
|
+
sel_registerName("initWithFrame:"),
|
|
44
|
+
((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 44, 24));
|
|
45
|
+
id contentView = ((id(*)(id, SEL))objc_msgSend)(
|
|
46
|
+
(id)window->handle, sel_registerName("contentView"));
|
|
47
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
48
|
+
contentView, sel_registerName("addSubview:"), well);
|
|
49
|
+
self->handle = (uint64_t)well;
|
|
50
|
+
```
|
|
51
|
+
```
|
|
52
|
+
#arch: c
|
|
53
|
+
#platform: ios
|
|
54
|
+
id well = ((id(*)(id, SEL, CGRect))objc_msgSend)(
|
|
55
|
+
((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("UIColorWell"), sel_registerName("alloc")),
|
|
56
|
+
sel_registerName("initWithFrame:"),
|
|
57
|
+
((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 44, 44));
|
|
58
|
+
id parentView = ((id(*)(id, SEL))objc_msgSend)(
|
|
59
|
+
((id(*)(id, SEL))objc_msgSend)(
|
|
60
|
+
(id)window->handle, sel_registerName("rootViewController")),
|
|
61
|
+
sel_registerName("view"));
|
|
62
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
63
|
+
parentView, sel_registerName("addSubview:"), well);
|
|
64
|
+
self.handle = (uint64_t)well;
|
|
65
|
+
```
|
|
66
|
+
```
|
|
67
|
+
#arch: aarch64_use_c
|
|
68
|
+
#platform: ios
|
|
69
|
+
id well = ((id(*)(id, SEL, CGRect))objc_msgSend)(
|
|
70
|
+
((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("UIColorWell"), sel_registerName("alloc")),
|
|
71
|
+
sel_registerName("initWithFrame:"),
|
|
72
|
+
((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 44, 44));
|
|
73
|
+
id parentView = ((id(*)(id, SEL))objc_msgSend)(
|
|
74
|
+
((id(*)(id, SEL))objc_msgSend)(
|
|
75
|
+
(id)window->handle, sel_registerName("rootViewController")),
|
|
76
|
+
sel_registerName("view"));
|
|
77
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
78
|
+
parentView, sel_registerName("addSubview:"), well);
|
|
79
|
+
self->handle = (uint64_t)well;
|
|
80
|
+
```
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
pub func set_frame = (ref self, int x, int y, int width, int height) {
|
|
84
|
+
```
|
|
85
|
+
#arch: c
|
|
86
|
+
#platform: macos
|
|
87
|
+
((void(*)(id, SEL, CGRect))objc_msgSend)(
|
|
88
|
+
(id)self->handle, sel_registerName("setFrame:"),
|
|
89
|
+
((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
|
|
90
|
+
```
|
|
91
|
+
```
|
|
92
|
+
#arch: aarch64_use_c
|
|
93
|
+
#platform: macos
|
|
94
|
+
((void(*)(id, SEL, CGRect))objc_msgSend)(
|
|
95
|
+
(id)self->handle, sel_registerName("setFrame:"),
|
|
96
|
+
((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
|
|
97
|
+
```
|
|
98
|
+
```
|
|
99
|
+
#arch: c
|
|
100
|
+
#platform: ios
|
|
101
|
+
((void(*)(id, SEL, CGRect))objc_msgSend)(
|
|
102
|
+
(id)self->handle, sel_registerName("setFrame:"),
|
|
103
|
+
((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
|
|
104
|
+
```
|
|
105
|
+
```
|
|
106
|
+
#arch: aarch64_use_c
|
|
107
|
+
#platform: ios
|
|
108
|
+
((void(*)(id, SEL, CGRect))objc_msgSend)(
|
|
109
|
+
(id)self->handle, sel_registerName("setFrame:"),
|
|
110
|
+
((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
|
|
111
|
+
```
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Set the well's color from 0-255 components.
|
|
115
|
+
pub func set_rgb = (self, int red, int green, int blue) {
|
|
116
|
+
```
|
|
117
|
+
#arch: c
|
|
118
|
+
#platform: macos
|
|
119
|
+
id color = ((id(*)(id, SEL, double, double, double, double))objc_msgSend)(
|
|
120
|
+
(id)objc_getClass("NSColor"), sel_registerName("colorWithCalibratedRed:green:blue:alpha:"),
|
|
121
|
+
(double)red / 255.0, (double)green / 255.0, (double)blue / 255.0, 1.0);
|
|
122
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
123
|
+
(id)self->handle, sel_registerName("setColor:"), color);
|
|
124
|
+
```
|
|
125
|
+
```
|
|
126
|
+
#arch: aarch64_use_c
|
|
127
|
+
#platform: macos
|
|
128
|
+
id color = ((id(*)(id, SEL, double, double, double, double))objc_msgSend)(
|
|
129
|
+
(id)objc_getClass("NSColor"), sel_registerName("colorWithCalibratedRed:green:blue:alpha:"),
|
|
130
|
+
(double)red / 255.0, (double)green / 255.0, (double)blue / 255.0, 1.0);
|
|
131
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
132
|
+
(id)self->handle, sel_registerName("setColor:"), color);
|
|
133
|
+
```
|
|
134
|
+
```
|
|
135
|
+
#arch: c
|
|
136
|
+
#platform: ios
|
|
137
|
+
id color = ((id(*)(id, SEL, double, double, double, double))objc_msgSend)(
|
|
138
|
+
(id)objc_getClass("UIColor"), sel_registerName("colorWithRed:green:blue:alpha:"),
|
|
139
|
+
(double)red / 255.0, (double)green / 255.0, (double)blue / 255.0, 1.0);
|
|
140
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
141
|
+
(id)self->handle, sel_registerName("setColor:"), color);
|
|
142
|
+
```
|
|
143
|
+
```
|
|
144
|
+
#arch: aarch64_use_c
|
|
145
|
+
#platform: ios
|
|
146
|
+
id color = ((id(*)(id, SEL, double, double, double, double))objc_msgSend)(
|
|
147
|
+
(id)objc_getClass("UIColor"), sel_registerName("colorWithRed:green:blue:alpha:"),
|
|
148
|
+
(double)red / 255.0, (double)green / 255.0, (double)blue / 255.0, 1.0);
|
|
149
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
150
|
+
(id)self->handle, sel_registerName("setColor:"), color);
|
|
151
|
+
```
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// The well's current color as 0-255 components ([red, green, blue]).
|
|
155
|
+
// A color the user picked from the panel can land between two 255ths —
|
|
156
|
+
// the components round to the nearest.
|
|
157
|
+
pub func rgb = (self, out Rgb) {
|
|
158
|
+
```
|
|
159
|
+
#arch: c
|
|
160
|
+
#platform: macos
|
|
161
|
+
id color = ((id(*)(id, SEL))objc_msgSend)(
|
|
162
|
+
(id)self->handle, sel_registerName("color"));
|
|
163
|
+
double r = 0, g = 0, b = 0, a = 0;
|
|
164
|
+
((void(*)(id, SEL, double*, double*, double*, double*))objc_msgSend)(
|
|
165
|
+
color, sel_registerName("getRed:green:blue:alpha:"), &r, &g, &b, &a);
|
|
166
|
+
struct Rgb result;
|
|
167
|
+
result.red = (int)(r * 255.0 + 0.5);
|
|
168
|
+
result.green = (int)(g * 255.0 + 0.5);
|
|
169
|
+
result.blue = (int)(b * 255.0 + 0.5);
|
|
170
|
+
return result;
|
|
171
|
+
```
|
|
172
|
+
```
|
|
173
|
+
#arch: aarch64_use_c
|
|
174
|
+
#platform: macos
|
|
175
|
+
id color = ((id(*)(id, SEL))objc_msgSend)(
|
|
176
|
+
(id)self->handle, sel_registerName("color"));
|
|
177
|
+
double r = 0, g = 0, b = 0, a = 0;
|
|
178
|
+
((void(*)(id, SEL, double*, double*, double*, double*))objc_msgSend)(
|
|
179
|
+
color, sel_registerName("getRed:green:blue:alpha:"), &r, &g, &b, &a);
|
|
180
|
+
struct Rgb result;
|
|
181
|
+
result.red = (int)(r * 255.0 + 0.5);
|
|
182
|
+
result.green = (int)(g * 255.0 + 0.5);
|
|
183
|
+
result.blue = (int)(b * 255.0 + 0.5);
|
|
184
|
+
return result;
|
|
185
|
+
```
|
|
186
|
+
```
|
|
187
|
+
#arch: c
|
|
188
|
+
#platform: ios
|
|
189
|
+
id color = ((id(*)(id, SEL))objc_msgSend)(
|
|
190
|
+
(id)self->handle, sel_registerName("color"));
|
|
191
|
+
double r = 0, g = 0, b = 0, a = 0;
|
|
192
|
+
((void(*)(id, SEL, double*, double*, double*, double*))objc_msgSend)(
|
|
193
|
+
color, sel_registerName("getRed:green:blue:alpha:"), &r, &g, &b, &a);
|
|
194
|
+
struct Rgb result;
|
|
195
|
+
result.red = (int)(r * 255.0 + 0.5);
|
|
196
|
+
result.green = (int)(g * 255.0 + 0.5);
|
|
197
|
+
result.blue = (int)(b * 255.0 + 0.5);
|
|
198
|
+
return result;
|
|
199
|
+
```
|
|
200
|
+
```
|
|
201
|
+
#arch: aarch64_use_c
|
|
202
|
+
#platform: ios
|
|
203
|
+
id color = ((id(*)(id, SEL))objc_msgSend)(
|
|
204
|
+
(id)self->handle, sel_registerName("color"));
|
|
205
|
+
double r = 0, g = 0, b = 0, a = 0;
|
|
206
|
+
((void(*)(id, SEL, double*, double*, double*, double*))objc_msgSend)(
|
|
207
|
+
color, sel_registerName("getRed:green:blue:alpha:"), &r, &g, &b, &a);
|
|
208
|
+
struct Rgb result;
|
|
209
|
+
result.red = (int)(r * 255.0 + 0.5);
|
|
210
|
+
result.green = (int)(g * 255.0 + 0.5);
|
|
211
|
+
result.blue = (int)(b * 255.0 + 0.5);
|
|
212
|
+
return result;
|
|
213
|
+
```
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
pub func set_hidden = (self, bool hidden) {
|
|
217
|
+
```
|
|
218
|
+
#arch: c
|
|
219
|
+
#platform: macos
|
|
220
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(
|
|
221
|
+
(id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
|
|
222
|
+
```
|
|
223
|
+
```
|
|
224
|
+
#arch: aarch64_use_c
|
|
225
|
+
#platform: macos
|
|
226
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(
|
|
227
|
+
(id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
|
|
228
|
+
```
|
|
229
|
+
```
|
|
230
|
+
#arch: c
|
|
231
|
+
#platform: ios
|
|
232
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(
|
|
233
|
+
(id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
|
|
234
|
+
```
|
|
235
|
+
```
|
|
236
|
+
#arch: aarch64_use_c
|
|
237
|
+
#platform: ios
|
|
238
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(
|
|
239
|
+
(id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
|
|
240
|
+
```
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// ── Control trait conformance ──
|
|
244
|
+
pub func intrinsic_size = (self, out Size) {
|
|
245
|
+
var [w, h] = native_intrinsic(self.handle)
|
|
246
|
+
var s = Size()
|
|
247
|
+
s.width = w
|
|
248
|
+
s.height = h
|
|
249
|
+
return s
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
pub func measure = (self, BoxConstraints constraints, out Size) {
|
|
253
|
+
var Size s = self.intrinsic_size()
|
|
254
|
+
if s.width > constraints.max_width {
|
|
255
|
+
s.width = constraints.max_width
|
|
256
|
+
}
|
|
257
|
+
if s.width < constraints.min_width {
|
|
258
|
+
s.width = constraints.min_width
|
|
259
|
+
}
|
|
260
|
+
if s.height > constraints.max_height {
|
|
261
|
+
s.height = constraints.max_height
|
|
262
|
+
}
|
|
263
|
+
if s.height < constraints.min_height {
|
|
264
|
+
s.height = constraints.min_height
|
|
265
|
+
}
|
|
266
|
+
return s
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
func #destroy = () {
|
|
270
|
+
```
|
|
271
|
+
#arch: c
|
|
272
|
+
#platform: macos
|
|
273
|
+
if (self->handle) {
|
|
274
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
|
|
275
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
|
|
276
|
+
self->handle = 0;
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
```
|
|
280
|
+
#arch: aarch64_use_c
|
|
281
|
+
#platform: macos
|
|
282
|
+
if (self->handle) {
|
|
283
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
|
|
284
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
|
|
285
|
+
self->handle = 0;
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
```
|
|
289
|
+
#arch: c
|
|
290
|
+
#platform: ios
|
|
291
|
+
if (self->handle) {
|
|
292
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
|
|
293
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
|
|
294
|
+
self->handle = 0;
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
```
|
|
298
|
+
#arch: aarch64_use_c
|
|
299
|
+
#platform: ios
|
|
300
|
+
if (self->handle) {
|
|
301
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
|
|
302
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
|
|
303
|
+
self->handle = 0;
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
}
|
|
307
|
+
}
|