drawnui-react 0.1.0-preview.3 → 0.1.0-preview.30

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 (91) hide show
  1. package/README.md +15 -1
  2. package/SKIPPED.md +32 -25
  3. package/dist/controls/AnimatedFramesRenderer.d.ts +7 -0
  4. package/dist/controls/AnimatedFramesRenderer.js +16 -1
  5. package/dist/controls/DrawnGame.d.ts +40 -0
  6. package/dist/controls/DrawnGame.js +64 -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 +15 -1
  12. package/dist/controls/SkiaButton.js +21 -4
  13. package/dist/controls/SkiaCarousel.d.ts +21 -2
  14. package/dist/controls/SkiaCarousel.js +49 -5
  15. package/dist/controls/SkiaCheckbox.d.ts +0 -1
  16. package/dist/controls/SkiaCheckbox.js +0 -6
  17. package/dist/controls/SkiaDrawer.d.ts +2 -0
  18. package/dist/controls/SkiaDrawer.js +2 -0
  19. package/dist/controls/SkiaEditor.d.ts +38 -1
  20. package/dist/controls/SkiaEditor.js +223 -49
  21. package/dist/controls/SkiaGif.d.ts +3 -0
  22. package/dist/controls/SkiaGif.js +12 -2
  23. package/dist/controls/SkiaImage.js +15 -10
  24. package/dist/controls/SkiaLabel.d.ts +78 -7
  25. package/dist/controls/SkiaLabel.js +379 -60
  26. package/dist/controls/SkiaLabelFps.d.ts +16 -0
  27. package/dist/controls/SkiaLabelFps.js +41 -0
  28. package/dist/controls/SkiaLayout.d.ts +97 -9
  29. package/dist/controls/SkiaLayout.js +387 -22
  30. package/dist/controls/SkiaLottie.js +4 -2
  31. package/dist/controls/SkiaProgress.d.ts +2 -1
  32. package/dist/controls/SkiaProgress.js +6 -3
  33. package/dist/controls/SkiaRadioButton.js +4 -3
  34. package/dist/controls/SkiaRichLabel.d.ts +1 -1
  35. package/dist/controls/SkiaRichLabel.js +11 -1
  36. package/dist/controls/SkiaScroll.d.ts +35 -5
  37. package/dist/controls/SkiaScroll.js +234 -23
  38. package/dist/controls/SkiaScrollBar.d.ts +27 -0
  39. package/dist/controls/SkiaScrollBar.js +51 -2
  40. package/dist/controls/SkiaShaderCarousel.d.ts +5 -0
  41. package/dist/controls/SkiaShaderCarousel.js +5 -0
  42. package/dist/controls/SkiaShape.d.ts +13 -2
  43. package/dist/controls/SkiaShape.js +50 -10
  44. package/dist/controls/SkiaSlider.d.ts +20 -2
  45. package/dist/controls/SkiaSlider.js +59 -5
  46. package/dist/controls/SkiaSprite.d.ts +1 -0
  47. package/dist/controls/SkiaSprite.js +4 -0
  48. package/dist/controls/SkiaSvg.js +1 -1
  49. package/dist/controls/SkiaSwitch.d.ts +0 -1
  50. package/dist/controls/SkiaSwitch.js +0 -6
  51. package/dist/controls/SkiaToggle.d.ts +25 -5
  52. package/dist/controls/SkiaToggle.js +58 -5
  53. package/dist/controls/SnappingLayout.d.ts +12 -1
  54. package/dist/controls/SnappingLayout.js +19 -1
  55. package/dist/core/Accessibility.d.ts +80 -0
  56. package/dist/core/Accessibility.js +421 -8
  57. package/dist/core/Animators.d.ts +37 -1
  58. package/dist/core/Animators.js +102 -9
  59. package/dist/core/Canvas.d.ts +108 -7
  60. package/dist/core/Canvas.js +353 -29
  61. package/dist/core/Easing.d.ts +12 -1
  62. package/dist/core/Easing.js +25 -1
  63. package/dist/core/Gestures.d.ts +34 -2
  64. package/dist/core/Gestures.js +84 -3
  65. package/dist/core/Hover.d.ts +47 -0
  66. package/dist/core/Hover.js +134 -0
  67. package/dist/core/KeyboardManager.d.ts +13 -0
  68. package/dist/core/KeyboardManager.js +18 -0
  69. package/dist/core/ScrollAnimators.js +9 -0
  70. package/dist/core/Shaping.d.ts +40 -0
  71. package/dist/core/Shaping.js +224 -0
  72. package/dist/core/SkiaControl.d.ts +209 -9
  73. package/dist/core/SkiaControl.js +500 -59
  74. package/dist/core/SkiaEffect.d.ts +17 -0
  75. package/dist/core/SkiaEffect.js +43 -8
  76. package/dist/core/SkiaImageManager.js +1 -1
  77. package/dist/core/Super.d.ts +22 -2
  78. package/dist/core/Super.js +47 -3
  79. package/dist/core/Types.d.ts +11 -1
  80. package/dist/core/Types.js +32 -1
  81. package/dist/core/ViewsAdapter.d.ts +7 -2
  82. package/dist/core/ViewsAdapter.js +10 -3
  83. package/dist/index.d.ts +3 -0
  84. package/dist/index.js +3 -0
  85. package/dist/react/SkiaShell.js +33 -14
  86. package/dist/react/index.d.ts +17 -4
  87. package/dist/react/index.js +103 -15
  88. package/dist/react/reconciler.js +33 -13
  89. package/dist/vite/index.d.ts +9 -0
  90. package/dist/vite/index.js +36 -3
  91. package/package.json +41 -3
@@ -88,7 +88,7 @@ export class SkiaGridStructure {
88
88
  spans = new Map();
89
89
  explicitWidth;
90
90
  explicitHeight;
91
- constructor(grid, widthConstraint, heightConstraint, scale) {
91
+ constructor(grid, widthConstraint, heightConstraint, scale, children = grid.Views) {
92
92
  this.grid = grid;
93
93
  this.widthConstraint = widthConstraint;
94
94
  this.heightConstraint = heightConstraint;
@@ -99,7 +99,7 @@ export class SkiaGridStructure {
99
99
  this.explicitHeight = grid.HeightRequest;
100
100
  this.Rows = this.InitializeTracks(grid.RowDefinitions, grid.DefaultRowDefinition);
101
101
  this.Columns = this.InitializeTracks(grid.ColumnDefinitions, grid.DefaultColumnDefinition);
102
- this.children = grid.Views.filter((v) => v.IsVisible);
102
+ this.children = children.filter((v) => v.IsVisible);
103
103
  this.InitializeCells();
104
104
  this.MeasureCells();
105
105
  }
@@ -294,7 +294,20 @@ export class SkiaGridStructure {
294
294
  ResolveStarRows(heightConstraint) {
295
295
  this.ResolveStars(this.Rows, heightConstraint - this.GridHeight(), (c) => c.IsRowSpanStar, (v) => v.MeasuredSize.Units.Height);
296
296
  }
297
+ /**
298
+ * C# SizesAutoRow: the child decides the height of its single Auto row, so it is measured with the height that row
299
+ * could still grow to, not with the row's current size (drawnui-cross 6p).
300
+ */
301
+ SizesAutoRow(cell) { return cell.RowSpan === 1 && this.Rows[cell.Row].IsAuto; }
302
+ static NeedFillY(child) { return child.VerticalOptions === "Fill" && child.HeightRequest < 0; }
303
+ /**
304
+ * C# HeightOnAutoRow: the height the single Auto row could still grow to, unbounded for a vertical Fill child (which
305
+ * would take the whole constraint). The row's size so far came from a first pass at the grid's whole width, so a
306
+ * label wrapping in a star column was measured against its one-line height.
307
+ */
308
+ HeightOnAutoRow(cell, child) { return SkiaGridStructure.NeedFillY(child) ? Infinity : this.AvailableHeight(cell); }
297
309
  MeasureKnownCells() {
310
+ let autoRowGrew = false;
298
311
  for (const cell of this.cells) {
299
312
  if (!cell.NeedsKnownMeasurePass)
300
313
  continue;
@@ -307,12 +320,30 @@ export class SkiaGridStructure {
307
320
  continue;
308
321
  const child = this.children[cell.ViewIndex];
309
322
  const rect = this.GetCellBoundsFor(child);
310
- this.MeasurePx(child, rect.Width, rect.Height);
323
+ if (child.IsVisible && this.SizesAutoRow(cell)) {
324
+ // the row grows to the child at its real width, within the room the grid has left
325
+ let grown = this.MeasurePx(child, rect.Width, this.HeightOnAutoRow(cell, child)).Height;
326
+ const available = this.AvailableHeight(cell);
327
+ if (isFinite(available) && grown > available)
328
+ grown = available;
329
+ if (grown > this.Rows[cell.Row].Size) {
330
+ this.Rows[cell.Row].Update(grown);
331
+ autoRowGrew = true;
332
+ }
333
+ }
334
+ else
335
+ this.MeasurePx(child, rect.Width, rect.Height);
311
336
  if (cell.IsColumnSpanStar && cell.ColumnSpan > 1)
312
337
  this.TrackSpan({ Key: `c${cell.Column}:${cell.ColumnSpan}`, Start: cell.Column, Length: cell.ColumnSpan, IsColumn: true, Requested: rect.Width });
313
338
  if (cell.IsRowSpanStar && cell.RowSpan > 1)
314
339
  this.TrackSpan({ Key: `r${cell.Row}:${cell.RowSpan}`, Start: cell.Row, Length: cell.RowSpan, IsColumn: false, Requested: rect.Height });
315
340
  }
341
+ if (autoRowGrew) {
342
+ // star rows were resolved against the smaller Auto rows: they get what is left now, nothing when Auto took it all
343
+ SkiaGridStructure.ZeroOutStars(this.Rows);
344
+ if (this.heightConstraint - this.GridHeight() > 0)
345
+ this.ResolveStarRows(this.heightConstraint);
346
+ }
316
347
  }
317
348
  AvailableWidth(cell) {
318
349
  let w = 0, absolute = true;
@@ -390,10 +421,15 @@ export class SkiaGridStructure {
390
421
  RemeasureChildrenAtFinalCells() {
391
422
  for (const cell of this.cells) {
392
423
  const child = this.children[cell.ViewIndex];
424
+ if (!child.IsVisible)
425
+ continue;
393
426
  const rect = this.GetCellBoundsFor(child);
394
427
  if (rect.Width <= 0 || rect.Height <= 0)
395
428
  continue;
396
- const m = this.MeasurePx(child, rect.Width, rect.Height);
429
+ // on an Auto row a child that is not Fill vertically keeps the height the row can grow to, as in
430
+ // MeasureKnownCells: the same request returns at once, and wrapped text is not cut to the row
431
+ const height = this.SizesAutoRow(cell) && !SkiaGridStructure.NeedFillY(child) ? Math.max(rect.Height, this.AvailableHeight(cell)) : rect.Height;
432
+ const m = this.MeasurePx(child, rect.Width, height);
397
433
  if (cell.ColumnSpan === 1 && this.Columns[cell.Column].IsAuto && m.Width > this.Columns[cell.Column].Size)
398
434
  this.Columns[cell.Column].Update(m.Width);
399
435
  if (cell.RowSpan === 1 && this.Rows[cell.Row].IsAuto && m.Height > this.Rows[cell.Row].Size)
@@ -4,15 +4,21 @@ import { SkiaLayout } from "./SkiaLayout";
4
4
  /**
5
5
  * Mirrors DrawnUi SkiaBackdrop: draws what is already painted beneath its box through `Blur` (points, default 5)
6
6
  * and `Brightness` (gamma, 1 = unchanged), tinted by `BackgroundColor`; children draw first and are blurred too.
7
- * The snapshot comes from the surface being drawn (`UseContext`) or the on-screen surface. Not cached (re-blurs
8
- * on every frame it is drawn in; inside a cached parent it is re-recorded with that parent).
7
+ * The snapshot comes from the surface being drawn (`UseContext`, the area it covers there through every ancestor
8
+ * transform) or the on-screen surface. Not cached (re-blurs on every frame it is drawn in). Its picture-cached parents
9
+ * should use `UseCache = None` (the app sets it, the library never changes a parent's cache; a one-time console warning
10
+ * names the case); inside an Image-cached ancestor it copies that cache's surface
11
+ * (right when what shows through the glass is inside that cache, wrong when it should show content outside it).
9
12
  */
10
13
  export declare class SkiaBackdrop extends SkiaLayout {
14
+ /** Samples what is drawn below: a composite above redraws it whole when something inside changes (drawnui-cross 6m). */
15
+ protected get SamplesContent(): boolean;
11
16
  Blur: number;
12
17
  Brightness: number;
13
18
  /** Snapshot the surface currently drawn into (true) or the on-screen surface (false). */
14
19
  UseContext: boolean;
15
20
  private snapshot?;
21
+ private warnedPicture;
16
22
  constructor();
17
23
  get HasEffects(): boolean;
18
24
  /** The last snapshot taken (C# GetImage hands it over: the caller owns it afterwards). */
@@ -4,15 +4,21 @@ import { SkiaLayout } from "./SkiaLayout";
4
4
  /**
5
5
  * Mirrors DrawnUi SkiaBackdrop: draws what is already painted beneath its box through `Blur` (points, default 5)
6
6
  * and `Brightness` (gamma, 1 = unchanged), tinted by `BackgroundColor`; children draw first and are blurred too.
7
- * The snapshot comes from the surface being drawn (`UseContext`) or the on-screen surface. Not cached (re-blurs
8
- * on every frame it is drawn in; inside a cached parent it is re-recorded with that parent).
7
+ * The snapshot comes from the surface being drawn (`UseContext`, the area it covers there through every ancestor
8
+ * transform) or the on-screen surface. Not cached (re-blurs on every frame it is drawn in). Its picture-cached parents
9
+ * should use `UseCache = None` (the app sets it, the library never changes a parent's cache; a one-time console warning
10
+ * names the case); inside an Image-cached ancestor it copies that cache's surface
11
+ * (right when what shows through the glass is inside that cache, wrong when it should show content outside it).
9
12
  */
10
13
  export class SkiaBackdrop extends SkiaLayout {
14
+ /** Samples what is drawn below: a composite above redraws it whole when something inside changes (drawnui-cross 6m). */
15
+ get SamplesContent() { return true; }
11
16
  Blur = 5;
12
17
  Brightness = 1;
13
18
  /** Snapshot the surface currently drawn into (true) or the on-screen surface (false). */
14
19
  UseContext = true;
15
20
  snapshot;
21
+ warnedPicture = false;
16
22
  constructor() {
17
23
  super();
18
24
  this.HorizontalOptions = "Fill";
@@ -38,16 +44,36 @@ export class SkiaBackdrop extends SkiaLayout {
38
44
  }
39
45
  if (!this.HasEffects)
40
46
  return;
47
+ // recorded into a parent's picture cache: its copy of what is behind goes into the picture. The library never
48
+ // changes a parent's cache (Nick, C# cf18cf29): it says so once, the app sets UseCache = None on those parents
49
+ if (ctx.Context.Recording && !this.warnedPicture) {
50
+ this.warnedPicture = true;
51
+ console.warn(`[SkiaBackdrop]${this.Tag ? ` ${this.Tag}` : ""} is recorded into a parent's picture cache (Operations / OperationsFull, the default of SkiaShape): its copy of what is behind goes into the picture. Set UseCache = None on its picture-cached parents.`);
52
+ }
41
53
  // C# UseContext: snapshot the surface the pixels end up on — the on-screen surface or the nearest Image cache
42
- // surface (Origin = its top-left in canvas pixels). Content beneath is already there because caches are recorded
43
- // inline while the parent paints, so this also works while an Operations picture is being recorded.
54
+ // surface. Copied where the backdrop really is on that surface: its rect through the canvas matrix (ancestor
55
+ // scale, move, rotation, 3D, the cache origin), rounded out, clamped to the surface, and drawn back 1:1 with the
56
+ // matrix undone, clipped to the backdrop's own (maybe turned) rect: the blur stays the same on screen while an
57
+ // ancestor scales (C# 6fd3bae3). The global surface (UseContext false) is copied at the layout rect.
44
58
  const surface = this.UseContext ? ctx.Context.Surface : this.Superview?.Surface;
45
59
  if (!surface)
46
60
  return;
47
61
  surface.flush();
48
- const origin = this.UseContext ? ctx.Context.Origin : undefined;
49
- const ox = origin?.X ?? 0, oy = origin?.Y ?? 0;
50
- const l = Math.floor(d.Left - ox), t = Math.floor(d.Top - oy), r = Math.ceil(d.Right - ox), b = Math.ceil(d.Bottom - oy);
62
+ let l = Math.floor(d.Left), t = Math.floor(d.Top), r = Math.ceil(d.Right), b = Math.ceil(d.Bottom);
63
+ let device = null;
64
+ if (this.UseContext) {
65
+ const m = canvas.getTotalMatrix();
66
+ const p = CK.Matrix.mapPoints(m, [d.Left, d.Top, d.Right, d.Top, d.Right, d.Bottom, d.Left, d.Bottom]);
67
+ l = Math.max(0, Math.floor(Math.min(p[0], p[2], p[4], p[6])));
68
+ t = Math.max(0, Math.floor(Math.min(p[1], p[3], p[5], p[7])));
69
+ r = Math.min(surface.width(), Math.ceil(Math.max(p[0], p[2], p[4], p[6])));
70
+ b = Math.min(surface.height(), Math.ceil(Math.max(p[1], p[3], p[5], p[7])));
71
+ if (r <= l || b <= t)
72
+ return;
73
+ device = CK.Matrix.invert(m);
74
+ if (!device)
75
+ return;
76
+ }
51
77
  // whole-surface snapshot, sub-rect on draw: a bounded snapshot of a GPU surface is not origin-safe in CanvasKit
52
78
  const image = surface.makeImageSnapshot();
53
79
  if (!image)
@@ -61,7 +87,13 @@ export class SkiaBackdrop extends SkiaLayout {
61
87
  paint.setColorFilter(gamma);
62
88
  const saved = canvas.save();
63
89
  canvas.clipRect(CK.LTRBRect(d.Left, d.Top, d.Right, d.Bottom), CK.ClipOp.Intersect, true);
64
- canvas.drawImageRectOptions(image, CK.LTRBRect(l, t, r, b), CK.LTRBRect(d.Left, d.Top, d.Right, d.Bottom), CK.FilterMode.Linear, CK.MipmapMode.None, paint);
90
+ if (device) {
91
+ canvas.concat(device);
92
+ canvas.drawImageRectOptions(image, CK.LTRBRect(l, t, r, b), CK.LTRBRect(l, t, r, b), CK.FilterMode.Nearest, CK.MipmapMode.None, paint);
93
+ }
94
+ else {
95
+ canvas.drawImageRectOptions(image, CK.LTRBRect(l, t, r, b), CK.LTRBRect(d.Left, d.Top, d.Right, d.Bottom), CK.FilterMode.Linear, CK.MipmapMode.None, paint);
96
+ }
65
97
  canvas.restoreToCount(saved);
66
98
  blur?.delete();
67
99
  gamma?.delete();
@@ -69,12 +101,8 @@ export class SkiaBackdrop extends SkiaLayout {
69
101
  const kill = this.snapshot;
70
102
  this.snapshot = image;
71
103
  kill?.delete();
72
- // What is beneath may change without invalidating this branch (an image that loads later, a sibling animating):
73
- // stale the ancestors' caches for the NEXT frame, after the current record has finished, without asking for one.
74
- queueMicrotask(() => { let p = this.Parent; while (p) {
75
- p.InvalidateCache();
76
- p = p.Parent;
77
- } });
104
+ // the library never changes how a parent's cache behaves (Nick, 2026-10-25): a cached parent replays the copy it
105
+ // recorded, as in C#; the app sets UseCache = None on the parents of a backdrop that must follow what is behind
78
106
  }
79
107
  OnDisposing() { this.snapshot?.delete(); this.snapshot = undefined; }
80
108
  }
@@ -10,6 +10,8 @@ import { type PrebuiltControlStyle, type ResolvedControlStyle } from "../core/Co
10
10
  * PanThreshold. Press feedback = ApplyEffect (ripple), no darkening.
11
11
  */
12
12
  export declare class SkiaButton extends SkiaLayout {
13
+ /** Takes mouse hover unless ReceivesHover is set false (C# ReceivesHoverByDefault). */
14
+ protected ReceivesHoverByDefault(): boolean;
13
15
  static PanThreshold: number;
14
16
  Text: string;
15
17
  /** Look of the default content (C# SkiaButton.ControlStyle): background, corners, font, minimum size when left unset. */
@@ -24,7 +26,17 @@ export declare class SkiaButton extends SkiaLayout {
24
26
  StrokeColor: Color;
25
27
  StrokeWidth: number;
26
28
  IsPressed: boolean;
27
- IsDisabled: boolean;
29
+ private respondsToGestures;
30
+ /**
31
+ * False switches the button off for the user: taps, presses and keyboard activation do nothing (no Tapped, Down, Up),
32
+ * a tap on it does not reach controls under it, and screen readers report it disabled. Code can still change it.
33
+ * Same property as on toggles, sliders, scrolls and drawers (drawnui-cross 6w). Default true.
34
+ */
35
+ get RespondsToGestures(): boolean;
36
+ set RespondsToGestures(v: boolean);
37
+ /** @deprecated The opposite of RespondsToGestures, which every control uses: set `RespondsToGestures = false`. */
38
+ get IsDisabled(): boolean;
39
+ set IsDisabled(v: boolean);
28
40
  LockPanning: boolean;
29
41
  /** Touch feedback played on Down (DrawnUi SkiaButton.ApplyEffect). */
30
42
  ApplyEffect: SkiaTouchAnimation;
@@ -41,6 +53,8 @@ export declare class SkiaButton extends SkiaLayout {
41
53
  static DefaultAccessibilityRole?: string;
42
54
  protected DefaultAccessibilityLabel(): string | undefined;
43
55
  protected DefaultAccessibilityCanInteract(): boolean;
56
+ /** With RespondsToGestures = false the button ignores taps, keyboard navigation skips it and it is reported disabled. */
57
+ protected AcceptsInput(): boolean;
44
58
  /** The button's own BackgroundColor/CornerRadius/Stroke are the frame's; the button itself paints nothing. */
45
59
  protected PaintBackground(): void;
46
60
  get UsingControlStyle(): ResolvedControlStyle;
@@ -10,6 +10,8 @@ import { ResolveControlStyle } from "../core/ControlStyle";
10
10
  * PanThreshold. Press feedback = ApplyEffect (ripple), no darkening.
11
11
  */
12
12
  export class SkiaButton extends SkiaLayout {
13
+ /** Takes mouse hover unless ReceivesHover is set false (C# ReceivesHoverByDefault). */
14
+ ReceivesHoverByDefault() { return true; }
13
15
  static PanThreshold = 5;
14
16
  Text = "";
15
17
  /** Look of the default content (C# SkiaButton.ControlStyle): background, corners, font, minimum size when left unset. */
@@ -24,7 +26,20 @@ export class SkiaButton extends SkiaLayout {
24
26
  StrokeColor = Colors.Transparent;
25
27
  StrokeWidth = 0;
26
28
  IsPressed = false;
27
- IsDisabled = false;
29
+ respondsToGestures = true;
30
+ /**
31
+ * False switches the button off for the user: taps, presses and keyboard activation do nothing (no Tapped, Down, Up),
32
+ * a tap on it does not reach controls under it, and screen readers report it disabled. Code can still change it.
33
+ * Same property as on toggles, sliders, scrolls and drawers (drawnui-cross 6w). Default true.
34
+ */
35
+ get RespondsToGestures() { return this.respondsToGestures; }
36
+ set RespondsToGestures(v) { if (this.respondsToGestures !== v) {
37
+ this.respondsToGestures = v;
38
+ this.NotifyAccessibility();
39
+ } }
40
+ /** @deprecated The opposite of RespondsToGestures, which every control uses: set `RespondsToGestures = false`. */
41
+ get IsDisabled() { return !this.respondsToGestures; }
42
+ set IsDisabled(v) { this.RespondsToGestures = !v; }
28
43
  LockPanning = false;
29
44
  /** Touch feedback played on Down (DrawnUi SkiaButton.ApplyEffect). */
30
45
  ApplyEffect = "Ripple"; // C# default
@@ -58,7 +73,9 @@ export class SkiaButton extends SkiaLayout {
58
73
  /** Set to `Aria.RoleButton` to expose every button (React extension). */
59
74
  static DefaultAccessibilityRole;
60
75
  DefaultAccessibilityLabel() { return this.Text || undefined; }
61
- DefaultAccessibilityCanInteract() { return !this.IsDisabled; }
76
+ DefaultAccessibilityCanInteract() { return this.respondsToGestures; }
77
+ /** With RespondsToGestures = false the button ignores taps, keyboard navigation skips it and it is reported disabled. */
78
+ AcceptsInput() { return this.respondsToGestures; }
62
79
  /** The button's own BackgroundColor/CornerRadius/Stroke are the frame's; the button itself paints nothing. */
63
80
  PaintBackground() { }
64
81
  get UsingControlStyle() { return ResolveControlStyle(this.ControlStyle); }
@@ -126,8 +143,8 @@ export class SkiaButton extends SkiaLayout {
126
143
  this.Repaint();
127
144
  }
128
145
  ProcessGestures(args, apply) {
129
- if (this.IsDisabled)
130
- return null;
146
+ if (!this.respondsToGestures)
147
+ return this.BlockedGestureResult(args); // no press, no Down / Up / Tapped; a tap on it stops here
131
148
  const point = args.Event.Location;
132
149
  if (args.Type === "Down") {
133
150
  this.IsPressed = true;
@@ -15,6 +15,8 @@ export interface SnapPoint {
15
15
  * `DynamicSize` sizes an auto-sized carousel from the selected slide, `SwipeSpeed` / `LinearSpeedMs` tune the snap.
16
16
  */
17
17
  export declare class SkiaCarousel extends SnappingLayout {
18
+ /** Takes mouse hover unless ReceivesHover is set false (C# ReceivesHoverByDefault). */
19
+ protected ReceivesHoverByDefault(): boolean;
18
20
  IsVertical: boolean;
19
21
  /** Side padding in points so the previous/next slides peek in. */
20
22
  SidesOffset: number;
@@ -99,10 +101,21 @@ export declare class SkiaCarousel extends SnappingLayout {
99
101
  private GetVirtualSnapPoints;
100
102
  protected GetVirtualAnchor(current: SKPoint): SnapPoint;
101
103
  protected FindNearestAnchorInternal(current: SKPoint, velocity: SKPoint): SKPoint;
102
- /** C# SkiaCarousel.ScrollToNearestAnchor: velocity below 100 counts as none; looped snaps around virtual anchors. */
104
+ /** C# SkiaCarousel.ScrollToNearestAnchor: velocity below SnapVelocityThreshold counts as none; looped snaps around virtual anchors. */
103
105
  ScrollToNearestAnchor(location: SKPoint, velocity: SKPoint): void;
104
- /** C# SkiaCarousel.SelectNextAnchor: base choice, plus a wrap to the virtual anchor at the strip borders when looped. */
106
+ /** C# SkiaCarousel.SelectNextAnchor: the choice below, at most one slide from where a finger gesture started. */
105
107
  SelectNextAnchor(origin: SKPoint, velocity: SKPoint): SKPoint;
108
+ /**
109
+ * A finger release moves at most one slide from the slide its gesture started on, as iOS paging and the Android
110
+ * ViewPager do (C# 1070e0db): a drag past the middle makes the next slide the nearest one, and the flick then went one
111
+ * further. Code moves (ScrollTo, SelectedIndex) are not limited: releaseHome is set only while a release snaps.
112
+ */
113
+ private LimitToNeighbours;
114
+ /** The slide a finger gesture started on (the target when it caught a snap in flight), see LimitToNeighbours. */
115
+ private gestureHome?;
116
+ private releaseHome?;
117
+ /** Base choice, plus a wrap to the virtual anchor at the strip borders when looped. */
118
+ private SelectNextAnchorInternal;
106
119
  /** C# FixIndex: a virtual anchor becomes the real one, the position keeps its offset (visually identical, looped drawing wraps). */
107
120
  private FixIndex;
108
121
  private FixPosition;
@@ -127,6 +140,12 @@ export declare class SkiaCarousel extends SnappingLayout {
127
140
  /** C# RenderViewsList: position every slide, draw the visible ones (+ neighbours when PreloadNeighboors), release the rest. */
128
141
  protected Paint(ctx: DrawingContext): void;
129
142
  private SlideRect;
143
+ /**
144
+ * Whether the slide at `index` takes part in hit-testing for the frame being rendered (C# IsSlideHitTestable).
145
+ * Every slide drawn on screen does by default; a carousel whose slides share one rect (SkiaShaderCarousel) narrows
146
+ * this to the slide the user actually sees.
147
+ */
148
+ protected IsSlideHitTestable(_index: number): boolean;
130
149
  protected GetGestureListeners(): readonly SkiaControl[];
131
150
  ProcessGestures(args: SkiaGesturesParameters, apply: GestureEventProcessingInfo): SkiaControl | null;
132
151
  protected DefaultAccessibilityLabel(): string | undefined;
@@ -11,6 +11,8 @@ import { SnappingLayout } from "./SnappingLayout";
11
11
  * `DynamicSize` sizes an auto-sized carousel from the selected slide, `SwipeSpeed` / `LinearSpeedMs` tune the snap.
12
12
  */
13
13
  export class SkiaCarousel extends SnappingLayout {
14
+ /** Takes mouse hover unless ReceivesHover is set false (C# ReceivesHoverByDefault). */
15
+ ReceivesHoverByDefault() { return true; }
14
16
  IsVertical = false;
15
17
  /** Side padding in points so the previous/next slides peek in. */
16
18
  SidesOffset = 0;
@@ -230,9 +232,10 @@ export class SkiaCarousel extends SnappingLayout {
230
232
  }
231
233
  return super.FindNearestAnchorInternal(current, velocity);
232
234
  }
233
- /** C# SkiaCarousel.ScrollToNearestAnchor: velocity below 100 counts as none; looped snaps around virtual anchors. */
235
+ /** C# SkiaCarousel.ScrollToNearestAnchor: velocity below SnapVelocityThreshold counts as none; looped snaps around virtual anchors. */
234
236
  ScrollToNearestAnchor(location, velocity) {
235
- velocity = new SKPoint(Math.abs(velocity.X) < 100 ? 0 : velocity.X, Math.abs(velocity.Y) < 100 ? 0 : velocity.Y);
237
+ const t = this.SnapVelocityThreshold;
238
+ velocity = new SKPoint(Math.abs(velocity.X) < t ? 0 : velocity.X, Math.abs(velocity.Y) < t ? 0 : velocity.Y);
236
239
  if (this.ApplyLoopedLogic) {
237
240
  const origin = this.FindNearestAnchorInternal(location, velocity);
238
241
  const target = this.SelectNextAnchor(origin, velocity);
@@ -244,8 +247,30 @@ export class SkiaCarousel extends SnappingLayout {
244
247
  }
245
248
  super.ScrollToNearestAnchor(location, velocity);
246
249
  }
247
- /** C# SkiaCarousel.SelectNextAnchor: base choice, plus a wrap to the virtual anchor at the strip borders when looped. */
250
+ /** C# SkiaCarousel.SelectNextAnchor: the choice below, at most one slide from where a finger gesture started. */
248
251
  SelectNextAnchor(origin, velocity) {
252
+ return this.LimitToNeighbours(this.SelectNextAnchorInternal(origin, velocity));
253
+ }
254
+ /**
255
+ * A finger release moves at most one slide from the slide its gesture started on, as iOS paging and the Android
256
+ * ViewPager do (C# 1070e0db): a drag past the middle makes the next slide the nearest one, and the flick then went one
257
+ * further. Code moves (ScrollTo, SelectedIndex) are not limited: releaseHome is set only while a release snaps.
258
+ */
259
+ LimitToNeighbours(target) {
260
+ const home = this.releaseHome;
261
+ if (!home)
262
+ return target;
263
+ const at = (p) => this.SnapPoints.findIndex((s) => Math.abs(s.X - p.X) <= 1 && Math.abs(s.Y - p.Y) <= 1);
264
+ const from = at(home), to = at(target);
265
+ if (from < 0 || to < 0 || Math.abs(to - from) <= 1)
266
+ return target; // a looped wrap goes to a virtual point next to the edge: one slide already
267
+ return this.SnapPoints[from + Math.sign(to - from)];
268
+ }
269
+ /** The slide a finger gesture started on (the target when it caught a snap in flight), see LimitToNeighbours. */
270
+ gestureHome;
271
+ releaseHome;
272
+ /** Base choice, plus a wrap to the virtual anchor at the strip borders when looped. */
273
+ SelectNextAnchorInternal(origin, velocity) {
249
274
  if (!this.ApplyLoopedLogic)
250
275
  return super.SelectNextAnchor(origin, velocity);
251
276
  const baseTarget = super.SelectNextAnchor(origin, velocity);
@@ -504,7 +529,7 @@ export class SkiaCarousel extends SnappingLayout {
504
529
  view.Measure(inner.Width, inner.Height, scale); // recycled cells carry new content
505
530
  view.Arrange(this.SlideRect(inner, this.SlideOffset(cell.offset), scale), view.WidthRequest, view.HeightRequest, scale);
506
531
  view.Render(ctx);
507
- if (cell.visible)
532
+ if (cell.visible && this.IsSlideHitTestable(cell.index))
508
533
  visible.push(view);
509
534
  }
510
535
  this.visibleViews = visible;
@@ -514,6 +539,12 @@ export class SkiaCarousel extends SnappingLayout {
514
539
  ? SKRect.Create(inner.Left, inner.Top + offset.Y * scale, inner.Width, inner.Height)
515
540
  : SKRect.Create(inner.Left + offset.X * scale, inner.Top, inner.Width, inner.Height);
516
541
  }
542
+ /**
543
+ * Whether the slide at `index` takes part in hit-testing for the frame being rendered (C# IsSlideHitTestable).
544
+ * Every slide drawn on screen does by default; a carousel whose slides share one rect (SkiaShaderCarousel) narrows
545
+ * this to the slide the user actually sees.
546
+ */
547
+ IsSlideHitTestable(_index) { return true; }
517
548
  GetGestureListeners() { return this.visibleViews; }
518
549
  // ---- gestures (port of C# SkiaCarousel.ProcessGestures) ----
519
550
  ProcessGestures(args, apply) {
@@ -542,6 +573,9 @@ export class SkiaCarousel extends SnappingLayout {
542
573
  this.FixPosition();
543
574
  this.panningOffset = this.CurrentPosition;
544
575
  this.panningStart = this.CurrentPosition;
576
+ // a swipe that catches a snap in flight starts from the slide that snap was going to
577
+ const going = this.snapIfNoPanOnUp ? this.SnapPoints.find((s) => Math.abs(s.X - this.CurrentSnap.X) <= 1 && Math.abs(s.Y - this.CurrentSnap.Y) <= 1) : undefined;
578
+ this.gestureHome = going ?? (this.SnapPoints.length > 0 ? this.FindNearestAnchor(this.CurrentPosition) : undefined);
545
579
  };
546
580
  switch (args.Type) {
547
581
  case "Down":
@@ -555,6 +589,10 @@ export class SkiaCarousel extends SnappingLayout {
555
589
  if (!this.IsUserPanning) {
556
590
  const movex = Math.abs(e.Distance.Total.X), movey = Math.abs(e.Distance.Total.Y);
557
591
  const along = this.IsVertical ? movey : movex, across = this.IsVertical ? movex : movey;
592
+ // a first move too short to tell the direction decides nothing yet (a 1 CSS px move at devicePixelRatio 2):
593
+ // marking it wrong kept the whole drag dead until the next press (DrawnUi.Rust c6b22e3; C# decides on every move)
594
+ if (along < scale * 2 && across < scale * 2)
595
+ return consumedDefault;
558
596
  if (along < scale * 2 || across > along) {
559
597
  this.wrongDirection = true;
560
598
  return consumedDefault;
@@ -578,7 +616,13 @@ export class SkiaCarousel extends SnappingLayout {
578
616
  consumed = this;
579
617
  const final = this.velocityAccumulator.CalculateFinalVelocity(500);
580
618
  this.CurrentSnap = this.CurrentPosition;
581
- this.ScrollToNearestAnchor(this.CurrentSnap, new SKPoint(final.X, final.Y));
619
+ this.releaseHome = this.gestureHome;
620
+ try {
621
+ this.ScrollToNearestAnchor(this.CurrentSnap, new SKPoint(final.X, final.Y));
622
+ }
623
+ finally {
624
+ this.releaseHome = undefined;
625
+ }
582
626
  this.IsUserPanning = false;
583
627
  this.IsUserFocused = false;
584
628
  this.snapIfNoPanOnUp = false;
@@ -15,7 +15,6 @@ export declare class SkiaCheckbox extends SkiaToggle {
15
15
  get ColorCheckOn(): Color;
16
16
  set ColorCheckOn(v: Color);
17
17
  protected StyleDefault(name: "ColorThumbOn" | "ColorFrameOn" | "ColorThumbOff" | "ColorFrameOff"): Color | undefined;
18
- private SetContentSize;
19
18
  protected CreateDefaultContent(): void;
20
19
  ApplyProperties(): void;
21
20
  }
@@ -27,12 +27,6 @@ export class SkiaCheckbox extends SkiaToggle {
27
27
  };
28
28
  return table[this.UsingControlStyle]?.[name];
29
29
  }
30
- SetContentSize(w, h) {
31
- if (this.WidthRequest < 0)
32
- this.WidthRequest = w;
33
- if (this.HeightRequest < 0)
34
- this.HeightRequest = h;
35
- }
36
30
  CreateDefaultContent() {
37
31
  const off = new SkiaShape();
38
32
  off.Tag = "FrameOff";
@@ -9,6 +9,8 @@ import { SnappingLayout } from "./SnappingLayout";
9
9
  * so it must be aligned to its edge by the parent (VerticalOptions="End" for FromBottom, etc.).
10
10
  */
11
11
  export declare class SkiaDrawer extends SnappingLayout {
12
+ /** Takes mouse hover unless ReceivesHover is set false (C# ReceivesHoverByDefault). */
13
+ protected ReceivesHoverByDefault(): boolean;
12
14
  Direction: DrawerDirection;
13
15
  /** Points that stay visible when closed. */
14
16
  HeaderSize: number;
@@ -7,6 +7,8 @@ import { SnappingLayout } from "./SnappingLayout";
7
7
  * so it must be aligned to its edge by the parent (VerticalOptions="End" for FromBottom, etc.).
8
8
  */
9
9
  export class SkiaDrawer extends SnappingLayout {
10
+ /** Takes mouse hover unless ReceivesHover is set false (C# ReceivesHoverByDefault). */
11
+ ReceivesHoverByDefault() { return true; }
10
12
  Direction = "FromBottom";
11
13
  /** Points that stay visible when closed. */
12
14
  HeaderSize = 0;
@@ -51,6 +51,8 @@ export declare class SkiaEditor extends SkiaShape {
51
51
  CanShowCursor: boolean;
52
52
  SelectionColor: Color;
53
53
  private cursorPosition;
54
+ /** A caret position was given (by the app, a tap, a selection): focusing keeps it; otherwise focusing puts the caret at the end. */
55
+ private cursorPlaced;
54
56
  private selectionLength;
55
57
  private isFocused;
56
58
  private controlStyle;
@@ -58,7 +60,8 @@ export declare class SkiaEditor extends SkiaShape {
58
60
  private readonly placeholder;
59
61
  private scrollX;
60
62
  private scrollY;
61
- private blink;
63
+ /** The caret blinks on a timer, asleep between blinks: no frame runs while it waits (DrawnUi.Rust editor_rules). */
64
+ private blinkTimer;
62
65
  private caretVisible;
63
66
  private subscribed;
64
67
  private stubSelectionStop;
@@ -70,6 +73,12 @@ export declare class SkiaEditor extends SkiaShape {
70
73
  private styleApplied;
71
74
  private layoutVersion;
72
75
  private boxes;
76
+ /** The glyph box starting at a text index, and the one ending at it. */
77
+ private readonly boxAt;
78
+ private readonly boxEnd;
79
+ /** Grapheme boundaries of the text, the places a caret may stand. */
80
+ private stops;
81
+ private stopsText;
73
82
  constructor();
74
83
  get Text(): string;
75
84
  set Text(v: string);
@@ -102,6 +111,9 @@ export declare class SkiaEditor extends SkiaShape {
102
111
  set CursorPosition(v: number);
103
112
  get SelectionLength(): number;
104
113
  set SelectionLength(v: number);
114
+ /** Shows the caret for a full half second, then blinks every 500 ms. */
115
+ private StartBlink;
116
+ private StopBlink;
105
117
  private OnCursorMoved;
106
118
  get IsFocused(): boolean;
107
119
  set IsFocused(v: boolean);
@@ -121,14 +133,34 @@ export declare class SkiaEditor extends SkiaShape {
121
133
  /** Keeps the caret inside the padded box by scrolling the label (C#: SkiaScroll under the label). */
122
134
  private ScrollToCaret;
123
135
  private Boxes;
136
+ private Stops;
137
+ /** The laid-out line a caret index belongs to: the line holding the character before it, else the one starting at it. */
138
+ private static LineOf;
139
+ /** Where the caret before character `index` stands (label pixels): its x, the direction of the text there, its line box. */
140
+ private CaretPlace;
124
141
  /** Rect of the caret before character `index` (label pixels), or undefined before the first layout. */
125
142
  private CaretRectLabelPx;
143
+ /** The grapheme boundary of a line whose caret x is nearest to `x` (a tie: the smaller index). */
144
+ private NearestStop;
126
145
  /** C# GetCursorPosition: the text index nearest to a point in label pixels. */
127
146
  private HitTestIndex;
147
+ /**
148
+ * Left / Right from a caret index: the grapheme boundary on its line whose caret x is nearest that way (equal x: the
149
+ * one logically nearest); at the visual edge of the line one grapheme logically, forward for Right in a
150
+ * left-to-right paragraph and backward in a right-to-left one (Left the other way round).
151
+ */
152
+ private VisualTarget;
128
153
  private LabelPoint;
129
154
  protected Paint(ctx: DrawingContext): void;
130
155
  ProcessGestures(args: SkiaGesturesParameters, apply: GestureEventProcessingInfo): SkiaControl | null;
156
+ /** A text field is a Tab stop by default, like a native text box, with no Tapped handler needed. */
157
+ protected DefaultAccessibilityCanInteract(): boolean;
158
+ /** Keyboard navigation reached the field (Tab) or left it: take the caret and the input sink like a native text box, or release them. */
159
+ OnAccessibilityFocused(focused: boolean): void;
160
+ /** Enter / Space on the field while it has no caret start editing; while editing they are text. */
131
161
  OnAccessibilityActivated(): void;
162
+ /** While editing, arrows, Home / End and PageUp / PageDown belong to the text: they never move a surrounding group. */
163
+ OnAccessibilityKey(_key: string): boolean;
132
164
  protected DefaultAccessibilityLabel(): string | undefined;
133
165
  Submit(): void;
134
166
  private ExecuteSubmit;
@@ -151,6 +183,11 @@ export declare class SkiaEditor extends SkiaShape {
151
183
  StubDelete(count?: number): void;
152
184
  /** Arrow / Home / End: the anchor stays, the moving edge follows (shift), or the selection collapses in the move direction. */
153
185
  StubMoveCursor(delta: number, extendSelection?: boolean): void;
186
+ /**
187
+ * Arrow Left (-1) / Right (1): visual moves, as native text fields (see VisualTarget). Without Shift a selection
188
+ * collapses to its visually left (Left) or right (Right) edge; with Shift its moving edge moves.
189
+ */
190
+ MoveVisual(dir: -1 | 1, extendSelection?: boolean): void;
154
191
  StubSelectRange(start: number, length: number): void;
155
192
  StubSelectAll(): void;
156
193
  /** Up / Down keep the caret x on the neighbouring line (C# HandleVerticalArrow). */