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
@@ -0,0 +1,224 @@
1
+ import { Super } from "./Super";
2
+ /**
3
+ * Text shaping (C# SkiaLabel DrawShapedText, HarfBuzzSharp there; DrawnUi.Rust shaping.rs, harfrust) for the text that
4
+ * needs it: complex scripts whose letters join or reorder (Arabic, Hebrew marks, Indic, Thai...) and emoji sequences
5
+ * (ZWJ families, skin tones, flags, keycaps). Everything else keeps the plain path: one glyph per character.
6
+ * HarfBuzz and ICU come with the CanvasKit paragraph module, already in the build (no extra wasm): a run is laid out as a
7
+ * one-font paragraph and its shaped glyphs are read back; the label keeps its own line breaking and font fallback.
8
+ */
9
+ /** C# SkiaLabel.UnicodeNeedsShaping, plus the characters that make emoji sequences and the right-to-left scripts C# leaves out. */
10
+ export function NeedsShaping(cp) {
11
+ return (cp >= 0x0590 && cp <= 0x08FF) // Hebrew, Arabic, Syriac, Arabic Supplement, Thaana, NKo, Samaritan, Mandaic, Arabic Extended
12
+ || (cp >= 0x0900 && cp <= 0x0DFF) // Devanagari .. Sinhala
13
+ || (cp >= 0x0E00 && cp <= 0x0FFF) // Thai, Lao, Tibetan
14
+ || (cp >= 0x1000 && cp <= 0x109F) // Myanmar
15
+ || (cp >= 0x10A0 && cp <= 0x10FF) // Georgian
16
+ || (cp >= 0x1100 && cp <= 0x11FF) // Hangul Jamo
17
+ || (cp >= 0x1200 && cp <= 0x137F) // Ethiopic
18
+ || (cp >= 0x1780 && cp <= 0x18AF) // Khmer, Mongolian
19
+ || cp === 0x200C || cp === 0x200D // ZWNJ, ZWJ
20
+ || cp === 0x20E3 // keycap
21
+ || (cp >= 0x2600 && cp <= 0x27BF) // symbols that have emoji forms
22
+ || (cp >= 0xFB1D && cp <= 0xFDFF) // Hebrew and Arabic presentation forms A
23
+ || (cp >= 0xFE00 && cp <= 0xFE0F) // variation selectors (VS15 / VS16)
24
+ || (cp >= 0xFE70 && cp <= 0xFEFF) // Arabic presentation forms B
25
+ || (cp >= 0x1F000 && cp <= 0x1FAFF) // emoji, regional indicators (flags), skin tones
26
+ || (cp >= 0xE0020 && cp <= 0xE007F); // tag sequences (subdivision flags)
27
+ }
28
+ /** Characters that belong to the glyph before them (an emoji sequence or a mark): they keep its font (C# JoinsPreviousGlyph). */
29
+ export function JoinsPrevious(cp) {
30
+ return cp === 0x200D || cp === 0x20E3 || (cp >= 0xFE00 && cp <= 0xFE0F) || (cp >= 0x1F3FB && cp <= 0x1F3FF) || (cp >= 0xE0020 && cp <= 0xE007F);
31
+ }
32
+ /** Right-to-left letters: a paragraph with one of them gets the bidirectional pass. */
33
+ export function IsRtl(cp) {
34
+ return (cp >= 0x0590 && cp <= 0x08FF) || (cp >= 0xFB1D && cp <= 0xFDFF) || (cp >= 0xFE70 && cp <= 0xFEFF) || (cp >= 0x10800 && cp <= 0x10FFF) || (cp >= 0x1E800 && cp <= 0x1EFFF);
35
+ }
36
+ /** Whether a text has a character `test` accepts. */
37
+ export function HasCodePoint(text, test) {
38
+ for (let i = 0; i < text.length; i++) {
39
+ const c = text.charCodeAt(i);
40
+ // below U+0590 nothing needs shaping or is right to left
41
+ if (c < 0x0590)
42
+ continue;
43
+ const cp = text.codePointAt(i);
44
+ if (test(cp))
45
+ return true;
46
+ if (cp > 0xFFFF)
47
+ i++;
48
+ }
49
+ return false;
50
+ }
51
+ const cache = new Map();
52
+ /** Bounds the shaping cache; a label re-measured with new text shapes again. */
53
+ const CacheLimit = 4000;
54
+ /**
55
+ * Shapes `text` with `font` in one direction (the caller splits runs by font and by bidirectional level), `spacing`
56
+ * pixels after every code point. Undefined when the font was not registered through the font registry (no shaping
57
+ * data): the caller keeps its plain glyphs.
58
+ */
59
+ export function Shape(font, text, rtl, spacing) {
60
+ const family = Super.ShapingFamilyOf(font);
61
+ if (!family || !text)
62
+ return undefined;
63
+ const size = font.getSize();
64
+ const key = `${family}|${size}|${rtl ? 1 : 0}|${spacing}|${text}`;
65
+ const hit = cache.get(key);
66
+ if (hit !== undefined)
67
+ return hit ?? undefined;
68
+ const shaped = ShapeNow(font, family, size, text, rtl, spacing);
69
+ if (cache.size >= CacheLimit)
70
+ cache.clear();
71
+ cache.set(key, shaped ?? null);
72
+ return shaped;
73
+ }
74
+ /** Width a run is laid out in: one line, never wrapped; a right-to-left run ends at its right edge. */
75
+ const LayoutWidth = 1e6;
76
+ function Paragraph(family, size, text, rtl) {
77
+ const CK = Super.CK;
78
+ const style = new CK.ParagraphStyle({ textStyle: { fontFamilies: [family], fontSize: size }, textDirection: rtl ? CK.TextDirection.RTL : CK.TextDirection.LTR });
79
+ const builder = CK.ParagraphBuilder.MakeFromFontProvider(style, Super.ShapingFonts);
80
+ builder.addText(text);
81
+ const paragraph = builder.build();
82
+ builder.delete();
83
+ paragraph.layout(LayoutWidth);
84
+ return paragraph;
85
+ }
86
+ function ShapeNow(font, family, size, text, rtl, spacing) {
87
+ const paragraph = Paragraph(family, size, text, rtl);
88
+ try {
89
+ const lines = paragraph.getShapedLines();
90
+ if (lines.length === 0)
91
+ return undefined;
92
+ // the code point of every UTF-8 byte offset (the shaped runs report clusters in UTF-8)
93
+ const cpOfByte = [], u16OfCp = [];
94
+ let cps = 0, u16 = 0;
95
+ for (const ch of text) {
96
+ const c = ch.codePointAt(0), bytes = c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;
97
+ for (let b = 0; b < bytes; b++)
98
+ cpOfByte.push(cps);
99
+ u16OfCp.push(u16);
100
+ cps++;
101
+ u16 += ch.length;
102
+ }
103
+ const cpOf = (byte) => cpOfByte[Math.min(byte, cpOfByte.length - 1)] ?? 0;
104
+ let count = 0;
105
+ for (const l of lines)
106
+ for (const r of l.runs)
107
+ count += r.glyphs.length;
108
+ const glyphs = new Uint16Array(count), positions = new Float32Array(count * 2), advances = new Array(cps).fill(0), clusters = new Array(count);
109
+ // one line (no width limit, no line breaks in a run); runs come in visual order. Glyph positions include their
110
+ // offsets (a mark sits off its pen position), so the run's left edge and width come from the paragraph itself.
111
+ const shapedWidth = paragraph.getMaxIntrinsicWidth();
112
+ const left = rtl ? LayoutWidth - shapedWidth : 0;
113
+ let k = 0;
114
+ for (const l of lines) {
115
+ for (const r of l.runs) {
116
+ for (let g = 0; g < r.glyphs.length; g++, k++) {
117
+ glyphs[k] = r.glyphs[g];
118
+ positions[k * 2] = r.positions[g * 2] - left;
119
+ positions[k * 2 + 1] = r.positions[g * 2 + 1] - l.baseline;
120
+ clusters[k] = cpOf(r.offsets[g]);
121
+ }
122
+ }
123
+ }
124
+ // the advance of every grapheme on its first code point (caret boxes): the paragraph's own grapheme bounds, which
125
+ // follow the shaped pen advances (DrawnUi.Rust: HarfBuzz x_advance per cluster)
126
+ let sum = 0;
127
+ for (let i = 0; i < cps; i++) {
128
+ const info = paragraph.getGlyphInfoAt(u16OfCp[i]);
129
+ if (!info || info.graphemeClusterTextRange.start !== u16OfCp[i])
130
+ continue;
131
+ const b = info.graphemeLayoutBounds;
132
+ advances[i] = b[2] - b[0];
133
+ sum += advances[i];
134
+ }
135
+ if (sum <= 0) {
136
+ // no grapheme bounds: the glyphs' own widths, scaled to the shaped width
137
+ const glyphWidths = font.getGlyphWidths(glyphs);
138
+ for (let g = 0; g < count; g++) {
139
+ advances[clusters[g]] += glyphWidths[g];
140
+ sum += glyphWidths[g];
141
+ }
142
+ if (sum > 0)
143
+ for (let i = 0; i < advances.length; i++)
144
+ advances[i] *= shapedWidth / sum;
145
+ }
146
+ if (spacing !== 0) {
147
+ // visual order: the spacing of the code points between two clusters goes between them
148
+ let extra = 0, last = -1;
149
+ for (let g = 0; g < count; g++) {
150
+ if (last >= 0 && last !== clusters[g])
151
+ extra += spacing * Math.abs(last - clusters[g]);
152
+ last = clusters[g];
153
+ positions[g * 2] += extra;
154
+ }
155
+ for (let i = 0; i < advances.length; i++)
156
+ advances[i] += spacing;
157
+ }
158
+ const width = shapedWidth + spacing * cps;
159
+ return { Glyphs: glyphs, Positions: positions, Advances: advances, Width: width };
160
+ }
161
+ finally {
162
+ paragraph.delete();
163
+ }
164
+ }
165
+ /**
166
+ * Bidirectional runs of a line (Unicode bidirectional algorithm, ICU in CanvasKit), read from the visual order of a
167
+ * paragraph of that line: digits after Arabic in a left-to-right paragraph stay with the Arabic run (level 2), as the
168
+ * algorithm orders them. Undefined when no font was registered for shaping.
169
+ */
170
+ export function BidiRuns(text, rtlParagraph) {
171
+ const family = Super.AnyShapingFamily();
172
+ if (!family || !text)
173
+ return undefined;
174
+ const CK = Super.CK;
175
+ const paragraph = Paragraph(family, 12, text, rtlParagraph);
176
+ try {
177
+ // UTF-16 index of every UTF-8 byte offset (the shaped runs report clusters in UTF-8)
178
+ const u16OfByte = [];
179
+ let u = 0;
180
+ for (const ch of text) {
181
+ const c = ch.codePointAt(0), bytes = c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;
182
+ for (let k = 0; k < bytes; k++)
183
+ u16OfByte.push(u);
184
+ u += ch.length;
185
+ }
186
+ u16OfByte.push(u);
187
+ // every cluster start with the rank of its run; runs come left to right
188
+ const starts = [];
189
+ const firstOfRank = [];
190
+ let rank = 0;
191
+ for (const l of paragraph.getShapedLines()) {
192
+ for (const r of l.runs) {
193
+ let first = Infinity;
194
+ for (let g = 0; g < r.glyphs.length; g++) {
195
+ const at = u16OfByte[Math.min(r.offsets[g], u16OfByte.length - 1)];
196
+ starts.push({ At: at, Rank: rank });
197
+ first = Math.min(first, at);
198
+ }
199
+ firstOfRank.push(first);
200
+ rank++;
201
+ }
202
+ }
203
+ if (starts.length === 0)
204
+ return undefined;
205
+ starts.sort((x, y) => x.At - y.At);
206
+ const map = { Rank: new Int32Array(text.length), Rtl: new Uint8Array(text.length) };
207
+ let k = 0, current = starts[0].Rank;
208
+ for (let i = 0; i < text.length; i++) {
209
+ while (k < starts.length && starts[k].At <= i)
210
+ current = starts[k++].Rank;
211
+ map.Rank[i] = current;
212
+ }
213
+ const rtlOfRank = firstOfRank.map((at) => {
214
+ const info = Number.isFinite(at) ? paragraph.getGlyphInfoAt(at) : null;
215
+ return info ? info.dir.value === CK.TextDirection.RTL.value : rtlParagraph;
216
+ });
217
+ for (let i = 0; i < text.length; i++)
218
+ map.Rtl[i] = rtlOfRank[map.Rank[i]] ? 1 : 0;
219
+ return map;
220
+ }
221
+ finally {
222
+ paragraph.delete();
223
+ }
224
+ }
@@ -1,8 +1,9 @@
1
1
  import type { Canvas as SkCanvas, Image, Path, SkPicture, Surface } from "canvaskit-wasm";
2
- import { type Color, type LayoutOptions, SKRect, ScaledSize, type SkiaCacheType, type SkiaGradient, type SkiaTouchAnimation, Thickness } from "./Types";
3
- import { type IOverlayEffect } from "./Animators";
2
+ import { type Color, type LayoutOptions, SKRect, ScaledSize, type SkiaCacheType, type SkiaGradient, type SkiaTouchAnimation, Thickness, type ThicknessValue } from "./Types";
3
+ import { type AnimatorBase, type IOverlayEffect } from "./Animators";
4
4
  import { Easing } from "./Easing";
5
5
  import type { Canvas } from "./Canvas";
6
+ import type { InputKey } from "./KeyboardManager";
6
7
  import { ContextMenuEventArgs, ControlTappedEventArgs, GestureEventProcessingInfo, type LockTouch, SKPoint, SkiaGesturesInfo, SkiaGesturesParameters } from "./Gestures";
7
8
  import { type CachedTexture, type IPostRendererEffect, type SkiaEffect } from "./SkiaEffect";
8
9
  /** Mirrors DrawnUi DrawingContext: ctx.Context.Canvas / Surface, ctx.Destination (pixels), ctx.Scale. */
@@ -20,6 +21,10 @@ export interface DrawingContext {
20
21
  Y: number;
21
22
  };
22
23
  Recording?: boolean;
24
+ /** The picture being recorded is drawn scaled, turned, skewed or projected: images blitted into it sample smoothly (C#). */
25
+ PlaybackDistorted?: boolean;
26
+ /** An image cache (or a picture holding one) was blitted here (C#): the picture is recorded again when its playback distortion changes. */
27
+ HasImageBlits?: boolean;
23
28
  };
24
29
  Destination: SKRect;
25
30
  Scale: number;
@@ -35,8 +40,27 @@ export declare class CachedObject {
35
40
  constructor(Type: SkiaCacheType,
36
41
  /** Rect the content was recorded for, canvas pixels at recording time. */
37
42
  Bounds: SKRect, Scale: number, Picture?: SkPicture | undefined, Image?: Image | undefined);
38
- /** Replays the cache with its top-left moved to (left, top). */
39
- Draw(canvas: SkCanvas, left: number, top: number): void;
43
+ /** Canvas.GpuEpoch it was made in: after a WebGL context restore it is remade (a picture may replay old GPU images). */
44
+ Epoch: number;
45
+ /** A picture recorded to be drawn distorted: the images in it sample smoothly (C# CachedObject.PlaybackDistorted). */
46
+ PlaybackDistorted: boolean;
47
+ /** A picture holding image blits, whose sampling was fixed when it was recorded (C# CachedObject.HasImageBlits). */
48
+ HasImageBlits: boolean;
49
+ /** C# PaintRenderObject: the blit paint is antialiased (else a turned bitmap keeps stair steps along its own border), dithered when distorted. */
50
+ private static blitPaint?;
51
+ private static blitPaintDithered?;
52
+ private static BlitPaint;
53
+ /** Replays the cache with its top-left moved to (left, top); `smooth` = an image drawn distorted (linear + mipmaps). */
54
+ Draw(canvas: SkCanvas, left: number, top: number, smooth?: boolean): void;
55
+ /**
56
+ * C# GetPictureImage: the picture of a picture cache (Operations, OperationsFull) drawn into an image, made on the
57
+ * first call (on `main`'s GPU context when given) and kept as long as this cache lives. Shader effects read it as
58
+ * their input, so on such a control they work on its own content, as on an Image cache.
59
+ */
60
+ GetPictureImage(main?: Surface): Image | undefined;
61
+ private pictureImage?;
62
+ /** The picture drawn into an image, once GetPictureImage made it. */
63
+ get PictureImage(): Image | undefined;
40
64
  Dispose(): void;
41
65
  }
42
66
  /**
@@ -63,7 +87,10 @@ export declare class SkiaControl {
63
87
  Row: number;
64
88
  ColumnSpan: number;
65
89
  RowSpan: number;
66
- Margin: Thickness;
90
+ private margin;
91
+ /** Space around the control (points); a number is the same on every side, as C# XAML (`Thickness.From`). */
92
+ get Margin(): Thickness;
93
+ set Margin(v: ThicknessValue);
67
94
  /**
68
95
  * DrawnUi LockRatio: 0 = off; positive = square of the LARGER of the two sizes (requests or constraints),
69
96
  * negative = square of the SMALLER one. Infinite sides are ignored, so WidthRequest=150 + LockRatio=1 = 150x150.
@@ -83,6 +110,14 @@ export declare class SkiaControl {
83
110
  /** Degrees. */
84
111
  SkewX: number;
85
112
  SkewY: number;
113
+ /** Degrees, a 3D turn around the horizontal axis through the pivot, seen with perspective (C# RotationX). */
114
+ RotationX: number;
115
+ /** Degrees, a 3D turn around the vertical axis through the pivot (C# RotationY). */
116
+ RotationY: number;
117
+ /** Degrees, a 3D turn around the axis facing the viewer, after RotationX and RotationY (C# RotationZ). */
118
+ RotationZ: number;
119
+ /** Depth: toward the viewer (+, bigger) or away (−, smaller), turned or flat; draws at 576 / (576 − TranslationZ) (C# TranslationZ). */
120
+ TranslationZ: number;
86
121
  /** Pivot for Rotation/Scale/Skew as a fraction of the box (MAUI default 0.5). */
87
122
  AnchorX: number;
88
123
  AnchorY: number;
@@ -106,6 +141,7 @@ export declare class SkiaControl {
106
141
  get Scale(): number;
107
142
  set Scale(v: number);
108
143
  get HasTransform(): boolean;
144
+ private get Has3d();
109
145
  /** Matrix applied at the last render (canvas space), undefined when none; gestures map through its inverse. */
110
146
  RenderTransformMatrix?: number[];
111
147
  /** Generic numeric parameters (DrawnUi Value1/Value2): SkiaShape Arc uses start angle / sweep angle in degrees. */
@@ -135,18 +171,43 @@ export declare class SkiaControl {
135
171
  private compositeSurface?;
136
172
  /** Own content or structure changed: the next composite record is a full one. */
137
173
  private compositeFull;
174
+ /** Where the kept composite surface starts relative to DrawingRect (the effects margin it was laid out with). */
175
+ private compositeInsetX;
176
+ private compositeInsetY;
138
177
  /** Canvas-pixel bounds this control covered when its parent last recorded it (composite erase region). */
139
178
  private lastCompositeBounds?;
140
- /** What the last composite record did (diagnostics): "full" or "partial", the number of children re-recorded and which ones. */
179
+ /**
180
+ * What the last composite record did (diagnostics): "full" or "partial", the number of children re-recorded and which
181
+ * ones; Areas: the pixels erased and drawn again for changes deeper than a child (C# Areas), Changed: the controls
182
+ * those areas belong to (C# Changed).
183
+ */
141
184
  LastCompositeRecord: {
142
185
  Mode: "full" | "partial";
143
186
  Children: number;
144
187
  Dirty: readonly SkiaControl[];
188
+ Areas: readonly SKRect[];
189
+ Changed: readonly SkiaControl[];
145
190
  };
191
+ /** C# MaxCompositionAreas: more areas than this in one composite record draw it whole instead. */
192
+ static MaxCompositionAreas: number;
193
+ /** C# MaxCompositionShare: areas covering more than this share of a composite draw it whole instead. */
194
+ static MaxCompositionShare: number;
195
+ /**
196
+ * Changes deeper than a direct child since the last composite record (drawnui-cross 6m): the control, the direct child
197
+ * it is in, where it was drawn before the change (its own drawn bounds, as drawn) and its rect then.
198
+ */
199
+ private compositeDeep?;
200
+ /** Set while an UpdateDraw climbs: the ancestors re-measure but an ImageComposite among them keeps its partial record. */
201
+ private static drawOrigin;
146
202
  /** The children a composite record can re-record individually; layouts return their views. */
147
203
  protected GetCompositeChildren(): readonly SkiaControl[];
148
204
  /** C# TrackChildAsDirty (DirtyChildrenTracker): the child changed without a remeasure of this control. */
149
205
  TrackChildAsDirty(child: SkiaControl): void;
206
+ private static readonly rejectRect;
207
+ /** Its cache must be recorded before it can be drawn (none, dirty, another type, scale, size or GPU context). */
208
+ private CacheStale;
209
+ /** Its rect grown by its effects margin, through the matrix it is drawn with, lies outside the canvas clip. */
210
+ private OutsideClip;
150
211
  /** Drawn bounds in canvas pixels including transforms and effects margins (C# GetTransformedDirtyBounds). */
151
212
  GetTransformedDirtyBounds(): SKRect;
152
213
  /** Current cache, if any. */
@@ -157,6 +218,36 @@ export declare class SkiaControl {
157
218
  /** Consume every gesture that lands on this control so nothing below (z-order) receives it. */
158
219
  BlockGesturesBelow: boolean;
159
220
  LockChildrenGestures: LockTouch;
221
+ private receivesHover?;
222
+ /**
223
+ * Whether this control takes mouse hover: the canvas sets IsHovered while the mouse is over it. Opt-in: false by
224
+ * default, true by default only in the controls that always had hover (SkiaButton, SkiaSlider, the toggles,
225
+ * SkiaRadioButton, SkiaCarousel, SkiaDrawer), never because a control has a tap handler. A HoverChanged handler turns
226
+ * it on (C# fluent OnHovered) unless it is set.
227
+ */
228
+ get ReceivesHover(): boolean;
229
+ set ReceivesHover(value: boolean);
230
+ /** The value of ReceivesHover until it is set. */
231
+ protected ReceivesHoverByDefault(): boolean;
232
+ private isHovered;
233
+ /**
234
+ * True while the mouse is over this control and it takes hover. Every such control under the pointer is hovered at
235
+ * once (a card and the button inside it, as CSS :hover); it stays as it is while content moves under the pointer and
236
+ * is checked again when that stops. Touch never hovers.
237
+ */
238
+ get IsHovered(): boolean;
239
+ /** IsHovered changed: true when the mouse came over this control, false when it left (C# HoverChanged / OnHovered). */
240
+ HoverChanged?: (sender: SkiaControl, hovered: boolean) => void;
241
+ /** Set by the canvas's HoverManager. */
242
+ ApplyHover(on: boolean): void;
243
+ /** A scroll, carousel or drawer moving its content right now: hover waits until it stops (C# IsScrolling / InTransition). */
244
+ MovesContent(): boolean;
245
+ /**
246
+ * Hover hit path (HoverManager): this control is under the point (in its own space), its children under it follow,
247
+ * top-most first, by the routing rules of ProcessGestures. True when this subtree blocks gestures below it, so the
248
+ * controls under it get no hover (a popup over a list).
249
+ */
250
+ CollectHovered(point: SKPoint, into: SkiaControl[], xs?: number[], ys?: number[]): boolean;
160
251
  TouchEffectColor: Color;
161
252
  /** Plays a ripple (from the tap point) when Tapped fires. */
162
253
  AnimationTapped: SkiaTouchAnimation;
@@ -164,6 +255,11 @@ export declare class SkiaControl {
164
255
  AnimationTappedSpeed: number;
165
256
  /** Overlay effects drawn above this control's content every frame (ripple etc). */
166
257
  readonly PostAnimators: IOverlayEffect[];
258
+ /**
259
+ * C# PendingUnattachedAnimators: animators started while no Canvas was above this control yet (e.g. a game loop
260
+ * started in a constructor). They start on the control's first arrange, where C# starts them in SuperViewChanged.
261
+ */
262
+ PendingUnattachedAnimators?: AnimatorBase[];
167
263
  private visualEffects;
168
264
  /** Post-renderer effects among VisualEffects (C# EffectPostRenderers). */
169
265
  EffectPostRenderers: (SkiaEffect & IPostRendererEffect)[];
@@ -175,7 +271,12 @@ export declare class SkiaControl {
175
271
  protected OnVisualEffectsChanged(): void;
176
272
  /** Post renderers that can render this frame (compiled shaders); an unready effect leaves the control drawn plainly. */
177
273
  private ActivePostRenderers;
178
- /** C# CachedImage: the cached texture and the canvas rect it was rasterized over (Image caches only). */
274
+ /**
275
+ * C# CachedImage: the cached texture (Image caches only) and the canvas rect it covers NOW. Scrolled content is
276
+ * re-arranged here, not drawn through a translated canvas, so a cache recorded before its control moved is blitted
277
+ * at the control's current aligned rect (RenderContent) and its record-time Bounds are stale: an effect sampling it
278
+ * there (the slides of a SkiaShaderCarousel after the page scrolled) was off by the scroll amount.
279
+ */
179
280
  get CachedImage(): CachedTexture | undefined;
180
281
  /** Clip overlay effects to the control's shape (CreateClip). */
181
282
  ClipEffects: boolean;
@@ -198,6 +299,11 @@ export declare class SkiaControl {
198
299
  * built in code-behind is styled on its first measure and keeps whatever the code already set.
199
300
  */
200
301
  ApplyInitialStyles(atConstruction?: boolean): void;
302
+ /**
303
+ * C# IsChildrenItem: added by the app (JSX children or the `Children` list), not a part the control made itself. A new
304
+ * `Children` list drops only these, so a control's own parts keep their place.
305
+ */
306
+ IsChildrenItem: boolean;
201
307
  AddSubView(_control: SkiaControl): void;
202
308
  InsertSubView(_index: number, control: SkiaControl): void;
203
309
  RemoveSubView(_control: SkiaControl): void;
@@ -220,6 +326,14 @@ export declare class SkiaControl {
220
326
  protected MeasureAbsolute(_widthConstraint: number, _heightConstraint: number, scale: number): ScaledSize;
221
327
  /** Places MeasuredSize inside destination per Margin + Horizontal/VerticalOptions -> DrawingRect. */
222
328
  Arrange(destination: SKRect, _widthRequest: number, _heightRequest: number, scale: number): void;
329
+ /**
330
+ * A cached ancestor replays its picture where a re-arrange moved it (a scroll) without rendering this control again,
331
+ * so the matrix made at its last Render moves with its rect: taps, hover and the accessibility rect stay on what is
332
+ * drawn (C# offsets the cached render tree instead). A control that renders again gets a fresh matrix there.
333
+ */
334
+ private FollowMatrix;
335
+ /** C# SuperViewChanged: starts the animators queued before this control was attached. */
336
+ private StartPendingAnimators;
223
337
  private static nextAccessibilityId;
224
338
  /** Stable identity for the DOM overlay. */
225
339
  readonly AccessibilityId: number;
@@ -244,7 +358,11 @@ export declare class SkiaControl {
244
358
  protected DefaultAccessibilityLabel(): string | undefined;
245
359
  get AccessibilityHint(): string | undefined;
246
360
  set AccessibilityHint(v: string | undefined);
247
- /** Tab stop + activation; unset = true when the control handles Tapped. */
361
+ /**
362
+ * Whether keyboard navigation and assistive technology may focus and use this node: the explicit value, else the class
363
+ * default (true when the control handles Tapped), and in both cases only while a tap could reach the control
364
+ * (CanReceiveGesture), so Tab, Enter / Space and screen-reader activation never use a control the pointer cannot.
365
+ */
248
366
  get AccessibilityCanInteract(): boolean;
249
367
  set AccessibilityCanInteract(v: boolean);
250
368
  protected DefaultAccessibilityCanInteract(): boolean;
@@ -253,6 +371,8 @@ export declare class SkiaControl {
253
371
  * host's pointer cursor. Default: the control as a whole (AccessibilityCanInteract); SkiaLabel adds its tappable spans.
254
372
  */
255
373
  WantsPointerCursor(_x: number, _y: number): boolean;
374
+ /** A range control's value for screen readers (slider, progress); undefined for everything else (drawnui-cross 6c). */
375
+ get AccessibilityValue(): import("./Accessibility").AccessibilityValue | undefined;
256
376
  /** aria-pressed for toggles; undefined = not a toggle. */
257
377
  get AccessibilityIsPressed(): boolean | undefined;
258
378
  set AccessibilityIsPressed(v: boolean | undefined);
@@ -281,6 +401,30 @@ export declare class SkiaControl {
281
401
  OnAccessibilityActivated(): void;
282
402
  /** Overlay focus arrives on / leaves this node (inputs may activate their sink here). */
283
403
  OnAccessibilityFocused(_focused: boolean): void;
404
+ /**
405
+ * Keyboard navigation hands this control the keys it may use while it holds keyboard focus (ArrowLeft / Right / Up /
406
+ * Down, Home, End, PageUp, PageDown, DOM `event.code` names). Return true when the key was used; the default uses none,
407
+ * so the key moves focus inside the arrow-key group around the control.
408
+ */
409
+ OnAccessibilityKey(_key: InputKey): boolean;
410
+ /**
411
+ * Whether a pointer gesture of this kind would reach this control, by the rules the gesture dispatch applies: the
412
+ * control and every ancestor draw, none of them is InputTransparent, no ancestor keeps this gesture from its children
413
+ * (LockChildrenGestures, PassNone included) and the control accepts input (AcceptsInput). Opacity does not count, as
414
+ * for the pointer. Keyboard navigation uses it: Tapped for Tab and Enter / Space, Panning for the arrow keys.
415
+ */
416
+ CanReceiveGesture(gesture: SkiaGesturesParameters["Type"]): boolean;
417
+ /**
418
+ * False while the control ignores input itself: RespondsToGestures = false on a button, toggle, slider, scroll...
419
+ * Taps, keyboard and the accessibility state (reported disabled) all follow it (drawnui-cross 6w). Default true.
420
+ */
421
+ protected AcceptsInput(): boolean;
422
+ /**
423
+ * What a control that takes no input returns for a gesture that reached it (C# BlockedGestureResult): it keeps a
424
+ * press, tap or long press, so nothing under it reacts to them, and lets moves and wheel go on to the controls around
425
+ * it (a scroll behind it still scrolls).
426
+ */
427
+ protected BlockedGestureResult(args: SkiaGesturesParameters): SkiaControl | null;
284
428
  NotifyAccessibilityFocused(focused: boolean): void;
285
429
  /** DrawnUi SmartMax: larger of two sizes, an infinite one loses. */
286
430
  protected static SmartMax(a: number, b: number): number;
@@ -303,8 +447,22 @@ export declare class SkiaControl {
303
447
  /** DrawingRect grown by the effects margin, in pixels — the rect a cache is recorded for. */
304
448
  protected ExpandedCacheRect(scale: number): SKRect;
305
449
  Render(ctx: DrawingContext): void;
306
- /** Port of DrawnUi ApplyTransforms: T(-pivot) · rotation · scale/skew · T(pivot) · translation, in canvas pixels. */
450
+ /** Port of DrawnUi ApplyTransforms: T(-pivot) · rotation · scale/skew · 3D · T(pivot) · translation, in canvas pixels. */
307
451
  protected CreateRenderTransformMatrix(destination: SKRect, scale: number): number[];
452
+ /** C# camera distance of the 3D transforms (Sk3dView.CameraDistance): 8 inches at 72 dpi, in canvas pixels. */
453
+ static readonly CameraDistance = 576;
454
+ /**
455
+ * C# Create3dMatrix (Sk3dView): RotationX, then RotationY, then RotationZ (negated) around the pivot, projected from
456
+ * the camera; TranslationZ is depth, a flat control at depth z draws at camera / (camera − z).
457
+ */
458
+ static Create3dMatrix(rotationX: number, rotationY: number, rotationZ: number, translationZ: number): number[];
459
+ /** C# SkiaSamplingOptions.IsMoveOnly: the matrix only moves (or mirrors), so a bitmap keeps its pixels 1:1. */
460
+ static IsMoveOnly(m: ArrayLike<number>): boolean;
461
+ /**
462
+ * C# WillDrawDistorted: what this control draws here ends up scaled, turned, skewed or projected, by its own transforms
463
+ * or a live ancestor's (both in the canvas matrix) or by the picture it is recorded into. Images then sample smoothly.
464
+ */
465
+ protected WillDrawDistorted(ctx: DrawingContext): boolean;
308
466
  /** Maps a point given in the parent's space into this control's untransformed space (DrawnUi TransformPointToLocalSpace). */
309
467
  TransformPointToLocalSpace(point: SKPoint): SKPoint;
310
468
  /**
@@ -314,6 +472,8 @@ export declare class SkiaControl {
314
472
  private AlignedCacheRect;
315
473
  /** Cache blit or live paint, then post animators — the part a transform/opacity layer wraps. */
316
474
  private RenderContent;
475
+ /** Blits a cache: an image samples smoothly when drawn distorted; a picture being recorded learns it holds image blits. */
476
+ private DrawCache;
317
477
  /** Background + Paint(): the part of the control that a cache captures. */
318
478
  protected PaintContent(ctx: DrawingContext): void;
319
479
  /** Subclasses whose PaintBackground has something to draw without a BackgroundColor (shape shadows). */
@@ -377,11 +537,51 @@ export declare class SkiaControl {
377
537
  Update(): void;
378
538
  /** Redraw without remeasure and WITHOUT dropping caches (position/overlay changes). */
379
539
  Repaint(): void;
540
+ /**
541
+ * A parent (not the control itself) is hidden: a change here asks for no frame and the latest state shows when the
542
+ * parent is shown again (C# 329f6c44 HiddenUpdateTests, DrawnUi.Rust hidden_updates). The control's own visibility
543
+ * change still draws: it is the one that hides or shows it.
544
+ */
545
+ UnderHiddenParent(): boolean;
546
+ /** The control or a parent is hidden: its animators pause until it shows again. */
547
+ HiddenInTree(): boolean;
548
+ /** The control an invalidation started at while it climbs (InvalidateMeasure): a hidden parent of it wakes no frame. */
549
+ private static invalidateOrigin;
380
550
  /**
381
551
  * Transform / Opacity changed: this control's own cache is still valid (content unchanged) but every ancestor
382
552
  * cache holds its composited output, so those are staled before redrawing (DrawnUi RedrawCanvas + parent invalidation).
383
553
  */
384
554
  RepaintComposition(): void;
555
+ /**
556
+ * Update() for a change of how this control looks, not of its size (a color set through props, C# NeedDraw): the same
557
+ * re-measure and cache invalidation, but an ImageComposite above redraws only this control's area instead of
558
+ * recording whole (drawnui-cross 6m). The record still goes whole when the control's rect changed after all.
559
+ */
560
+ UpdateDraw(): void;
561
+ /**
562
+ * A change of this control that keeps its layout, to every ImageComposite above: a direct child is drawn again whole
563
+ * (C# TrackChildAsDirty), a deeper control by its area, read now as it was drawn (its last matrix and effects margin).
564
+ */
565
+ private ReportToComposites;
566
+ /** The matrix this control will be drawn with (Render), from its current properties; undefined when none. */
567
+ private CurrentMatrix;
568
+ /** Where this control will be drawn: its rect grown by its effects margin, through its current matrix. */
569
+ private DrawnBoundsNow;
570
+ private static MapRect;
571
+ /** Its output depends on all of its content (a visual effect; a backdrop samples below): a change inside redraws it whole. */
572
+ protected get SamplesContent(): boolean;
573
+ /**
574
+ * Where a deep change shows inside the composite (drawnui-cross 6m rule b): the control as drawn before and as drawn
575
+ * now, then through the transform of every ancestor up to the composite. undefined: draw the child whole (an effect
576
+ * or a backdrop on the way, the control gone from the child); null: the layout changed, record whole.
577
+ */
578
+ private static DeepArea;
579
+ /**
580
+ * DrawnUi IsParentIndependent: this control's size never changes the layout around it, so its own invalidation
581
+ * stops here (ancestors composite again, nothing above re-measures). The parent re-measures it on draw when
582
+ * NeedMeasure is set. Used by SkiaScroll for its scroll bars.
583
+ */
584
+ IsParentIndependent: boolean;
385
585
  /** Size or content may have changed: this control and all ancestors remeasure and re-record. */
386
586
  InvalidateMeasure(): void;
387
587
  /** Hit rect in pixels (no transforms in this port, so it is DrawingRect). */