drawnui-react 0.1.0-preview.8 → 1.0.1

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 (117) hide show
  1. package/README.md +229 -22
  2. package/SKIPPED.md +38 -29
  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 +25 -3
  8. package/dist/controls/GridStructure.js +81 -5
  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 +51 -2
  20. package/dist/controls/SkiaEditor.js +292 -58
  21. package/dist/controls/SkiaGif.d.ts +7 -0
  22. package/dist/controls/SkiaGif.js +25 -4
  23. package/dist/controls/SkiaImage.d.ts +10 -0
  24. package/dist/controls/SkiaImage.js +80 -19
  25. package/dist/controls/SkiaLabel.d.ts +200 -11
  26. package/dist/controls/SkiaLabel.js +925 -93
  27. package/dist/controls/SkiaLabelFps.d.ts +12 -0
  28. package/dist/controls/SkiaLabelFps.js +35 -0
  29. package/dist/controls/SkiaLayout.d.ts +89 -9
  30. package/dist/controls/SkiaLayout.js +397 -23
  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 +86 -7
  39. package/dist/controls/SkiaScroll.js +361 -40
  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 +15 -2
  45. package/dist/controls/SkiaShape.js +57 -10
  46. package/dist/controls/SkiaShell.d.ts +282 -0
  47. package/dist/controls/SkiaShell.js +972 -0
  48. package/dist/controls/SkiaSlider.d.ts +20 -2
  49. package/dist/controls/SkiaSlider.js +61 -7
  50. package/dist/controls/SkiaSprite.d.ts +4 -0
  51. package/dist/controls/SkiaSprite.js +27 -11
  52. package/dist/controls/SkiaSvg.d.ts +4 -0
  53. package/dist/controls/SkiaSvg.js +28 -4
  54. package/dist/controls/SkiaSwitch.d.ts +0 -1
  55. package/dist/controls/SkiaSwitch.js +4 -8
  56. package/dist/controls/SkiaToggle.d.ts +25 -5
  57. package/dist/controls/SkiaToggle.js +58 -5
  58. package/dist/controls/SnappingLayout.d.ts +12 -1
  59. package/dist/controls/SnappingLayout.js +21 -2
  60. package/dist/controls/TooltipStyle.d.ts +52 -0
  61. package/dist/controls/TooltipStyle.js +88 -0
  62. package/dist/core/Accessibility.d.ts +162 -11
  63. package/dist/core/Accessibility.js +882 -22
  64. package/dist/core/Animators.d.ts +37 -1
  65. package/dist/core/Animators.js +102 -9
  66. package/dist/core/Canvas.d.ts +307 -8
  67. package/dist/core/Canvas.js +1202 -66
  68. package/dist/core/ControlStyle.d.ts +2 -0
  69. package/dist/core/ControlStyle.js +2 -0
  70. package/dist/core/DesignerActions.d.ts +32 -0
  71. package/dist/core/DesignerActions.js +68 -0
  72. package/dist/core/Easing.d.ts +12 -1
  73. package/dist/core/Easing.js +25 -1
  74. package/dist/core/Gestures.d.ts +86 -2
  75. package/dist/core/Gestures.js +184 -4
  76. package/dist/core/Hover.d.ts +51 -0
  77. package/dist/core/Hover.js +140 -0
  78. package/dist/core/ImageEffects.d.ts +2 -0
  79. package/dist/core/ImageEffects.js +2 -0
  80. package/dist/core/KeyboardManager.d.ts +40 -0
  81. package/dist/core/KeyboardManager.js +98 -8
  82. package/dist/core/PopupWindows.d.ts +94 -0
  83. package/dist/core/PopupWindows.js +207 -0
  84. package/dist/core/Props.d.ts +11 -0
  85. package/dist/core/Props.js +44 -0
  86. package/dist/core/ScrollAnimators.d.ts +6 -0
  87. package/dist/core/ScrollAnimators.js +16 -1
  88. package/dist/core/Shaping.d.ts +40 -0
  89. package/dist/core/Shaping.js +224 -0
  90. package/dist/core/SkiaControl.d.ts +306 -13
  91. package/dist/core/SkiaControl.js +681 -75
  92. package/dist/core/SkiaEffect.d.ts +29 -1
  93. package/dist/core/SkiaEffect.js +78 -16
  94. package/dist/core/SkiaImageManager.d.ts +101 -18
  95. package/dist/core/SkiaImageManager.js +318 -63
  96. package/dist/core/Styles.js +7 -1
  97. package/dist/core/Super.d.ts +33 -2
  98. package/dist/core/Super.js +58 -12
  99. package/dist/core/TextInputProxy.d.ts +31 -1
  100. package/dist/core/TextInputProxy.js +97 -15
  101. package/dist/core/Tooltips.d.ts +71 -0
  102. package/dist/core/Tooltips.js +205 -0
  103. package/dist/core/Types.d.ts +11 -1
  104. package/dist/core/Types.js +32 -1
  105. package/dist/core/ViewsAdapter.d.ts +7 -2
  106. package/dist/core/ViewsAdapter.js +10 -3
  107. package/dist/index.d.ts +8 -0
  108. package/dist/index.js +8 -0
  109. package/dist/react/SkiaShell.d.ts +8 -74
  110. package/dist/react/SkiaShell.js +163 -475
  111. package/dist/react/index.d.ts +48 -4
  112. package/dist/react/index.js +210 -43
  113. package/dist/react/reconciler.d.ts +32 -0
  114. package/dist/react/reconciler.js +71 -40
  115. package/dist/vite/index.d.ts +9 -0
  116. package/dist/vite/index.js +36 -3
  117. package/package.json +103 -5
@@ -44,6 +44,11 @@ export declare class SkiaImage extends SkiaControl {
44
44
  /** C# ImageBitmap: show an already decoded image (shared, not owned) instead of loading a Source. */
45
45
  get ImageBitmap(): Image | undefined;
46
46
  set ImageBitmap(image: Image | undefined);
47
+ /**
48
+ * Shows an image: the control holds it while it draws it (the image manager never deletes an image a control holds,
49
+ * and deletes a copy of its own once the control lets it go: SkiaImageManager.Hold / Free).
50
+ */
51
+ private Show;
47
52
  IsLoading: boolean;
48
53
  /** Where the scaled image was drawn last frame, canvas pixels. */
49
54
  DisplayRect: SKRect;
@@ -72,4 +77,9 @@ export declare class SkiaImage extends SkiaControl {
72
77
  */
73
78
  protected MeasureAbsolute(widthConstraint: number, heightConstraint: number, scale: number): ScaledSize;
74
79
  protected Paint(ctx: DrawingContext): void;
80
+ private tileShader?;
81
+ private tileShaderKey?;
82
+ /** Repeat shader of the image placed at `display`, kept until the image or its placement changes (C# cached fill shader). */
83
+ private TileShader;
84
+ protected OnDisposing(): void;
75
85
  }
@@ -42,8 +42,8 @@ export class SkiaImage extends SkiaControl {
42
42
  switch (this.AddEffect) {
43
43
  case "Tint": return this.ColorTint !== Colors.Transparent ? SkiaImageEffects.Tint(this.ColorTint, this.EffectBlendMode) : null;
44
44
  case "Darken": return this.Darken !== 0 ? SkiaImageEffects.Darken(this.Darken) : null;
45
- case "BlackAndWhite":
46
- case "Grayscale": return SkiaImageEffects.Grayscale();
45
+ case "BlackAndWhite": return SkiaImageEffects.Grayscale();
46
+ case "Grayscale": return SkiaImageEffects.Grayscale2();
47
47
  case "Pastel": return SkiaImageEffects.Pastel();
48
48
  case "Lighten": return this.Lighten !== 0 ? SkiaImageEffects.Lighten(this.Lighten) : null;
49
49
  case "Sepia": return SkiaImageEffects.Sepia();
@@ -69,9 +69,21 @@ export class SkiaImage extends SkiaControl {
69
69
  return;
70
70
  this.loadGeneration++;
71
71
  this.IsLoading = false;
72
- this.LoadedSource = image;
72
+ this.Show(image);
73
73
  this.Update();
74
74
  }
75
+ /**
76
+ * Shows an image: the control holds it while it draws it (the image manager never deletes an image a control holds,
77
+ * and deletes a copy of its own once the control lets it go: SkiaImageManager.Hold / Free).
78
+ */
79
+ Show(image) {
80
+ if (this.LoadedSource === image)
81
+ return;
82
+ const old = this.LoadedSource;
83
+ this.LoadedSource = image;
84
+ SkiaImageManager.Instance.Hold(image);
85
+ SkiaImageManager.Instance.Free(old);
86
+ }
75
87
  IsLoading = false;
76
88
  /** Where the scaled image was drawn last frame, canvas pixels. */
77
89
  DisplayRect = SKRect.Empty;
@@ -88,16 +100,29 @@ export class SkiaImage extends SkiaControl {
88
100
  return;
89
101
  this.source = value;
90
102
  const generation = ++this.loadGeneration;
91
- this.LoadedSource = undefined;
103
+ this.Show(undefined);
92
104
  if (!value) {
93
105
  this.IsLoading = false;
94
106
  this.Update();
95
107
  return;
96
108
  }
97
109
  this.IsLoading = true;
98
- SkiaImageManager.Instance.LoadImageManagedAsync(value, undefined, this.LoadPriority).then((image) => { if (generation !== this.loadGeneration)
99
- return; this.IsLoading = false; this.LoadedSource = image; this.Update(); this.Success?.(this, value); }, (error) => { if (generation !== this.loadGeneration)
100
- return; this.IsLoading = false; this.Error?.(this, error); });
110
+ SkiaImageManager.Instance.LoadImageManagedAsync(value, undefined, this.LoadPriority).then((image) => {
111
+ if (generation !== this.loadGeneration || this.IsDisposed) {
112
+ // a load nobody shows: a copy of its own goes at once, a shared image stays in the cache
113
+ SkiaImageManager.Instance.Hold(image);
114
+ SkiaImageManager.Instance.Free(image);
115
+ return;
116
+ }
117
+ this.IsLoading = false;
118
+ if (!image) {
119
+ this.Error?.(this, new Error(`DrawnUi: cannot load image '${value}'`));
120
+ return;
121
+ }
122
+ this.Show(image);
123
+ this.Update();
124
+ this.Success?.(this, value);
125
+ });
101
126
  }
102
127
  /** Port of DrawnUi SkiaControl.RescaleAspect: per-axis scale to apply to (width, height) inside dest. */
103
128
  static RescaleAspect(width, height, dest, stretch) {
@@ -140,7 +165,7 @@ export class SkiaImage extends SkiaControl {
140
165
  if (width * aspectX > dest.Width || height * aspectY > dest.Height)
141
166
  aspectX = aspectY = Math.min(s1, s2);
142
167
  break;
143
- case "Tile": break; // C# too: tiling is SkiaImageTiles
168
+ case "Tile": break; // natural size, repeated over the destination when drawn
144
169
  }
145
170
  return { X: aspectX, Y: aspectY };
146
171
  }
@@ -164,20 +189,25 @@ export class SkiaImage extends SkiaControl {
164
189
  MeasureAbsolute(widthConstraint, heightConstraint, scale) {
165
190
  const img = this.LoadedSource;
166
191
  let w = widthConstraint, h = heightConstraint;
167
- if (img) {
168
- const aspect = img.width() / img.height();
169
- if (!isFinite(w) && isFinite(h))
170
- w = h * aspect;
171
- else if (!isFinite(h) && isFinite(w))
172
- h = w / aspect;
192
+ // nothing loaded: the box it is offered (C# OnMeasuring), an unbounded side 0
193
+ if (!img) {
194
+ this.AspectScale = { X: 0, Y: 0 };
195
+ return ScaledSize.FromPixels(isFinite(w) ? w : 0, isFinite(h) ? h : 0, scale);
173
196
  }
174
- if (!isFinite(w) || !isFinite(h)) {
197
+ const iw = img.width(), ih = img.height();
198
+ if (!isFinite(w) && isFinite(h))
199
+ w = h * iw / ih;
200
+ else if (!isFinite(h) && isFinite(w))
201
+ h = w * ih / iw;
202
+ if (!isFinite(w) || !isFinite(h) || iw <= 0 || ih <= 0) {
175
203
  this.AspectScale = { X: 0, Y: 0 };
176
204
  return ScaledSize.FromPixels(0, 0, scale);
177
205
  }
178
- if (img)
179
- this.AspectScale = SkiaImage.RescaleAspect(img.width(), img.height(), SKRect.Create(0, 0, w, h), this.Aspect);
180
- return ScaledSize.FromPixels(w, h, scale);
206
+ // C# OnMeasuring / DrawnUi.Rust: an auto-sized side is the bitmap's pixels scaled by the aspect for this box, never
207
+ // more than the box (a Fill or requested side still takes its box in Measure)
208
+ const s = SkiaImage.RescaleAspect(iw, ih, SKRect.Create(0, 0, w, h), this.Aspect);
209
+ this.AspectScale = s;
210
+ return ScaledSize.FromPixels(Math.min(iw * s.X, w), Math.min(ih * s.Y, h), scale);
181
211
  }
182
212
  Paint(ctx) {
183
213
  const img = this.LoadedSource;
@@ -213,10 +243,41 @@ export class SkiaImage extends SkiaControl {
213
243
  paint.setImageFilter(blur);
214
244
  if (this.PaintColorFilter)
215
245
  paint.setColorFilter(this.PaintColorFilter);
216
- canvas.drawImageRectOptions(img, CK.LTRBRect(0, 0, img.width(), img.height()), CK.LTRBRect(display.Left, display.Top, display.Right, display.Bottom), CK.FilterMode.Linear, CK.MipmapMode.Linear, paint);
246
+ if (this.Aspect === "Tile") {
247
+ // C# DrawSourceRegion: the image at its natural size repeats over the whole destination from the aligned copy
248
+ if (!overflows)
249
+ canvas.clipRect(CK.LTRBRect(dest.Left, dest.Top, dest.Right, dest.Bottom), CK.ClipOp.Intersect, true);
250
+ paint.setShader(this.TileShader(img, display));
251
+ canvas.drawRect(CK.LTRBRect(dest.Left, dest.Top, dest.Right, dest.Bottom), paint);
252
+ }
253
+ else {
254
+ canvas.drawImageRectOptions(img, CK.LTRBRect(0, 0, img.width(), img.height()), CK.LTRBRect(display.Left, display.Top, display.Right, display.Bottom), CK.FilterMode.Linear, CK.MipmapMode.Linear, paint);
255
+ }
217
256
  colorFilter?.delete();
218
257
  blur?.delete();
219
258
  paint.delete();
220
259
  canvas.restoreToCount(saved);
221
260
  }
261
+ tileShader;
262
+ tileShaderKey;
263
+ /** Repeat shader of the image placed at `display`, kept until the image or its placement changes (C# cached fill shader). */
264
+ TileShader(img, display) {
265
+ const k = this.tileShaderKey;
266
+ if (this.tileShader && k && k.Image === img && k.Left === display.Left && k.Top === display.Top && k.Width === display.Width && k.Height === display.Height)
267
+ return this.tileShader;
268
+ this.tileShader?.delete();
269
+ const CK = Super.CK, M = CK.Matrix;
270
+ const local = M.multiply(M.translated(display.Left, display.Top), M.scaled(display.Width / img.width(), display.Height / img.height()));
271
+ this.tileShader = img.makeShaderOptions(CK.TileMode.Repeat, CK.TileMode.Repeat, CK.FilterMode.Linear, CK.MipmapMode.None, local);
272
+ this.tileShaderKey = { Image: img, Left: display.Left, Top: display.Top, Width: display.Width, Height: display.Height };
273
+ return this.tileShader;
274
+ }
275
+ OnDisposing() {
276
+ this.tileShader?.delete();
277
+ this.tileShader = undefined;
278
+ this.tileShaderKey = undefined;
279
+ this.loadGeneration++;
280
+ this.Show(undefined);
281
+ super.OnDisposing();
282
+ }
222
283
  }
@@ -1,6 +1,6 @@
1
1
  import { type DrawingContext, SkiaControl } from "../core/SkiaControl";
2
2
  import { type GestureEventProcessingInfo, type SkiaGesturesParameters } from "../core/Gestures";
3
- import { type Color, type DrawTextAlignment, type FontAttributes, type LineBreakMode, ScaledSize, type SkiaGradient, type TextAlignment, type TextTransform, Thickness } from "../core/Types";
3
+ import { type Color, type DrawTextAlignment, type FontAttributes, type LineBreakMode, ScaledSize, type SkiaGradient, type TextAlignment, type TextTransform, Thickness, type ThicknessValue } from "../core/Types";
4
4
  import { TextSpan } from "./TextSpan";
5
5
  /** One code point of the laid-out text: its UTF-16 index/length in Text and its box in pixels relative to DrawingRect. */
6
6
  export interface GlyphBox {
@@ -10,7 +10,8 @@ export interface GlyphBox {
10
10
  Left: number;
11
11
  Top: number;
12
12
  Width: number;
13
- Height: number;
13
+ Height: number; /** The code point runs right to left (its box is in visual place). */
14
+ Rtl?: boolean;
14
15
  }
15
16
  /** A laid-out line: first text index, box in pixels relative to DrawingRect. */
16
17
  export interface LineBox {
@@ -43,16 +44,27 @@ export declare class SkiaLabel extends SkiaControl {
43
44
  private verticalTextAlignment;
44
45
  private lineSpacing;
45
46
  private lineHeight;
47
+ private paragraphSpacing;
48
+ private lineHeightUniform;
49
+ /** The height every line takes under LineHeightUniform: the tallest laid-out line's (C# MeasuredLineHeight). */
50
+ private uniformLineHeight;
51
+ private characterSpacing;
46
52
  private textTransform;
47
53
  private padding;
48
54
  /** Styled fragments; when not empty they replace `Text` (same precedence as C#). */
49
55
  readonly Spans: TextSpan[];
50
56
  /** Set to `Aria.RoleText` to expose every label to screen readers (React extension; C# is opt-in per control). */
51
57
  static DefaultAccessibilityRole?: string;
58
+ /** Highlight drawn over selected text (AccessibilityTextSelectable), for every label (C# SkiaLabel.TextSelectionColor). */
59
+ static TextSelectionColor: Color;
60
+ /** Caption of the Copy button shown over a touch selection (C# SkiaLabel.CopyButtonText). */
61
+ static CopyButtonText: string;
52
62
  /** Like C# OnTextInternalChanged: the spoken label is the text (or the joined spans) unless AccessibilityLabel is set. */
53
63
  protected DefaultAccessibilityLabel(): string | undefined;
54
64
  constructor();
55
65
  private Set;
66
+ /** A property that changes only the look (a color): no layout change, see UpdateDraw. */
67
+ private SetLook;
56
68
  get Text(): string;
57
69
  set Text(v: string);
58
70
  get FontSize(): number;
@@ -84,10 +96,27 @@ export declare class SkiaLabel extends SkiaControl {
84
96
  /** Multiplier applied to the natural line height (ascent + descent). */
85
97
  get LineHeight(): number;
86
98
  set LineHeight(v: number);
99
+ /**
100
+ * Space above every paragraph after the first, in lines of the label's font (C# ParagraphSpacing, default 0.25). A
101
+ * paragraph starts after "\n"; U+2028 breaks the line inside a paragraph.
102
+ */
103
+ get ParagraphSpacing(): number;
104
+ set ParagraphSpacing(v: number);
105
+ /** LineHeightUniform: true = every line as tall as the tallest one; false (default in every engine) = each line its own height. */
106
+ get LineHeightUniform(): boolean;
107
+ set LineHeightUniform(v: boolean);
108
+ /**
109
+ * C# CharacterSpacing: 1 = the font's own spacing; every glyph is followed by (CharacterSpacing - 1) points more
110
+ * (less below 1), the line measures and wraps at the width it draws (C# 7cf1007c, DrawnUi.Rust label).
111
+ */
112
+ get CharacterSpacing(): number;
113
+ set CharacterSpacing(v: number);
87
114
  get TextTransform(): TextTransform;
88
115
  set TextTransform(v: TextTransform);
89
116
  get Padding(): Thickness;
90
- set Padding(v: Thickness);
117
+ set Padding(v: ThicknessValue);
118
+ /** A label with text, in Text or in its spans, shows text of its own (no accessibility-label tooltip). */
119
+ ShowsText(): boolean;
91
120
  /** Number of laid-out lines after the last measure. */
92
121
  get LinesCount(): number;
93
122
  AddSubView(control: SkiaControl | TextSpan): void;
@@ -96,18 +125,54 @@ export declare class SkiaLabel extends SkiaControl {
96
125
  private lines;
97
126
  private mainFonts?;
98
127
  private readonly fontsCache;
99
- private readonly runCache;
128
+ /** Runs of a text per style (Segment), and the same runs carrying a span; cleared when the glyph spacing changes. */
129
+ private runCache;
130
+ private spanRunCache;
131
+ /** Wrap tokens of the text, kept while the label has not changed (NeedMeasure) at the same scale. */
132
+ private tokens?;
133
+ /** CharacterSpacing in pixels at the measured scale: added after every glyph of a run (its Width includes them). */
134
+ private glyphSpacing;
100
135
  private ResolveFonts;
101
136
  /** The label's own style, and the base every span inherits from. */
102
137
  private ResolveMainFonts;
103
138
  private ResolveSpanFonts;
104
- private static Advance;
139
+ private static NeedsShapingOrRtl;
140
+ /** Width of a text in one font: the shaped glyphs where the text needs shaping (Arabic joins, emoji sequences), else glyph by glyph. */
141
+ private Advance;
142
+ private static readonly Ignorable;
143
+ /**
144
+ * Default-ignorable code points (zero width space, joiners, direction marks, word joiners, variation selectors such
145
+ * as U+FE0F after an emoji, tags) that none of the fonts has draw nothing and take no room, never the missing-glyph
146
+ * box (DrawnUi.Rust label_ignorables; text is not shaped here, C# hides them by shaping).
147
+ */
148
+ private static DropIgnorables;
105
149
  /**
106
150
  * Splits text into runs by glyph availability: the main font, or the first fallback that has a glyph where the
107
- * main font has glyph 0. Spaces always stay on the main font (fallback faces often carry very wide spaces).
151
+ * main font has glyph 0. Spaces always stay on the main font (fallback faces often carry very wide spaces). A joiner,
152
+ * a variation selector, a skin tone or a tag keeps the font of the glyph before it: an emoji sequence is one run.
108
153
  */
109
154
  private Segment;
110
155
  private Width;
156
+ /** A line never starts with these (closing punctuation, small kana, the long vowel mark): JIS X 4051 kinsoku (C#). */
157
+ private static readonly NoBreakBefore;
158
+ /** A line never ends with these (opening brackets and quotes). */
159
+ private static readonly NoBreakAfter;
160
+ /** Chinese / Japanese: ideographs, kana, CJK punctuation, full-width forms (C# IsCjkAt). Korean breaks at spaces only. */
161
+ private static readonly Cjk;
162
+ private static CanBreakBetween;
163
+ /**
164
+ * C# CanBreakInsideWord: whether a line may break between text[index - 1] and text[index] (UTF-16 indexes) inside a
165
+ * space-free run: next to a Chinese or Japanese character, never before closing punctuation or small kana, never
166
+ * after an opening bracket, never inside a surrogate pair.
167
+ */
168
+ static CanBreakInsideWord(text: string, index: number): boolean;
169
+ /**
170
+ * C# FitAtBreak: the last place inside the word where a Chinese / Japanese line may break and `prefix` plus the word
171
+ * up to there still fits; code points from the word's start, 0 = none.
172
+ */
173
+ private FitCjk;
174
+ /** The word cut after `count` code points: the head goes on a line, the rest follows. */
175
+ private SplitWord;
111
176
  private Transform;
112
177
  /**
113
178
  * Paragraphs (split on "\n") of wrap tokens, built from Spans when present, else from Text.
@@ -116,11 +181,67 @@ export declare class SkiaLabel extends SkiaControl {
116
181
  private Tokenize;
117
182
  private NewLine;
118
183
  private Append;
119
- /** Word-wraps tokens into lines that fit maxWidth (Infinity = no wrap), applies MaxLines with a tail ellipsis. */
184
+ /**
185
+ * Word-wraps tokens into lines that fit maxWidth (Infinity = no wrap); keeps the lines that fit maxHeight (at least one)
186
+ * and MaxLines, the last kept one ending with a tail ellipsis (C# / DrawnUi.Rust: a label in a box too short for its
187
+ * text cuts it, not only MaxLines).
188
+ */
189
+ /** The last layout broke a line because the text did not fit: its max-content is wider than the constraint. */
190
+ private wrapped;
191
+ /** The last layout cut lines (MaxLines, height, an ellipsis): its lines depend on the room it had. */
192
+ private truncated;
193
+ /**
194
+ * Lines laid out without wrapping or cutting stay the same for any room that holds them: reused, while nothing in the
195
+ * label changed (NeedMeasure), for a later measure with at least that width and height (C# 5f24f577 label line reuse).
196
+ */
197
+ private reusable?;
120
198
  private LayoutLines;
199
+ /** A paragraph is right to left when its first strong letter is (DrawnUi.Rust split_bidi). */
200
+ static FirstStrongIsRtl(text: string): boolean;
201
+ /** The runs of a line cut where its visual run changes; `map` per UTF-16 index of the line text. */
202
+ private SplitByRuns;
203
+ /**
204
+ * After the layout, lines whose text needs shaping or runs right to left (DrawnUi.Rust build_blobs): with
205
+ * right-to-left text every run is cut where its bidirectional run changes (Unicode bidirectional algorithm, ICU, the
206
+ * paragraph direction from its first strong letter); runs that are right to left or need shaping get shaped glyphs;
207
+ * runs are placed in visual order. Lines without such text are left as they are (plain path).
208
+ */
209
+ private ShapeLines;
210
+ /**
211
+ * Where each run of a line with right-to-left text goes: visual runs left to right; inside a run, pieces (spans, fonts)
212
+ * in logical order, reversed in a right-to-left run.
213
+ */
214
+ private static PlaceRuns;
215
+ /** A line's own height: its spans' largest ascent plus largest descent, times LineHeight, rounded once to whole pixels. */
216
+ private OwnLineHeight;
121
217
  private LineHeightPx;
218
+ /** C# GetSpaceBetweenLines: the label font's Leading times LineSpacing when it has one, else (LineSpacing - 1) lines. */
219
+ private LineGap;
220
+ /**
221
+ * As DrawnUi.Net: the baseline sits at the line's bottom minus its descent, the extra space of LineHeight split above and
222
+ * below the text (a line of lh pixels holds lh / LineHeight of text).
223
+ */
224
+ private BaselineIn;
225
+ /** ParagraphSpacing above a line that starts a paragraph (after the first): that many lines of the label's font, with their gap. */
226
+ private ParagraphSpace;
122
227
  private BlockHeight;
123
- protected MeasureAbsolute(widthConstraint: number, _heightConstraint: number, scale: number): ScaledSize;
228
+ /** Pixels of ink outside the lines' advance boxes, at their left and right ends (side bearings, italic slant). */
229
+ private inkLeft;
230
+ private inkRight;
231
+ /** Ink drawn outside the label's box (a "j" hook, an italic slant) is recorded by caches too, as C# draws it whole. */
232
+ ComputeEffectsMargin(scale: number): Thickness;
233
+ /**
234
+ * C# (after 106e768a): the ink bounds of the first glyph of each line's leftmost run and the last glyph of its
235
+ * rightmost run, beyond the advance box of that run. Two glyph bounds per line, at measure.
236
+ */
237
+ private MeasureInkOverhang;
238
+ /**
239
+ * Where a line starts inside [left, right] (drawnui-cross 6am): Start and End follow the paragraph's direction (in a
240
+ * right-to-left paragraph Start is the right edge); Center is centered; Fill* lines are not stretched here and sit
241
+ * at the paragraph's start.
242
+ */
243
+ private LineX;
244
+ protected MeasureAbsolute(widthConstraint: number, heightConstraint: number, scale: number): ScaledSize;
124
245
  /** C# GradientByLines: FillGradient spans each line's bounds (default) instead of the whole text block. */
125
246
  GradientByLines: boolean;
126
247
  /** C# KeepSpacesOnLineBreaks / NeedsGlyphPositions: accepted; glyph boxes are always available through GetGlyphBoxes. */
@@ -132,8 +253,6 @@ export declare class SkiaLabel extends SkiaControl {
132
253
  get MeasuredLineHeight(): number;
133
254
  /** Line origins relative to DrawingRect, same alignment math as Paint. */
134
255
  private LineGeometry;
135
- /** Lines as CSS text for the accessibility overlay (AccessibilityTextSelectable): font alias chain, weight and px size. */
136
- GetAccessibilityTextLines(scale: number): import("../core/Accessibility").AccessibilityTextLine[];
137
256
  /** Laid-out lines with their text index range (a wrapped-away space or line break sits between two lines). */
138
257
  GetLineBoxes(): LineBox[];
139
258
  /** Every code point of the laid-out text with its box (editor caret / selection / hit testing). */
@@ -151,12 +270,82 @@ export declare class SkiaLabel extends SkiaControl {
151
270
  private HasDropShadow;
152
271
  /** C# measurement: stroke adds StrokeWidth*2 on each axis, the shadow adds DropShadowSize + offset (pixels). */
153
272
  private EffectsExtra;
154
- /** C# SkiaLabel.SetupBackgroundPaint: no BackgroundColor = no background, the gradient goes on the glyphs. */
273
+ /**
274
+ * FillGradient goes to one place (C# 9637994b, as DrawnUi.Rust): the background of a label that paints one (a
275
+ * BackgroundColor with alpha above 0), whose glyphs keep TextColor; else the glyphs.
276
+ */
155
277
  protected FillGradientPaintsBackground(): boolean;
278
+ private HasBackground;
279
+ /** The gradient the glyphs are painted with: none when the label's background takes FillGradient. */
280
+ protected get TextFillGradient(): SkiaGradient | undefined;
156
281
  protected Paint(ctx: DrawingContext): void;
157
282
  ProcessGestures(args: SkiaGesturesParameters, apply: GestureEventProcessingInfo): SkiaControl | null;
158
283
  /** Pointer cursor over a tappable span (the label itself may not be tappable). */
159
284
  WantsPointerCursor(x: number, y: number): boolean;
160
285
  /** Return null to not consume the tap. */
161
286
  protected OnSpanTapped(span: TextSpan, args: SkiaGesturesParameters, apply: GestureEventProcessingInfo): SkiaControl | null;
287
+ get AccessibilityTextSelectable(): boolean;
288
+ /**
289
+ * The text can be selected and copied, drawn by the label (C# SkiaLabel.AccessibilityTextSelectable). Mouse: drag, double
290
+ * click for a word. Touch: long press picks a word, keep the finger down and drag to extend, a Copy button appears.
291
+ * Ctrl+C (Cmd+C) copies and Ctrl+A selects all while the label holds the selection; a click elsewhere drops it. The label
292
+ * takes the mouse press for this, so it no longer reaches controls under it. Free when off. Copies through
293
+ * Super.SetClipboardText.
294
+ */
295
+ set AccessibilityTextSelectable(v: boolean);
296
+ private selStart;
297
+ private selLength;
298
+ private anchorStart;
299
+ private anchorEnd;
300
+ private selecting;
301
+ private touchSelection;
302
+ private copyPressed;
303
+ private selectionKeysAttached;
304
+ private lastClickMs;
305
+ private lastClickX;
306
+ private lastClickY;
307
+ /** The drawn Copy button of a touch selection, relative to DrawingRect (pixels); empty when none. */
308
+ private copyButton;
309
+ private selectionMap?;
310
+ /** Start of the selection in the selection's source: the label's text when the lines are taken from it verbatim, else the drawn lines joined. */
311
+ get SelectionStart(): number;
312
+ /** Length of the selection, 0 when nothing is selected. */
313
+ get SelectionLength(): number;
314
+ /** The selected text, empty when nothing is selected. */
315
+ get SelectedText(): string;
316
+ /** Selects a range of the text (see SelectionStart for what the indexes count). */
317
+ Select(start: number, length: number): void;
318
+ /** Selects all of the text. */
319
+ SelectAll(): void;
320
+ /** Drops the selection. */
321
+ ClearSelection(): void;
322
+ /** The app showed its own context menu for a touch selection: the drawn Copy button steps aside, the selection stays. */
323
+ HideCopyButton(): void;
324
+ /** Puts the selected text on the clipboard through Super.SetClipboardText. False when nothing is selected. */
325
+ CopySelection(): boolean;
326
+ /** A selectable label takes the canvas focus while text is selected and drops the selection when the focus moves elsewhere. */
327
+ SetFrameworkFocus(focus: boolean): boolean;
328
+ protected OnDisposing(): void;
329
+ private AttachSelectionKeys;
330
+ private static readonly noChar;
331
+ private readonly onSelectionKey;
332
+ private ClaimSelectionFocus;
333
+ /**
334
+ * The drawn lines mapped onto a source string: the label's text when every line is found in it in order (spaces
335
+ * dropped at wraps are then copied too), else the lines joined, a new line between paragraphs. Each line keeps its
336
+ * caret slots (x of each text index, relative to DrawingRect) and its glyph boxes.
337
+ */
338
+ private SelectionMap;
339
+ /** Text index under a point relative to DrawingRect (pixels). */
340
+ private IndexAt;
341
+ private WordAt;
342
+ /** Text index under a canvas point (pixels), for a selection a page drag makes across labels. */
343
+ TextIndexAtCanvas(x: number, y: number): number;
344
+ /** Length of the text a selection counts in (see SelectionStart). */
345
+ get SelectableLength(): number;
346
+ private SelectBetween;
347
+ /** Pointer handling of AccessibilityTextSelectable; null lets the gesture go on as usual. */
348
+ protected ProcessTextSelection(args: SkiaGesturesParameters, apply: GestureEventProcessingInfo): SkiaControl | null;
349
+ /** Draws the selection over the lines just drawn, and the Copy button of a touch selection. */
350
+ protected DrawTextSelection(ctx: DrawingContext): void;
162
351
  }