drawnui-react 0.1.0-preview.9 → 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.
- package/README.md +229 -22
- package/SKIPPED.md +37 -28
- package/dist/controls/AnimatedFramesRenderer.d.ts +9 -0
- package/dist/controls/AnimatedFramesRenderer.js +18 -1
- package/dist/controls/DrawnGame.d.ts +44 -0
- package/dist/controls/DrawnGame.js +82 -0
- package/dist/controls/GridStructure.d.ts +25 -3
- package/dist/controls/GridStructure.js +81 -5
- package/dist/controls/SkiaBackdrop.d.ts +8 -2
- package/dist/controls/SkiaBackdrop.js +42 -14
- package/dist/controls/SkiaButton.d.ts +17 -3
- package/dist/controls/SkiaButton.js +26 -8
- package/dist/controls/SkiaCarousel.d.ts +22 -3
- package/dist/controls/SkiaCarousel.js +85 -9
- package/dist/controls/SkiaCheckbox.d.ts +0 -1
- package/dist/controls/SkiaCheckbox.js +2 -7
- package/dist/controls/SkiaDrawer.d.ts +15 -0
- package/dist/controls/SkiaDrawer.js +42 -7
- package/dist/controls/SkiaEditor.d.ts +51 -2
- package/dist/controls/SkiaEditor.js +292 -58
- package/dist/controls/SkiaGif.d.ts +7 -0
- package/dist/controls/SkiaGif.js +25 -4
- package/dist/controls/SkiaImage.d.ts +10 -0
- package/dist/controls/SkiaImage.js +80 -19
- package/dist/controls/SkiaLabel.d.ts +200 -11
- package/dist/controls/SkiaLabel.js +925 -93
- package/dist/controls/SkiaLabelFps.d.ts +12 -0
- package/dist/controls/SkiaLabelFps.js +35 -0
- package/dist/controls/SkiaLayout.d.ts +89 -9
- package/dist/controls/SkiaLayout.js +397 -23
- package/dist/controls/SkiaLottie.js +5 -3
- package/dist/controls/SkiaProgress.d.ts +2 -1
- package/dist/controls/SkiaProgress.js +8 -5
- package/dist/controls/SkiaRadioButton.d.ts +2 -0
- package/dist/controls/SkiaRadioButton.js +16 -4
- package/dist/controls/SkiaRichLabel.d.ts +1 -1
- package/dist/controls/SkiaRichLabel.js +11 -1
- package/dist/controls/SkiaScroll.d.ts +86 -7
- package/dist/controls/SkiaScroll.js +361 -40
- package/dist/controls/SkiaScrollBar.d.ts +27 -0
- package/dist/controls/SkiaScrollBar.js +51 -2
- package/dist/controls/SkiaShaderCarousel.d.ts +11 -1
- package/dist/controls/SkiaShaderCarousel.js +27 -5
- package/dist/controls/SkiaShape.d.ts +15 -2
- package/dist/controls/SkiaShape.js +57 -10
- package/dist/controls/SkiaShell.d.ts +282 -0
- package/dist/controls/SkiaShell.js +972 -0
- package/dist/controls/SkiaSlider.d.ts +20 -2
- package/dist/controls/SkiaSlider.js +61 -7
- package/dist/controls/SkiaSprite.d.ts +4 -0
- package/dist/controls/SkiaSprite.js +27 -11
- package/dist/controls/SkiaSvg.d.ts +4 -0
- package/dist/controls/SkiaSvg.js +28 -4
- package/dist/controls/SkiaSwitch.d.ts +0 -1
- package/dist/controls/SkiaSwitch.js +4 -8
- package/dist/controls/SkiaToggle.d.ts +25 -5
- package/dist/controls/SkiaToggle.js +58 -5
- package/dist/controls/SnappingLayout.d.ts +12 -1
- package/dist/controls/SnappingLayout.js +21 -2
- package/dist/controls/TooltipStyle.d.ts +52 -0
- package/dist/controls/TooltipStyle.js +88 -0
- package/dist/core/Accessibility.d.ts +162 -11
- package/dist/core/Accessibility.js +882 -22
- package/dist/core/Animators.d.ts +37 -1
- package/dist/core/Animators.js +102 -9
- package/dist/core/Canvas.d.ts +307 -8
- package/dist/core/Canvas.js +1202 -66
- package/dist/core/ControlStyle.d.ts +2 -0
- package/dist/core/ControlStyle.js +2 -0
- package/dist/core/DesignerActions.d.ts +32 -0
- package/dist/core/DesignerActions.js +68 -0
- package/dist/core/Easing.d.ts +12 -1
- package/dist/core/Easing.js +25 -1
- package/dist/core/Gestures.d.ts +86 -2
- package/dist/core/Gestures.js +184 -4
- package/dist/core/Hover.d.ts +51 -0
- package/dist/core/Hover.js +140 -0
- package/dist/core/ImageEffects.d.ts +2 -0
- package/dist/core/ImageEffects.js +2 -0
- package/dist/core/KeyboardManager.d.ts +40 -0
- package/dist/core/KeyboardManager.js +98 -8
- package/dist/core/PopupWindows.d.ts +94 -0
- package/dist/core/PopupWindows.js +207 -0
- package/dist/core/Props.d.ts +11 -0
- package/dist/core/Props.js +44 -0
- package/dist/core/ScrollAnimators.d.ts +6 -0
- package/dist/core/ScrollAnimators.js +16 -1
- package/dist/core/Shaping.d.ts +40 -0
- package/dist/core/Shaping.js +224 -0
- package/dist/core/SkiaControl.d.ts +306 -13
- package/dist/core/SkiaControl.js +681 -75
- package/dist/core/SkiaEffect.d.ts +29 -1
- package/dist/core/SkiaEffect.js +78 -16
- package/dist/core/SkiaImageManager.d.ts +101 -18
- package/dist/core/SkiaImageManager.js +318 -63
- package/dist/core/Styles.js +7 -1
- package/dist/core/Super.d.ts +33 -2
- package/dist/core/Super.js +58 -12
- package/dist/core/TextInputProxy.d.ts +31 -1
- package/dist/core/TextInputProxy.js +97 -15
- package/dist/core/Tooltips.d.ts +71 -0
- package/dist/core/Tooltips.js +205 -0
- package/dist/core/Types.d.ts +11 -1
- package/dist/core/Types.js +32 -1
- package/dist/core/ViewsAdapter.d.ts +7 -2
- package/dist/core/ViewsAdapter.js +10 -3
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/react/SkiaShell.d.ts +8 -74
- package/dist/react/SkiaShell.js +163 -475
- package/dist/react/index.d.ts +48 -4
- package/dist/react/index.js +210 -43
- package/dist/react/reconciler.d.ts +32 -0
- package/dist/react/reconciler.js +71 -40
- package/dist/vite/index.d.ts +9 -0
- package/dist/vite/index.js +36 -3
- package/package.json +103 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { CanvasLeaveWatchers, SkiaControl } from "../core/SkiaControl";
|
|
1
2
|
import { SKPoint } from "../core/Gestures";
|
|
2
3
|
import { Super } from "../core/Super";
|
|
3
|
-
import {
|
|
4
|
-
import { ResolveControlStyle } from "../core/ControlStyle";
|
|
4
|
+
import { DefaultAccent, ResolveControlStyle } from "../core/ControlStyle";
|
|
5
5
|
import { KeyboardManager } from "../core/KeyboardManager";
|
|
6
6
|
import { TextInputProxy } from "../core/TextInputProxy";
|
|
7
7
|
import { Colors, ScaledSize, SKRect, Thickness } from "../core/Types";
|
|
@@ -59,6 +59,8 @@ export class SkiaEditor extends SkiaShape {
|
|
|
59
59
|
CanShowCursor = true;
|
|
60
60
|
SelectionColor = "#5590CFFE";
|
|
61
61
|
cursorPosition = 0;
|
|
62
|
+
/** A caret position was given (by the app, a tap, a selection): focusing keeps it; otherwise focusing puts the caret at the end. */
|
|
63
|
+
cursorPlaced = false;
|
|
62
64
|
selectionLength = 0;
|
|
63
65
|
isFocused = false;
|
|
64
66
|
controlStyle = "Unset";
|
|
@@ -67,18 +69,30 @@ export class SkiaEditor extends SkiaShape {
|
|
|
67
69
|
placeholder = new SkiaLabel();
|
|
68
70
|
scrollX = 0;
|
|
69
71
|
scrollY = 0;
|
|
70
|
-
|
|
72
|
+
/** The caret blinks on a timer, asleep between blinks: no frame runs while it waits (DrawnUi.Rust editor_rules). */
|
|
73
|
+
blinkTimer = 0;
|
|
71
74
|
caretVisible = true;
|
|
72
75
|
subscribed = false;
|
|
73
76
|
stubSelectionStop = -1;
|
|
74
77
|
selectionMovingEdge = -1;
|
|
75
78
|
onKeyDown = (key, e) => this.OnKeyDown(key, e);
|
|
76
|
-
onKeyChar = (ch, e) => {
|
|
79
|
+
onKeyChar = (ch, e) => {
|
|
80
|
+
if (KeyboardManager.IsOwnedByElement(e) || KeyboardManager.IsInputMethodKey(e))
|
|
81
|
+
return; // a page control or the IME owns it
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
this.StubTypeText(ch);
|
|
84
|
+
};
|
|
77
85
|
selectionAnchor = -1;
|
|
78
86
|
dragSelecting = false;
|
|
79
87
|
styleApplied = {};
|
|
80
88
|
layoutVersion = -1;
|
|
81
89
|
boxes = [];
|
|
90
|
+
/** The glyph box starting at a text index, and the one ending at it. */
|
|
91
|
+
boxAt = new Map();
|
|
92
|
+
boxEnd = new Map();
|
|
93
|
+
/** Grapheme boundaries of the text, the places a caret may stand. */
|
|
94
|
+
stops = [0];
|
|
95
|
+
stopsText = "";
|
|
82
96
|
constructor() {
|
|
83
97
|
super();
|
|
84
98
|
this.Type = "Rectangle";
|
|
@@ -93,15 +107,6 @@ export class SkiaEditor extends SkiaShape {
|
|
|
93
107
|
this.placeholder.IsVisible = false;
|
|
94
108
|
this.AddSubView(this.placeholder);
|
|
95
109
|
this.AddSubView(this.Label);
|
|
96
|
-
this.blink.mMinValue = 0;
|
|
97
|
-
this.blink.mMaxValue = 1;
|
|
98
|
-
this.blink.Speed = 1000;
|
|
99
|
-
this.blink.Repeat = -1;
|
|
100
|
-
this.blink.OnUpdated = (v) => { const visible = v < 0.5; if (visible !== this.caretVisible) {
|
|
101
|
-
this.caretVisible = visible;
|
|
102
|
-
this.InvalidateCache();
|
|
103
|
-
this.RepaintComposition();
|
|
104
|
-
} };
|
|
105
110
|
this.ApplyControlStyleVisuals();
|
|
106
111
|
this.UpdateLabel();
|
|
107
112
|
}
|
|
@@ -177,8 +182,11 @@ export class SkiaEditor extends SkiaShape {
|
|
|
177
182
|
get ShouldSubmitOnEnter() { return this.IsMultiline && this.ReturnType === "Send"; }
|
|
178
183
|
/** Caret index (UTF-16 units) = the left edge of the selection when one exists. */
|
|
179
184
|
get CursorPosition() { return this.cursorPosition; }
|
|
185
|
+
/** A position from app code as a whole number: beyond the text (MAX_SAFE_INTEGER, Infinity) is the end, NaN is 0. */
|
|
186
|
+
static Whole(v) { return Number.isNaN(v) ? 0 : Math.trunc(v); }
|
|
180
187
|
set CursorPosition(v) {
|
|
181
|
-
|
|
188
|
+
this.cursorPlaced = true;
|
|
189
|
+
const p = Math.max(0, Math.min(this.text.length, SkiaEditor.Whole(v)));
|
|
182
190
|
if (p === this.cursorPosition)
|
|
183
191
|
return;
|
|
184
192
|
this.cursorPosition = p;
|
|
@@ -186,15 +194,31 @@ export class SkiaEditor extends SkiaShape {
|
|
|
186
194
|
}
|
|
187
195
|
get SelectionLength() { return this.selectionLength; }
|
|
188
196
|
set SelectionLength(v) {
|
|
189
|
-
const l = Math.max(0, Math.min(this.text.length - this.cursorPosition, v
|
|
197
|
+
const l = Math.max(0, Math.min(this.text.length - this.cursorPosition, SkiaEditor.Whole(v)));
|
|
190
198
|
if (l === this.selectionLength)
|
|
191
199
|
return;
|
|
192
200
|
this.selectionLength = l;
|
|
193
201
|
this.OnCursorMoved();
|
|
194
202
|
}
|
|
203
|
+
/** Shows the caret for a full half second, then blinks every 500 ms; while the window is inactive no caret, no timer. */
|
|
204
|
+
StartBlink() {
|
|
205
|
+
this.StopBlink();
|
|
206
|
+
const canvas = this.Superview;
|
|
207
|
+
this.caretVisible = canvas?.IsWindowActive !== false;
|
|
208
|
+
if (!this.caretVisible)
|
|
209
|
+
return;
|
|
210
|
+
this.blinkTimer = window.setInterval(() => { this.caretVisible = !this.caretVisible; this.InvalidateCache(); this.RepaintComposition(); }, 500);
|
|
211
|
+
}
|
|
212
|
+
StopBlink() { if (this.blinkTimer) {
|
|
213
|
+
clearInterval(this.blinkTimer);
|
|
214
|
+
this.blinkTimer = 0;
|
|
215
|
+
} }
|
|
195
216
|
OnCursorMoved() {
|
|
196
217
|
this.ScrollToCaret();
|
|
197
|
-
this.
|
|
218
|
+
if (this.isFocused)
|
|
219
|
+
this.StartBlink();
|
|
220
|
+
else
|
|
221
|
+
this.caretVisible = true;
|
|
198
222
|
TextInputProxy.Sync(this);
|
|
199
223
|
this.CursorMoved?.(this);
|
|
200
224
|
this.InvalidateCache();
|
|
@@ -209,9 +233,16 @@ export class SkiaEditor extends SkiaShape {
|
|
|
209
233
|
if (SkiaEditor.Focused && SkiaEditor.Focused !== this)
|
|
210
234
|
SkiaEditor.Focused.IsFocused = false;
|
|
211
235
|
SkiaEditor.Focused = this;
|
|
236
|
+
// focused with no caret placed (from code, by the keyboard): the caret goes to the end of the text, as a tap after
|
|
237
|
+
// the text does, and the native field takes that position when it attaches (C# 2285b422: typing appends)
|
|
238
|
+
if (!this.cursorPlaced) {
|
|
239
|
+
this.cursorPlaced = true;
|
|
240
|
+
this.cursorPosition = this.text.length;
|
|
241
|
+
this.selectionLength = 0;
|
|
242
|
+
this.ScrollToCaret();
|
|
243
|
+
}
|
|
212
244
|
this.SetFocusNative(true);
|
|
213
|
-
this.
|
|
214
|
-
this.blink.Start();
|
|
245
|
+
this.StartBlink();
|
|
215
246
|
}
|
|
216
247
|
else {
|
|
217
248
|
if (SkiaEditor.Focused === this)
|
|
@@ -220,9 +251,17 @@ export class SkiaEditor extends SkiaShape {
|
|
|
220
251
|
this.dragSelecting = false;
|
|
221
252
|
this.stubSelectionStop = -1;
|
|
222
253
|
this.selectionMovingEdge = -1;
|
|
223
|
-
this.
|
|
254
|
+
this.StopBlink();
|
|
224
255
|
this.SetFocusNative(false);
|
|
225
256
|
}
|
|
257
|
+
// the canvas focus follows the editor's own (a press, Tab, code), so a tap elsewhere can end the editing (6ap)
|
|
258
|
+
const canvas = this.Superview;
|
|
259
|
+
if (canvas) {
|
|
260
|
+
if (v)
|
|
261
|
+
canvas.ReportFocus(this, this);
|
|
262
|
+
else if (canvas.FocusedChild === this)
|
|
263
|
+
canvas.ReportFocus(undefined, this);
|
|
264
|
+
}
|
|
226
265
|
this.FocusChanged?.(this, v);
|
|
227
266
|
this.NotifyAccessibility();
|
|
228
267
|
this.InvalidateCache();
|
|
@@ -241,7 +280,7 @@ export class SkiaEditor extends SkiaShape {
|
|
|
241
280
|
: style === "Material" ? { bg: "#EFEBF4", corner: 4, stroke: Colors.Transparent, strokeW: 0, cursor: "#2196F3" }
|
|
242
281
|
: style === "Material3" ? { bg: "#E6E0E9", corner: 4, stroke: Colors.Transparent, strokeW: 0, cursor: "#6750A4" }
|
|
243
282
|
: style === "Windows" ? { bg: "#FFFFFF", corner: 2, stroke: "#8A8A8A", strokeW: 1, cursor: "#0078D4" }
|
|
244
|
-
: { bg: "#F2F3F5", corner: 8, stroke: Colors.Transparent, strokeW: 0, cursor:
|
|
283
|
+
: { bg: "#F2F3F5", corner: 8, stroke: Colors.Transparent, strokeW: 0, cursor: DefaultAccent };
|
|
245
284
|
const apply = (key, current, next, set) => {
|
|
246
285
|
if (!(key in this.styleApplied) || this.styleApplied[key] === current) {
|
|
247
286
|
set();
|
|
@@ -305,16 +344,27 @@ export class SkiaEditor extends SkiaShape {
|
|
|
305
344
|
MeasureAbsolute(w, h, scale) {
|
|
306
345
|
const px = this.Padding.HorizontalThickness * scale, py = this.Padding.VerticalThickness * scale;
|
|
307
346
|
const innerW = isFinite(w) ? Math.max(0, w - px) : Infinity;
|
|
347
|
+
// Single-line: the label is Start-aligned and measures to its content, so Center / End alignment had nothing to
|
|
348
|
+
// align in. Give it the field as a MINIMUM: short text centers in the field, longer text still grows past it and
|
|
349
|
+
// scrolls (C# 2e334ddd). A right-to-left paragraph aligns even with Start (it starts at the right, drawnui-cross 6am,
|
|
350
|
+
// C# 8e4b18ef).
|
|
351
|
+
const aligns = this.horizontalTextAlignment !== "Start" || SkiaLabel.FirstStrongIsRtl(this.Label.Text);
|
|
352
|
+
const minWidth = !this.IsMultiline && aligns && isFinite(innerW) && innerW > 0 ? innerW / scale : -1;
|
|
353
|
+
if (this.Label.MinimumWidthRequest !== minWidth) {
|
|
354
|
+
this.Label.MinimumWidthRequest = minWidth;
|
|
355
|
+
this.Label.NeedMeasure = true;
|
|
356
|
+
}
|
|
308
357
|
const labelSize = this.Label.Measure(this.IsMultiline ? innerW : Infinity, Infinity, scale);
|
|
309
358
|
if (this.placeholder.IsVisible)
|
|
310
359
|
this.placeholder.Measure(innerW, Infinity, scale);
|
|
311
360
|
const lineH = this.Label.MeasuredLineHeight || this.placeholder.MeasuredLineHeight || this.GetSingleLineHeightPts() * scale;
|
|
312
|
-
let
|
|
361
|
+
let contentH = lineH * (this.maxLines > 0 ? this.maxLines : 1);
|
|
313
362
|
if (this.AutoHeight && this.IsMultiline) {
|
|
314
|
-
|
|
315
|
-
|
|
363
|
+
// the visible lines as the label lays them out: each its own height, with line and paragraph spacing between
|
|
364
|
+
const boxes = this.Label.GetLineBoxes();
|
|
365
|
+
const k = this.maxLines > 0 ? Math.min(boxes.length, this.maxLines) : boxes.length;
|
|
366
|
+
contentH = k > 0 ? boxes[k - 1].Top + boxes[k - 1].Height - boxes[0].Top : lineH;
|
|
316
367
|
}
|
|
317
|
-
const contentH = lineH * lines;
|
|
318
368
|
const width = isFinite(w) ? w : labelSize.Pixels.Width + px;
|
|
319
369
|
return ScaledSize.FromPixels(width, Math.ceil(contentH) + py, scale);
|
|
320
370
|
}
|
|
@@ -355,34 +405,89 @@ export class SkiaEditor extends SkiaShape {
|
|
|
355
405
|
this.OnLayoutChanged();
|
|
356
406
|
}
|
|
357
407
|
// ---- caret / selection geometry (pixels relative to the label's DrawingRect) ----
|
|
408
|
+
// Rules shared with DrawnUi.Rust (drawnui-cross 6ak): boxes are visual, the caret at index i is the trailing edge of
|
|
409
|
+
// character i - 1 on its line (the leading edge of the first character at a line start), taps and Left / Right go to
|
|
410
|
+
// the grapheme boundary whose caret x is nearest.
|
|
358
411
|
Boxes() {
|
|
359
412
|
if (this.layoutVersion !== this.Label.LayoutVersion) {
|
|
360
413
|
this.boxes = this.Label.GetGlyphBoxes();
|
|
361
414
|
this.layoutVersion = this.Label.LayoutVersion;
|
|
415
|
+
this.boxAt.clear();
|
|
416
|
+
this.boxEnd.clear();
|
|
417
|
+
for (const b of this.boxes) {
|
|
418
|
+
this.boxAt.set(b.Index, b);
|
|
419
|
+
this.boxEnd.set(b.Index + b.Length, b);
|
|
420
|
+
}
|
|
362
421
|
}
|
|
363
422
|
return this.boxes;
|
|
364
423
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
424
|
+
Stops() {
|
|
425
|
+
if (this.stopsText !== this.text) {
|
|
426
|
+
this.stopsText = this.text;
|
|
427
|
+
this.stops = SkiaEditor.Graphemes(this.text).map((g) => g.index);
|
|
428
|
+
this.stops.push(this.text.length);
|
|
429
|
+
}
|
|
430
|
+
return this.stops;
|
|
431
|
+
}
|
|
432
|
+
/** The laid-out line a caret index belongs to: the line holding the character before it, else the one starting at it. */
|
|
433
|
+
static LineOf(index, lines) {
|
|
434
|
+
for (const l of lines)
|
|
435
|
+
if (index > l.Start && index <= l.End)
|
|
436
|
+
return l;
|
|
437
|
+
for (const l of lines)
|
|
438
|
+
if (index === l.Start)
|
|
439
|
+
return l;
|
|
440
|
+
let line = lines[0];
|
|
441
|
+
for (const l of lines)
|
|
442
|
+
if (l.Start <= index)
|
|
443
|
+
line = l; // in a space wrapped away: the line before it
|
|
444
|
+
return line;
|
|
445
|
+
}
|
|
446
|
+
/** Where the caret before character `index` stands (label pixels): its x, the direction of the text there, its line box. */
|
|
447
|
+
CaretPlace(index) {
|
|
368
448
|
const lines = this.Label.GetLineBoxes();
|
|
369
449
|
if (lines.length === 0)
|
|
370
450
|
return undefined;
|
|
451
|
+
const boxes = this.Boxes();
|
|
452
|
+
const line = SkiaEditor.LineOf(index, lines);
|
|
453
|
+
const trailing = (b) => ({ X: b.Rtl ? b.Left : b.Left + b.Width, Rtl: !!b.Rtl, Top: b.Top, Height: b.Height });
|
|
454
|
+
if (index > line.Start) {
|
|
455
|
+
let prev = this.boxEnd.get(index);
|
|
456
|
+
if (!prev || prev.Line !== line.Line) {
|
|
457
|
+
prev = undefined;
|
|
458
|
+
for (const b of boxes)
|
|
459
|
+
if (b.Line === line.Line && b.Index < index)
|
|
460
|
+
prev = b;
|
|
461
|
+
}
|
|
462
|
+
if (prev)
|
|
463
|
+
return trailing(prev);
|
|
464
|
+
}
|
|
465
|
+
const cur = this.boxAt.get(index);
|
|
466
|
+
if (cur && cur.Line === line.Line)
|
|
467
|
+
return { X: cur.Rtl ? cur.Left + cur.Width : cur.Left, Rtl: !!cur.Rtl, Top: cur.Top, Height: cur.Height };
|
|
468
|
+
return { X: line.Left, Rtl: false, Top: line.Top, Height: line.Height };
|
|
469
|
+
}
|
|
470
|
+
/** Rect of the caret before character `index` (label pixels), or undefined before the first layout. */
|
|
471
|
+
CaretRectLabelPx(index = this.cursorPosition + this.selectionLength) {
|
|
472
|
+
const place = this.CaretPlace(index);
|
|
473
|
+
if (!place)
|
|
474
|
+
return undefined;
|
|
371
475
|
const caretW = 2 * this.RenderingScale;
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
476
|
+
return SKRect.Create(place.Rtl ? place.X - caretW : place.X, place.Top, caretW, place.Height);
|
|
477
|
+
}
|
|
478
|
+
/** The grapheme boundary of a line whose caret x is nearest to `x` (a tie: the smaller index). */
|
|
479
|
+
NearestStop(line, x) {
|
|
480
|
+
let best = -1, bestD = Infinity;
|
|
481
|
+
for (const i of this.Stops()) {
|
|
482
|
+
if (i < line.Start || i > line.End)
|
|
483
|
+
continue;
|
|
484
|
+
const d = Math.abs((this.CaretPlace(i)?.X ?? 0) - x);
|
|
485
|
+
if (d < bestD - 0.01) {
|
|
486
|
+
best = i;
|
|
487
|
+
bestD = d;
|
|
488
|
+
}
|
|
381
489
|
}
|
|
382
|
-
|
|
383
|
-
return SKRect.Create(prev.Left + prev.Width, prev.Top, caretW, prev.Height);
|
|
384
|
-
const first = lines[0];
|
|
385
|
-
return SKRect.Create(first.Left, first.Top, caretW, first.Height);
|
|
490
|
+
return best >= 0 ? best : Math.min(line.Start, this.text.length);
|
|
386
491
|
}
|
|
387
492
|
/** C# GetCursorPosition: the text index nearest to a point in label pixels. */
|
|
388
493
|
HitTestIndex(x, y) {
|
|
@@ -395,16 +500,54 @@ export class SkiaEditor extends SkiaShape {
|
|
|
395
500
|
line = l;
|
|
396
501
|
break;
|
|
397
502
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
const
|
|
407
|
-
|
|
503
|
+
return this.NearestStop(line, x);
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Left / Right from a caret index: the grapheme boundary on its line whose caret x is nearest that way (equal x: the
|
|
507
|
+
* one logically nearest); at the visual edge of the line one grapheme logically, forward for Right in a
|
|
508
|
+
* left-to-right paragraph and backward in a right-to-left one (Left the other way round).
|
|
509
|
+
*/
|
|
510
|
+
VisualTarget(from, dir) {
|
|
511
|
+
const lines = this.Label.GetLineBoxes();
|
|
512
|
+
const stops = this.Stops();
|
|
513
|
+
let line;
|
|
514
|
+
if (lines.length > 0) {
|
|
515
|
+
line = SkiaEditor.LineOf(from, lines);
|
|
516
|
+
const x0 = this.CaretPlace(from)?.X ?? 0;
|
|
517
|
+
let best = -1, bestX = 0;
|
|
518
|
+
for (const i of stops) {
|
|
519
|
+
if (i < line.Start || i > line.End || i === from)
|
|
520
|
+
continue;
|
|
521
|
+
const x = this.CaretPlace(i)?.X ?? 0;
|
|
522
|
+
if ((x - x0) * dir <= 0.01)
|
|
523
|
+
continue;
|
|
524
|
+
if (best < 0 || (x - bestX) * dir < -0.01 || (Math.abs(x - bestX) <= 0.01 && Math.abs(i - from) < Math.abs(best - from))) {
|
|
525
|
+
best = i;
|
|
526
|
+
bestX = x;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
if (best >= 0)
|
|
530
|
+
return best;
|
|
531
|
+
}
|
|
532
|
+
const start = Math.max(this.text.lastIndexOf(ParagraphBreak, from - 1) + 1, 0);
|
|
533
|
+
const end = this.text.indexOf(ParagraphBreak, from);
|
|
534
|
+
const step = SkiaLabel.FirstStrongIsRtl(this.text.slice(start, end < 0 ? undefined : end)) ? -dir : dir;
|
|
535
|
+
let to = from;
|
|
536
|
+
if (step > 0) {
|
|
537
|
+
for (const i of stops)
|
|
538
|
+
if (i > from) {
|
|
539
|
+
to = i;
|
|
540
|
+
break;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
else
|
|
544
|
+
for (let k = stops.length - 1; k >= 0; k--)
|
|
545
|
+
if (stops[k] < from) {
|
|
546
|
+
to = stops[k];
|
|
547
|
+
break;
|
|
548
|
+
}
|
|
549
|
+
// the step only crosses to the next or previous line: inside a mixed line the visual end stays put
|
|
550
|
+
return line && lines.length > 0 && SkiaEditor.LineOf(to, lines) === line ? from : to;
|
|
408
551
|
}
|
|
409
552
|
LabelPoint(args, apply, starting = false) {
|
|
410
553
|
const loc = starting ? args.Event.StartingLocation : apply.MappedLocation;
|
|
@@ -424,9 +567,10 @@ export class SkiaEditor extends SkiaShape {
|
|
|
424
567
|
const paint = new CK.Paint();
|
|
425
568
|
paint.setColor(Super.ParseColor(this.SelectionColor));
|
|
426
569
|
const end = this.cursorPosition + this.selectionLength;
|
|
570
|
+
// every selected character's own visual box: across a direction boundary the highlight can be two blocks
|
|
427
571
|
for (const b of this.Boxes())
|
|
428
|
-
if (b.Index >= this.cursorPosition && b.Index < end)
|
|
429
|
-
canvas.drawRect(CK.LTRBRect(lr.Left + b.Left, lr.Top + b.Top, lr.Left + b.Left +
|
|
572
|
+
if (b.Index >= this.cursorPosition && b.Index < end && b.Width > 0)
|
|
573
|
+
canvas.drawRect(CK.LTRBRect(lr.Left + b.Left, lr.Top + b.Top, lr.Left + b.Left + b.Width, lr.Top + b.Top + b.Height), paint);
|
|
430
574
|
paint.delete();
|
|
431
575
|
canvas.restoreToCount(saved);
|
|
432
576
|
}
|
|
@@ -445,7 +589,21 @@ export class SkiaEditor extends SkiaShape {
|
|
|
445
589
|
}
|
|
446
590
|
}
|
|
447
591
|
// ---- gestures (C# ProcessGestures: tap places the caret, drag selects, long press selects the word) ----
|
|
592
|
+
/** The press now down is not the main button's. */
|
|
593
|
+
otherButtonPress = false;
|
|
448
594
|
ProcessGestures(args, apply) {
|
|
595
|
+
// a press with another mouse button (a right click for the context menu) leaves the caret and the selection as they
|
|
596
|
+
// are, also as it drags or is held; it still focuses the field (DrawnUi.Net b6d65b8b)
|
|
597
|
+
if (args.Type === "Down")
|
|
598
|
+
this.otherButtonPress = !SkiaControl.IsPrimaryPointer(args);
|
|
599
|
+
if (this.otherButtonPress && (args.Type === "Down" || args.Type === "Panning" || args.Type === "LongPressing")) {
|
|
600
|
+
if (args.Type === "Down") {
|
|
601
|
+
this.dragSelecting = false;
|
|
602
|
+
if (!this.isFocused)
|
|
603
|
+
this.IsFocused = true;
|
|
604
|
+
}
|
|
605
|
+
return this;
|
|
606
|
+
}
|
|
449
607
|
switch (args.Type) {
|
|
450
608
|
case "Down": {
|
|
451
609
|
const p = this.LabelPoint(args, apply);
|
|
@@ -468,6 +626,7 @@ export class SkiaEditor extends SkiaShape {
|
|
|
468
626
|
this.stubSelectionStop = -1;
|
|
469
627
|
this.selectionMovingEdge = -1;
|
|
470
628
|
}
|
|
629
|
+
this.cursorPlaced = true;
|
|
471
630
|
if (!this.isFocused)
|
|
472
631
|
this.IsFocused = true;
|
|
473
632
|
this.OnCursorMoved();
|
|
@@ -489,19 +648,34 @@ export class SkiaEditor extends SkiaShape {
|
|
|
489
648
|
this.SelectWord(this.HitTestIndex(p.X, p.Y));
|
|
490
649
|
this.dragSelecting = true;
|
|
491
650
|
this.selectionAnchor = this.cursorPosition;
|
|
651
|
+
this.cursorPlaced = true;
|
|
492
652
|
if (!this.isFocused)
|
|
493
653
|
this.IsFocused = true;
|
|
494
654
|
return this;
|
|
495
655
|
}
|
|
496
656
|
case "Up":
|
|
497
657
|
this.dragSelecting = false;
|
|
658
|
+
this.otherButtonPress = false;
|
|
498
659
|
return this;
|
|
499
660
|
case "Tapped": return this;
|
|
661
|
+
// the field scrolls its text only to follow the caret: the wheel is the page's, over the field too
|
|
662
|
+
case "Wheel": return null;
|
|
500
663
|
}
|
|
501
664
|
return this;
|
|
502
665
|
}
|
|
503
|
-
|
|
504
|
-
|
|
666
|
+
/** The canvas gives or takes the focus (a tap elsewhere): an editor always takes it. */
|
|
667
|
+
SetFrameworkFocus(focus) { this.IsFocused = focus; return true; }
|
|
668
|
+
/** A text field is a Tab stop by default, like a native text box, with no Tapped handler needed. */
|
|
669
|
+
DefaultAccessibilityCanInteract() { return true; }
|
|
670
|
+
/** Keyboard navigation reached the field (Tab) or left it: take the caret and the input sink like a native text box, or release them. */
|
|
671
|
+
OnAccessibilityFocused(focused) { this.IsFocused = focused; }
|
|
672
|
+
/** Enter / Space on the field while it has no caret start editing; while editing they are text. */
|
|
673
|
+
OnAccessibilityActivated() { if (!this.IsFocused)
|
|
674
|
+
this.OnAccessibilityFocused(true); }
|
|
675
|
+
/** While editing, arrows, Home / End and PageUp / PageDown belong to the text: they never move a surrounding group. */
|
|
676
|
+
OnAccessibilityKey(_key) { return this.IsFocused; }
|
|
677
|
+
/** The typed text, else the placeholder. A password field never exposes its text: only the placeholder (C# SkiaEditor). */
|
|
678
|
+
DefaultAccessibilityLabel() { return (!this.isPassword && this.text) || this.placeholderText || undefined; }
|
|
505
679
|
// ---- editing API (C# names) ----
|
|
506
680
|
Submit() {
|
|
507
681
|
if (this.IsMultiline && !this.ShouldSubmitOnEnter) {
|
|
@@ -517,6 +691,7 @@ export class SkiaEditor extends SkiaShape {
|
|
|
517
691
|
}
|
|
518
692
|
SelectAll() { this.SetSelection(0, this.text.length); }
|
|
519
693
|
SetSelection(start, end) {
|
|
694
|
+
this.cursorPlaced = true;
|
|
520
695
|
const s = Math.max(0, Math.min(this.text.length, Math.min(start, end))), e = Math.max(0, Math.min(this.text.length, Math.max(start, end)));
|
|
521
696
|
this.cursorPosition = s;
|
|
522
697
|
this.selectionLength = e - s;
|
|
@@ -571,15 +746,42 @@ export class SkiaEditor extends SkiaShape {
|
|
|
571
746
|
KeyboardManager.Subscribe(this.onKeyDown, this.onKeyChar);
|
|
572
747
|
KeyboardManager.BlurExternalTextInput();
|
|
573
748
|
TextInputProxy.Attach(this);
|
|
749
|
+
CanvasLeaveWatchers.add(this);
|
|
750
|
+
this.windowCanvas = this.Superview;
|
|
751
|
+
this.windowCanvas?.WindowActiveChanged?.add(this.onWindowActive);
|
|
574
752
|
}
|
|
575
753
|
else {
|
|
576
754
|
TextInputProxy.Detach(this);
|
|
577
755
|
KeyboardManager.Unsubscribe(this.onKeyDown, this.onKeyChar);
|
|
756
|
+
CanvasLeaveWatchers.delete(this);
|
|
757
|
+
this.windowCanvas?.WindowActiveChanged?.delete(this.onWindowActive);
|
|
758
|
+
this.windowCanvas = undefined;
|
|
578
759
|
}
|
|
579
760
|
}
|
|
761
|
+
// the window the editor is focused in (C# WindowActiveChanged, subscribed only while focused)
|
|
762
|
+
windowCanvas;
|
|
763
|
+
/** The window lost the keyboard: the caret hides and stops blinking (no redraws); back: it shows again in this field. */
|
|
764
|
+
onWindowActive = (active) => {
|
|
765
|
+
if (!this.isFocused)
|
|
766
|
+
return;
|
|
767
|
+
if (active)
|
|
768
|
+
this.StartBlink();
|
|
769
|
+
else {
|
|
770
|
+
this.StopBlink();
|
|
771
|
+
this.caretVisible = false;
|
|
772
|
+
}
|
|
773
|
+
this.InvalidateCache();
|
|
774
|
+
this.RepaintComposition();
|
|
775
|
+
};
|
|
776
|
+
/** Removed from the canvas while focused: the editing ends (caret timer, keys, text proxy). */
|
|
777
|
+
OnLeftCanvas() { this.IsFocused = false; }
|
|
580
778
|
OnKeyDown(key, e) {
|
|
581
779
|
const shift = KeyboardManager.IsShiftPressed, ctrl = KeyboardManager.IsControlPressed, alt = KeyboardManager.IsAltPressed;
|
|
582
780
|
const handled = () => e.preventDefault();
|
|
781
|
+
// keys of another element (a page field or button, an overlay node) and of the input method are not the editor's:
|
|
782
|
+
// a composition keeps its arrows, Escape and Backspace (C# 845b26e9, GitHub #231)
|
|
783
|
+
if (KeyboardManager.IsInputMethodKey(e) || (KeyboardManager.IsOwnedByElement(e) && !TextInputProxy.IsProxyTarget(e.target)))
|
|
784
|
+
return;
|
|
583
785
|
// with the hidden textarea focused these keys become input / clipboard events there and are applied from those
|
|
584
786
|
if (TextInputProxy.IsActive(this) && TextInputProxy.IsProxyTarget(e.target) && (key === "Backspace" || key === "Delete" || key === "Enter" || key === "NumpadEnter" || (ctrl && (key === "KeyC" || key === "KeyX" || key === "KeyV"))))
|
|
585
787
|
return;
|
|
@@ -599,11 +801,11 @@ export class SkiaEditor extends SkiaShape {
|
|
|
599
801
|
break;
|
|
600
802
|
case "ArrowLeft":
|
|
601
803
|
handled();
|
|
602
|
-
this.
|
|
804
|
+
this.MoveVisual(-1, shift);
|
|
603
805
|
break;
|
|
604
806
|
case "ArrowRight":
|
|
605
807
|
handled();
|
|
606
|
-
this.
|
|
808
|
+
this.MoveVisual(1, shift);
|
|
607
809
|
break;
|
|
608
810
|
case "ArrowUp":
|
|
609
811
|
if (this.IsMultiline) {
|
|
@@ -725,6 +927,39 @@ export class SkiaEditor extends SkiaShape {
|
|
|
725
927
|
this.selectionMovingEdge = -1;
|
|
726
928
|
this.OnCursorMoved();
|
|
727
929
|
}
|
|
930
|
+
/**
|
|
931
|
+
* Arrow Left (-1) / Right (1): visual moves, as native text fields (see VisualTarget). Without Shift a selection
|
|
932
|
+
* collapses to its visually left (Left) or right (Right) edge; with Shift its moving edge moves.
|
|
933
|
+
*/
|
|
934
|
+
MoveVisual(dir, extendSelection = false) {
|
|
935
|
+
if (!extendSelection && this.HasSelection) {
|
|
936
|
+
const a = this.cursorPosition, b = this.cursorPosition + this.selectionLength;
|
|
937
|
+
const xa = this.CaretPlace(a)?.X ?? 0, xb = this.CaretPlace(b)?.X ?? 0;
|
|
938
|
+
const to = dir < 0 ? (xa <= xb ? a : b) : (xa >= xb ? a : b);
|
|
939
|
+
this.cursorPosition = to;
|
|
940
|
+
this.selectionLength = 0;
|
|
941
|
+
this.stubSelectionStop = -1;
|
|
942
|
+
this.selectionMovingEdge = -1;
|
|
943
|
+
this.OnCursorMoved();
|
|
944
|
+
return;
|
|
945
|
+
}
|
|
946
|
+
// a selection made by dragging has no moving edge yet: its end moves
|
|
947
|
+
if (extendSelection && this.HasSelection && this.selectionMovingEdge < 0) {
|
|
948
|
+
this.stubSelectionStop = this.cursorPosition;
|
|
949
|
+
this.selectionMovingEdge = this.cursorPosition + this.selectionLength;
|
|
950
|
+
}
|
|
951
|
+
const from = extendSelection && this.HasSelection ? this.selectionMovingEdge : this.cursorPosition;
|
|
952
|
+
if (extendSelection && !this.HasSelection) {
|
|
953
|
+
this.stubSelectionStop = this.cursorPosition;
|
|
954
|
+
this.selectionMovingEdge = this.cursorPosition;
|
|
955
|
+
}
|
|
956
|
+
const to = this.VisualTarget(from, dir);
|
|
957
|
+
if (extendSelection) {
|
|
958
|
+
this.StubMoveCursor(to - this.selectionMovingEdge, true);
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
this.StubMoveCursor(to - this.cursorPosition, false);
|
|
962
|
+
}
|
|
728
963
|
StubSelectRange(start, length) {
|
|
729
964
|
const len = this.text.length;
|
|
730
965
|
const s = Math.max(0, Math.min(len, start)), l = Math.max(0, Math.min(len - s, length));
|
|
@@ -794,8 +1029,7 @@ export class SkiaEditor extends SkiaShape {
|
|
|
794
1029
|
return out;
|
|
795
1030
|
}
|
|
796
1031
|
OnDisposing() {
|
|
797
|
-
this.
|
|
798
|
-
this.blink.Dispose();
|
|
1032
|
+
this.StopBlink();
|
|
799
1033
|
if (SkiaEditor.Focused === this)
|
|
800
1034
|
SkiaEditor.Focused = undefined;
|
|
801
1035
|
this.SetFocusNative(false);
|
|
@@ -14,6 +14,8 @@ export declare class GifAnimation {
|
|
|
14
14
|
private positionsMs;
|
|
15
15
|
/** Negative = the last frame. */
|
|
16
16
|
SeekFrame(frame: number): void;
|
|
17
|
+
/** Start (ms) of the frame after the one at `msTime`; DurationMs after the last one. */
|
|
18
|
+
NextFrameStartMs(msTime: number): number;
|
|
17
19
|
GetFrameNumber(msTime: number): number;
|
|
18
20
|
/** Decodes every frame of an encoded GIF (CanvasKit AnimatedImage). */
|
|
19
21
|
LoadFromBytes(bytes: ArrayBuffer): void;
|
|
@@ -37,11 +39,16 @@ export declare class SkiaGif extends AnimatedFramesRenderer {
|
|
|
37
39
|
set Source(v: string);
|
|
38
40
|
Start(delayMs?: number): void;
|
|
39
41
|
protected OnAnimatorUpdated(value: number): void;
|
|
42
|
+
protected NextChangeMs(value: number): number | undefined;
|
|
40
43
|
/** Seeks by time in ms (the animator range is 0..DurationMs). */
|
|
41
44
|
protected OnAnimatorSeeking(time: number): void;
|
|
42
45
|
protected OnAnimatorInitializing(): void;
|
|
43
46
|
protected ApplySpeed(): void;
|
|
44
47
|
protected CheckCanStartAnimator(): boolean;
|
|
48
|
+
/** Shows a frame by index, negative = last frame (C# ShowFrame). */
|
|
49
|
+
protected ShowFrame(frame: number): void;
|
|
50
|
+
/** Shows DefaultFrame (a frame index, -1 = last) when not playing. */
|
|
51
|
+
protected ApplyDefaultFrame(): void;
|
|
45
52
|
SetAnimation(animation: GifAnimation, disposePrevious: boolean): void;
|
|
46
53
|
ReloadSource(): void;
|
|
47
54
|
/** Loads (does not apply) a GIF; C# LoadSource. */
|
package/dist/controls/SkiaGif.js
CHANGED
|
@@ -21,6 +21,13 @@ export class GifAnimation {
|
|
|
21
21
|
if (frame >= 0 && frame <= this.TotalFrames - 1)
|
|
22
22
|
this.Frame = this.Frames[frame];
|
|
23
23
|
}
|
|
24
|
+
/** Start (ms) of the frame after the one at `msTime`; DurationMs after the last one. */
|
|
25
|
+
NextFrameStartMs(msTime) {
|
|
26
|
+
for (let i = 0; i < this.positionsMs.length; i++)
|
|
27
|
+
if (msTime < this.positionsMs[i])
|
|
28
|
+
return this.positionsMs[i];
|
|
29
|
+
return this.DurationMs;
|
|
30
|
+
}
|
|
24
31
|
GetFrameNumber(msTime) {
|
|
25
32
|
if (this.positionsMs.length === 0 || this.DurationMs <= 0)
|
|
26
33
|
return 0;
|
|
@@ -87,7 +94,9 @@ export class SkiaGif extends AnimatedFramesRenderer {
|
|
|
87
94
|
loadGeneration = 0;
|
|
88
95
|
constructor() {
|
|
89
96
|
super();
|
|
90
|
-
|
|
97
|
+
// C# ImageDoubleBuffered pays off where a thread bakes the bitmap; on the web it is one offscreen pass per frame
|
|
98
|
+
// change, so the web engines draw a GIF frame with no cache (drawnui-cross rule 3)
|
|
99
|
+
this.UseCache = "None";
|
|
91
100
|
}
|
|
92
101
|
get Source() { return this.source; }
|
|
93
102
|
set Source(v) { if (this.source !== v) {
|
|
@@ -97,6 +106,7 @@ export class SkiaGif extends AnimatedFramesRenderer {
|
|
|
97
106
|
Start(delayMs = 0) { if ((this.Animation?.TotalFrames ?? 0) > 0)
|
|
98
107
|
super.Start(delayMs); }
|
|
99
108
|
OnAnimatorUpdated(value) { this.Seek(value); }
|
|
109
|
+
NextChangeMs(value) { return this.Animation && this.Animation.DurationMs > 0 ? this.Animation.NextFrameStartMs(value) : undefined; }
|
|
100
110
|
/** Seeks by time in ms (the animator range is 0..DurationMs). */
|
|
101
111
|
OnAnimatorSeeking(time) {
|
|
102
112
|
const a = this.Animation;
|
|
@@ -121,9 +131,20 @@ export class SkiaGif extends AnimatedFramesRenderer {
|
|
|
121
131
|
if (!this.Animation || !this.Animator)
|
|
122
132
|
return;
|
|
123
133
|
const d = this.Animation.DurationMs;
|
|
124
|
-
this.Animator.Speed = this.
|
|
134
|
+
this.Animator.Speed = this.GetPlaybackDurationMs(d);
|
|
125
135
|
}
|
|
126
136
|
CheckCanStartAnimator() { return (this.Animation?.TotalFrames ?? 0) > 0; }
|
|
137
|
+
/** Shows a frame by index, negative = last frame (C# ShowFrame). */
|
|
138
|
+
ShowFrame(frame) {
|
|
139
|
+
if (!this.Animation)
|
|
140
|
+
return;
|
|
141
|
+
this.Animation.SeekFrame(frame);
|
|
142
|
+
this.InvalidateCache();
|
|
143
|
+
this.RepaintComposition();
|
|
144
|
+
}
|
|
145
|
+
/** Shows DefaultFrame (a frame index, -1 = last) when not playing. */
|
|
146
|
+
ApplyDefaultFrame() { if (!this.IsPlaying && this.Animation)
|
|
147
|
+
this.ShowFrame(this.DefaultFrame); }
|
|
127
148
|
SetAnimation(animation, disposePrevious) {
|
|
128
149
|
if (!animation || animation === this.Animation)
|
|
129
150
|
return;
|
|
@@ -133,7 +154,7 @@ export class SkiaGif extends AnimatedFramesRenderer {
|
|
|
133
154
|
this.Stop();
|
|
134
155
|
this.Animation = animation;
|
|
135
156
|
this.InitializeAnimator();
|
|
136
|
-
this.
|
|
157
|
+
this.ShowFrame(this.DefaultFrame);
|
|
137
158
|
if (wasPlaying && !this.IsPlaying)
|
|
138
159
|
this.Start();
|
|
139
160
|
if (kill && disposePrevious)
|
|
@@ -158,7 +179,7 @@ export class SkiaGif extends AnimatedFramesRenderer {
|
|
|
158
179
|
async LoadSource(source) {
|
|
159
180
|
if (!source)
|
|
160
181
|
return undefined;
|
|
161
|
-
const r = await fetch(source);
|
|
182
|
+
const r = await fetch(Super.ResolveAssetUrl(source));
|
|
162
183
|
if (!r.ok)
|
|
163
184
|
throw new Error(`${r.status} ${source}`);
|
|
164
185
|
const animation = new GifAnimation();
|