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

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 (107) hide show
  1. package/README.md +129 -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 +241 -10
  65. package/dist/core/Canvas.js +739 -44
  66. package/dist/core/ControlStyle.d.ts +2 -0
  67. package/dist/core/ControlStyle.js +2 -0
  68. package/dist/core/DesignerActions.d.ts +32 -0
  69. package/dist/core/DesignerActions.js +68 -0
  70. package/dist/core/Easing.d.ts +12 -1
  71. package/dist/core/Easing.js +25 -1
  72. package/dist/core/Gestures.d.ts +81 -2
  73. package/dist/core/Gestures.js +177 -3
  74. package/dist/core/Hover.d.ts +51 -0
  75. package/dist/core/Hover.js +140 -0
  76. package/dist/core/ImageEffects.d.ts +2 -0
  77. package/dist/core/ImageEffects.js +2 -0
  78. package/dist/core/KeyboardManager.d.ts +40 -0
  79. package/dist/core/KeyboardManager.js +98 -8
  80. package/dist/core/PopupWindows.d.ts +94 -0
  81. package/dist/core/PopupWindows.js +205 -0
  82. package/dist/core/ScrollAnimators.js +9 -0
  83. package/dist/core/Shaping.d.ts +40 -0
  84. package/dist/core/Shaping.js +224 -0
  85. package/dist/core/SkiaControl.d.ts +284 -11
  86. package/dist/core/SkiaControl.js +630 -66
  87. package/dist/core/SkiaEffect.d.ts +17 -0
  88. package/dist/core/SkiaEffect.js +43 -8
  89. package/dist/core/SkiaImageManager.js +1 -1
  90. package/dist/core/Super.d.ts +29 -2
  91. package/dist/core/Super.js +54 -3
  92. package/dist/core/Tooltips.d.ts +71 -0
  93. package/dist/core/Tooltips.js +205 -0
  94. package/dist/core/Types.d.ts +11 -1
  95. package/dist/core/Types.js +32 -1
  96. package/dist/core/ViewsAdapter.d.ts +7 -2
  97. package/dist/core/ViewsAdapter.js +10 -3
  98. package/dist/index.d.ts +7 -0
  99. package/dist/index.js +7 -0
  100. package/dist/react/SkiaShell.js +65 -26
  101. package/dist/react/index.d.ts +51 -4
  102. package/dist/react/index.js +180 -18
  103. package/dist/react/reconciler.d.ts +20 -0
  104. package/dist/react/reconciler.js +69 -14
  105. package/dist/vite/index.d.ts +9 -0
  106. package/dist/vite/index.js +36 -3
  107. package/package.json +66 -2
@@ -18,17 +18,43 @@ export declare class AnimatorBase {
18
18
  StartFrameTimeNanos: number;
19
19
  OnStart?: () => void;
20
20
  OnStop?: () => void;
21
+ /** Paused: the canvas does not tick it and it wakes no frames; Resume goes on from where it was (C# Pause / Resume). */
22
+ IsPaused: boolean;
23
+ /** Paused by the canvas because its control is hidden; resumed when it shows again. */
24
+ PausedWhileHidden: boolean;
25
+ /**
26
+ * Frame time (ns) before which nothing it shows changes: the canvas does not tick it and it keeps no frames coming
27
+ * until then, a timer wakes the frame loop at that time (a GIF or a sprite between two frames; DrawnUi.Rust frame
28
+ * animators sleep between changes). 0 = tick every frame.
29
+ */
30
+ SleepUntilNanos: number;
21
31
  private delayHandle;
32
+ private delayEnd;
33
+ private delayLeft;
34
+ private pausedAt;
22
35
  constructor(parent: SkiaControl);
23
36
  protected Register(): boolean;
24
37
  protected Unregister(): void;
25
38
  Start(delayMs?: number): void;
39
+ /** Freezes the run (and what is left of a start delay); Resume goes on from there. */
40
+ Pause(): void;
41
+ /** Goes on from where Pause froze it: the paused time is not counted. */
42
+ Resume(): void;
26
43
  Stop(): void;
27
44
  /** Returns true when there is nothing more to do (not running / finished). */
28
45
  TickFrame(frameTimeNanos: number): boolean;
29
46
  Dispose(): void;
30
47
  private SetRunning;
31
48
  }
49
+ /**
50
+ * DrawnUi ActionOnTickAnimator: runs `action(frameTimeNanos)` on every frame until stopped, a game loop for
51
+ * DrawnGame or any per-frame work.
52
+ */
53
+ export declare class ActionOnTickAnimator extends AnimatorBase {
54
+ private readonly action;
55
+ constructor(parent: SkiaControl, action: (frameTimeNanos: number) => void);
56
+ TickFrame(frameTimeNanos: number): boolean;
57
+ }
32
58
  /** DrawnUi SkiaValueAnimator: drives mValue from mMinValue to mMaxValue over Speed ms with Easing. */
33
59
  export declare class SkiaValueAnimator extends AnimatorBase {
34
60
  mValue: number;
@@ -46,10 +72,20 @@ export declare class SkiaValueAnimator extends AnimatorBase {
46
72
  TickFrame(frameTimeNanos: number): boolean;
47
73
  /** Passed over mValue; subclasses derive their own reported value here. */
48
74
  protected TransformReportedValue(_deltaT: number): number;
49
- /** Updates mValue from elapsed time; true when the target was reached. */
75
+ /**
76
+ * Updates mValue from elapsed time; true when the run is over. The eased value is not clamped to the range: a spring
77
+ * easing goes past its ends, and a run whose mMinValue is above mMaxValue (a ping-pong's way back) goes down.
78
+ */
50
79
  protected UpdateValue(_deltaT: number, deltaFromStart: number): boolean;
51
80
  protected FinishedRunning(): boolean;
52
81
  }
82
+ /** DrawnUi PingPongAnimator: every repeat runs the other way (Repeat -1 = forever by default). */
83
+ export declare class PingPongAnimator extends SkiaValueAnimator {
84
+ /** One way done, the next starts (C# CycleFInished). */
85
+ CycleFinished?: () => void;
86
+ constructor(parent: SkiaControl);
87
+ protected FinishedRunning(): boolean;
88
+ }
53
89
  /** DrawnUi RenderingAnimator: a value animator that paints itself above its Parent (IOverlayEffect). */
54
90
  export declare class RenderingAnimator extends SkiaValueAnimator implements IOverlayEffect {
55
91
  constructor(parent: SkiaControl);
@@ -16,7 +16,20 @@ export class AnimatorBase {
16
16
  StartFrameTimeNanos = 0;
17
17
  OnStart;
18
18
  OnStop;
19
+ /** Paused: the canvas does not tick it and it wakes no frames; Resume goes on from where it was (C# Pause / Resume). */
20
+ IsPaused = false;
21
+ /** Paused by the canvas because its control is hidden; resumed when it shows again. */
22
+ PausedWhileHidden = false;
23
+ /**
24
+ * Frame time (ns) before which nothing it shows changes: the canvas does not tick it and it keeps no frames coming
25
+ * until then, a timer wakes the frame loop at that time (a GIF or a sprite between two frames; DrawnUi.Rust frame
26
+ * animators sleep between changes). 0 = tick every frame.
27
+ */
28
+ SleepUntilNanos = 0;
19
29
  delayHandle = 0;
30
+ delayEnd = 0;
31
+ delayLeft = 0;
32
+ pausedAt = 0;
20
33
  constructor(parent) { this.Parent = parent; }
21
34
  Register() {
22
35
  const parent = this.Parent;
@@ -29,7 +42,14 @@ export class AnimatorBase {
29
42
  if (!parent.PostAnimators.includes(effect))
30
43
  parent.PostAnimators.push(effect);
31
44
  }
32
- const ok = parent.Superview?.RegisterAnimator(this) ?? false;
45
+ const superview = parent.Superview;
46
+ const ok = superview?.RegisterAnimator(this) ?? false;
47
+ // C# SkiaControl.RegisterAnimator: not attached yet, queue it; the parent starts it on its first arrange
48
+ if (!superview && !parent.IsDisposed) {
49
+ const pending = parent.PendingUnattachedAnimators ??= [];
50
+ if (!pending.includes(this))
51
+ pending.push(this);
52
+ }
33
53
  parent.Repaint();
34
54
  return ok;
35
55
  }
@@ -42,6 +62,9 @@ export class AnimatorBase {
42
62
  if (i >= 0)
43
63
  parent.PostAnimators.splice(i, 1);
44
64
  }
65
+ const pending = parent.PendingUnattachedAnimators?.indexOf(this) ?? -1;
66
+ if (pending >= 0)
67
+ parent.PendingUnattachedAnimators.splice(pending, 1);
45
68
  parent.Superview?.UnregisterAnimator(this.Uid);
46
69
  }
47
70
  Start(delayMs = 0) {
@@ -50,6 +73,8 @@ export class AnimatorBase {
50
73
  this.delayHandle = 0;
51
74
  }
52
75
  if (delayMs > 0) {
76
+ // the delay waits without frames
77
+ this.delayEnd = performance.now() + delayMs;
53
78
  this.delayHandle = window.setTimeout(() => { this.delayHandle = 0; this.Start(); }, delayMs);
54
79
  return;
55
80
  }
@@ -62,7 +87,43 @@ export class AnimatorBase {
62
87
  }
63
88
  }
64
89
  }
90
+ /** Freezes the run (and what is left of a start delay); Resume goes on from there. */
91
+ Pause() {
92
+ if (this.IsPaused)
93
+ return;
94
+ this.IsPaused = true;
95
+ this.pausedAt = performance.now();
96
+ if (this.delayHandle) {
97
+ clearTimeout(this.delayHandle);
98
+ this.delayHandle = 0;
99
+ this.delayLeft = Math.max(0, this.delayEnd - this.pausedAt);
100
+ }
101
+ }
102
+ /** Goes on from where Pause froze it: the paused time is not counted. */
103
+ Resume() {
104
+ if (!this.IsPaused)
105
+ return;
106
+ this.IsPaused = false;
107
+ const paused = (performance.now() - this.pausedAt) * 1_000_000;
108
+ if (this.StartFrameTimeNanos !== 0) {
109
+ this.StartFrameTimeNanos += paused;
110
+ this.LastFrameTimeNanos += paused;
111
+ }
112
+ if (this.SleepUntilNanos !== 0)
113
+ this.SleepUntilNanos += paused;
114
+ if (this.delayLeft > 0) {
115
+ const left = this.delayLeft;
116
+ this.delayLeft = 0;
117
+ this.Start(left);
118
+ return;
119
+ }
120
+ this.Parent?.Repaint(); // frames again
121
+ }
65
122
  Stop() {
123
+ this.IsPaused = false;
124
+ this.PausedWhileHidden = false;
125
+ this.SleepUntilNanos = 0;
126
+ this.delayLeft = 0;
66
127
  if (this.delayHandle) {
67
128
  clearTimeout(this.delayHandle);
68
129
  this.delayHandle = 0;
@@ -96,6 +157,21 @@ export class AnimatorBase {
96
157
  this.OnStop?.();
97
158
  }
98
159
  }
160
+ /**
161
+ * DrawnUi ActionOnTickAnimator: runs `action(frameTimeNanos)` on every frame until stopped, a game loop for
162
+ * DrawnGame or any per-frame work.
163
+ */
164
+ export class ActionOnTickAnimator extends AnimatorBase {
165
+ action;
166
+ constructor(parent, action) {
167
+ super(parent);
168
+ this.action = action;
169
+ }
170
+ TickFrame(frameTimeNanos) {
171
+ this.action(frameTimeNanos);
172
+ return super.TickFrame(frameTimeNanos);
173
+ }
174
+ }
99
175
  /** DrawnUi SkiaValueAnimator: drives mValue from mMinValue to mMaxValue over Speed ms with Easing. */
100
176
  export class SkiaValueAnimator extends AnimatorBase {
101
177
  mValue = 0;
@@ -130,23 +206,21 @@ export class SkiaValueAnimator extends AnimatorBase {
130
206
  }
131
207
  /** Passed over mValue; subclasses derive their own reported value here. */
132
208
  TransformReportedValue(_deltaT) { return this.mValue; }
133
- /** Updates mValue from elapsed time; true when the target was reached. */
209
+ /**
210
+ * Updates mValue from elapsed time; true when the run is over. The eased value is not clamped to the range: a spring
211
+ * easing goes past its ends, and a run whose mMinValue is above mMaxValue (a ping-pong's way back) goes down.
212
+ */
134
213
  UpdateValue(_deltaT, deltaFromStart) {
135
214
  const elapsedMs = deltaFromStart / 1_000_000;
136
215
  const progress = this.Speed > 0 ? elapsedMs / this.Speed : 1;
137
216
  const deltaValue = this.mMaxValue - this.mMinValue;
138
217
  const eased = this.Easing.Ease(Math.min(progress, 1));
139
218
  this.Progress = eased;
140
- const value = deltaValue * eased + this.mMinValue;
141
- if (value < this.mMinValue) {
142
- this.mValue = this.mMinValue;
143
- return false;
144
- }
145
- if (value >= this.mMaxValue || progress >= 1) {
219
+ if (progress >= 1) {
146
220
  this.mValue = this.mMaxValue;
147
221
  return true;
148
222
  }
149
- this.mValue = value;
223
+ this.mValue = deltaValue * eased + this.mMinValue;
150
224
  return false;
151
225
  }
152
226
  FinishedRunning() {
@@ -163,6 +237,25 @@ export class SkiaValueAnimator extends AnimatorBase {
163
237
  return true;
164
238
  }
165
239
  }
240
+ /** DrawnUi PingPongAnimator: every repeat runs the other way (Repeat -1 = forever by default). */
241
+ export class PingPongAnimator extends SkiaValueAnimator {
242
+ /** One way done, the next starts (C# CycleFInished). */
243
+ CycleFinished;
244
+ constructor(parent) { super(parent); this.Repeat = -1; }
245
+ FinishedRunning() {
246
+ if (this.Repeat !== 0) {
247
+ this.CycleFinished?.();
248
+ if (this.Repeat > 0)
249
+ this.Repeat--;
250
+ [this.mMinValue, this.mMaxValue] = [this.mMaxValue, this.mMinValue];
251
+ this.mValue = this.mMinValue;
252
+ this.LastFrameTimeNanos = 0;
253
+ this.StartFrameTimeNanos = 0;
254
+ return false;
255
+ }
256
+ return super.FinishedRunning();
257
+ }
258
+ }
166
259
  /** DrawnUi RenderingAnimator: a value animator that paints itself above its Parent (IOverlayEffect). */
167
260
  export class RenderingAnimator extends SkiaValueAnimator {
168
261
  constructor(parent) { super(parent); }
@@ -1,19 +1,29 @@
1
1
  import type { Surface } from "canvaskit-wasm";
2
- import type { SkiaControl } from "./SkiaControl";
2
+ import { type DrawingContext, type SkiaControl } from "./SkiaControl";
3
3
  import type { AnimatorBase } from "./Animators";
4
4
  import { SkiaAccessibilityManager } from "./Accessibility";
5
- import { type Color, type RenderingModeType } from "./Types";
6
- import { ContextMenuEventArgs, type GesturesMode, SkiaGesturesParameters, TouchActionEventArgs } from "./Gestures";
5
+ import { HoverManager } from "./Hover";
6
+ import { type TooltipStyleLike } from "./Tooltips";
7
+ import { PopupAnchor, type PopupId, type PopupWindowOptions } from "./PopupWindows";
8
+ import { type Color, type RenderingModeType, SKRect } from "./Types";
9
+ import { ContextMenuEventArgs, type GesturesMode, SKPoint, SkiaGesturesParameters, TouchActionEventArgs } from "./Gestures";
7
10
  /**
8
11
  * Mirrors DrawnUi Canvas (DrawnView): hosts one Content control on an HTML canvas element,
9
12
  * owns RenderingScale (devicePixelRatio), the surface, the on-demand frame loop and raw input.
10
13
  * Frames are drawn only after Update() (invalidation), never continuously.
11
14
  * Gestures are accumulated and processed in order at the START of the next frame, like DrawnUi.
12
15
  */
16
+ /** The system's light / dark appearance (DrawnUi.Rust SystemTheme). */
17
+ export type SystemTheme = "Light" | "Dark";
13
18
  export declare class Canvas {
14
19
  readonly Element: HTMLCanvasElement;
15
20
  /** Points a pointer may travel between Down and Up and still count as a tap (AppoMobi TouchEffect default). */
16
21
  static TappedCancelMoveThresholdPoints: number;
22
+ /**
23
+ * A press held this long without moving past TappedCancelMoveThresholdPoints is a LongPressing, at the press point
24
+ * (AppoMobi TouchEffect, DrawnUi.Rust LONG_PRESS_MS); its release sends no Tapped. A timer, no frames while waiting.
25
+ */
26
+ static LongPressTimeMs: number;
17
27
  BackgroundColor: Color;
18
28
  /** Accelerated = WebGL surface, Default = software. Read once at first frame. */
19
29
  RenderingMode: RenderingModeType;
@@ -23,8 +33,108 @@ export declare class Canvas {
23
33
  /** Frames per second over the last second of drawn frames. */
24
34
  FPS: number;
25
35
  private frameTimes;
36
+ /** DrawnView.WasRendered: a frame has been drawn on a ready surface (set after the first one completes). */
37
+ WasRendered: boolean;
38
+ /** DrawnView.CanRender: the surface (and its GPU context when accelerated) is ready to draw. */
39
+ get CanRender(): boolean;
40
+ /**
41
+ * DrawnView.WillFirstTimeDraw: raised once, right before the first frame drawn on a ready surface, with that
42
+ * frame's drawing context. The engine draws its first frame while it is being constructed (so the page never shows
43
+ * an unpainted canvas): pass it through the constructor's `init` to receive that frame.
44
+ */
45
+ WillFirstTimeDraw?: (sender: Canvas, context: DrawingContext["Context"]) => void;
46
+ /** DrawnView.WasDrawn: raised after every frame has been drawn (the C# event passes no context). */
47
+ WasDrawn?: (sender: Canvas) => void;
48
+ /**
49
+ * The system's light / dark appearance (DrawnUi.Rust `system_theme`): undefined until the host learns it, which it
50
+ * does when the canvas is created (`prefers-color-scheme`), then it follows every change.
51
+ */
52
+ get SystemTheme(): SystemTheme | undefined;
53
+ /**
54
+ * Raised once when the host learns the system theme (set it in the Canvas init / the `<Canvas>` prop to get that first
55
+ * value), then once per change; a repeated value is not raised. No handler, no call; it never asks for a frame.
56
+ */
57
+ SystemThemeChanged?: (theme: SystemTheme) => void;
58
+ private systemTheme?;
59
+ private themeQuery?;
60
+ private readonly onThemeQuery;
61
+ private SetSystemTheme;
26
62
  /** Registry + rate-limited snapshot of accessible controls, rendered by the DOM overlay (DrawnUi AccessibilityManager). */
27
63
  readonly AccessibilityManager: SkiaAccessibilityManager;
64
+ /** Mouse hover of the controls (drawnui-cross 6m): ReceivesHover / IsHovered / HoverChanged. */
65
+ readonly Hover: HoverManager;
66
+ private tooltipController?;
67
+ /** Made on first use: a canvas that never shows a tooltip allocates nothing for it. */
68
+ private get tooltip();
69
+ /** Look and timing of the tooltips on this canvas; unset uses `Super.TooltipStyle`. */
70
+ TooltipStyle?: TooltipStyleLike;
71
+ get TooltipStyleUsed(): TooltipStyleLike;
72
+ /** The text of the tooltip shown now, undefined when none is shown. */
73
+ get ShownTooltip(): string | undefined;
74
+ private popupLayer?;
75
+ /** Made on first use, like the tooltip. */
76
+ private get popups();
77
+ private popupKeysHooked;
78
+ /** Raised when a popup window closed: picked, a press outside, Escape, the wheel, window blur or ClosePopupWindow. */
79
+ readonly PopupWindowClosed: Set<(id: PopupId) => void>;
80
+ /** The root controls of the open popup windows, bottom to top: a read-only view for tools (a new array per read). */
81
+ get PopupWindowRoots(): readonly SkiaControl[];
82
+ private wasDrawnListeners?;
83
+ /**
84
+ * Handlers run at the end of every drawn frame, after the `WasDrawn` callback and before the surface is flushed (a
85
+ * tool drawing an overlay on `Surface.getCanvas()`). Made on first use: a canvas without listeners does no work.
86
+ */
87
+ get WasDrawnListeners(): Set<(sender: Canvas) => void>;
88
+ private readonly raiseWasDrawn;
89
+ /**
90
+ * Shows `content` over everything, opening from `anchor` the way native menus do: at a point (a right click, canvas
91
+ * points), or below a rect or a control (a dropdown), flipped to the other side where it does not fit. It closes with
92
+ * a press outside it, Escape, the wheel outside it, window blur, `ClosePopupWindow` and the options.
93
+ */
94
+ OpenPopupWindow(content: SkiaControl, anchor: PopupAnchor | SKPoint | SKRect | SkiaControl | {
95
+ X: number;
96
+ Y: number;
97
+ }, options?: PopupWindowOptions): PopupId;
98
+ /** Closes the popup window (nothing when it is closed already). */
99
+ ClosePopupWindow(id: PopupId): void;
100
+ /** Closes every popup window. */
101
+ ClosePopupWindows(): void;
102
+ /** The popup window is still open. */
103
+ IsPopupWindowOpen(id: PopupId): boolean;
104
+ /**
105
+ * Moves the keyboard and screen-reader focus to `control` at the end of the next frame, for app code such as a custom
106
+ * menu that moves its highlight (C# DrawnView.SetAccessibilityFocus). A control not drawn yet gets it once it is, within
107
+ * 3 seconds. It wins over the library's own moves in the same frame (a closed popup window giving the keyboard back to
108
+ * its opener); undefined cancels a move still waiting. The focus ring shows only if the keyboard is in use.
109
+ */
110
+ SetAccessibilityFocus(control?: SkiaControl): void;
111
+ /**
112
+ * The drawn control with the keyboard and screen-reader focus (C# KeyboardFocusNode). Set undefined to let no drawn
113
+ * control keep it: the DOM focus goes back to the canvas and the keys belong to the app; a control moves it there.
114
+ */
115
+ get KeyboardFocusNode(): SkiaControl | undefined;
116
+ set KeyboardFocusNode(control: SkiaControl | undefined);
117
+ /** True while a popup window that takes input is open. */
118
+ get HasPopupWindows(): boolean;
119
+ /** The content of the top popup window that takes input. */
120
+ get TopPopupWindow(): SkiaControl | undefined;
121
+ /** The window stopped being active (blur): popup windows and the tooltip close, as native menus do. */
122
+ OnWindowDeactivated(): void;
123
+ /**
124
+ * The browser window (tab) has the keyboard (C# DrawnView.IsWindowActive): false after its blur, true again after its
125
+ * focus. A focused editor hides its caret while it is false.
126
+ */
127
+ IsWindowActive: boolean;
128
+ /** Raised when IsWindowActive changes (C# WindowActiveChanged). */
129
+ readonly WindowActiveChanged: Set<(active: boolean) => void>;
130
+ private SetWindowActive;
131
+ RaisePopupWindowClosed(id: PopupId): void;
132
+ private AfterPopupsChanged;
133
+ private readonly onPopupKey;
134
+ private HookPopupKeys;
135
+ private readonly onWindowBlur;
136
+ private readonly onWindowInactive;
137
+ private readonly onWindowActive;
28
138
  private content?;
29
139
  get Content(): SkiaControl | undefined;
30
140
  set Content(value: SkiaControl | undefined);
@@ -35,7 +145,15 @@ export declare class Canvas {
35
145
  private frameId;
36
146
  private disposed;
37
147
  private readonly observer;
38
- constructor(Element: HTMLCanvasElement);
148
+ /** The WebGL context is lost: no frames until the browser restores it. */
149
+ private contextLost;
150
+ /**
151
+ * Bumped when the WebGL context was restored: every GPU object made before (Image caches, picture caches that may
152
+ * replay them, kept composite surfaces, effect textures) is remade at its next draw (DrawnUi.Rust Gpu::epoch).
153
+ */
154
+ GpuEpoch: number;
155
+ /** `init` runs before the first frame is drawn: the place to attach `WillFirstTimeDraw` / `WasDrawn` for that frame. */
156
+ constructor(Element: HTMLCanvasElement, init?: (canvas: Canvas) => void);
39
157
  /** Request a redraw (full measure + arrange + render) on the next animation frame. */
40
158
  Update(): void;
41
159
  /** Deletes the current surface; a pending frame on it is cancelled first (drawing on a deleted surface faults). */
@@ -48,6 +166,17 @@ export declare class Canvas {
48
166
  * redrawn content lands in the same paint and no blank frame is ever shown while dragging.
49
167
  */
50
168
  private OnResized;
169
+ /** WebGL context lost: keep the browser restoring it (preventDefault) and stop the frames. */
170
+ private readonly onContextLost;
171
+ /**
172
+ * WebGL context restored (as DrawnUi.Rust and the C# Wasm / Blazor heads): every GL object of the lost generation is
173
+ * gone. The old Skia context is abandoned first, while its own GL handle is current and before the new context makes
174
+ * any object, so its GL calls reach only lost-generation objects. CanvasKit exposes no `abandonContext`;
175
+ * `releaseResourcesAndAbandonContext` is its only way to abandon, and after it freeing an old image or surface makes no
176
+ * GL call. Then the same WebGL object is registered again (the old handle deleted first, which clears the canvas'
177
+ * context object) with a new GrContext and surface; GpuEpoch makes the old generation's GPU objects remake themselves.
178
+ */
179
+ private readonly onContextRestored;
51
180
  /** Draws one frame immediately (outside the rAF loop) and presents it. */
52
181
  private DrawNow;
53
182
  private Draw;
@@ -60,10 +189,32 @@ export declare class Canvas {
60
189
  readonly AnimatingControls: Map<number, AnimatorBase>;
61
190
  RegisterAnimator(animator: AnimatorBase): boolean;
62
191
  UnregisterAnimator(uid: number): void;
192
+ /**
193
+ * `root` leaves this canvas (removed from its parent, replaced as content, disposed): what runs for its subtree stops,
194
+ * as DrawnUi.Rust 44c718f. Its animators leave the frame loop: disposed, they stop; only removed, they pause and wait on
195
+ * their control (PendingUnattachedAnimators), going on from there when it is arranged on a canvas again. A focused editor in it loses the
196
+ * focus, a game in it stops getting keys (CanvasLeaveWatchers). Runs once per removal, never per frame.
197
+ */
198
+ ControlLeft(root: SkiaControl, disposed: boolean): void;
199
+ private static readonly reportedAnimators;
200
+ /** An animator's callback threw: logged once for that animator, the frame goes on. */
201
+ private static ReportAnimatorError;
63
202
  /** Ticks every registered animator once; returns how many ran. */
64
203
  protected ExecuteAnimators(frameTimeNanos: number): number;
204
+ private wakeTimer;
205
+ private wakeAtNanos;
206
+ /** One timer for the earliest sleeping animator: the frame loop wakes then, no frames run in between. */
207
+ private WakeAt;
65
208
  /** Frames drawn so far (SkiaBackdrop uses it to refresh once after a cached record). */
66
209
  FrameIndex: number;
210
+ /**
211
+ * DrawnView.WheelDeltaPerNotch: the Wheel.Delta one mouse-wheel notch produces, 100 CSS pixels in Chrome and Edge. A
212
+ * scroll moves by the event's share of a notch, so a touchpad, which sends many small events, scrolls as far as the
213
+ * fingers moved. 0 = units unknown: every event scrolls one line.
214
+ */
215
+ WheelDeltaPerNotch: number;
216
+ /** Vsync time of the last frame the animators ran on (nanoseconds, the performance.now() timeline). */
217
+ FrameTimeNanos: number;
67
218
  /** On-screen surface (SkiaBackdrop snapshots it). */
68
219
  get Surface(): Surface | undefined;
69
220
  /**
@@ -87,26 +238,77 @@ export declare class Canvas {
87
238
  private readonly previousTouchArgs;
88
239
  private readonly pendingGestures;
89
240
  private readonly onPointer;
241
+ /** The mouse left the canvas: hover ends at once, also while content moves. */
242
+ private readonly onPointerLeave;
90
243
  private readonly preventTouch;
244
+ /** Gestures="Enabled": touch / pen pointers whose Down a control used (see OnTouchAction). */
245
+ private readonly claimedTouches;
246
+ /** Gestures="Enabled": while a claimed touch is down the page may not take its drag. */
247
+ private readonly preventClaimedTouch;
91
248
  /** Called when no control handled a context-menu request; return true to suppress the browser's canvas menu. */
92
249
  ContextMenu?: (sender: Canvas, e: ContextMenuEventArgs) => boolean | void;
93
250
  /** DOM contextmenu (right click / long press / Menu key) -> ContextMenuEventArgs routed through the tree like a tap. */
94
251
  private readonly onContextMenu;
252
+ /**
253
+ * The Menu key, Shift+F10 or a screen reader's context-menu command on the control in keyboard focus (the DOM
254
+ * `contextmenu` of its overlay node): its context menu opens at its center, from it or the first control above it with
255
+ * a ContextMenu handler, then the Canvas' own (Source "keyboard", as every DrawnUI engine). True when one took it.
256
+ */
257
+ OpenContextMenuFromKeyboard(control: SkiaControl, native: MouseEvent): boolean;
95
258
  private cursorPointer;
96
259
  /**
97
260
  * DrawnUi.Blazor shows `cursor: pointer` over interactive controls through its overlay elements; here the overlay
98
- * is pointer-events:none, so the mouse position is tested against the accessibility snapshot (the accessible
99
- * controls' rects in points, already sorted and rate-limited), each hit control answering WantsPointerCursor
100
- * (itself tappable, or a tappable span of a label), and the canvas element's cursor is switched only when the
101
- * answer changes. Mouse moves only, no work without a mouse and none in the frame loop.
261
+ * is pointer-events:none, so the canvas decides from the hover hit path (Hover.Path: the controls under the mouse by
262
+ * the routing rules of ProcessGestures, so nothing below a popup that blocks gestures below): a control in the
263
+ * accessibility tree (it has a role) that answers WantsPointerCursor (itself tappable, or a tappable span of a label)
264
+ * shows the hand. A popup's close-on-background-tap wrapper has no role, so its backdrop shows none. The canvas
265
+ * element's cursor is switched only when the answer changes. Mouse moves only, none in the frame loop.
102
266
  */
103
267
  private UpdateCursor;
104
- /** Mouse wheel -> TouchActionResult.Wheel (page scroll suppressed while gestures are enabled). */
268
+ /**
269
+ * Mouse wheel -> TouchActionResult.Wheel.
270
+ * Lock keeps every wheel on the canvas. Enabled shares it with the page, like DrawnUi.Blazor's
271
+ * TouchHandlingStyle.Manual: the page scrolls unless a control consumed this wheel. The browser needs that answer
272
+ * inside this handler, so the wheel is processed now instead of at the next frame (Blazor does the same, for the
273
+ * same reason); pending gestures are flushed first so the event order is kept.
274
+ */
105
275
  private readonly onWheel;
276
+ /**
277
+ * Processes one gesture immediately (after whatever is queued) and reports whether a control USED it: a consumer
278
+ * that marked the event Handled, or any consumer that is not a `BlockGesturesBelow` layer. A blocker returns itself
279
+ * for every gesture it keeps from the controls below (a shell page, a popup backdrop), which is not a use: counting
280
+ * it would block the page wheel over every shell app.
281
+ */
282
+ private ProcessGestureNow;
283
+ /**
284
+ * The page axes a touch pan over the canvas hands to the browser: "pan-y" when the page (or a scrolling ancestor) can
285
+ * scroll vertically, "pan-x" horizontally, both, or "none". Mirrors MAUI's Gestures="Enabled" inside a native scroll
286
+ * view, where the parent takes the pans it scrolls in.
287
+ */
288
+ private static PageScrollAxes;
289
+ /**
290
+ * Gestures="Enabled" shares touch pans with the page like MAUI's Enabled inside a native scroll view: along an axis
291
+ * the page can scroll, the browser takes the pan (and sends pointercancel), taps and the other axis stay on the
292
+ * canvas. A page that cannot scroll, and Lock, keep every touch. The browser reads touch-action when a touch starts,
293
+ * so it is kept current ahead of time: on attach, when the window / html / body resize, and after every touch.
294
+ */
295
+ private readonly UpdateTouchAction;
296
+ private pageObserver?;
106
297
  private AttachInput;
298
+ /** The page's own overscroll-behavior before Lock set it to none (html, body), put back on detach. */
299
+ private pageOverscroll?;
107
300
  private DetachInput;
108
301
  /** Port of DrawnUi.Blazor Canvas.OnTouchAction: per-pointer state machine producing Down / Panning / Tapped / Up. */
109
302
  OnTouchAction(args: TouchActionEventArgs): void;
303
+ /** The fingers down, for TouchActionEventArgs.Manipulation (pinch and turn). */
304
+ private readonly fingers;
305
+ /** The press had a second finger: it is no tap (AppoMobi.Blazor.Gestures). */
306
+ private multiTouch;
307
+ private readonly longPressTimers;
308
+ private readonly longPressed;
309
+ /** The long press of a new press: due LongPressTimeMs later unless the pointer moves away or lets go. */
310
+ private ArmLongPress;
311
+ private DisarmLongPress;
110
312
  private OnGestureEvent;
111
313
  private ProcessPendingGestures;
112
314
  /**
@@ -118,6 +320,35 @@ export declare class Canvas {
118
320
  private gestureOwner;
119
321
  /** DrawnUi IsSavedGesture: the types replayed to the owner instead of being routed again. */
120
322
  private static IsSavedGesture;
121
- /** Entry into the control tree, same shape as DrawnUi Canvas.ProcessGestures. */
323
+ private arrowsStart;
324
+ /**
325
+ * While no drawn control has keyboard focus (or only one behind the active modal), the arrow keys start keyboard
326
+ * navigation as the first Tab does: Down and Right go to the first Tab stop, Up and Left to the last, and the key is used
327
+ * for that. Once a control has focus the arrows work as usual (inside a list or a menu). Off by default, since games use
328
+ * the arrows as their own keys while nothing is focused: an app turns it on for its menu screens and off while playing.
329
+ */
330
+ get ArrowsStartKeyboardNavigation(): boolean;
331
+ set ArrowsStartKeyboardNavigation(v: boolean);
332
+ private readonly onArrowKey;
333
+ private focusedChild?;
334
+ private focusAtDown?;
335
+ private tapNoFocus;
336
+ private reportingFocus;
337
+ /**
338
+ * A control that left the canvas (removed or disposed) is let go by the focus, the gesture dispatch and the tooltips,
339
+ * so the last control that took input does not keep its page alive (C# 4cb28ab6). Checked once per frame.
340
+ */
341
+ private ForgetGoneControls;
342
+ /** The control that has the canvas focus (an editor while it edits, a CanBeFocused control that was tapped). */
343
+ get FocusedChild(): SkiaControl | undefined;
344
+ /**
345
+ * Moves the focus. The new control is asked first and the focus moves only when it takes it (a tap on a button leaves an
346
+ * editor focused); undefined clears it. Nothing moves while the focused control has LockFocus. `setter` is a control
347
+ * that focused itself already (an editor on its press) or the focused control letting go itself (Escape, submit).
348
+ */
349
+ ReportFocus(value: SkiaControl | undefined, setter?: SkiaControl): void;
350
+ /** Entry into the control tree; on a completed tap the focus follows it (C# Canvas: focus only on Tapped). */
122
351
  protected ProcessGestures(root: SkiaControl, args: SkiaGesturesParameters): SkiaControl | null;
352
+ /** Same shape as DrawnUi Canvas.ProcessGestures. */
353
+ private RouteGestures;
123
354
  }