nomen-lang 0.7.1 → 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.
Files changed (50) hide show
  1. package/core/System/Buffer.nm +32 -0
  2. package/core/System/ClassBuffer.nm +24 -0
  3. package/core/System/Controls/Alert.nm +326 -0
  4. package/core/System/Controls/App.nm +147 -0
  5. package/core/System/Controls/Button.nm +119 -1
  6. package/core/System/Controls/CheckBox.nm +24 -0
  7. package/core/System/Controls/ColorPicker.nm +307 -0
  8. package/core/System/Controls/ComboBox.nm +430 -0
  9. package/core/System/Controls/Container.nm +837 -9
  10. package/core/System/Controls/Control.nm +443 -0
  11. package/core/System/Controls/DatePicker.nm +288 -0
  12. package/core/System/Controls/Form.nm +70 -0
  13. package/core/System/Controls/GroupBox.nm +267 -0
  14. package/core/System/Controls/ImageView.nm +311 -0
  15. package/core/System/Controls/LevelIndicator.nm +305 -0
  16. package/core/System/Controls/ListView.nm +633 -0
  17. package/core/System/Controls/Menu.nm +428 -0
  18. package/core/System/Controls/NumberInput.nm +56 -0
  19. package/core/System/Controls/OtpInput.nm +50 -0
  20. package/core/System/Controls/OutlineView.nm +598 -0
  21. package/core/System/Controls/Pagination.nm +142 -0
  22. package/core/System/Controls/Popover.nm +296 -0
  23. package/core/System/Controls/Progress.nm +348 -0
  24. package/core/System/Controls/Radio.nm +292 -0
  25. package/core/System/Controls/Scrollable.nm +584 -0
  26. package/core/System/Controls/SearchField.nm +326 -0
  27. package/core/System/Controls/SecureField.nm +344 -0
  28. package/core/System/Controls/Segmented.nm +380 -0
  29. package/core/System/Controls/Select.nm +340 -0
  30. package/core/System/Controls/Separator.nm +198 -0
  31. package/core/System/Controls/Sheet.nm +329 -0
  32. package/core/System/Controls/Slider.nm +315 -0
  33. package/core/System/Controls/Spinner.nm +287 -0
  34. package/core/System/Controls/SplitView.nm +509 -0
  35. package/core/System/Controls/Stepper.nm +349 -0
  36. package/core/System/Controls/Switch.nm +259 -0
  37. package/core/System/Controls/Table.nm +833 -0
  38. package/core/System/Controls/Tabs.nm +500 -0
  39. package/core/System/Controls/Text.nm +108 -11
  40. package/core/System/Controls/TextBox.nm +112 -1
  41. package/core/System/Controls/TextView.nm +329 -0
  42. package/core/System/Controls/Toggle.nm +346 -0
  43. package/core/System/Controls/Toolbar.nm +501 -0
  44. package/core/System/Controls/Tooltip.nm +76 -0
  45. package/core/System/Controls/Window.nm +1549 -91
  46. package/core/System/List.nm +34 -0
  47. package/core/System/Map.nm +21 -4
  48. package/core/System/Set.nm +14 -0
  49. package/dist/index.mjs +2556 -656
  50. package/package.json +1 -1
@@ -0,0 +1,509 @@
1
+ /**
2
+ * A resizable multi-pane container (NSSplitView)
3
+ *
4
+ * An OWNING STRUCT (STRUCT_PLAN_3 Phase R, tranche 4 — the shape menu): the
5
+ * single field is a platform handle, so the value is movable and its
6
+ * `#destroy` releases what the handle names. The constructor's `self` is
7
+ * the inline instance (the `.` accessor); methods keep the pointer form.
8
+ *
9
+ * The pane count and divider orientation are fixed at construction. Each
10
+ * pane hosts controls on its own view: `content_window(index)` hands back a
11
+ * Window-shaped value whose `contentView` is the pane view itself (the
12
+ * `-contentView`-answers-self trick — see Scrollable), so control
13
+ * constructors and `Container.layout` target a pane unchanged. NSSplitView
14
+ * owns the pane geometry: when the split view is framed (or the user drags
15
+ * a divider) AppKit resizes the pane views synchronously, so re-run the
16
+ * pane layouts after re-framing — registrable pane roots
17
+ * (`Container.set_pane`) put that on the run loop. A shared delegate holds
18
+ * every divider at its current position across re-frames (the AppKit
19
+ * default re-divides panes equally), so a programmatic divider position set
20
+ * with `set_position` (read with `position`) stays put. iOS defers to
21
+ * UISplitViewController (a view-controller-level type — see GUI_PLAN
22
+ * Tier 2; the iOS blocks are TODO stubs).
23
+ **/
24
+ pub mv struct SplitView : Control {
25
+ var uint64 handle = 0
26
+
27
+ // File-scope helper: the pane view class (answers `-contentView` with
28
+ // `self`; registered once, like NomenResizeDelegate).
29
+ pub func #init = (self, Window window, int count: count > 0, bool vertical) {
30
+ ```
31
+ #arch: c
32
+ #platform: macos
33
+ #scope: file
34
+ static id nomen_pane_content_view(id self, SEL cmd) {
35
+ (void)cmd;
36
+ return self;
37
+ }
38
+ static id nomen_pane_class(void) {
39
+ Class Pv = objc_getClass("NomenSplitPaneView");
40
+ if (!Pv) {
41
+ Pv = objc_allocateClassPair(objc_getClass("NSView"), "NomenSplitPaneView", 0);
42
+ if (Pv) {
43
+ class_addMethod(Pv, sel_registerName("contentView"), (IMP)nomen_pane_content_view, "@@:");
44
+ objc_registerClassPair(Pv);
45
+ }
46
+ }
47
+ return Pv;
48
+ }
49
+
50
+ // The delegate's resize-subviews hook: keep every divider at its
51
+ // CURRENT position — panes 0..n-2 keep their sizes, the LAST pane
52
+ // absorbs the delta. Without it NSSplitView's default adjustSubviews
53
+ // re-divides the panes equally on every re-frame (window resizes
54
+ // included), so a programmatic set_position drifts back; with it the
55
+ // divider is pinned where the app left it. One shared delegate
56
+ // serves every split view: the hook derives everything from the
57
+ // passed view. AXIS NOTE: isVertical YES means the DIVIDER is
58
+ // vertical, so the panes sit side by side and advance along X
59
+ // (left|right); a horizontal split stacks along Y. Kept sizes are
60
+ // clamped to the room left in the bounds, so the frames always
61
+ // tile exactly (AppKit validates the tiling and warns when a
62
+ // delegate leaves the panes out of bounds or overlapping).
63
+ static void nomen_split_resize_panes(id self, SEL cmd, id sv, NSSize oldSize) {
64
+ (void)self; (void)cmd; (void)oldSize;
65
+ id subviews = ((id(*)(id, SEL))objc_msgSend)(sv, sel_registerName("subviews"));
66
+ long n = ((long(*)(id, SEL))objc_msgSend)(subviews, sel_registerName("count"));
67
+ if (n < 1) return;
68
+ CGRect bounds = ((CGRect(*)(id, SEL))objc_msgSend)(sv, sel_registerName("bounds"));
69
+ BOOL vertical = ((BOOL(*)(id, SEL))objc_msgSend)(sv, sel_registerName("isVertical"));
70
+ double thickness = ((double(*)(id, SEL))objc_msgSend)(sv, sel_registerName("dividerThickness"));
71
+ // Panes advance along `extent` and every pane spans `cross`.
72
+ double extent = vertical ? bounds.size.width : bounds.size.height;
73
+ double cross = vertical ? bounds.size.height : bounds.size.width;
74
+ double cursor = 0;
75
+ for (long i = 0; i < n; i++) {
76
+ id pane = ((id(*)(id, SEL, unsigned long))objc_msgSend)(
77
+ subviews, sel_registerName("objectAtIndex:"), (unsigned long)i);
78
+ CGRect f = ((CGRect(*)(id, SEL))objc_msgSend)(pane, sel_registerName("frame"));
79
+ double size;
80
+ if (i < n - 1) {
81
+ size = vertical ? f.size.width : f.size.height;
82
+ // Clamp: later panes keep at least their dividers' room,
83
+ // so the kept sizes can never overflow the bounds.
84
+ double room = extent - cursor - (n - 1 - i) * thickness;
85
+ if (size > room) size = room;
86
+ } else {
87
+ size = extent - cursor;
88
+ }
89
+ if (size < 0) size = 0;
90
+ CGRect nf = vertical
91
+ ? CGRectMake(cursor, 0, size, cross)
92
+ : CGRectMake(0, cursor, cross, size);
93
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(pane, sel_registerName("setFrame:"), nf);
94
+ cursor += size + thickness;
95
+ }
96
+ }
97
+ static id g_split_delegate = 0;
98
+ static id nomen_split_delegate(void) {
99
+ Class Sd = objc_getClass("NomenSplitDelegate");
100
+ if (!Sd) {
101
+ Sd = objc_allocateClassPair(objc_getClass("NSObject"), "NomenSplitDelegate", 0);
102
+ if (Sd) {
103
+ class_addMethod(Sd, sel_registerName("splitView:resizeSubviewsWithOldSize:"),
104
+ (IMP)nomen_split_resize_panes, "v@:@@{NSSize=dd}");
105
+ objc_registerClassPair(Sd);
106
+ }
107
+ }
108
+ if (!g_split_delegate) {
109
+ g_split_delegate = ((id(*)(id, SEL))objc_msgSend)(Sd, sel_registerName("new"));
110
+ }
111
+ return g_split_delegate;
112
+ }
113
+ ```
114
+ ```
115
+ #arch: aarch64_use_c
116
+ #platform: macos
117
+ #scope: file
118
+ static id nomen_pane_content_view(id self, SEL cmd) {
119
+ (void)cmd;
120
+ return self;
121
+ }
122
+ static id nomen_pane_class(void) {
123
+ Class Pv = objc_getClass("NomenSplitPaneView");
124
+ if (!Pv) {
125
+ Pv = objc_allocateClassPair(objc_getClass("NSView"), "NomenSplitPaneView", 0);
126
+ if (Pv) {
127
+ class_addMethod(Pv, sel_registerName("contentView"), (IMP)nomen_pane_content_view, "@@:");
128
+ objc_registerClassPair(Pv);
129
+ }
130
+ }
131
+ return Pv;
132
+ }
133
+
134
+ // The delegate's resize-subviews hook (see the c twin above — note
135
+ // the axis: isVertical YES means panes advance along X).
136
+ static void nomen_split_resize_panes(id self, SEL cmd, id sv, NSSize oldSize) {
137
+ (void)self; (void)cmd; (void)oldSize;
138
+ id subviews = ((id(*)(id, SEL))objc_msgSend)(sv, sel_registerName("subviews"));
139
+ long n = ((long(*)(id, SEL))objc_msgSend)(subviews, sel_registerName("count"));
140
+ if (n < 1) return;
141
+ CGRect bounds = ((CGRect(*)(id, SEL))objc_msgSend)(sv, sel_registerName("bounds"));
142
+ BOOL vertical = ((BOOL(*)(id, SEL))objc_msgSend)(sv, sel_registerName("isVertical"));
143
+ double thickness = ((double(*)(id, SEL))objc_msgSend)(sv, sel_registerName("dividerThickness"));
144
+ // Panes advance along `extent` and every pane spans `cross`.
145
+ double extent = vertical ? bounds.size.width : bounds.size.height;
146
+ double cross = vertical ? bounds.size.height : bounds.size.width;
147
+ double cursor = 0;
148
+ for (long i = 0; i < n; i++) {
149
+ id pane = ((id(*)(id, SEL, unsigned long))objc_msgSend)(
150
+ subviews, sel_registerName("objectAtIndex:"), (unsigned long)i);
151
+ CGRect f = ((CGRect(*)(id, SEL))objc_msgSend)(pane, sel_registerName("frame"));
152
+ double size;
153
+ if (i < n - 1) {
154
+ size = vertical ? f.size.width : f.size.height;
155
+ // Clamp: later panes keep at least their dividers' room,
156
+ // so the kept sizes can never overflow the bounds.
157
+ double room = extent - cursor - (n - 1 - i) * thickness;
158
+ if (size > room) size = room;
159
+ } else {
160
+ size = extent - cursor;
161
+ }
162
+ if (size < 0) size = 0;
163
+ CGRect nf = vertical
164
+ ? CGRectMake(cursor, 0, size, cross)
165
+ : CGRectMake(0, cursor, cross, size);
166
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(pane, sel_registerName("setFrame:"), nf);
167
+ cursor += size + thickness;
168
+ }
169
+ }
170
+ static id g_split_delegate = 0;
171
+ static id nomen_split_delegate(void) {
172
+ Class Sd = objc_getClass("NomenSplitDelegate");
173
+ if (!Sd) {
174
+ Sd = objc_allocateClassPair(objc_getClass("NSObject"), "NomenSplitDelegate", 0);
175
+ if (Sd) {
176
+ class_addMethod(Sd, sel_registerName("splitView:resizeSubviewsWithOldSize:"),
177
+ (IMP)nomen_split_resize_panes, "v@:@@{NSSize=dd}");
178
+ objc_registerClassPair(Sd);
179
+ }
180
+ }
181
+ if (!g_split_delegate) {
182
+ g_split_delegate = ((id(*)(id, SEL))objc_msgSend)(Sd, sel_registerName("new"));
183
+ }
184
+ return g_split_delegate;
185
+ }
186
+ ```
187
+ ```
188
+ #arch: c
189
+ #platform: macos
190
+ id sv = ((id(*)(id, SEL, CGRect))objc_msgSend)(
191
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSSplitView"), sel_registerName("alloc")),
192
+ sel_registerName("initWithFrame:"),
193
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 300, 160));
194
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(sv, sel_registerName("setVertical:"), vertical ? 1 : 0);
195
+ for (long i = 0; i < (long)count; i++) {
196
+ id pane = ((id(*)(id, SEL, CGRect))objc_msgSend)(
197
+ ((id(*)(id, SEL))objc_msgSend)(nomen_pane_class(), sel_registerName("alloc")),
198
+ sel_registerName("initWithFrame:"),
199
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 10, 10));
200
+ ((void(*)(id, SEL, id))objc_msgSend)(sv, sel_registerName("addSubview:"), pane);
201
+ }
202
+ id contentView = ((id(*)(id, SEL))objc_msgSend)(
203
+ (id)window->handle, sel_registerName("contentView"));
204
+ ((void(*)(id, SEL, id))objc_msgSend)(
205
+ contentView, sel_registerName("addSubview:"), sv);
206
+ // Hold the dividers across re-frames (see the delegate above): the
207
+ // pane pass (Container.set_pane / Window.relayout) can then rely on
208
+ // the pane frames AppKit just adjusted, and a set_position pin holds
209
+ // without the app re-pinning on every resize.
210
+ ((void(*)(id, SEL, id))objc_msgSend)(
211
+ sv, sel_registerName("setDelegate:"), nomen_split_delegate());
212
+ self.handle = (uint64_t)sv;
213
+ ```
214
+ ```
215
+ #arch: aarch64_use_c
216
+ #platform: macos
217
+ id sv = ((id(*)(id, SEL, CGRect))objc_msgSend)(
218
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSSplitView"), sel_registerName("alloc")),
219
+ sel_registerName("initWithFrame:"),
220
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 300, 160));
221
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(sv, sel_registerName("setVertical:"), vertical ? 1 : 0);
222
+ for (long i = 0; i < (long)count; i++) {
223
+ id pane = ((id(*)(id, SEL, CGRect))objc_msgSend)(
224
+ ((id(*)(id, SEL))objc_msgSend)(nomen_pane_class(), sel_registerName("alloc")),
225
+ sel_registerName("initWithFrame:"),
226
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 10, 10));
227
+ ((void(*)(id, SEL, id))objc_msgSend)(sv, sel_registerName("addSubview:"), pane);
228
+ }
229
+ id contentView = ((id(*)(id, SEL))objc_msgSend)(
230
+ (id)window->handle, sel_registerName("contentView"));
231
+ ((void(*)(id, SEL, id))objc_msgSend)(
232
+ contentView, sel_registerName("addSubview:"), sv);
233
+ ((void(*)(id, SEL, id))objc_msgSend)(
234
+ sv, sel_registerName("setDelegate:"), nomen_split_delegate());
235
+ self->handle = (uint64_t)sv;
236
+ ```
237
+ ```
238
+ #arch: c
239
+ #platform: ios
240
+ /* TODO: iOS — UISplitViewController is view-controller-level, not an
241
+ * embeddable control (see GUI_PLAN Tier 2; defer). */
242
+ ```
243
+ ```
244
+ #arch: aarch64_use_c
245
+ #platform: ios
246
+ /* TODO: iOS (see #init) */
247
+ ```
248
+ }
249
+
250
+ // A Window-shaped handle to pane `index`'s view: pass it to control
251
+ // constructors and `Container.layout` to host controls on that pane. The
252
+ // value retains the pane view (+1), so its scope-exit `#destroy` releases
253
+ // its OWN reference and the SplitView's stays balanced — keep the
254
+ // SplitView alive at least as long as the returned value.
255
+ pub func content_window = (self, int index, out Window) {
256
+ ```
257
+ #arch: c
258
+ #platform: macos
259
+ id subviews = ((id(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("subviews"));
260
+ id pane = ((id(*)(id, SEL, unsigned long))objc_msgSend)(
261
+ subviews, sel_registerName("objectAtIndex:"), (unsigned long)index);
262
+ extern void *_Window_traits[];
263
+ struct Window w;
264
+ w._vt = (void *)&_Window_traits;
265
+ w.handle = (uint64_t)pane;
266
+ ((id(*)(id, SEL))objc_msgSend)(pane, sel_registerName("retain"));
267
+ return w;
268
+ ```
269
+ ```
270
+ #arch: aarch64_use_c
271
+ #platform: macos
272
+ id subviews = ((id(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("subviews"));
273
+ id pane = ((id(*)(id, SEL, unsigned long))objc_msgSend)(
274
+ subviews, sel_registerName("objectAtIndex:"), (unsigned long)index);
275
+ extern void *Window_traits;
276
+ struct Window w;
277
+ w._vt = (void *)&Window_traits;
278
+ w.handle = (uint64_t)pane;
279
+ ((id(*)(id, SEL))objc_msgSend)(pane, sel_registerName("retain"));
280
+ return w;
281
+ ```
282
+ ```
283
+ #arch: c
284
+ #platform: ios
285
+ /* TODO: iOS (see #init) */
286
+ {
287
+ extern void *_Window_traits[];
288
+ struct Window w;
289
+ w._vt = (void *)&_Window_traits;
290
+ w.handle = 0;
291
+ return w;
292
+ }
293
+ ```
294
+ ```
295
+ #arch: aarch64_use_c
296
+ #platform: ios
297
+ /* TODO: iOS (see #init) */
298
+ {
299
+ extern void *Window_traits;
300
+ struct Window w;
301
+ w._vt = (void *)&Window_traits;
302
+ w.handle = 0;
303
+ return w;
304
+ }
305
+ ```
306
+ }
307
+
308
+ pub func count = (self, out int) {
309
+ ```
310
+ #arch: c
311
+ #platform: macos
312
+ id subviews = ((id(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("subviews"));
313
+ return (int)((long(*)(id, SEL))objc_msgSend)(subviews, sel_registerName("count"));
314
+ ```
315
+ ```
316
+ #arch: aarch64_use_c
317
+ #platform: macos
318
+ id subviews = ((id(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("subviews"));
319
+ return (int)((long(*)(id, SEL))objc_msgSend)(subviews, sel_registerName("count"));
320
+ ```
321
+ ```
322
+ #arch: c
323
+ #platform: ios
324
+ /* TODO: iOS (see #init) */
325
+ return 0;
326
+ ```
327
+ ```
328
+ #arch: aarch64_use_c
329
+ #platform: ios
330
+ /* TODO: iOS (see #init) */
331
+ return 0;
332
+ ```
333
+ }
334
+
335
+ // Move divider `index`. For a vertical split the position is the left
336
+ // edge of the pane after the divider, in points from the left.
337
+ pub func set_position = (ref self, float position, int divider) {
338
+ ```
339
+ #arch: c
340
+ #platform: macos
341
+ // NSSplitView manages its panes only after a layout pass (a window
342
+ // that has been shown); give it one explicitly so the divider move
343
+ // has real pane frames to work from, then move the divider.
344
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("adjustSubviews"));
345
+ ((void(*)(id, SEL, double, long))objc_msgSend)(
346
+ (id)self->handle, sel_registerName("setPosition:ofDividerAtIndex:"),
347
+ position, (long)divider);
348
+ ```
349
+ ```
350
+ #arch: aarch64_use_c
351
+ #platform: macos
352
+ // NSSplitView manages its panes only after a layout pass (a window
353
+ // that has been shown); give it one explicitly so the divider move
354
+ // has real pane frames to work from, then move the divider.
355
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("adjustSubviews"));
356
+ ((void(*)(id, SEL, double, long))objc_msgSend)(
357
+ (id)self->handle, sel_registerName("setPosition:ofDividerAtIndex:"),
358
+ position, (long)divider);
359
+ ```
360
+ ```
361
+ #arch: c
362
+ #platform: ios
363
+ /* TODO: iOS (see #init) */
364
+ ```
365
+ ```
366
+ #arch: aarch64_use_c
367
+ #platform: ios
368
+ /* TODO: iOS (see #init) */
369
+ ```
370
+ }
371
+
372
+ // Divider 0's position: the first pane's width (vertical split) or
373
+ // height (horizontal split), in points.
374
+ pub func position = (self, out float) {
375
+ ```
376
+ #arch: c
377
+ #platform: macos
378
+ id subviews = ((id(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("subviews"));
379
+ if (((long(*)(id, SEL))objc_msgSend)(subviews, sel_registerName("count")) < 1) return 0.0;
380
+ BOOL vertical = ((BOOL(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("isVertical"));
381
+ id first = ((id(*)(id, SEL, unsigned long))objc_msgSend)(
382
+ subviews, sel_registerName("objectAtIndex:"), 0UL);
383
+ CGRect frame = ((CGRect(*)(id, SEL))objc_msgSend)(first, sel_registerName("frame"));
384
+ return vertical ? frame.size.width : frame.size.height;
385
+ ```
386
+ ```
387
+ #arch: aarch64_use_c
388
+ #platform: macos
389
+ id subviews = ((id(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("subviews"));
390
+ if (((long(*)(id, SEL))objc_msgSend)(subviews, sel_registerName("count")) < 1) return 0.0;
391
+ BOOL vertical = ((BOOL(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("isVertical"));
392
+ id first = ((id(*)(id, SEL, unsigned long))objc_msgSend)(
393
+ subviews, sel_registerName("objectAtIndex:"), 0UL);
394
+ CGRect frame = ((CGRect(*)(id, SEL))objc_msgSend)(first, sel_registerName("frame"));
395
+ return vertical ? frame.size.width : frame.size.height;
396
+ ```
397
+ ```
398
+ #arch: c
399
+ #platform: ios
400
+ /* TODO: iOS (see #init) */
401
+ return 0.0;
402
+ ```
403
+ ```
404
+ #arch: aarch64_use_c
405
+ #platform: ios
406
+ /* TODO: iOS (see #init) */
407
+ return 0.0;
408
+ ```
409
+ }
410
+
411
+ pub func set_hidden = (self, bool hidden) {
412
+ ```
413
+ #arch: c
414
+ #platform: macos
415
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
416
+ (id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
417
+ ```
418
+ ```
419
+ #arch: aarch64_use_c
420
+ #platform: macos
421
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
422
+ (id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
423
+ ```
424
+ }
425
+
426
+ // ── Control trait conformance ──
427
+ pub func set_frame = (ref self, int x, int y, int width, int height) {
428
+ ```
429
+ #arch: c
430
+ #platform: macos
431
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
432
+ (id)self->handle, sel_registerName("setFrame:"),
433
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
434
+ ```
435
+ ```
436
+ #arch: aarch64_use_c
437
+ #platform: macos
438
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
439
+ (id)self->handle, sel_registerName("setFrame:"),
440
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
441
+ ```
442
+ ```
443
+ #arch: c
444
+ #platform: ios
445
+ /* TODO: iOS (see #init) */
446
+ ```
447
+ ```
448
+ #arch: aarch64_use_c
449
+ #platform: ios
450
+ /* TODO: iOS (see #init) */
451
+ ```
452
+ }
453
+
454
+ pub func intrinsic_size = (self, out Size) {
455
+ var [w, h] = native_intrinsic(self.handle)
456
+ var s = Size()
457
+ s.width = w
458
+ s.height = h
459
+ return s
460
+ }
461
+
462
+ pub func measure = (self, BoxConstraints constraints, out Size) {
463
+ var Size s = self.intrinsic_size()
464
+ if s.width > constraints.max_width {
465
+ s.width = constraints.max_width
466
+ }
467
+ if s.width < constraints.min_width {
468
+ s.width = constraints.min_width
469
+ }
470
+ if s.height > constraints.max_height {
471
+ s.height = constraints.max_height
472
+ }
473
+ if s.height < constraints.min_height {
474
+ s.height = constraints.min_height
475
+ }
476
+ return s
477
+ }
478
+
479
+ func #destroy = () {
480
+ ```
481
+ #arch: c
482
+ #platform: macos
483
+ if (self->handle) {
484
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
485
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
486
+ self->handle = 0;
487
+ }
488
+ ```
489
+ ```
490
+ #arch: aarch64_use_c
491
+ #platform: macos
492
+ if (self->handle) {
493
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
494
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
495
+ self->handle = 0;
496
+ }
497
+ ```
498
+ ```
499
+ #arch: c
500
+ #platform: ios
501
+ /* TODO: iOS (see #init) */
502
+ ```
503
+ ```
504
+ #arch: aarch64_use_c
505
+ #platform: ios
506
+ /* TODO: iOS (see #init) */
507
+ ```
508
+ }
509
+ }