drawnui-react 0.1.0-preview.4 → 0.1.0-preview.40

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 (105) hide show
  1. package/README.md +119 -14
  2. package/SKIPPED.md +36 -26
  3. package/dist/controls/AnimatedFramesRenderer.d.ts +9 -0
  4. package/dist/controls/AnimatedFramesRenderer.js +18 -1
  5. package/dist/controls/DrawnGame.d.ts +44 -0
  6. package/dist/controls/DrawnGame.js +82 -0
  7. package/dist/controls/GridStructure.d.ts +16 -2
  8. package/dist/controls/GridStructure.js +40 -4
  9. package/dist/controls/SkiaBackdrop.d.ts +8 -2
  10. package/dist/controls/SkiaBackdrop.js +42 -14
  11. package/dist/controls/SkiaButton.d.ts +17 -3
  12. package/dist/controls/SkiaButton.js +26 -8
  13. package/dist/controls/SkiaCarousel.d.ts +22 -3
  14. package/dist/controls/SkiaCarousel.js +85 -9
  15. package/dist/controls/SkiaCheckbox.d.ts +0 -1
  16. package/dist/controls/SkiaCheckbox.js +2 -7
  17. package/dist/controls/SkiaDrawer.d.ts +15 -0
  18. package/dist/controls/SkiaDrawer.js +42 -7
  19. package/dist/controls/SkiaEditor.d.ts +48 -2
  20. package/dist/controls/SkiaEditor.js +268 -53
  21. package/dist/controls/SkiaGif.d.ts +7 -0
  22. package/dist/controls/SkiaGif.js +25 -4
  23. package/dist/controls/SkiaImage.d.ts +5 -0
  24. package/dist/controls/SkiaImage.js +48 -14
  25. package/dist/controls/SkiaLabel.d.ts +117 -9
  26. package/dist/controls/SkiaLabel.js +526 -80
  27. package/dist/controls/SkiaLabelFps.d.ts +16 -0
  28. package/dist/controls/SkiaLabelFps.js +41 -0
  29. package/dist/controls/SkiaLayout.d.ts +89 -9
  30. package/dist/controls/SkiaLayout.js +364 -21
  31. package/dist/controls/SkiaLottie.js +5 -3
  32. package/dist/controls/SkiaProgress.d.ts +2 -1
  33. package/dist/controls/SkiaProgress.js +8 -5
  34. package/dist/controls/SkiaRadioButton.d.ts +2 -0
  35. package/dist/controls/SkiaRadioButton.js +16 -4
  36. package/dist/controls/SkiaRichLabel.d.ts +1 -1
  37. package/dist/controls/SkiaRichLabel.js +11 -1
  38. package/dist/controls/SkiaScroll.d.ts +35 -5
  39. package/dist/controls/SkiaScroll.js +252 -32
  40. package/dist/controls/SkiaScrollBar.d.ts +27 -0
  41. package/dist/controls/SkiaScrollBar.js +51 -2
  42. package/dist/controls/SkiaShaderCarousel.d.ts +11 -1
  43. package/dist/controls/SkiaShaderCarousel.js +27 -5
  44. package/dist/controls/SkiaShape.d.ts +13 -2
  45. package/dist/controls/SkiaShape.js +50 -10
  46. package/dist/controls/SkiaSlider.d.ts +20 -2
  47. package/dist/controls/SkiaSlider.js +61 -7
  48. package/dist/controls/SkiaSprite.d.ts +4 -0
  49. package/dist/controls/SkiaSprite.js +22 -10
  50. package/dist/controls/SkiaSvg.d.ts +4 -0
  51. package/dist/controls/SkiaSvg.js +28 -4
  52. package/dist/controls/SkiaSwitch.d.ts +0 -1
  53. package/dist/controls/SkiaSwitch.js +4 -8
  54. package/dist/controls/SkiaToggle.d.ts +25 -5
  55. package/dist/controls/SkiaToggle.js +58 -5
  56. package/dist/controls/SnappingLayout.d.ts +12 -1
  57. package/dist/controls/SnappingLayout.js +21 -2
  58. package/dist/controls/TooltipStyle.d.ts +52 -0
  59. package/dist/controls/TooltipStyle.js +88 -0
  60. package/dist/core/Accessibility.d.ts +134 -0
  61. package/dist/core/Accessibility.js +675 -9
  62. package/dist/core/Animators.d.ts +37 -1
  63. package/dist/core/Animators.js +102 -9
  64. package/dist/core/Canvas.d.ts +222 -10
  65. package/dist/core/Canvas.js +698 -37
  66. package/dist/core/ControlStyle.d.ts +2 -0
  67. package/dist/core/ControlStyle.js +2 -0
  68. package/dist/core/Easing.d.ts +12 -1
  69. package/dist/core/Easing.js +25 -1
  70. package/dist/core/Gestures.d.ts +81 -2
  71. package/dist/core/Gestures.js +177 -3
  72. package/dist/core/Hover.d.ts +51 -0
  73. package/dist/core/Hover.js +140 -0
  74. package/dist/core/ImageEffects.d.ts +2 -0
  75. package/dist/core/ImageEffects.js +2 -0
  76. package/dist/core/KeyboardManager.d.ts +40 -0
  77. package/dist/core/KeyboardManager.js +98 -8
  78. package/dist/core/PopupWindows.d.ts +94 -0
  79. package/dist/core/PopupWindows.js +205 -0
  80. package/dist/core/ScrollAnimators.js +9 -0
  81. package/dist/core/Shaping.d.ts +40 -0
  82. package/dist/core/Shaping.js +224 -0
  83. package/dist/core/SkiaControl.d.ts +279 -10
  84. package/dist/core/SkiaControl.js +621 -64
  85. package/dist/core/SkiaEffect.d.ts +17 -0
  86. package/dist/core/SkiaEffect.js +43 -8
  87. package/dist/core/SkiaImageManager.js +1 -1
  88. package/dist/core/Super.d.ts +29 -2
  89. package/dist/core/Super.js +54 -3
  90. package/dist/core/Tooltips.d.ts +71 -0
  91. package/dist/core/Tooltips.js +205 -0
  92. package/dist/core/Types.d.ts +11 -1
  93. package/dist/core/Types.js +32 -1
  94. package/dist/core/ViewsAdapter.d.ts +7 -2
  95. package/dist/core/ViewsAdapter.js +10 -3
  96. package/dist/index.d.ts +6 -0
  97. package/dist/index.js +6 -0
  98. package/dist/react/SkiaShell.js +65 -26
  99. package/dist/react/index.d.ts +33 -4
  100. package/dist/react/index.js +157 -18
  101. package/dist/react/reconciler.d.ts +20 -0
  102. package/dist/react/reconciler.js +69 -14
  103. package/dist/vite/index.d.ts +9 -0
  104. package/dist/vite/index.js +36 -3
  105. package/package.json +61 -2
@@ -2,19 +2,95 @@ import { SkiaControl } from "../core/SkiaControl";
2
2
  import { ViewsAdapter } from "../core/ViewsAdapter";
3
3
  import { SKRect, ScaledSize, Thickness } from "../core/Types";
4
4
  import { SkiaGridStructure } from "./GridStructure";
5
+ /**
6
+ * The place of one item in a recycled templated Row / Wrap / Grid / split Column. C# measures the structure on one
7
+ * template instance bound to each item in turn: Measure here binds a pooled view to the item, keeps its size, the
8
+ * constraints and what the template decided for that item, then gives the view back unless the item is on screen.
9
+ * The same item measured again with the same constraints keeps its size without a rebind (as the list keeps its item
10
+ * heights: a new ItemsSource array is how content changes). Arrange only records the slot; the drawing pass binds a
11
+ * view to each slot it draws.
12
+ */
13
+ class TemplatedSlot {
14
+ Index;
15
+ factory;
16
+ IsVisible = true;
17
+ Row = 0;
18
+ Column = 0;
19
+ RowSpan = 1;
20
+ ColumnSpan = 1;
21
+ HorizontalOptions = "Start";
22
+ VerticalOptions = "Start";
23
+ Margin = Thickness.Zero;
24
+ WidthRequest = -1;
25
+ HeightRequest = -1;
26
+ MinimumWidthRequest = -1;
27
+ MinimumHeightRequest = -1;
28
+ MeasuredSize = ScaledSize.Default;
29
+ /** The view's fit-content size from the same measure (SkiaControl.FitPixels). */
30
+ FitPixels = { Width: 0, Height: 0 };
31
+ WidthConstraint = Infinity;
32
+ HeightConstraint = Infinity;
33
+ /** The rect the layout arranged this slot in (pixels). */
34
+ Destination = SKRect.Empty;
35
+ /** The view last arranged in this slot and the Destination it got, so an unchanged view is not arranged twice. */
36
+ ArrangedView;
37
+ ArrangedFor;
38
+ measuredItem;
39
+ measuredScale = 0;
40
+ constructor(Index, factory) {
41
+ this.Index = Index;
42
+ this.factory = factory;
43
+ }
44
+ Measure(widthConstraint, heightConstraint, scale) {
45
+ const shown = this.factory.GetViewForIndex(this.Index), item = this.factory.Items[this.Index];
46
+ if (!shown && item === this.measuredItem && scale === this.measuredScale
47
+ && Object.is(widthConstraint, this.WidthConstraint) && Object.is(heightConstraint, this.HeightConstraint))
48
+ return this.MeasuredSize;
49
+ const view = shown ?? this.factory.GetOrCreateViewForIndex(this.Index, true);
50
+ if (!view) {
51
+ this.FitPixels = { Width: 0, Height: 0 };
52
+ return (this.MeasuredSize = ScaledSize.Default);
53
+ }
54
+ this.MeasuredSize = view.Measure(widthConstraint, heightConstraint, scale);
55
+ this.FitPixels = view.FitPixels;
56
+ this.measuredItem = item;
57
+ this.measuredScale = scale;
58
+ this.WidthConstraint = widthConstraint;
59
+ this.HeightConstraint = heightConstraint;
60
+ this.IsVisible = view.IsVisible;
61
+ this.RowSpan = view.RowSpan;
62
+ this.ColumnSpan = view.ColumnSpan;
63
+ this.HorizontalOptions = view.HorizontalOptions;
64
+ this.VerticalOptions = view.VerticalOptions;
65
+ this.Margin = view.Margin;
66
+ this.WidthRequest = view.WidthRequest;
67
+ this.HeightRequest = view.HeightRequest;
68
+ this.MinimumWidthRequest = view.MinimumWidthRequest;
69
+ this.MinimumHeightRequest = view.MinimumHeightRequest;
70
+ if (!shown)
71
+ this.factory.ReleaseViewAt(this.Index);
72
+ return this.MeasuredSize;
73
+ }
74
+ Arrange(destination, _widthRequest, _heightRequest, _scale) { this.Destination = destination; }
75
+ }
5
76
  /**
6
77
  * Mirrors DrawnUi SkiaLayout (Absolute / Column / Row / Wrap / Grid).
7
78
  * Column/Row give children an infinite main axis (MAUI stack semantics: Fill on the main axis = auto-sized).
8
79
  *
9
- * Templated mode (ItemsSource + ItemTemplate) is a Column only: cells are created through the ViewsAdapter for
10
- * the indexes inside the visible viewport (+ VirtualisationInflated), everything else is arithmetic —
11
- * MeasureFirst measures one cell and assumes uniform size, MeasureAll measures every item once.
80
+ * Templated mode (ItemsSource + ItemTemplate): a single-column Column is the virtualized list, cells are created through
81
+ * the ViewsAdapter for the indexes inside the visible viewport (+ VirtualisationInflated), everything else is arithmetic —
82
+ * MeasureAll (default) measures every item once, MeasureFirst measures one cell and assumes uniform size. A templated
83
+ * Row / Wrap / Grid / split Column follows RecyclingTemplate: Enabled measures every item on pooled views and binds views
84
+ * only to the slots drawn, Disabled keeps one view per item.
12
85
  */
13
86
  export class SkiaLayout extends SkiaControl {
14
87
  /** Layout type. SkiaShape redeclares it as ShapeType (any shape value lays out as Absolute), like the C# hidden Type. */
15
88
  Type = "Absolute";
16
89
  Spacing = 0;
17
- Padding = Thickness.Zero;
90
+ padding = Thickness.Zero;
91
+ /** Space inside the layout around its children (points); a number is the same on every side (`Thickness.From`). */
92
+ get Padding() { return this.padding; }
93
+ set Padding(v) { this.padding = Thickness.From(v); }
18
94
  // ---- grid (same names as DrawnUi; definitions as "*, 2*, Auto, 100" or an array) ----
19
95
  ColumnDefinitions;
20
96
  RowDefinitions;
@@ -26,7 +102,16 @@ export class SkiaLayout extends SkiaControl {
26
102
  /** Structure computed by the last measure; cells are arranged from it. */
27
103
  GridStructure;
28
104
  // ---- templated children (same names as DrawnUi) ----
29
- RecyclingTemplate = "Enabled";
105
+ recyclingTemplate = "Enabled";
106
+ /** Enabled: views come from a pool and are bound to the items being drawn; Disabled: one view per item, never rebound. */
107
+ get RecyclingTemplate() { return this.recyclingTemplate; }
108
+ set RecyclingTemplate(value) {
109
+ if (this.recyclingTemplate === value)
110
+ return;
111
+ this.recyclingTemplate = value;
112
+ if (this.itemTemplate)
113
+ this.ApplyItemsSource(); // the pool follows the mode
114
+ }
30
115
  /** Column count for Column / Wrap content and a templated Grid (0 = free flow); C# Split. */
31
116
  Split = 0;
32
117
  /** Split > 0: every slot keeps the same width (true) or the cell keeps its measured width (C# SplitAlign). */
@@ -35,7 +120,8 @@ export class SkiaLayout extends SkiaControl {
35
120
  DynamicColumns = false;
36
121
  /** Templated Grid: fill column-major (top to bottom, then next column) instead of row-major (C# Invert). */
37
122
  Invert = false;
38
- MeasureItemsStrategy = "MeasureFirst";
123
+ /** Default MeasureAll (DrawnUi 1.10.6.20): every item keeps its own size; MeasureFirst is explicit uniform rows. */
124
+ MeasureItemsStrategy = "MeasureAll";
39
125
  /** Realized views per item (Disabled) or a recycled pool for the visible range (Enabled). */
40
126
  ChildrenFactory = new ViewsAdapter(this);
41
127
  FirstVisibleIndex = -1;
@@ -43,7 +129,7 @@ export class SkiaLayout extends SkiaControl {
43
129
  itemsSource;
44
130
  itemTemplate;
45
131
  structureDirty = true;
46
- /** Per-item heights in pixels (MeasureAll) or a single uniform height (MeasureFirst). */
132
+ /** Per-item heights in pixels (MeasureAll, the default) or a single uniform height (MeasureFirst). */
47
133
  itemHeights = [];
48
134
  uniformHeight = 0;
49
135
  measuredWidthPx = 0;
@@ -66,7 +152,7 @@ export class SkiaLayout extends SkiaControl {
66
152
  return;
67
153
  const old = this.itemsSource;
68
154
  this.itemsSource = value;
69
- if (value && old && this.IsTemplated && !this.structureDirty && this.ApplyIncrementalChange(old, value)) {
155
+ if (value && old && this.IsTemplated && !this.IsMasonry && !this.structureDirty && this.ApplyIncrementalChange(old, value)) {
70
156
  this.InvalidateMeasure();
71
157
  return;
72
158
  }
@@ -215,13 +301,29 @@ export class SkiaLayout extends SkiaControl {
215
301
  this.ApplyItemsSource();
216
302
  }
217
303
  get IsTemplated() { return !!this.itemTemplate && !!this.itemsSource; }
218
- /** The virtualized list case: a templated single-column Column. Templated Row / Wrap / Grid realize every item. */
304
+ /** The virtualized list case: a templated single-column Column. */
219
305
  get IsTemplatedList() { return this.IsTemplated && this.Type === "Column" && this.Split <= 1; }
220
- /** Views taking part in the layout pass: static children, or every item of a templated Row / Wrap / Grid (C# non-list layouts are not virtualized). */
306
+ /** A templated Row / Wrap / Grid / split Column with RecyclingTemplate Enabled: slots measured on pooled views, views bound to the slots drawn. */
307
+ get IsRecycledLayout() { return this.IsTemplated && !this.IsTemplatedList && this.recyclingTemplate === "Enabled"; }
308
+ /** Slots of a recycled layout, one per item. */
309
+ slots;
310
+ /**
311
+ * What the layout pass measures and arranges: static children; the slots of a recycled templated layout; or, with
312
+ * RecyclingTemplate Disabled, one realized view per item.
313
+ */
221
314
  LayoutViews() {
222
315
  if (!this.IsTemplated)
223
316
  return this.views;
224
- const n = this.itemsSource.length, out = [];
317
+ const n = this.itemsSource.length;
318
+ if (this.IsRecycledLayout) {
319
+ if (this.slots?.length !== n) {
320
+ // a masonry keeps the slots it has: an appended page (LoadMore) measures only the new items
321
+ const keep = this.IsMasonry ? this.slots ?? [] : [];
322
+ this.slots = Array.from({ length: n }, (_, i) => keep[i] ?? new TemplatedSlot(i, this.ChildrenFactory));
323
+ }
324
+ return this.slots;
325
+ }
326
+ const out = [];
225
327
  for (let i = 0; i < n; i++) {
226
328
  const v = this.ChildrenFactory.GetOrCreateViewForIndex(i);
227
329
  if (v)
@@ -231,7 +333,8 @@ export class SkiaLayout extends SkiaControl {
231
333
  }
232
334
  /** Drops realized cells and rebuilds the structure (DrawnUi ApplyItemsSource). */
233
335
  ApplyItemsSource() {
234
- this.ChildrenFactory.Initialize(this.itemTemplate, this.itemsSource ?? [], this.RecyclingTemplate);
336
+ this.ChildrenFactory.Initialize(this.itemTemplate, this.itemsSource ?? [], this.recyclingTemplate);
337
+ this.slots = undefined;
235
338
  this.structureDirty = true;
236
339
  this.InvalidateMeasure();
237
340
  }
@@ -267,11 +370,69 @@ export class SkiaLayout extends SkiaControl {
267
370
  get Views() { return this.IsTemplated ? this.ChildrenFactory.GetViewsInUse() : this.views; }
268
371
  /** Settable children list like DrawnUi Children (ignored while templated). */
269
372
  get Children() { return this.views; }
373
+ /**
374
+ * C# Children reset (ChildrenCollectionSync, 66a1eb02): the app's children the new list no longer holds are removed,
375
+ * the ones it gained are added, then all of them take the list's order inside the slots app children occupy, so the
376
+ * parts a control made itself keep their place.
377
+ */
270
378
  set Children(value) {
379
+ const keep = new Set(value);
380
+ for (const v of [...this.views])
381
+ if (v.IsChildrenItem && !keep.has(v))
382
+ this.RemoveSubView(v);
383
+ const inViews = new Set(this.views);
384
+ for (const v of value) {
385
+ v.IsChildrenItem = true;
386
+ if (!inViews.has(v))
387
+ this.AddSubView(v);
388
+ }
389
+ this.OrderChildren(value);
390
+ }
391
+ /**
392
+ * C# Insert / Move of a Children collection (the reconciler's appendChild / insertBefore): `child` goes before
393
+ * `before` among the app's children, or last without it. A new child is attached at the end of the views and an
394
+ * append stops there; otherwise the app's children take their new order inside the slots they occupy.
395
+ */
396
+ InsertChild(child, before) {
397
+ child.IsChildrenItem = true;
398
+ const attached = child.Parent === this && this.views.includes(child);
399
+ if (!attached)
400
+ this.AddSubView(child);
401
+ if (!attached && !before)
402
+ return;
403
+ const order = this.views.filter((v) => v.IsChildrenItem && v !== child);
404
+ const at = before ? order.indexOf(before) : -1;
405
+ order.splice(at < 0 ? order.length : at, 0, child);
406
+ this.OrderChildren(order);
407
+ }
408
+ /** C# OrderViews: the given children, in their order, inside the slots they occupy in the views; nothing else moves. */
409
+ OrderChildren(ordered) {
410
+ const inViews = new Set(this.views);
411
+ const present = ordered.filter((v) => inViews.delete(v));
412
+ if (present.length < 2)
413
+ return;
414
+ const isChild = new Set(present);
415
+ let next = 0, changed = false;
416
+ for (let i = 0; i < this.views.length && next < present.length; i++) {
417
+ if (!isChild.has(this.views[i]))
418
+ continue;
419
+ if (this.views[i] !== present[next]) {
420
+ this.views[i] = present[next];
421
+ changed = true;
422
+ }
423
+ next++;
424
+ }
425
+ if (changed) {
426
+ this.orderedViews = undefined;
427
+ this.InvalidateMeasure();
428
+ }
429
+ }
430
+ /** A child showing text (a caption inside a button) is text of its own: the accessibility label then makes no tooltip. */
431
+ ShowsText() { return this.views.some((v) => v.ShowsText()); }
432
+ /** C# ClearChildren: removes every subview, the control's own parts included. */
433
+ ClearChildren() {
271
434
  for (const v of [...this.views])
272
435
  this.RemoveSubView(v);
273
- for (const v of value)
274
- this.AddSubView(v);
275
436
  }
276
437
  orderedViews;
277
438
  /** Static children sorted by ZIndex (stable), computed once per change (C# GetOrderedSubviews). */
@@ -298,10 +459,18 @@ export class SkiaLayout extends SkiaControl {
298
459
  }
299
460
  AddSubView(control) { this.InsertSubView(this.views.length, control); }
300
461
  InsertSubView(index, control) {
462
+ // already a child: a move (React reorders keyed children by inserting an existing one elsewhere), never a 2nd copy
463
+ const at = control.Parent === this ? this.views.indexOf(control) : -1;
464
+ if (at >= 0) {
465
+ this.views.splice(at, 1);
466
+ if (at < index)
467
+ index--;
468
+ }
301
469
  control.Parent = this;
302
- this.views.splice(index, 0, control);
470
+ this.views.splice(Math.min(Math.max(0, index), this.views.length), 0, control);
303
471
  this.orderedViews = undefined;
304
472
  this.InvalidateMeasure();
473
+ this.Superview?.Hover?.RequestCheck(); // a popup / page under a still mouse
305
474
  }
306
475
  RemoveSubView(control) {
307
476
  const i = this.views.indexOf(control);
@@ -309,8 +478,11 @@ export class SkiaLayout extends SkiaControl {
309
478
  return;
310
479
  this.views.splice(i, 1);
311
480
  this.orderedViews = undefined;
481
+ const canvas = this.Superview;
482
+ canvas?.ControlLeft(control, false);
312
483
  control.Parent = undefined;
313
484
  this.InvalidateMeasure();
485
+ canvas?.Hover?.RequestCheck();
314
486
  }
315
487
  // ---- measure ----
316
488
  MeasureAbsolute(widthConstraint, heightConstraint, scale) {
@@ -326,10 +498,17 @@ export class SkiaLayout extends SkiaControl {
326
498
  const s = this.MeasureWrap(w, scale);
327
499
  return ScaledSize.FromPixels(s.w + px, s.h + py, scale);
328
500
  }
501
+ if (this.IsMasonry) {
502
+ const s = this.MeasureMasonry(w, scale);
503
+ return ScaledSize.FromPixels(s.w + px, s.h + py, scale);
504
+ }
329
505
  if (this.Type === "Grid") {
330
506
  const s = this.MeasureGrid(w, h, scale);
331
507
  return ScaledSize.FromPixels(s.w + px, s.h + py, scale);
332
508
  }
509
+ // fit-content of the children on the cross axis (Fill children included, drawnui-cross 6an)
510
+ let fitW = 0, fitH = 0;
511
+ const visible = [];
333
512
  for (const v of this.LayoutViews()) {
334
513
  if (!v.IsVisible)
335
514
  continue;
@@ -349,13 +528,42 @@ export class SkiaLayout extends SkiaControl {
349
528
  cw = Math.max(cw, s.Pixels.Width);
350
529
  ch = Math.max(ch, s.Pixels.Height);
351
530
  }
531
+ fitW = Math.max(fitW, v.FitPixels.Width);
532
+ fitH = Math.max(fitH, v.FitPixels.Height);
533
+ visible.push(v);
352
534
  n++;
353
535
  }
536
+ // a stack that sizes itself on its cross axis (no request, not Fill, or Fill on an unbounded axis) is as wide / tall
537
+ // as its widest / tallest child needs; its Fill children are measured again at that size, so their wrapped heights /
538
+ // widths are the drawn ones
539
+ if (this.Type === "Column" && (this.HorizontalOptions !== "Fill" || !isFinite(w)) && this.WidthRequest < 0 && this.LockRatio === 0) {
540
+ const size = isFinite(w) ? Math.min(fitW, w) : fitW;
541
+ if (size !== cw) {
542
+ cw = size;
543
+ ch = 0;
544
+ for (const v of visible)
545
+ ch += (v.HorizontalOptions === "Fill" && v.WidthRequest < 0 ? v.Measure(size, Infinity, scale) : v.MeasuredSize).Pixels.Height;
546
+ }
547
+ }
548
+ else if (this.Type === "Row" && (this.VerticalOptions !== "Fill" || !isFinite(h)) && this.HeightRequest < 0 && this.LockRatio === 0) {
549
+ const size = isFinite(h) ? Math.min(fitH, h) : fitH;
550
+ if (size !== ch) {
551
+ ch = size;
552
+ cw = 0;
553
+ for (const v of visible)
554
+ cw += (v.VerticalOptions === "Fill" && v.HeightRequest < 0 ? v.Measure(Infinity, size, scale) : v.MeasuredSize).Pixels.Width;
555
+ }
556
+ }
354
557
  const gaps = Math.max(0, n - 1) * gap;
355
558
  if (this.Type === "Column")
356
559
  ch += gaps;
357
560
  if (this.Type === "Row")
358
561
  cw += gaps;
562
+ // what this layout's own content needs, for a stack around it (a Fill layout still returns the whole constraint)
563
+ this.fitContentPixels = {
564
+ Width: (this.Type === "Row" ? cw : Math.min(cw, fitW)) + px,
565
+ Height: (this.Type === "Column" ? ch : Math.min(ch, fitH)) + py,
566
+ };
359
567
  return ScaledSize.FromPixels(cw + px, ch + py, scale);
360
568
  }
361
569
  /** Wrap rows computed by the last measure: [childIndex, x, y, w, h] in pixels relative to the padded box. */
@@ -416,6 +624,60 @@ export class SkiaLayout extends SkiaControl {
416
624
  finishRow(true);
417
625
  return { w: maxW, h: this.wrapSlots.length ? y + rowH : 0 };
418
626
  }
627
+ get IsMasonry() { return this.Type === "Masonry"; }
628
+ /**
629
+ * C# MeasureMasonry / BuildMasonryLayout: Split columns of equal width, every item measured unbounded at the column
630
+ * width and put at the bottom of the shortest column (the first on a tie), so items of different heights leave no
631
+ * gaps; Spacing between columns and between items. Every item is laid out (no items window). A templated slot keeps
632
+ * the size of its item, so an appended page or an item that asked to be measured again (an image arrived) is the only
633
+ * one measured, and every item is placed again from the sizes known.
634
+ */
635
+ MeasureMasonry(width, scale) {
636
+ const columns = Math.max(1, this.Split);
637
+ const spacing = Math.round(this.Spacing * scale);
638
+ const columnWidth = columns > 1 ? Math.round((width - (columns - 1) * this.Spacing * scale) / columns) : width;
639
+ const bottoms = new Array(columns).fill(0), rows = new Array(columns).fill(0);
640
+ this.wrapSlots = [];
641
+ for (const v of this.LayoutViews()) {
642
+ if (!v.IsVisible)
643
+ continue;
644
+ let column = 0;
645
+ for (let c = 1; c < columns; c++)
646
+ if (bottoms[c] < bottoms[column])
647
+ column = c;
648
+ const h = v.Measure(columnWidth, Infinity, scale).Pixels.Height;
649
+ const x = column * (columnWidth + spacing), y = bottoms[column] + (rows[column]++ > 0 ? spacing : 0);
650
+ this.wrapSlots.push({ view: v, x, y, w: columnWidth, h });
651
+ bottoms[column] = y + h;
652
+ }
653
+ const used = Math.min(columns, this.wrapSlots.length);
654
+ return { w: used > 0 ? used * columnWidth + (used - 1) * spacing : 0, h: Math.max(0, ...bottoms) };
655
+ }
656
+ /**
657
+ * Where item `index` of a recycled templated Row / Wrap / Grid / split Column / Masonry was arranged (pixels), from
658
+ * its slot, also while no view shows it (ScrollToIndex to an item off screen); undefined otherwise.
659
+ */
660
+ GetItemRect(index) {
661
+ if (!this.IsRecycledLayout)
662
+ return undefined;
663
+ const d = this.slots?.[index]?.Destination;
664
+ return d && d.Width > 0 ? d : undefined;
665
+ }
666
+ /**
667
+ * Masonry: every placed item with its rect (pixels), in item order: what keyboard navigation follows, since the
668
+ * columns have uneven heights and the item `Split` places later is rarely under the focused one.
669
+ */
670
+ GetMasonryPlacement() {
671
+ if (!this.IsMasonry)
672
+ return [];
673
+ const r = this.DrawingRect, p = this.Padding, s = this.RenderingScale, left = r.Left + p.Left * s, top = r.Top + p.Top * s;
674
+ return this.wrapSlots.map((w) => ({
675
+ Index: w.view instanceof TemplatedSlot ? w.view.Index : this.IsTemplated ? w.view.ContextIndex : this.views.indexOf(w.view),
676
+ Rect: SKRect.Create(left + w.x, top + w.y, w.w, w.h),
677
+ }));
678
+ }
679
+ /** Masonry: where the slot of item `index` was arranged (pixels); see GetItemRect. */
680
+ GetMasonryItemRect(index) { return this.IsMasonry ? this.GetItemRect(index) : undefined; }
419
681
  /** Port of C# MeasureGrid: build the structure in points, stretch the last track when the grid fills, remeasure at final cells. */
420
682
  MeasureGrid(widthPx, heightPx, scale) {
421
683
  const wPts = widthPx / scale, hPts = heightPx / scale;
@@ -434,7 +696,7 @@ export class SkiaLayout extends SkiaControl {
434
696
  }
435
697
  });
436
698
  }
437
- const g = new SkiaGridStructure(this, wPts, hPts, scale);
699
+ const g = new SkiaGridStructure(this, wPts, hPts, scale, this.LayoutViews());
438
700
  g.DecompressStars(wPts, hPts);
439
701
  const needAutoWidth = this.WidthRequest < 0 && this.HorizontalOptions !== "Fill";
440
702
  const needAutoHeight = this.HeightRequest < 0 && this.VerticalOptions !== "Fill";
@@ -574,6 +836,11 @@ export class SkiaLayout extends SkiaControl {
574
836
  this.ChildrenFactory.ReleaseViewAt(index);
575
837
  return h;
576
838
  }
839
+ /**
840
+ * The item's offset and height are real, not estimated (C# LastMeasuredIndexLocal >= index): MeasureVisible knows
841
+ * them once the measured prefix passed the item; the other strategies always do.
842
+ */
843
+ IsItemMeasured(index) { return !this.IsTemplatedList || this.MeasureItemsStrategy !== "MeasureVisible" || index < this.mvMeasured; }
577
844
  /** Pixel offset of item index from the top of the layout content (inside padding). */
578
845
  GetItemOffsetPixels(index) {
579
846
  const scale = this.RenderingScale;
@@ -599,13 +866,29 @@ export class SkiaLayout extends SkiaControl {
599
866
  OnLayoutChanged() {
600
867
  if (this.IsTemplatedList)
601
868
  return; // cells are arranged per frame for the visible range only
869
+ this.ArrangeChildren();
870
+ // views on screen follow their slots also when a cache above skips the drawing pass (gestures, accessibility)
871
+ if (this.IsRecycledLayout) {
872
+ const scale = this.RenderingScale;
873
+ for (const v of this.ChildrenFactory.GetViewsInUse()) {
874
+ const s = this.slots?.[v.ContextIndex];
875
+ if (s) {
876
+ v.Arrange(s.Destination, v.WidthRequest, v.HeightRequest, scale);
877
+ s.ArrangedView = v;
878
+ s.ArrangedFor = s.Destination;
879
+ }
880
+ }
881
+ }
882
+ }
883
+ /** Static children and realized views are arranged; the slots of a recycled layout record where their item goes. */
884
+ ArrangeChildren() {
602
885
  const scale = this.RenderingScale;
603
886
  const p = this.Padding;
604
887
  const r = this.DrawingRect;
605
888
  const inner = new SKRect(r.Left + p.Left * scale, r.Top + p.Top * scale, r.Right - p.Right * scale, r.Bottom - p.Bottom * scale);
606
889
  const gap = this.Spacing * scale;
607
890
  let cursor = this.Type === "Row" ? inner.Left : inner.Top;
608
- if (this.IsWrapFlow) {
891
+ if (this.IsWrapFlow || this.IsMasonry) {
609
892
  for (const s of this.wrapSlots)
610
893
  s.view.Arrange(SKRect.Create(inner.Left + s.x, inner.Top + s.y, s.w, s.h), s.view.WidthRequest, s.view.HeightRequest, scale);
611
894
  return;
@@ -645,12 +928,68 @@ export class SkiaLayout extends SkiaControl {
645
928
  this.PaintTemplated(ctx);
646
929
  return;
647
930
  }
931
+ if (this.IsRecycledLayout) {
932
+ this.PaintSlots(ctx);
933
+ return;
934
+ }
648
935
  const composing = this.IsRenderingWithComposition;
649
- for (const v of this.GetOrderedSubviews())
650
- if (!composing || this.DirtyChildrenInternal.has(v))
651
- v.Render(ctx);
936
+ for (const v of this.GetOrderedSubviews()) {
937
+ if (composing && !this.DirtyChildrenInternal.has(v))
938
+ continue;
939
+ v.Render(ctx); // a child entirely outside the clip skips itself
940
+ }
941
+ }
942
+ GetCompositeChildren() { return this.IsTemplatedList || this.IsRecycledLayout ? [] : this.GetOrderedSubviews(); }
943
+ drawnSlots = new Set();
944
+ /**
945
+ * Recycled templated layout (C# DrawStack): a view from the pool is bound to each slot that can be seen and drawn
946
+ * there; the views of the other slots go back to the pool.
947
+ */
948
+ PaintSlots(ctx) {
949
+ const slots = this.slots ?? [], f = this.ChildrenFactory, scale = this.RenderingScale, area = this.SlotsArea();
950
+ const drawn = this.drawnSlots;
951
+ drawn.clear();
952
+ for (const s of slots) {
953
+ const d = s.Destination;
954
+ if (s.IsVisible && d.Right > area.Left && d.Left < area.Right && d.Bottom > area.Top && d.Top < area.Bottom)
955
+ drawn.add(s.Index);
956
+ }
957
+ f.ReleaseExcept(drawn);
958
+ this.FirstVisibleIndex = this.LastVisibleIndex = -1;
959
+ for (const i of drawn) {
960
+ const s = slots[i], view = f.GetOrCreateViewForIndex(i, true);
961
+ if (!view)
962
+ continue;
963
+ // a view last measured for another item is measured for this one; the whole size is compared because a Wrap has
964
+ // no main-axis size key (C# 3d7bd78f)
965
+ const has = view.MeasuredSize.Pixels, want = s.MeasuredSize.Pixels;
966
+ if (Math.abs(has.Width - want.Width) > 1 || Math.abs(has.Height - want.Height) > 1)
967
+ view.NeedMeasure = true;
968
+ const size = view.MeasuredSize;
969
+ view.Measure(s.WidthConstraint, s.HeightConstraint, scale);
970
+ if (s.ArrangedView !== view || s.ArrangedFor !== s.Destination || view.MeasuredSize !== size) {
971
+ view.Arrange(s.Destination, view.WidthRequest, view.HeightRequest, scale);
972
+ s.ArrangedView = view;
973
+ s.ArrangedFor = s.Destination;
974
+ }
975
+ view.Render(ctx);
976
+ if (this.FirstVisibleIndex < 0)
977
+ this.FirstVisibleIndex = i;
978
+ this.LastVisibleIndex = i;
979
+ }
980
+ }
981
+ /**
982
+ * Where slots are drawn (C# GetOnScreenVisibleArea): what can be seen, inflated by VirtualisationInflated. Under a
983
+ * cache (this layout's or an ancestor's, below the nearest scroll) every slot, because the cache is blitted later at
984
+ * other offsets.
985
+ */
986
+ SlotsArea() {
987
+ for (let c = this; c && !("ViewportOffsetY" in c); c = c.Parent)
988
+ if (c.UsingCacheType !== "None")
989
+ return this.DrawingRect;
990
+ const v = this.GetVisibleViewport(), inflate = this.VirtualisationInflated * this.RenderingScale;
991
+ return new SKRect(v.Left - inflate, v.Top - inflate, v.Right + inflate, v.Bottom + inflate);
652
992
  }
653
- GetCompositeChildren() { return this.IsTemplatedList ? [] : this.GetOrderedSubviews(); }
654
993
  /** Realizes, binds, arranges and draws only the cells intersecting the visible viewport (+ inflation). */
655
994
  PaintTemplated(ctx) {
656
995
  const items = this.itemsSource;
@@ -780,6 +1119,10 @@ export class SkiaLayer extends SkiaLayout {
780
1119
  export class SkiaGrid extends SkiaLayout {
781
1120
  constructor() { super(); this.Type = "Grid"; this.HorizontalOptions = "Fill"; }
782
1121
  }
1122
+ /** SkiaLayout Type=Masonry + Split 2 + HorizontalOptions=Fill (DrawnUi alias): columns, each item to the shortest one. */
1123
+ export class SkiaMasonry extends SkiaLayout {
1124
+ constructor() { super(); this.Type = "Masonry"; this.Split = 2; this.HorizontalOptions = "Fill"; }
1125
+ }
783
1126
  /** SkiaLayout Type=Wrap + HorizontalOptions=Fill (DrawnUi alias): responsive flow of fixed-size children. */
784
1127
  export class SkiaWrap extends SkiaLayout {
785
1128
  constructor() { super(); this.Type = "Wrap"; this.HorizontalOptions = "Fill"; }
@@ -32,7 +32,9 @@ export class SkiaLottie extends AnimatedFramesRenderer {
32
32
  Animation;
33
33
  constructor() {
34
34
  super();
35
- this.UseCache = "ImageDoubleBuffered";
35
+ // C# ImageDoubleBuffered pays off where a thread bakes the bitmap; on the web it is one offscreen pass per frame
36
+ // while playing, so the web engines default to Operations (drawnui-cross rule 3)
37
+ this.UseCache = "Operations";
36
38
  }
37
39
  get Source() { return this.source; }
38
40
  set Source(v) { if (this.source !== v) {
@@ -121,7 +123,7 @@ export class SkiaLottie extends AnimatedFramesRenderer {
121
123
  if (!this.Animation || !this.Animator)
122
124
  return;
123
125
  const durationMs = this.Animation.duration() * 1000;
124
- this.Animator.Speed = this.SpeedRatio < 1 ? durationMs * (1 + this.SpeedRatio) : durationMs / this.SpeedRatio;
126
+ this.Animator.Speed = this.GetPlaybackDurationMs(durationMs);
125
127
  }
126
128
  OnAnimatorInitializing() {
127
129
  if (!this.Animation || !this.Animator)
@@ -174,7 +176,7 @@ export class SkiaLottie extends AnimatedFramesRenderer {
174
176
  return Promise.resolve(cached);
175
177
  let p = SkiaLottie.inFlight.get(source);
176
178
  if (!p) {
177
- p = fetch(source).then(async (r) => { if (!r.ok)
179
+ p = fetch(Super.ResolveAssetUrl(source)).then(async (r) => { if (!r.ok)
178
180
  throw new Error(`${r.status} ${source}`); const json = await r.text(); SkiaLottie.CachedAnimations.set(source, json); return json; })
179
181
  .finally(() => SkiaLottie.inFlight.delete(source));
180
182
  SkiaLottie.inFlight.set(source, p);
@@ -36,5 +36,6 @@ export declare class SkiaProgress extends SkiaControl {
36
36
  get Ratio(): number;
37
37
  protected MeasureAbsolute(w: number, _h: number, scale: number): ScaledSize;
38
38
  protected Paint(ctx: DrawingContext): void;
39
- protected DefaultAccessibilityLabel(): string | undefined;
39
+ /** Value between Min and Max, read as "65%"; the name is the app's AccessibilityLabel only (drawnui-cross 6c). */
40
+ get AccessibilityValue(): import("../core/Accessibility").AccessibilityValue;
40
41
  }
@@ -1,6 +1,6 @@
1
1
  import { SkiaControl } from "../core/SkiaControl";
2
2
  import { Super } from "../core/Super";
3
- import { ResolveControlStyle } from "../core/ControlStyle";
3
+ import { DefaultAccent, ResolveControlStyle } from "../core/ControlStyle";
4
4
  import { ScaledSize } from "../core/Types";
5
5
  /**
6
6
  * Mirrors DrawnUi SkiaProgress (SkiaRangeBase): a horizontal track with a progress trail, per-style track height and
@@ -33,9 +33,9 @@ export class SkiaProgress extends SkiaControl {
33
33
  set Max(v) { this.max = v; this.Update(); }
34
34
  /** Unset = per-style palette. */
35
35
  get TrackColor() { return this.trackColor ?? SkiaProgress.Palette(this.UsingControlStyle).track; }
36
- set TrackColor(v) { this.trackColor = v; this.Update(); }
36
+ set TrackColor(v) { this.trackColor = v; this.UpdateDraw(); }
37
37
  get ProgressColor() { return this.progressColor ?? SkiaProgress.Palette(this.UsingControlStyle).progress; }
38
- set ProgressColor(v) { this.progressColor = v; this.Update(); }
38
+ set ProgressColor(v) { this.progressColor = v; this.UpdateDraw(); }
39
39
  /** C# ResolvedTrackColor / ResolvedProgressColor / track heights per style. */
40
40
  static Palette(s) {
41
41
  switch (s) {
@@ -43,7 +43,7 @@ export class SkiaProgress extends SkiaControl {
43
43
  case "Material": return { track: "#E8EAED", progress: "#2196F3", height: 4, radius: 2 };
44
44
  case "Material3": return { track: "#E6E0E9", progress: "#6750A4", height: 4, radius: 2 };
45
45
  case "Windows": return { track: "#F3F2F1", progress: "#0078D4", height: 6, radius: 3 };
46
- default: return { track: "#D7DBE0", progress: "#DC143C", height: 8, radius: 4 };
46
+ default: return { track: "#D7DBE0", progress: DefaultAccent, height: 8, radius: 4 };
47
47
  }
48
48
  }
49
49
  get Ratio() { return this.max > this.min ? Math.max(0, Math.min(1, (this.value - this.min) / (this.max - this.min))) : 0; }
@@ -76,5 +76,8 @@ export class SkiaProgress extends SkiaControl {
76
76
  }
77
77
  paint.delete();
78
78
  }
79
- DefaultAccessibilityLabel() { return `${Math.round(this.Ratio * 100)}%`; }
79
+ /** Value between Min and Max, read as "65%"; the name is the app's AccessibilityLabel only (drawnui-cross 6c). */
80
+ get AccessibilityValue() {
81
+ return { Now: this.value, Min: this.min, Max: this.max, Step: 0, Text: `${Math.round(this.Ratio * 100)}%` };
82
+ }
80
83
  }
@@ -26,6 +26,8 @@ export declare class SkiaRadioButton extends SkiaToggle {
26
26
  private dot?;
27
27
  ApplyProperties(): void;
28
28
  protected DefaultAccessibilityLabel(): string | undefined;
29
+ /** A disposed radio leaves its group, and an empty group goes: the module-level registry keeps no page alive. */
30
+ protected OnDisposing(): void;
29
31
  private UpdateGroup;
30
32
  protected OnToggledChanged(): void;
31
33
  ProcessGestures(args: SkiaGesturesParameters, apply: GestureEventProcessingInfo): SkiaControl | null;