@effindomv2/fui-as 0.1.7 → 0.1.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effindomv2/fui-as",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "private": false,
5
5
  "license": "AGPL-3.0-only OR LicenseRef-EffinDom-Commercial",
6
6
  "description": "EffinDom v2 AssemblyScript frontend framework SDK and browser harness",
@@ -173,9 +173,7 @@ class DropdownOptionNode extends FlexBox {
173
173
 
174
174
  private syncPresenterLayout(): void {
175
175
  this.height(this.presenter.metrics.height, Unit.Pixel);
176
- this.presenter.root
177
- .width(100.0, Unit.Percent)
178
- .height(100.0, Unit.Percent);
176
+ this.presenter.root.fillSize();
179
177
  }
180
178
  }
181
179
 
@@ -44,8 +44,7 @@ class DefaultCheckboxIndicatorPresenter extends CheckboxIndicatorPresenter {
44
44
  .justifyContent(1);
45
45
  super(root, new PressableIndicatorMetrics(20.0, 20.0));
46
46
  const markHost = new FlexBox()
47
- .width(100.0, Unit.Percent)
48
- .height(100.0, Unit.Percent)
47
+ .fillSize()
49
48
  .alignItems(1)
50
49
  .justifyContent(1);
51
50
  const markNode = new Svg();
@@ -34,8 +34,7 @@ class DefaultDropdownChevronPresenter extends DropdownChevronPresenter {
34
34
 
35
35
  constructor() {
36
36
  const root = new FlexBox()
37
- .width(100.0, Unit.Percent)
38
- .height(100.0, Unit.Percent)
37
+ .fillSize()
39
38
  .alignItems(AlignItems.Center)
40
39
  .justifyContent(JustifyContent.Center);
41
40
  const iconNode = new Svg()
@@ -48,8 +47,7 @@ class DefaultDropdownChevronPresenter extends DropdownChevronPresenter {
48
47
 
49
48
  apply(theme: Theme, state: DropdownChevronVisualState): void {
50
49
  this.root
51
- .width(100.0, Unit.Percent)
52
- .height(100.0, Unit.Percent)
50
+ .fillSize()
53
51
  .alignItems(AlignItems.Center)
54
52
  .justifyContent(JustifyContent.Center);
55
53
  this.iconNode
@@ -51,8 +51,7 @@ class DefaultDropdownOptionRowPresenter extends DropdownOptionRowPresenter {
51
51
  .wrapping(false) as Text;
52
52
  labelNode.overflowFade(true, false);
53
53
  const root = new FlexBox()
54
- .width(100.0, Unit.Percent)
55
- .height(100.0, Unit.Percent)
54
+ .fillSize()
56
55
  .alignItems(AlignItems.Center)
57
56
  .child(labelNode);
58
57
  super(root, labelNode, new DropdownOptionRowMetrics(34.0));
package/src/core/Node.ts CHANGED
@@ -1343,6 +1343,38 @@ export abstract class Node implements DragGestureHost, Disposable {
1343
1343
  return false;
1344
1344
  }
1345
1345
 
1346
+ _debugNodeId(): string | null {
1347
+ return this.nodeIdValue;
1348
+ }
1349
+
1350
+ _debugTreePath(): string {
1351
+ const segments = new Array<i32>();
1352
+ let current: Node | null = this;
1353
+ while (current !== null) {
1354
+ const parent = current.retainedParent;
1355
+ if (parent === null) {
1356
+ break;
1357
+ }
1358
+ let childIndex = -1;
1359
+ for (let index = 0; index < parent.childNodes.length; ++index) {
1360
+ if (unchecked(parent.childNodes[index]) === current) {
1361
+ childIndex = index;
1362
+ break;
1363
+ }
1364
+ }
1365
+ if (childIndex < 0) {
1366
+ break;
1367
+ }
1368
+ segments.push(childIndex);
1369
+ current = parent;
1370
+ }
1371
+ let path = "root";
1372
+ for (let index = segments.length - 1; index >= 0; --index) {
1373
+ path += "/" + unchecked(segments[index]).toString();
1374
+ }
1375
+ return path;
1376
+ }
1377
+
1346
1378
  protected capturePointer(): void {
1347
1379
  if (!this.hasBuiltHandle()) {
1348
1380
  return;
package/src/core/Theme.ts CHANGED
@@ -38,6 +38,7 @@ export class Colors {
38
38
  readonly scrollbarThumb: u32,
39
39
  readonly dialogBackdrop: u32,
40
40
  readonly dialogShadow: u32,
41
+ readonly panelShadow: u32,
41
42
  readonly focusRing: u32,
42
43
  ) {}
43
44
  }
@@ -231,16 +232,17 @@ export function generateTheme(isDark: bool, accentColor: u32 = DEFAULT_ACCENT_CO
231
232
  : mixColor(accent, surface, 0.40);
232
233
  const dialogBackdrop = isDark ? rgba(0x00, 0x00, 0x00, 0x24) : rgba(0x00, 0x00, 0x00, 0x18);
233
234
  const dialogShadow = isDark ? rgba(0x00, 0x00, 0x00, 0xd8) : rgba(0x00, 0x00, 0x00, 0x88);
235
+ const panelShadow = withAlpha(dialogShadow, <u32>Math.round(<f32>colorAlpha(dialogShadow) * 0.30));
234
236
  const focusRing = accent;
235
237
  const contextMenuPanelBackground = isDark ? rgba(0x18, 0x1d, 0x26, 0xd8) : rgba(0xff, 0xff, 0xff, 0xdc);
236
238
  const contextMenuPanelBorderColor = isDark ? rgba(0xff, 0xff, 0xff, 0x10) : rgba(0x0f, 0x17, 0x2a, 0x14);
237
- const contextMenuPanelShadowColor = isDark ? rgba(0x00, 0x00, 0x00, 0xb0) : rgba(0x0f, 0x17, 0x2a, 0x24);
239
+ const contextMenuPanelShadowColor = panelShadow;
238
240
  const contextMenuItemBackground = rgba(0x00, 0x00, 0x00, 0x00);
239
241
  const contextMenuItemHover = isDark ? rgba(0xff, 0xff, 0xff, 0x0c) : rgba(0x0f, 0x17, 0x2a, 0x08);
240
242
  const contextMenuSeparatorColor = isDark ? rgba(0xff, 0xff, 0xff, 0x10) : rgba(0x0f, 0x17, 0x2a, 0x12);
241
243
  const toolTipPanelBackground = isDark ? rgba(0x11, 0x17, 0x20, 0xf0) : rgba(0xff, 0xff, 0xff, 0xf8);
242
244
  const toolTipPanelBorderColor = isDark ? rgba(0xff, 0xff, 0xff, 0x12) : rgba(0x0f, 0x17, 0x2a, 0x12);
243
- const toolTipPanelShadowColor = isDark ? rgba(0x00, 0x00, 0x00, 0xb8) : rgba(0x0f, 0x17, 0x2a, 0x22);
245
+ const toolTipPanelShadowColor = panelShadow;
244
246
 
245
247
  return new Theme(
246
248
  new Colors(
@@ -257,6 +259,7 @@ export function generateTheme(isDark: bool, accentColor: u32 = DEFAULT_ACCENT_CO
257
259
  scrollbarThumb,
258
260
  dialogBackdrop,
259
261
  dialogShadow,
262
+ panelShadow,
260
263
  focusRing,
261
264
  ),
262
265
  DEFAULT_SPACING,
@@ -623,6 +623,8 @@ export class FlexBox extends Node {
623
623
  let inFlowChildCount = 0;
624
624
  let fullMainAxisPercentChildCount = 0;
625
625
  let mainAxisPercentTotal: f32 = 0.0;
626
+ let firstFullMainAxisPercentChild: Node | null = null;
627
+ let firstFullMainAxisPercentChildIndex: i32 = -1;
626
628
 
627
629
  for (let i = 0; i < this.childNodes.length; ++i) {
628
630
  const child = unchecked(this.childNodes[i]);
@@ -639,6 +641,10 @@ export class FlexBox extends Node {
639
641
  mainAxisPercentTotal += percent;
640
642
  if (percent >= MAIN_AXIS_PERCENT_FULL_THRESHOLD) {
641
643
  fullMainAxisPercentChildCount += 1;
644
+ if (firstFullMainAxisPercentChild === null) {
645
+ firstFullMainAxisPercentChild = child;
646
+ firstFullMainAxisPercentChildIndex = i;
647
+ }
642
648
  }
643
649
  }
644
650
 
@@ -649,7 +655,11 @@ export class FlexBox extends Node {
649
655
  if (fullMainAxisPercentChildCount > 0) {
650
656
  if ((this.layoutWarningMask & LAYOUT_WARNING_FULL_MAIN_AXIS_PERCENT) == 0) {
651
657
  this.layoutWarningMask |= LAYOUT_WARNING_FULL_MAIN_AXIS_PERCENT;
652
- warn("Layout", this.buildFullMainAxisPercentWarning(isRow));
658
+ warn("Layout", this.buildFullMainAxisPercentWarning(
659
+ isRow,
660
+ firstFullMainAxisPercentChild,
661
+ firstFullMainAxisPercentChildIndex,
662
+ ));
653
663
  }
654
664
  return;
655
665
  }
@@ -721,18 +731,56 @@ export class FlexBox extends Node {
721
731
  this.cancelBackgroundColorTransition();
722
732
  }
723
733
 
724
- private buildFullMainAxisPercentWarning(isRow: bool): string {
734
+ private buildFullMainAxisPercentWarning(isRow: bool, child: Node | null, childIndex: i32): string {
735
+ let message = "";
725
736
  if (isRow) {
726
- return "A row container has an in-flow child using width(100.0, Unit.Percent) alongside siblings. Unit.Percent is literal parent-relative sizing, not flex sharing. Use fillWidth() when the child should take remaining row space.";
737
+ message = "A row container has an in-flow child using width(100.0, Unit.Percent) alongside siblings. Unit.Percent is literal parent-relative sizing, not flex sharing. Use fillWidth() when the child should take remaining row space.";
738
+ } else {
739
+ message = "A column container has an in-flow child using height(100.0, Unit.Percent) alongside siblings. Unit.Percent is literal parent-relative sizing, not flex sharing. Use fillHeight() when the child should take remaining column space.";
727
740
  }
728
- return "A column container has an in-flow child using height(100.0, Unit.Percent) alongside siblings. Unit.Percent is literal parent-relative sizing, not flex sharing. Use fillHeight() when the child should take remaining column space.";
741
+ return message + this.buildWarningContextSuffix(child, childIndex);
729
742
  }
730
743
 
731
744
  private buildMainAxisPercentOverflowWarning(isRow: bool): string {
745
+ let message = "";
732
746
  if (isRow) {
733
- return "A row container has in-flow children whose explicit width percentages exceed 100% in total. Unit.Percent is literal parent-relative sizing, not flex sharing. Use fillWidth() for the child that should expand, or reduce the percentages so they fit.";
747
+ message = "A row container has in-flow children whose explicit width percentages exceed 100% in total. Unit.Percent is literal parent-relative sizing, not flex sharing. Use fillWidth() for the child that should expand, or reduce the percentages so they fit.";
748
+ } else {
749
+ message = "A column container has in-flow children whose explicit height percentages exceed 100% in total. Unit.Percent is literal parent-relative sizing, not flex sharing. Use fillHeight() for the child that should expand, or reduce the percentages so they fit.";
750
+ }
751
+ return message + this.buildWarningContextSuffix(null, -1);
752
+ }
753
+
754
+ private buildWarningContextSuffix(child: Node | null, childIndex: i32): string {
755
+ const containerNodeId = this._debugNodeId();
756
+ const childNodeId = child !== null ? child._debugNodeId() : null;
757
+ const containerPath = this._debugTreePath();
758
+ const childPath = child !== null ? child._debugTreePath() : null;
759
+ const hasContainerNodeId = containerNodeId !== null && containerNodeId.length > 0;
760
+ const hasChildNodeId = childNodeId !== null && childNodeId.length > 0;
761
+ const hasChildPath = childPath !== null;
762
+ const hasChildIndex = childIndex >= 0;
763
+ let suffix = " [containerPath=" + containerPath;
764
+ let needsSeparator = true;
765
+ if (hasChildPath) {
766
+ suffix += ", childPath=" + changetype<string>(childPath);
767
+ }
768
+ if (hasContainerNodeId) {
769
+ suffix += ", containerNodeId=" + changetype<string>(containerNodeId);
770
+ needsSeparator = true;
771
+ }
772
+ if (hasChildNodeId) {
773
+ suffix += ", childNodeId=" + changetype<string>(childNodeId);
774
+ needsSeparator = true;
775
+ }
776
+ if (hasChildIndex) {
777
+ if (needsSeparator) {
778
+ suffix += ", ";
779
+ }
780
+ suffix += "childIndex=" + childIndex.toString();
734
781
  }
735
- return "A column container has in-flow children whose explicit height percentages exceed 100% in total. Unit.Percent is literal parent-relative sizing, not flex sharing. Use fillHeight() for the child that should expand, or reduce the percentages so they fit.";
782
+ suffix += "]";
783
+ return suffix;
736
784
  }
737
785
 
738
786
  protected applyVisualStyle(): void {
@@ -18,10 +18,48 @@ const POOL_OVERSCAN_ITEMS: i32 = 2;
18
18
 
19
19
  export type VirtualListBinder = (container: FlexBox, index: i32) => void;
20
20
 
21
+ abstract class VirtualListBinderCallback {
22
+ abstract invoke(container: FlexBox, index: i32): void;
23
+ }
24
+
25
+ class FunctionVirtualListBinderCallback extends VirtualListBinderCallback {
26
+ private readonly handler: VirtualListBinder;
27
+
28
+ constructor(handler: VirtualListBinder) {
29
+ super();
30
+ this.handler = handler;
31
+ }
32
+
33
+ invoke(container: FlexBox, index: i32): void {
34
+ this.handler(container, index);
35
+ }
36
+ }
37
+
38
+ class BoundVirtualListBinderCallback<Owner> extends VirtualListBinderCallback {
39
+ private readonly owner: Owner;
40
+ private readonly handler: (owner: Owner, container: FlexBox, index: i32) => void;
41
+
42
+ constructor(owner: Owner, handler: (owner: Owner, container: FlexBox, index: i32) => void) {
43
+ super();
44
+ this.owner = owner;
45
+ this.handler = handler;
46
+ }
47
+
48
+ invoke(container: FlexBox, index: i32): void {
49
+ this.handler(this.owner, container, index);
50
+ }
51
+ }
52
+
53
+ class MissingVirtualListBinderCallback extends VirtualListBinderCallback {
54
+ invoke(_container: FlexBox, _index: i32): void {
55
+ throw new VirtualListItemBindingError();
56
+ }
57
+ }
58
+
21
59
  export class VirtualList extends FlexBox {
22
60
  private totalItemsValue: i32;
23
61
  private readonly itemHeightValue: f32;
24
- private bindItemValue: VirtualListBinder;
62
+ private bindItemValue: VirtualListBinderCallback;
25
63
  private readonly scrollStateValue: ScrollState;
26
64
  private readonly scrollBoxValue: ScrollBox;
27
65
  private readonly contentValue: FlexBox;
@@ -45,9 +83,7 @@ export class VirtualList extends FlexBox {
45
83
  const poolSizeValue = maxVisible > 0 ? maxVisible + POOL_OVERSCAN_ITEMS : POOL_OVERSCAN_ITEMS;
46
84
  this.totalItemsValue = totalItemsValue;
47
85
  this.itemHeightValue = itemHeightValue;
48
- this.bindItemValue = (): void => {
49
- throw new VirtualListItemBindingError();
50
- };
86
+ this.bindItemValue = new MissingVirtualListBinderCallback();
51
87
  this.scrollStateValue = scrollStateValue;
52
88
  this.poolSizeValue = poolSizeValue;
53
89
 
@@ -63,9 +99,7 @@ export class VirtualList extends FlexBox {
63
99
  .child(topSpacerValue);
64
100
 
65
101
  for (let index = 0; index < poolSizeValue; ++index) {
66
- const container = new FlexBox()
67
- .width(FULL_SIZE, Unit.Percent)
68
- .height(FULL_SIZE, Unit.Percent);
102
+ const container = new FlexBox().fillSize();
69
103
  const rowArea = new SelectionArea()
70
104
  .width(FULL_SIZE, Unit.Percent)
71
105
  .height(0.0, Unit.Pixel)
@@ -81,8 +115,7 @@ export class VirtualList extends FlexBox {
81
115
  .scrollEnabledY(true)
82
116
  .scrollOffset(scrollStateValue.offsetX.value, scrollStateValue.offsetY.value)
83
117
  .scrollContentSize(-1.0, <f32>totalItemsValue * itemHeightValue)
84
- .width(FULL_SIZE, Unit.Percent)
85
- .height(FULL_SIZE, Unit.Percent)
118
+ .fillSize()
86
119
  .child(contentValue) as ScrollBox;
87
120
  scrollStateValue.contentHeight.value = <f32>totalItemsValue * itemHeightValue;
88
121
 
@@ -96,8 +129,7 @@ export class VirtualList extends FlexBox {
96
129
 
97
130
  this.flexDirection(FlexDirection.Column)
98
131
  .child(this.scrollBoxValue)
99
- .width(FULL_SIZE, Unit.Percent)
100
- .height(FULL_SIZE, Unit.Percent);
132
+ .fillSize();
101
133
  this.attachListeners();
102
134
  }
103
135
 
@@ -179,7 +211,7 @@ export class VirtualList extends FlexBox {
179
211
  }
180
212
 
181
213
  onBindItem(renderer: VirtualListBinder): this {
182
- this.bindItemValue = renderer;
214
+ this.bindItemValue = new FunctionVirtualListBinderCallback(renderer);
183
215
  this.currentFirstVisibleIndex = -1;
184
216
  this.currentLastVisibleIndex = -1;
185
217
  this.rebuildVisibleRange(true);
@@ -187,9 +219,7 @@ export class VirtualList extends FlexBox {
187
219
  }
188
220
 
189
221
  onBindItemWith<Owner>(owner: Owner, renderer: (owner: Owner, container: FlexBox, index: i32) => void): this {
190
- this.bindItemValue = (container: FlexBox, index: i32): void => {
191
- renderer(owner, container, index);
192
- };
222
+ this.bindItemValue = new BoundVirtualListBinderCallback<Owner>(owner, renderer);
193
223
  this.currentFirstVisibleIndex = -1;
194
224
  this.currentLastVisibleIndex = -1;
195
225
  this.rebuildVisibleRange(true);
@@ -444,7 +474,7 @@ export class VirtualList extends FlexBox {
444
474
  }
445
475
 
446
476
  private renderItem(container: FlexBox, index: i32): void {
447
- this.bindItemValue(container, index);
477
+ this.bindItemValue.invoke(container, index);
448
478
  }
449
479
 
450
480
  private maxOffsetForCurrentViewport(): f32 {