@geastack/apple 0.2.14 → 0.2.15

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.
@@ -38,10 +38,33 @@
38
38
  // full bounds, with no implicit padding, so the text fits the same space
39
39
  // our host measurement reported.
40
40
  @interface GeaTextCell : NSTextFieldCell
41
+ @property(nonatomic, assign) NSEdgeInsets contentInsets;
42
+ @property(nonatomic, assign) BOOL verticallyCenters;
41
43
  @end
42
44
  @implementation GeaTextCell
43
45
  - (NSRect)drawingRectForBounds:(NSRect)bounds { return bounds; }
44
46
  - (NSRect)titleRectForBounds:(NSRect)bounds { return bounds; }
47
+ - (NSRect)contentRectForBounds:(NSRect)bounds inView:(NSView *)view
48
+ {
49
+ const NSEdgeInsets inset = self.contentInsets;
50
+ bounds.origin.x += inset.left;
51
+ bounds.origin.y += view.isFlipped ? inset.top : inset.bottom;
52
+ bounds.size.width = std::max<CGFloat>(0, bounds.size.width - inset.left - inset.right);
53
+ bounds.size.height = std::max<CGFloat>(0, bounds.size.height - inset.top - inset.bottom);
54
+ return bounds;
55
+ }
56
+ - (void)drawInteriorWithFrame:(NSRect)frame inView:(NSView *)view
57
+ {
58
+ // NSString drawing respects paragraph alignment without NSTextFieldCell's
59
+ // extra centered-text margins. The engine owns the CSS border/content boxes.
60
+ NSRect content = [self contentRectForBounds:frame inView:view];
61
+ if (self.verticallyCenters) {
62
+ const NSRect measured = [self.attributedStringValue boundingRectWithSize:NSMakeSize(content.size.width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
63
+ content.origin.y += std::max<CGFloat>(0, (content.size.height - measured.size.height) / 2);
64
+ }
65
+ [self.attributedStringValue drawWithRect:content
66
+ options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
67
+ }
45
68
  @end
46
69
 
47
70
  @interface GeaLabelTextField : NSTextField
@@ -53,6 +76,30 @@
53
76
  - (void)mouseUp:(NSEvent *)event { [self.nextResponder mouseUp:event]; }
54
77
  @end
55
78
 
79
+ @interface GeaInputCell : NSTextFieldCell
80
+ @property(nonatomic, assign) NSEdgeInsets contentInsets;
81
+ @end
82
+ @implementation GeaInputCell
83
+ - (NSRect)drawingRectForBounds:(NSRect)bounds
84
+ {
85
+ const NSEdgeInsets inset = self.contentInsets;
86
+ bounds.origin.x += inset.left;
87
+ bounds.origin.y += self.controlView.isFlipped ? inset.top : inset.bottom;
88
+ bounds.size.width = std::max<CGFloat>(0, bounds.size.width - inset.left - inset.right);
89
+ bounds.size.height = std::max<CGFloat>(0, bounds.size.height - inset.top - inset.bottom);
90
+ return bounds;
91
+ }
92
+ - (NSRect)titleRectForBounds:(NSRect)bounds { return [self drawingRectForBounds:bounds]; }
93
+ - (void)editWithFrame:(NSRect)frame inView:(NSView *)view editor:(NSText *)editor delegate:(id)delegate event:(NSEvent *)event
94
+ {
95
+ [super editWithFrame:[self drawingRectForBounds:frame] inView:view editor:editor delegate:delegate event:event];
96
+ }
97
+ - (void)selectWithFrame:(NSRect)frame inView:(NSView *)view editor:(NSText *)editor delegate:(id)delegate start:(NSInteger)start length:(NSInteger)length
98
+ {
99
+ [super selectWithFrame:[self drawingRectForBounds:frame] inView:view editor:editor delegate:delegate start:start length:length];
100
+ }
101
+ @end
102
+
56
103
  // Editable text field used to materialize `<input>` JSX elements. Holds the
57
104
  // owning node id and forwards `controlTextDidChange:` to the framework as an
58
105
  // `input` PointerEvent; the framework's per-node listener registry then routes
@@ -67,6 +114,7 @@
67
114
  @end
68
115
 
69
116
  @implementation GeaInputField
117
+ + (Class)cellClass { return [GeaInputCell class]; }
70
118
 
71
119
  - (instancetype)initWithFrame:(NSRect)frameRect
72
120
  {
@@ -194,6 +242,62 @@ static int geaKeyCodeForCommand(SEL sel)
194
242
  }
195
243
  @end
196
244
 
245
+ static bool geaBooleanAttribute(int nodeId, const char *name)
246
+ {
247
+ auto &tree = gea::embedded::ui::Tree::instance();
248
+ const char *value = tree.getAttribute(nodeId, name);
249
+ return tree.hasAttribute(nodeId, name) && (!value || (std::strcmp(value, "false") != 0 && std::strcmp(value, "0") != 0));
250
+ }
251
+
252
+ static void geaControlInput(int nodeId, const char *value, const char *checked = nullptr)
253
+ {
254
+ auto &tree = gea::embedded::ui::Tree::instance();
255
+ if (nodeId < 0 || nodeId >= tree.nodeCount()) return;
256
+ if (geaBooleanAttribute(nodeId, "disabled")) return;
257
+ if (value) tree.setAttribute(nodeId, "value", value);
258
+ if (checked) tree.setAttribute(nodeId, "checked", checked);
259
+ gea::framework::events::PointerEvent event;
260
+ event.type = gea::framework::events::PointerEventType::Input;
261
+ event.targetId = nodeId;
262
+ tree.dispatchEvent(event);
263
+ }
264
+
265
+ @interface GeaChoice : NSButton
266
+ @property(nonatomic, assign) int nodeId;
267
+ @property(nonatomic, assign) BOOL radio;
268
+ @end
269
+ @implementation GeaChoice
270
+ - (void)geaChanged:(id)sender
271
+ {
272
+ (void)sender;
273
+ if (self.radio) self.state = NSControlStateValueOn;
274
+ geaControlInput(self.nodeId, nullptr, self.state == NSControlStateValueOn ? "true" : "false");
275
+ }
276
+ @end
277
+
278
+ @interface GeaPopUp : NSPopUpButton
279
+ @property(nonatomic, assign) int nodeId;
280
+ @end
281
+ @implementation GeaPopUp
282
+ - (void)geaChanged:(id)sender
283
+ {
284
+ (void)sender;
285
+ NSString *value = self.selectedItem.representedObject ?: self.selectedItem.title;
286
+ geaControlInput(self.nodeId, [value UTF8String] ?: "");
287
+ }
288
+ @end
289
+
290
+ @interface GeaStepper : NSStepper
291
+ @property(nonatomic, assign) int nodeId;
292
+ @end
293
+ @implementation GeaStepper
294
+ - (void)geaChanged:(id)sender
295
+ {
296
+ (void)sender;
297
+ geaControlInput(self.nodeId, [[NSString stringWithFormat:@"%.15g", self.doubleValue] UTF8String]);
298
+ }
299
+ @end
300
+
197
301
  // Root-level press handler. Installed once on the contentView during
198
302
  // MacosRenderer::sync. On mouse-down, asks the recognizer for the location,
199
303
  // hit-tests against the root, then walks up via nodeIdForView to find the
@@ -226,6 +330,38 @@ static NSView *hitTestInRoot(NSView *root, NSPoint point)
226
330
  return [root hitTest:[root convertPoint:point toView:root.superview]];
227
331
  }
228
332
 
333
+ void publishControlEventBounds(int nodeId)
334
+ {
335
+ auto &tree=gea::embedded::ui::Tree::instance();
336
+ for(int control=nodeId;control>=0;control=tree.node(control).parent){
337
+ if(std::strcmp(tree.getAttribute(control,"data-gea-control"),"true")!=0)continue;
338
+ auto bounds=tree.node(control).layout;
339
+ // Range values follow the thumb's actual travel, excluding arrow
340
+ // buttons, frame padding, and the value label.
341
+ const int owner=tree.node(control).parent;
342
+ const char *ownerType=tree.getAttribute(owner,"data-xaml-type");
343
+ if(std::strcmp(tree.getAttribute(control,"role"),"slider")==0 || std::strcmp(ownerType,"Slider")==0 || std::strcmp(ownerType,"LSSlider")==0){
344
+ for(int thumb=0;thumb<tree.nodeCount();++thumb){
345
+ const char *type=tree.getAttribute(thumb,"data-xaml-type");
346
+ if(std::strcmp(type,"LSThumb")!=0&&std::strcmp(type,"Thumb")!=0)continue;
347
+ bool belongs=false;
348
+ for(int ancestor=tree.node(thumb).parent;ancestor>=0;ancestor=tree.node(ancestor).parent)if(ancestor==owner){belongs=true;break;}
349
+ const int track=tree.node(thumb).parent;
350
+ if(!belongs||track<0)continue;
351
+ const auto &thumbBox=tree.node(thumb).layout;
352
+ const auto &trackBox=tree.node(track).layout;
353
+ if(trackBox.width>thumbBox.width){bounds.x=trackBox.x+thumbBox.width/2;bounds.width=trackBox.width-thumbBox.width;}
354
+ break;
355
+ }
356
+ }
357
+ tree.setAttribute(control,"data-gea-x",std::to_string(bounds.x).c_str());
358
+ tree.setAttribute(control,"data-gea-y",std::to_string(bounds.y).c_str());
359
+ tree.setAttribute(control,"data-gea-width",std::to_string(bounds.width).c_str());
360
+ tree.setAttribute(control,"data-gea-height",std::to_string(bounds.height).c_str());
361
+ break;
362
+ }
363
+ }
364
+
229
365
  int nodeIdForView(NSView *view)
230
366
  {
231
367
  while (view) {
@@ -268,8 +404,9 @@ int nodeIdForView(NSView *view)
268
404
  if (nodeId < 0) return;
269
405
  auto &tree = gea::embedded::ui::Tree::instance();
270
406
  if (nodeId >= tree.nodeCount()) return;
271
- PointerEvent ev;
272
- ev.type = type;
407
+ gea::macos::publishControlEventBounds(nodeId);
408
+ PointerEvent ev;
409
+ ev.type = type;
273
410
  ev.targetId = nodeId;
274
411
  ev.pointerId = 1;
275
412
  ev.x = px;
@@ -306,9 +443,12 @@ int nodeIdForView(NSView *view)
306
443
  // editor's value guard no longer skips, letting the title/body refresh
307
444
  // to the newly selected note. (Clicks on editable fields never reach
308
445
  // this recognizer — the delegate declines them.)
309
- if (root.window.firstResponder != root.window) {
310
- [root.window makeFirstResponder:nil];
311
- }
446
+ bool customInputs=false;
447
+ auto &inputTree=gea::embedded::ui::Tree::instance();
448
+ for(int i=0;i<inputTree.nodeCount();++i)if(std::strcmp(inputTree.getAttribute(i,"data-gea-inputs"),"true")==0){customInputs=true;break;}
449
+ if(customInputs)[root.window makeFirstResponder:root];
450
+ else if(root.window.firstResponder!=root.window)[root.window makeFirstResponder:nil];
451
+
312
452
  // Mouse-down: hit-test now, remember the node so the move and up
313
453
  // phases dispatch to the same target even if the cursor drifts.
314
454
  NSView *hit = gea::macos::hitTestInRoot(root, pInRoot);
@@ -359,8 +499,12 @@ int nodeIdForView(NSView *view)
359
499
  const NSPoint p = [root convertPoint:event.locationInWindow fromView:nil];
360
500
  NSView *hit = gea::macos::hitTestInRoot(root, p);
361
501
  for (NSView *v = hit; v != nil; v = v.superview) {
502
+ // Native controls own their tracking loops and dispatch their own actions.
503
+ // Recognizing a root press as well steals drags, menu tracking and repeats.
504
+ if ([v isKindOfClass:[NSButton class]] || [v isKindOfClass:[NSSlider class]] ||
505
+ [v isKindOfClass:[NSSwitch class]] || [v isKindOfClass:[NSStepper class]]) return NO;
362
506
  if ([v isKindOfClass:[NSTextView class]]) return NO;
363
- if ([v isKindOfClass:[NSTextField class]] && ((NSTextField *)v).isEditable) return NO;
507
+ if ([v isKindOfClass:[NSTextField class]] && (((NSTextField *)v).isEditable || ((NSTextField *)v).isSelectable)) return NO;
364
508
  // Canvas views dispatch their own coordinate-carrying touch events
365
509
  // (mouseDown/Dragged/Up in GeaCanvasView) — recognizing here too would
366
510
  // double-fire the press.
@@ -608,6 +752,41 @@ NSView *makeSwitch()
608
752
  return sw;
609
753
  }
610
754
 
755
+ NSView *makeChoice(bool radio)
756
+ {
757
+ GeaChoice *choice = [[GeaChoice alloc] initWithFrame:NSZeroRect];
758
+ choice.nodeId = -1;
759
+ choice.radio = radio;
760
+ choice.buttonType = radio ? NSButtonTypeRadio : NSButtonTypeSwitch;
761
+ choice.title = @"";
762
+ choice.target = choice;
763
+ choice.action = @selector(geaChanged:);
764
+ return choice;
765
+ }
766
+
767
+ NSView *makePopUp()
768
+ {
769
+ GeaPopUp *popup = [[GeaPopUp alloc] initWithFrame:NSZeroRect pullsDown:NO];
770
+ popup.nodeId = -1;
771
+ popup.menu.autoenablesItems = NO;
772
+ popup.target = popup;
773
+ popup.action = @selector(geaChanged:);
774
+ return popup;
775
+ }
776
+
777
+ NSView *makeStepper()
778
+ {
779
+ GeaStepper *stepper = [[GeaStepper alloc] initWithFrame:NSZeroRect];
780
+ stepper.nodeId = -1;
781
+ stepper.minValue = 0;
782
+ stepper.maxValue = 100;
783
+ stepper.increment = 1;
784
+ stepper.valueWraps = NO;
785
+ stepper.target = stepper;
786
+ stepper.action = @selector(geaChanged:);
787
+ return stepper;
788
+ }
789
+
611
790
  NSView *makeButton()
612
791
  {
613
792
  NSButton *btn = [[NSButton alloc] initWithFrame:NSZeroRect];
@@ -699,6 +878,7 @@ NSView *makeSymbolView()
699
878
  NSView *makeTextArea()
700
879
  {
701
880
  NSScrollView *sv = [[NSScrollView alloc] initWithFrame:NSZeroRect];
881
+ sv.automaticallyAdjustsContentInsets = NO;
702
882
  sv.hasVerticalScroller = YES;
703
883
  sv.hasHorizontalScroller = NO;
704
884
  sv.autohidesScrollers = YES;
@@ -711,6 +891,7 @@ NSView *makeTextArea()
711
891
  const NSSize cs = sv.contentSize;
712
892
  NSTextContainer *tc = [[NSTextContainer alloc] initWithContainerSize:NSMakeSize(cs.width, CGFLOAT_MAX)];
713
893
  tc.widthTracksTextView = YES;
894
+ tc.lineFragmentPadding = 0;
714
895
  NSLayoutManager *lm = [[NSLayoutManager alloc] init];
715
896
  [lm addTextContainer:tc];
716
897
  NSTextStorage *ts = [[NSTextStorage alloc] init];
@@ -738,14 +919,24 @@ NSView *makeTextArea()
738
919
  // materialized instead of an empty NSView. Calls to applyInputProps later
739
920
  // pick up placeholder / value / font / color from the node.
740
921
  NSView *makeViewForType(gea::embedded::ui::NodeType type, const char *tagName,
741
- const gea::embedded::ui::ComputedStyle &style, const char *inputType)
922
+ const gea::embedded::ui::ComputedStyle &style, const char *inputType, bool checkboxButton)
742
923
  {
743
924
  using gea::embedded::ui::NodeType;
744
925
  if (type == NodeType::View && tagName && std::strcmp(tagName, "input") == 0) {
745
926
  if (inputType && std::strcmp(inputType, "range") == 0) return makeSlider();
927
+ if (inputType && std::strcmp(inputType, "radio") == 0) return makeChoice(true);
928
+ if (checkboxButton) return makeChoice(false);
746
929
  if (inputType && std::strcmp(inputType, "checkbox") == 0) return makeSwitch();
747
930
  return makeInputField();
748
931
  }
932
+ if (type == NodeType::View && tagName && std::strcmp(tagName, "select") == 0) return makePopUp();
933
+ if (type == NodeType::View && tagName && std::strcmp(tagName, "stepper") == 0) return makeStepper();
934
+ if (type == NodeType::View && tagName && std::strcmp(tagName, "progress") == 0) {
935
+ NSProgressIndicator *progress = [[NSProgressIndicator alloc] initWithFrame:NSZeroRect];
936
+ progress.indeterminate = NO;
937
+ progress.maxValue = 100;
938
+ return progress;
939
+ }
749
940
  if (type == NodeType::View && tagName && std::strcmp(tagName, "textarea") == 0) {
750
941
  return makeTextArea();
751
942
  }
@@ -940,7 +1131,7 @@ char kInsetShadowKey; // CAShapeLayer casting the inset box-shadow
940
1131
 
941
1132
  CGColorRef createStyleCGColor(gea::embedded::ui::style_color_t color, uint8_t alpha)
942
1133
  {
943
- CGColor *base = gea::macos::rgb565ToCGColor(color);
1134
+ CGColor *base = gea::macos::nativeToCGColor(color);
944
1135
  if (alpha == 255) return base;
945
1136
  CGColor *faded = CGColorCreateCopyWithAlpha(base, alpha / 255.0);
946
1137
  CGColorRelease(base);
@@ -1201,7 +1392,7 @@ void applyViewStyle(NSView *view, const gea::embedded::ui::Node &node,
1201
1392
  // alpha in bg_alpha (255 = opaque). Without honoring it, translucent
1202
1393
  // backgrounds (weather's rgba(255,255,255,0.12) city chips) painted
1203
1394
  // fully opaque.
1204
- CGColor *bg = gea::macos::rgb565ToCGColor(node.style.bg_color);
1395
+ CGColor *bg = gea::macos::nativeToCGColor(node.style.bg_color);
1205
1396
  if (node.style.bg_alpha != 255) {
1206
1397
  CGColor *faded = CGColorCreateCopyWithAlpha(bg, node.style.bg_alpha / 255.0);
1207
1398
  CGColorRelease(bg);
@@ -1215,12 +1406,14 @@ void applyViewStyle(NSView *view, const gea::embedded::ui::Node &node,
1215
1406
  }
1216
1407
 
1217
1408
  view.alphaValue = static_cast<CGFloat>(node.style.opacity) / 255.0;
1218
- view.hidden = (node.style.display == 1);
1409
+ // Visibility preserves the arranged box, but suppresses its native artwork
1410
+ // and hit testing. Gea checkmarks toggle this independently of display.
1411
+ view.hidden = (node.style.display == 1 || node.style.visibility != 0);
1219
1412
 
1220
1413
  // Border (border_alpha carries the CSS alpha, same as bg_alpha above).
1221
1414
  if (node.style.border_width > 0) {
1222
1415
  view.layer.borderWidth = node.style.border_width;
1223
- CGColor *bc = gea::macos::rgb565ToCGColor(node.style.border_color);
1416
+ CGColor *bc = gea::macos::nativeToCGColor(node.style.border_color);
1224
1417
  if (node.style.border_alpha != 255) {
1225
1418
  CGColor *faded = CGColorCreateCopyWithAlpha(bc, node.style.border_alpha / 255.0);
1226
1419
  CGColorRelease(bc);
@@ -1306,11 +1499,19 @@ bool attributedStringHasTextDecoration(NSAttributedString *value)
1306
1499
  [value attribute:NSStrikethroughStyleAttributeName atIndex:0 effectiveRange:nil] != nil;
1307
1500
  }
1308
1501
 
1309
- void applyTextProps(NSTextField *tf, const gea::embedded::ui::Node &node)
1502
+ void applyTextProps(NSTextField *tf, const gea::embedded::ui::Node &node, int nodeId)
1310
1503
  {
1311
1504
  NSString *raw = [NSString stringWithUTF8String:(node.text.empty() ? "" : node.text.c_str())];
1312
1505
  NSFont *font = gea::macos::fontForId(node.style.font_id, node.style.font_size);
1313
- NSColor *color = gea::macos::rgb565ToNSColor(node.style.text_color);
1506
+ NSColor *color = gea::macos::nativeToNSColor(node.style.text_color);
1507
+ GeaTextCell *cell = (GeaTextCell *)tf.cell;
1508
+ const char *vertical = gea::embedded::ui::Tree::instance().getAttribute(nodeId, "data-text-valign");
1509
+ cell.verticallyCenters = vertical && std::strcmp(vertical, "center") == 0;
1510
+ cell.contentInsets = NSEdgeInsetsMake(
1511
+ node.style.padding[0] + gea::embedded::ui::computedBorderWidth(node.style, 0),
1512
+ node.style.padding[3] + gea::embedded::ui::computedBorderWidth(node.style, 3),
1513
+ node.style.padding[2] + gea::embedded::ui::computedBorderWidth(node.style, 2),
1514
+ node.style.padding[1] + gea::embedded::ui::computedBorderWidth(node.style, 1));
1314
1515
 
1315
1516
  NSTextAlignment alignment;
1316
1517
  switch (node.style.text_align) {
@@ -1319,30 +1520,15 @@ void applyTextProps(NSTextField *tf, const gea::embedded::ui::Node &node)
1319
1520
  default: alignment = NSTextAlignmentLeft;
1320
1521
  }
1321
1522
 
1322
- // Use the same attributes the host measurement hook (font_registry.mm's
1323
- // gea_host_measure_text) uses — same font, same break mode, default
1324
- // kerning. Identical attributes guarantee the rendered NSTextField has
1325
- // exactly the width/height the framework's layout engine allocated for
1326
- // the text node, so titles never end up with a gap below them from
1327
- // over-allocation and long labels never overflow into clipped territory
1328
- // from under-allocation.
1329
- //
1330
- // Alignment is deliberately NOT one of those attributes. An
1331
- // NSParagraphStyle whose `alignment` is NSTextAlignmentCenter makes
1332
- // NSTextFieldCell demand FOUR MORE POINTS of width for the same string
1333
- // (measured: "Reset"/Inter 15 needs 44pt with a natural or left/right
1334
- // paragraph and 48pt with a centred one). The measurement hook sets only
1335
- // `lineBreakMode`, so every centre-aligned label was laid out 4pt narrower
1336
- // than AppKit would draw it, `wraps = YES` broke the word onto a second
1337
- // line, and the field's one-line height hid it: "COUNTER" rendered as
1338
- // "COUNTE", "Reset" as "Rese", "Ready" as "Read". Single-glyph labels
1339
- // survived only because their boxes had more than 4pt of slack.
1340
- //
1341
- // `tf.alignment` below still centres the text and costs nothing, because
1342
- // the cell -- not the paragraph style -- applies it. Keep alignment there.
1343
1523
  NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init];
1344
- const CGFloat availableWidth = node.layout.width > 0 ? node.layout.width : CGFLOAT_MAX;
1524
+ const CGFloat contentWidth = node.layout.width - cell.contentInsets.left - cell.contentInsets.right;
1525
+ const CGFloat availableWidth = node.layout.width > 0 ? std::max<CGFloat>(0, contentWidth) : CGFLOAT_MAX;
1345
1526
  paragraph.lineBreakMode = gea::macos::lineBreakModeForText(raw, font, availableWidth);
1527
+ paragraph.alignment = alignment;
1528
+ if (node.style.line_height > 0) {
1529
+ paragraph.minimumLineHeight = node.style.line_height;
1530
+ paragraph.maximumLineHeight = node.style.line_height;
1531
+ }
1346
1532
  NSMutableDictionary *attrs = textAttributes(font ?: [NSFont systemFontOfSize:node.style.font_size > 0 ? node.style.font_size : 12],
1347
1533
  color,
1348
1534
  node.style.text_decoration);
@@ -1360,6 +1546,13 @@ void applyInputProps(GeaInputField *tf, const gea::embedded::ui::Node &node, int
1360
1546
  {
1361
1547
  using gea::embedded::ui::Tree;
1362
1548
  tf.nodeId = nodeId;
1549
+ tf.enabled = !geaBooleanAttribute(nodeId, "disabled");
1550
+ tf.editable = tf.enabled && !geaBooleanAttribute(nodeId, "readOnly") && !geaBooleanAttribute(nodeId, "readonly");
1551
+ ((GeaInputCell *)tf.cell).contentInsets = NSEdgeInsetsMake(
1552
+ node.style.padding[0] + gea::embedded::ui::computedBorderWidth(node.style, 0),
1553
+ node.style.padding[3] + gea::embedded::ui::computedBorderWidth(node.style, 3),
1554
+ node.style.padding[2] + gea::embedded::ui::computedBorderWidth(node.style, 2),
1555
+ node.style.padding[1] + gea::embedded::ui::computedBorderWidth(node.style, 1));
1363
1556
 
1364
1557
  // The store drives `value` via the framework's reactive-attribute machinery,
1365
1558
  // which writes to `node.setAttribute("value", ...)`. Mirror that to the
@@ -1372,7 +1565,7 @@ void applyInputProps(GeaInputField *tf, const gea::embedded::ui::Node &node, int
1372
1565
  // whether the field is currently focused — so the editor clears correctly.
1373
1566
  auto &tree = Tree::instance();
1374
1567
  const char *value = tree.getAttribute(nodeId, "value");
1375
- tf.textColor = gea::macos::rgb565ToNSColor(node.style.text_color);
1568
+ tf.textColor = gea::macos::nativeToNSColor(node.style.text_color);
1376
1569
  tf.font = gea::macos::fontForId(node.style.font_id, node.style.font_size);
1377
1570
  switch (node.style.text_align) {
1378
1571
  case 1: tf.alignment = NSTextAlignmentCenter; break;
@@ -1405,6 +1598,7 @@ void applySliderProps(GeaSlider *sl, const gea::embedded::ui::Node &node, int no
1405
1598
  using gea::embedded::ui::Tree;
1406
1599
  auto &tree = Tree::instance();
1407
1600
  sl.nodeId = nodeId;
1601
+ sl.enabled = !geaBooleanAttribute(nodeId, "disabled");
1408
1602
  const char *minA = tree.getAttribute(nodeId, "min");
1409
1603
  const char *maxA = tree.getAttribute(nodeId, "max");
1410
1604
  if (minA && minA[0]) sl.minValue = atof(minA);
@@ -1424,6 +1618,7 @@ void applySwitchProps(GeaSwitch *sw, const gea::embedded::ui::Node &node, int no
1424
1618
  using gea::embedded::ui::Tree;
1425
1619
  auto &tree = Tree::instance();
1426
1620
  sw.nodeId = nodeId;
1621
+ sw.enabled = !geaBooleanAttribute(nodeId, "disabled");
1427
1622
  const char *checked = tree.getAttribute(nodeId, "checked");
1428
1623
  const bool hasChecked = tree.hasAttribute(nodeId, "checked");
1429
1624
  const bool explicitlyOff = checked && (std::strcmp(checked, "false") == 0 || std::strcmp(checked, "0") == 0);
@@ -1432,6 +1627,105 @@ void applySwitchProps(GeaSwitch *sw, const gea::embedded::ui::Node &node, int no
1432
1627
  if (sw.state != want) sw.state = want;
1433
1628
  }
1434
1629
 
1630
+ void applyChoiceProps(GeaChoice *choice, int nodeId)
1631
+ {
1632
+ choice.nodeId = nodeId;
1633
+ choice.enabled = !geaBooleanAttribute(nodeId, "disabled");
1634
+ const NSControlStateValue state = geaBooleanAttribute(nodeId, "checked") ? NSControlStateValueOn : NSControlStateValueOff;
1635
+ if (choice.state != state) choice.state = state;
1636
+ }
1637
+
1638
+ NSString *controlText(int nodeId)
1639
+ {
1640
+ auto &tree = gea::embedded::ui::Tree::instance();
1641
+ std::string result;
1642
+ std::vector<int> stack{nodeId};
1643
+ while (!stack.empty()) {
1644
+ const int id = stack.back();
1645
+ stack.pop_back();
1646
+ const auto &node = tree.node(id);
1647
+ if (!node.text.empty()) result += node.text.c_str();
1648
+ std::vector<int> children;
1649
+ for (int child = node.first_child; child >= 0; child = tree.node(child).next_sibling) children.push_back(child);
1650
+ for (auto it = children.rbegin(); it != children.rend(); ++it) stack.push_back(*it);
1651
+ }
1652
+ return [NSString stringWithUTF8String:result.c_str()] ?: @"";
1653
+ }
1654
+
1655
+ void applyPopUpProps(GeaPopUp *popup, const gea::embedded::ui::Node &node, int nodeId)
1656
+ {
1657
+ auto &tree = gea::embedded::ui::Tree::instance();
1658
+ popup.nodeId = nodeId;
1659
+ popup.enabled = !geaBooleanAttribute(nodeId, "disabled");
1660
+ popup.font = gea::macos::fontForId(node.style.font_id, node.style.font_size);
1661
+ NSMutableArray<NSString *> *titles = [NSMutableArray array], *values = [NSMutableArray array];
1662
+ std::vector<bool> disabled;
1663
+ NSInteger selected = -1;
1664
+ const char *value = tree.getAttribute(nodeId, "value");
1665
+ NSString *desired = tree.hasAttribute(nodeId, "value") ? [NSString stringWithUTF8String:value] : nil;
1666
+ for (int child = node.first_child; child >= 0; child = tree.node(child).next_sibling) {
1667
+ const char *tag = tree.tagName(child);
1668
+ if (!tag || std::strcmp(tag, "option") != 0) continue;
1669
+ NSString *title = controlText(child);
1670
+ const char *optionValue = tree.getAttribute(child, "value");
1671
+ NSString *itemValue = tree.hasAttribute(child, "value") ? [NSString stringWithUTF8String:optionValue] : title;
1672
+ if ((desired && [desired isEqualToString:itemValue]) || (!desired && geaBooleanAttribute(child, "selected"))) selected = titles.count;
1673
+ [titles addObject:title];
1674
+ [values addObject:itemValue ?: @""];
1675
+ disabled.push_back(geaBooleanAttribute(child, "disabled"));
1676
+ }
1677
+ BOOL changed = popup.numberOfItems != (NSInteger)titles.count;
1678
+ for (NSUInteger i = 0; !changed && i < titles.count; ++i) {
1679
+ NSMenuItem *item = [popup itemAtIndex:i];
1680
+ changed = ![item.title isEqualToString:titles[i]] || ![item.representedObject isEqual:values[i]];
1681
+ }
1682
+ if (changed) {
1683
+ [popup removeAllItems];
1684
+ for (NSUInteger i = 0; i < titles.count; ++i) {
1685
+ NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:titles[i] action:nil keyEquivalent:@""];
1686
+ item.representedObject = values[i];
1687
+ [popup.menu addItem:item];
1688
+ }
1689
+ }
1690
+ for (NSUInteger i = 0; i < titles.count; ++i) [popup itemAtIndex:i].enabled = !disabled[i];
1691
+ if (selected >= 0 && popup.indexOfSelectedItem != selected) [popup selectItemAtIndex:selected];
1692
+ }
1693
+
1694
+ void applyStepperProps(GeaStepper *stepper, int nodeId)
1695
+ {
1696
+ auto &tree = gea::embedded::ui::Tree::instance();
1697
+ stepper.nodeId = nodeId;
1698
+ stepper.enabled = !geaBooleanAttribute(nodeId, "disabled");
1699
+ const char *min = tree.getAttribute(nodeId, "min"), *max = tree.getAttribute(nodeId, "max");
1700
+ const char *step = tree.getAttribute(nodeId, "step"), *value = tree.getAttribute(nodeId, "value");
1701
+ stepper.minValue = min && min[0] ? atof(min) : 0;
1702
+ stepper.maxValue = max && max[0] ? atof(max) : 100;
1703
+ stepper.increment = step && atof(step) > 0 ? atof(step) : 1;
1704
+ if (value && value[0]) stepper.doubleValue = atof(value);
1705
+ }
1706
+
1707
+ void applyProgressProps(NSProgressIndicator *progress, int nodeId)
1708
+ {
1709
+ auto &tree = gea::embedded::ui::Tree::instance();
1710
+ const char *style = tree.getAttribute(nodeId, "data-style");
1711
+ const NSProgressIndicatorStyle desiredStyle = style && std::strcmp(style, "spinner") == 0 ? NSProgressIndicatorStyleSpinning : NSProgressIndicatorStyleBar;
1712
+ const bool styleChanged = progress.style != desiredStyle;
1713
+ if (styleChanged) progress.style = desiredStyle;
1714
+ const bool indeterminate = geaBooleanAttribute(nodeId, "indeterminate");
1715
+ const bool modeChanged = progress.indeterminate != indeterminate;
1716
+ if (modeChanged) progress.indeterminate = indeterminate;
1717
+ const char *max = tree.getAttribute(nodeId, "max"), *value = tree.getAttribute(nodeId, "value");
1718
+ progress.maxValue = max && atof(max) > 0 ? atof(max) : 100;
1719
+ if (value && value[0]) progress.doubleValue = atof(value);
1720
+ const bool running = indeterminate && (!tree.hasAttribute(nodeId, "data-running") || geaBooleanAttribute(nodeId, "data-running"));
1721
+ NSNumber *previous = objc_getAssociatedObject(progress, "gea.progress_running");
1722
+ if (!previous || previous.boolValue != running || styleChanged || modeChanged) {
1723
+ if (running) [progress startAnimation:nil];
1724
+ else [progress stopAnimation:nil];
1725
+ objc_setAssociatedObject(progress, "gea.progress_running", @(running), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
1726
+ }
1727
+ }
1728
+
1435
1729
  void applySymbolProps(NSImageView *iv, const gea::embedded::ui::Node &node, int nodeId)
1436
1730
  {
1437
1731
  using gea::embedded::ui::Tree;
@@ -1455,7 +1749,7 @@ void applySymbolProps(NSImageView *iv, const gea::embedded::ui::Node &node, int
1455
1749
  // SF Symbols render as template images; tint with the node's CSS color
1456
1750
  // (falls back to the system label color so they adapt to dark mode).
1457
1751
  if (node.style.text_color != 0) {
1458
- iv.contentTintColor = gea::macos::rgb565ToNSColor(node.style.text_color);
1752
+ iv.contentTintColor = gea::macos::nativeToNSColor(node.style.text_color);
1459
1753
  } else {
1460
1754
  iv.contentTintColor = [NSColor labelColor];
1461
1755
  }
@@ -1490,10 +1784,16 @@ void applyTextAreaProps(NSScrollView *sv, const gea::embedded::ui::Node &node, i
1490
1784
  Tree &tree = Tree::instance();
1491
1785
  GeaTextAreaView *tv = objc_getAssociatedObject(sv, "gea.text_view");
1492
1786
  if (!tv) return;
1787
+ sv.contentInsets = NSEdgeInsetsMake(
1788
+ node.style.padding[0] + gea::embedded::ui::computedBorderWidth(node.style, 0),
1789
+ node.style.padding[3] + gea::embedded::ui::computedBorderWidth(node.style, 3),
1790
+ node.style.padding[2] + gea::embedded::ui::computedBorderWidth(node.style, 2),
1791
+ node.style.padding[1] + gea::embedded::ui::computedBorderWidth(node.style, 1));
1493
1792
  tv.nodeId = nodeId;
1793
+ tv.editable = !geaBooleanAttribute(nodeId, "disabled") && !geaBooleanAttribute(nodeId, "readOnly") && !geaBooleanAttribute(nodeId, "readonly");
1494
1794
 
1495
1795
  NSFont *font = gea::macos::fontForId(node.style.font_id, node.style.font_size > 0 ? node.style.font_size : 14);
1496
- NSColor *color = gea::macos::rgb565ToNSColor(node.style.text_color);
1796
+ NSColor *color = gea::macos::nativeToNSColor(node.style.text_color);
1497
1797
  tv.font = font ?: [NSFont systemFontOfSize:14];
1498
1798
  tv.textColor = color ?: [NSColor labelColor];
1499
1799
  tv.insertionPointColor = tv.textColor;
@@ -1527,6 +1827,7 @@ void applyButtonProps(NSButton *btn, const gea::embedded::ui::Node &node, int no
1527
1827
  {
1528
1828
  using namespace gea::embedded::ui;
1529
1829
  Tree &tree = Tree::instance();
1830
+ btn.enabled = !geaBooleanAttribute(nodeId, "disabled");
1530
1831
 
1531
1832
  // Title from the first Text child, if any. JSX <Button>label</Button>
1532
1833
  // produces a Button with a text child.
@@ -1572,7 +1873,7 @@ void applyButtonProps(NSButton *btn, const gea::embedded::ui::Node &node, int no
1572
1873
  if (btn.bordered != static_cast<BOOL>(!cssStyled)) btn.bordered = !cssStyled;
1573
1874
  if (cssStyled) {
1574
1875
  NSFont *font = gea::macos::fontForId(node.style.font_id, node.style.font_size);
1575
- NSColor *color = node.style.text_color != 0 ? gea::macos::rgb565ToNSColor(node.style.text_color)
1876
+ NSColor *color = node.style.text_color != 0 ? gea::macos::nativeToNSColor(node.style.text_color)
1576
1877
  : [NSColor labelColor];
1577
1878
  NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init];
1578
1879
  paragraph.alignment = NSTextAlignmentCenter;
@@ -1615,21 +1916,30 @@ void ensureViewClickRecognizer(NSView *view, int nodeId, bool wantsClick)
1615
1916
  // pressId at runtime.
1616
1917
  }
1617
1918
 
1618
- void applyImageProps(NSImageView *iv, const gea::embedded::ui::Node &node)
1919
+ void applyImageProps(NSImageView *iv, const gea::embedded::ui::Node &node, int nodeId)
1619
1920
  {
1620
1921
  // Re-decode when image_id changes; otherwise leave the current NSImage in
1621
1922
  // place to avoid rebuilding the bitmap every frame. We stash the last
1622
1923
  // imageId on the view via associated object.
1623
1924
  NSNumber *currentId = objc_getAssociatedObject(iv, "gea.image_id");
1624
- if (!currentId || currentId.intValue != node.image_id) {
1625
- iv.image = gea::macos::imageForId(node.image_id);
1925
+ NSValue *previousBox = objc_getAssociatedObject(iv, "gea.image_box");
1926
+ NSNumber *previousFit = objc_getAssociatedObject(iv, "gea.image_fit");
1927
+ const NSSize box = NSMakeSize(node.layout.width, node.layout.height);
1928
+ auto &imageTree = gea::embedded::ui::Tree::instance();
1929
+ NSString *cropKey = [NSString stringWithFormat:@"%s/%s/%s/%s", imageTree.getAttribute(nodeId, "data-source-x"), imageTree.getAttribute(nodeId, "data-source-y"), imageTree.getAttribute(nodeId, "data-source-width"), imageTree.getAttribute(nodeId, "data-source-height")];
1930
+ NSString *previousCrop = objc_getAssociatedObject(iv, "gea.image_crop");
1931
+ if (!iv.image || ![previousCrop isEqualToString:cropKey] || !currentId || currentId.intValue != node.image_id || !previousFit || previousFit.intValue != node.style.image_fit || (node.style.image_fit == 2 && (!previousBox || !NSEqualSizes(previousBox.sizeValue, box)))) {
1932
+ iv.image = gea::macos::imageForNode(nodeId);
1933
+ objc_setAssociatedObject(iv, "gea.image_crop", cropKey, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
1934
+ objc_setAssociatedObject(iv, "gea.image_box", [NSValue valueWithSize:box], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
1935
+ objc_setAssociatedObject(iv, "gea.image_fit", @(node.style.image_fit), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
1626
1936
  objc_setAssociatedObject(iv, "gea.image_id", @(node.image_id),
1627
1937
  OBJC_ASSOCIATION_RETAIN_NONATOMIC);
1628
1938
  }
1629
1939
  switch (node.style.image_fit) {
1630
1940
  case 0: iv.imageScaling = NSImageScaleAxesIndependently; break;
1631
1941
  case 1: iv.imageScaling = NSImageScaleProportionallyUpOrDown; break;
1632
- case 2: iv.imageScaling = NSImageScaleProportionallyUpOrDown; break; // "cover" ~ fit
1942
+ case 2: iv.imageScaling = NSImageScaleAxesIndependently; break; // cropped to the destination aspect above
1633
1943
  case 3: iv.imageScaling = NSImageScaleNone; break;
1634
1944
  case 4: iv.imageScaling = NSImageScaleProportionallyDown; break;
1635
1945
  default: iv.imageScaling = NSImageScaleAxesIndependently;
@@ -1674,17 +1984,25 @@ void applyTypeSpecificProps(NSView *view, const gea::embedded::ui::Node &node, i
1674
1984
  {
1675
1985
  using gea::embedded::ui::NodeType;
1676
1986
  if (node.type == NodeType::Text) {
1677
- applyTextProps((NSTextField *)view, node);
1987
+ applyTextProps((NSTextField *)view, node, nodeId);
1678
1988
  } else if (node.type == NodeType::Button) {
1679
1989
  applyButtonProps((NSButton *)view, node, nodeId);
1680
1990
  } else if (node.type == NodeType::Image) {
1681
- applyImageProps((NSImageView *)view, node);
1991
+ applyImageProps((NSImageView *)view, node, nodeId);
1682
1992
  } else if (node.type == NodeType::Canvas) {
1683
1993
  applyCanvasProps((GeaCanvasView *)view, node, nodeId);
1684
1994
  } else if ([view isKindOfClass:[GeaSlider class]]) {
1685
1995
  applySliderProps((GeaSlider *)view, node, nodeId);
1686
1996
  } else if ([view isKindOfClass:[GeaSwitch class]]) {
1687
1997
  applySwitchProps((GeaSwitch *)view, node, nodeId);
1998
+ } else if ([view isKindOfClass:[GeaChoice class]]) {
1999
+ applyChoiceProps((GeaChoice *)view, nodeId);
2000
+ } else if ([view isKindOfClass:[GeaPopUp class]]) {
2001
+ applyPopUpProps((GeaPopUp *)view, node, nodeId);
2002
+ } else if ([view isKindOfClass:[GeaStepper class]]) {
2003
+ applyStepperProps((GeaStepper *)view, nodeId);
2004
+ } else if ([view isKindOfClass:[NSProgressIndicator class]]) {
2005
+ applyProgressProps((NSProgressIndicator *)view, nodeId);
1688
2006
  } else if ([view isKindOfClass:[GeaInputField class]]) {
1689
2007
  applyInputProps((GeaInputField *)view, node, nodeId);
1690
2008
  } else if (objc_getAssociatedObject(view, "gea.is_symbol")) {
@@ -1715,7 +2033,7 @@ void applyTypeSpecificProps(NSView *view, const gea::embedded::ui::Node &node, i
1715
2033
  }
1716
2034
 
1717
2035
  bool viewMatchesNode(NSView *view, const gea::embedded::ui::Node &node,
1718
- const char *tagName, const char *inputType)
2036
+ const char *tagName, const char *inputType, bool checkboxButton)
1719
2037
  {
1720
2038
  using gea::embedded::ui::NodeType;
1721
2039
  if (!view) return false;
@@ -1725,9 +2043,14 @@ bool viewMatchesNode(NSView *view, const gea::embedded::ui::Node &node,
1725
2043
 
1726
2044
  if (node.type == NodeType::View && tagName && std::strcmp(tagName, "input") == 0) {
1727
2045
  if (inputType && std::strcmp(inputType, "range") == 0) return [view isKindOfClass:[GeaSlider class]];
2046
+ const bool radio = inputType && std::strcmp(inputType, "radio") == 0;
2047
+ if (radio || checkboxButton) return [view isKindOfClass:[GeaChoice class]] && ((GeaChoice *)view).radio == radio;
1728
2048
  if (inputType && std::strcmp(inputType, "checkbox") == 0) return [view isKindOfClass:[GeaSwitch class]];
1729
2049
  return [view isKindOfClass:[GeaInputField class]];
1730
2050
  }
2051
+ if (node.type == NodeType::View && tagName && std::strcmp(tagName, "select") == 0) return [view isKindOfClass:[GeaPopUp class]];
2052
+ if (node.type == NodeType::View && tagName && std::strcmp(tagName, "stepper") == 0) return [view isKindOfClass:[GeaStepper class]];
2053
+ if (node.type == NodeType::View && tagName && std::strcmp(tagName, "progress") == 0) return [view isKindOfClass:[NSProgressIndicator class]];
1731
2054
  if (node.type == NodeType::View && tagName && std::strcmp(tagName, "textarea") == 0) {
1732
2055
  return isTextAreaView;
1733
2056
  }
@@ -1758,6 +2081,8 @@ bool viewMatchesNode(NSView *view, const gea::embedded::ui::Node &node,
1758
2081
  ![view isKindOfClass:[GeaCanvasView class]] &&
1759
2082
  ![view isKindOfClass:[GeaSlider class]] &&
1760
2083
  ![view isKindOfClass:[GeaSwitch class]] &&
2084
+ ![view isKindOfClass:[GeaStepper class]] &&
2085
+ ![view isKindOfClass:[NSProgressIndicator class]] &&
1761
2086
  ![view isKindOfClass:[GeaInputField class]];
1762
2087
  }
1763
2088
  }
@@ -1768,13 +2093,15 @@ NSView *ensureViewForNode(int nodeId, const gea::embedded::ui::Node &node)
1768
2093
  NSView *view = nodeIdToView()[key];
1769
2094
  const char *tagName = gea::embedded::ui::Tree::instance().tagName(nodeId);
1770
2095
  const char *inputType = gea::embedded::ui::Tree::instance().getAttribute(nodeId, "type");
1771
- if (view && !viewMatchesNode(view, node, tagName, inputType)) {
2096
+ const char *control = gea::embedded::ui::Tree::instance().getAttribute(nodeId, "data-control");
2097
+ const bool checkboxButton = inputType && std::strcmp(inputType, "checkbox") == 0 && control && std::strcmp(control, "checkbox") == 0;
2098
+ if (view && !viewMatchesNode(view, node, tagName, inputType, checkboxButton)) {
1772
2099
  [view removeFromSuperview];
1773
2100
  [nodeIdToView() removeObjectForKey:key];
1774
2101
  view = nil;
1775
2102
  }
1776
2103
  if (view) return view;
1777
- view = makeViewForType(node.type, tagName, node.style, inputType);
2104
+ view = makeViewForType(node.type, tagName, node.style, inputType, checkboxButton);
1778
2105
  // Stamp the nodeId on the view so the root-level click handler can map
1779
2106
  // hit-tested NSViews back to tree nodes. Used by GeaRootClickBridge to
1780
2107
  // dispatch with the deepest matching node's id (event delegation —
@@ -1851,7 +2178,7 @@ void appendInlineRuns(NSMutableAttributedString *out, int nodeId,
1851
2178
  // ancestor's class). When the framework has filled them in we use
1852
2179
  // them; otherwise we keep the parent's value as the inherited default.
1853
2180
  if (node.style.text_color != 0) {
1854
- col = gea::macos::rgb565ToNSColor(node.style.text_color);
2181
+ col = gea::macos::nativeToNSColor(node.style.text_color);
1855
2182
  }
1856
2183
  NSFont *resolved = gea::macos::fontForId(node.style.font_id, node.style.font_size);
1857
2184
  if (resolved) font = resolved;
@@ -1864,7 +2191,7 @@ void appendInlineRuns(NSMutableAttributedString *out, int nodeId,
1864
2191
  NSColor *col = parentColor;
1865
2192
  NSFont *font = parentFont;
1866
2193
  if (node.style.text_color != 0) {
1867
- col = gea::macos::rgb565ToNSColor(node.style.text_color);
2194
+ col = gea::macos::nativeToNSColor(node.style.text_color);
1868
2195
  }
1869
2196
  NSFont *resolved = gea::macos::fontForId(node.style.font_id, node.style.font_size);
1870
2197
  if (resolved) font = resolved;
@@ -1905,7 +2232,7 @@ NSTextField *renderInlineComposition(int nodeId, NSView *parentNSView,
1905
2232
  }
1906
2233
 
1907
2234
  NSFont *parentFont = gea::macos::fontForId(node.style.font_id, node.style.font_size);
1908
- NSColor *parentColor = gea::macos::rgb565ToNSColor(node.style.text_color);
2235
+ NSColor *parentColor = gea::macos::nativeToNSColor(node.style.text_color);
1909
2236
  NSMutableAttributedString *composite = [[NSMutableAttributedString alloc] init];
1910
2237
  for (int c = node.first_child; c >= 0; c = tree.node(c).next_sibling) {
1911
2238
  appendInlineRuns(composite, c, parentFont, parentColor);
@@ -1914,7 +2241,13 @@ NSTextField *renderInlineComposition(int nodeId, NSView *parentNSView,
1914
2241
  // uses, so the visual style stays consistent.
1915
2242
  NSMutableParagraphStyle *ps = [[NSMutableParagraphStyle alloc] init];
1916
2243
  ps.lineBreakMode = NSLineBreakByWordWrapping;
2244
+ ps.alignment = node.style.text_align == 1 ? NSTextAlignmentCenter : node.style.text_align == 2 ? NSTextAlignmentRight : NSTextAlignmentLeft;
1917
2245
  [composite addAttribute:NSParagraphStyleAttributeName value:ps range:NSMakeRange(0, composite.length)];
2246
+ ((GeaTextCell *)field.cell).contentInsets = NSEdgeInsetsMake(
2247
+ node.style.padding[0] + computedBorderWidth(node.style, 0),
2248
+ node.style.padding[3] + computedBorderWidth(node.style, 3),
2249
+ node.style.padding[2] + computedBorderWidth(node.style, 2),
2250
+ node.style.padding[1] + computedBorderWidth(node.style, 1));
1918
2251
 
1919
2252
  field.attributedStringValue = composite;
1920
2253
  // Fill the parent's content box. The framework already laid the parent
@@ -1955,6 +2288,7 @@ void syncRecursive(int nodeId, NSView *parent, int parentAbsX, int parentAbsY, i
1955
2288
  // applyButtonProps; materializing the child as an NSTextField on top
1956
2289
  // would just be a redundant overlay. Skip descending into Buttons.
1957
2290
  if (node.type == NodeType::Button) return;
2291
+ if ([view isKindOfClass:[GeaPopUp class]]) return;
1958
2292
 
1959
2293
  // `<textarea>` owns its NSTextView as its only descendant — JSX children
1960
2294
  // (if any were authored) would otherwise be pushed inside NSTextView and