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
|
@@ -8,6 +8,8 @@ import { type Color, ScaledSize, Thickness } from "../core/Types";
|
|
|
8
8
|
* Track, selected trail and thumbs are painted directly; the C# thumb-position math (SliderHeight = thumb box) is kept.
|
|
9
9
|
*/
|
|
10
10
|
export declare class SkiaSlider extends SkiaControl {
|
|
11
|
+
/** Takes mouse hover unless ReceivesHover is set false (C# ReceivesHoverByDefault). */
|
|
12
|
+
protected ReceivesHoverByDefault(): boolean;
|
|
11
13
|
static DefaultAccessibilityRole?: string;
|
|
12
14
|
ControlStyle: PrebuiltControlStyle;
|
|
13
15
|
Min: number;
|
|
@@ -17,7 +19,11 @@ export declare class SkiaSlider extends SkiaControl {
|
|
|
17
19
|
/** Minimum distance between the two thumbs, in value units. */
|
|
18
20
|
RangeMin: number;
|
|
19
21
|
ClickOnTrailEnabled: boolean;
|
|
20
|
-
|
|
22
|
+
private respondsToGestures;
|
|
23
|
+
/** False: neither a drag nor the arrow keys move it (code still can), and it is reported disabled (drawnui-cross 6w). */
|
|
24
|
+
get RespondsToGestures(): boolean;
|
|
25
|
+
set RespondsToGestures(v: boolean);
|
|
26
|
+
protected AcceptsInput(): boolean;
|
|
21
27
|
IsPressed: boolean;
|
|
22
28
|
IsUserPanning: boolean;
|
|
23
29
|
/** Extra points around a thumb that still count as grabbing it (C# moreHotspotSize). */
|
|
@@ -70,5 +76,17 @@ export declare class SkiaSlider extends SkiaControl {
|
|
|
70
76
|
protected Paint(ctx: DrawingContext): void;
|
|
71
77
|
ProcessGestures(args: SkiaGesturesParameters, apply: GestureEventProcessingInfo): SkiaControl | null;
|
|
72
78
|
protected DefaultAccessibilityCanInteract(): boolean;
|
|
73
|
-
|
|
79
|
+
/** Enter / Space do nothing: the base taps the center, which would jump the value to the middle. */
|
|
80
|
+
OnAccessibilityActivated(): void;
|
|
81
|
+
/**
|
|
82
|
+
* Keyboard adjustment while the slider holds keyboard focus (C# SkiaSlider.OnAccessibilityKey): Right / Up increase and
|
|
83
|
+
* Left / Down decrease by Step (a hundredth of the range when Step is 0), PageUp / PageDown move a tenth of the range,
|
|
84
|
+
* Home / End go to Min / Max. A ranged slider moves its End thumb, which stops at Start.
|
|
85
|
+
*/
|
|
86
|
+
OnAccessibilityKey(key: string): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* End between Min and Max, read as the number, or "20 – 80" in range mode; the step is the arrow key's. The name is
|
|
89
|
+
* the app's AccessibilityLabel only (C# used to make the value the name, drawnui-cross 6c).
|
|
90
|
+
*/
|
|
91
|
+
get AccessibilityValue(): import("../core/Accessibility").AccessibilityValue;
|
|
74
92
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SkiaControl } from "../core/SkiaControl";
|
|
2
2
|
import { Super } from "../core/Super";
|
|
3
|
-
import { ResolveControlStyle } from "../core/ControlStyle";
|
|
3
|
+
import { DefaultAccent, ResolveControlStyle } from "../core/ControlStyle";
|
|
4
4
|
import { Colors, ScaledSize, SkiaShadow, Thickness } from "../core/Types";
|
|
5
5
|
import { SkiaShape } from "./SkiaShape";
|
|
6
6
|
/**
|
|
@@ -9,6 +9,8 @@ import { SkiaShape } from "./SkiaShape";
|
|
|
9
9
|
* Track, selected trail and thumbs are painted directly; the C# thumb-position math (SliderHeight = thumb box) is kept.
|
|
10
10
|
*/
|
|
11
11
|
export class SkiaSlider extends SkiaControl {
|
|
12
|
+
/** Takes mouse hover unless ReceivesHover is set false (C# ReceivesHoverByDefault). */
|
|
13
|
+
ReceivesHoverByDefault() { return true; }
|
|
12
14
|
static DefaultAccessibilityRole = "slider";
|
|
13
15
|
ControlStyle = "Unset";
|
|
14
16
|
Min = 0;
|
|
@@ -18,7 +20,14 @@ export class SkiaSlider extends SkiaControl {
|
|
|
18
20
|
/** Minimum distance between the two thumbs, in value units. */
|
|
19
21
|
RangeMin = 0;
|
|
20
22
|
ClickOnTrailEnabled = true;
|
|
21
|
-
|
|
23
|
+
respondsToGestures = true;
|
|
24
|
+
/** False: neither a drag nor the arrow keys move it (code still can), and it is reported disabled (drawnui-cross 6w). */
|
|
25
|
+
get RespondsToGestures() { return this.respondsToGestures; }
|
|
26
|
+
set RespondsToGestures(v) { if (this.respondsToGestures !== v) {
|
|
27
|
+
this.respondsToGestures = v;
|
|
28
|
+
this.NotifyAccessibility();
|
|
29
|
+
} }
|
|
30
|
+
AcceptsInput() { return this.respondsToGestures; }
|
|
22
31
|
IsPressed = false;
|
|
23
32
|
IsUserPanning = false;
|
|
24
33
|
/** Extra points around a thumb that still count as grabbing it (C# moreHotspotSize). */
|
|
@@ -60,11 +69,11 @@ export class SkiaSlider extends SkiaControl {
|
|
|
60
69
|
get SliderHeight() { return this.sliderHeight ?? this.Look().thumb + (this.EnableRange && this.UsingControlStyle !== "Unset" ? 8 : 0); }
|
|
61
70
|
set SliderHeight(v) { this.sliderHeight = v; this.Update(); }
|
|
62
71
|
get ThumbColor() { return this.thumbColor ?? this.Look().thumbColor; }
|
|
63
|
-
set ThumbColor(v) { this.thumbColor = v; this.
|
|
72
|
+
set ThumbColor(v) { this.thumbColor = v; this.UpdateDraw(); }
|
|
64
73
|
get TrackColor() { return this.trackColor ?? this.Look().track; }
|
|
65
|
-
set TrackColor(v) { this.trackColor = v; this.
|
|
74
|
+
set TrackColor(v) { this.trackColor = v; this.UpdateDraw(); }
|
|
66
75
|
get TrackSelectedColor() { return this.trackSelectedColor ?? this.Look().selected; }
|
|
67
|
-
set TrackSelectedColor(v) { this.trackSelectedColor = v; this.
|
|
76
|
+
set TrackSelectedColor(v) { this.trackSelectedColor = v; this.UpdateDraw(); }
|
|
68
77
|
/** C# style builders: thumb diameter, track height, palette, thumb shadow. */
|
|
69
78
|
Look() {
|
|
70
79
|
switch (this.UsingControlStyle) {
|
|
@@ -72,7 +81,7 @@ export class SkiaSlider extends SkiaControl {
|
|
|
72
81
|
case "Material": return { thumb: 20, trackH: 4, track: "#E8EAED", selected: "#2196F3", thumbColor: "#2196F3", shadow: new SkiaShadow({ X: 0, Y: 1, Blur: 2, Opacity: 0.3, Color: Colors.Black }) };
|
|
73
82
|
case "Material3": return { thumb: 20, trackH: 4, track: "#E6E0E9", selected: "#6750A4", thumbColor: "#6750A4", shadow: new SkiaShadow({ X: 0, Y: 1, Blur: 2, Opacity: 0.3, Color: Colors.Black }) };
|
|
74
83
|
case "Windows": return { thumb: 20, trackH: 4, track: "#C6C6C6", selected: "#0078D4", thumbColor: "#0078D4", shadow: new SkiaShadow({ X: 0, Y: 1, Blur: 2, Opacity: 0.25, Color: Colors.Black }) };
|
|
75
|
-
default: return { thumb: 35, trackH: 6, track: "#D7DBE0", selected:
|
|
84
|
+
default: return { thumb: 35, trackH: 6, track: "#D7DBE0", selected: DefaultAccent, thumbColor: DefaultAccent, shadow: new SkiaShadow({ X: 0, Y: 1, Blur: 3, Opacity: 0.25, Color: Colors.Black }) };
|
|
76
85
|
}
|
|
77
86
|
}
|
|
78
87
|
/** Thumb shadows paint outside the box: the cache must include them. */
|
|
@@ -239,5 +248,50 @@ export class SkiaSlider extends SkiaControl {
|
|
|
239
248
|
return super.ProcessGestures(args, apply);
|
|
240
249
|
}
|
|
241
250
|
DefaultAccessibilityCanInteract() { return this.RespondsToGestures; }
|
|
242
|
-
|
|
251
|
+
/** Enter / Space do nothing: the base taps the center, which would jump the value to the middle. */
|
|
252
|
+
OnAccessibilityActivated() { }
|
|
253
|
+
/**
|
|
254
|
+
* Keyboard adjustment while the slider holds keyboard focus (C# SkiaSlider.OnAccessibilityKey): Right / Up increase and
|
|
255
|
+
* Left / Down decrease by Step (a hundredth of the range when Step is 0), PageUp / PageDown move a tenth of the range,
|
|
256
|
+
* Home / End go to Min / Max. A ranged slider moves its End thumb, which stops at Start.
|
|
257
|
+
*/
|
|
258
|
+
OnAccessibilityKey(key) {
|
|
259
|
+
if (!this.RespondsToGestures)
|
|
260
|
+
return false;
|
|
261
|
+
const range = this.Max - this.Min, small = this.Step > 0 ? this.Step : range / 100, large = Math.max(small, range / 10);
|
|
262
|
+
const low = this.EnableRange ? this.Start : this.Min;
|
|
263
|
+
let value;
|
|
264
|
+
switch (key) {
|
|
265
|
+
case "ArrowRight":
|
|
266
|
+
case "ArrowUp":
|
|
267
|
+
value = this.End + small;
|
|
268
|
+
break;
|
|
269
|
+
case "ArrowLeft":
|
|
270
|
+
case "ArrowDown":
|
|
271
|
+
value = this.End - small;
|
|
272
|
+
break;
|
|
273
|
+
case "PageUp":
|
|
274
|
+
value = this.End + large;
|
|
275
|
+
break;
|
|
276
|
+
case "PageDown":
|
|
277
|
+
value = this.End - large;
|
|
278
|
+
break;
|
|
279
|
+
case "Home":
|
|
280
|
+
value = low;
|
|
281
|
+
break;
|
|
282
|
+
case "End":
|
|
283
|
+
value = this.Max;
|
|
284
|
+
break;
|
|
285
|
+
default: return false;
|
|
286
|
+
}
|
|
287
|
+
this.End = Math.min(this.Max, Math.max(low, value));
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* End between Min and Max, read as the number, or "20 – 80" in range mode; the step is the arrow key's. The name is
|
|
292
|
+
* the app's AccessibilityLabel only (C# used to make the value the name, drawnui-cross 6c).
|
|
293
|
+
*/
|
|
294
|
+
get AccessibilityValue() {
|
|
295
|
+
return { Now: this.end, Min: this.Min, Max: this.Max, Step: this.Step > 0 ? this.Step : (this.Max - this.Min) / 100, Text: this.EnableRange ? `${this.start} – ${this.end}` : "" };
|
|
296
|
+
}
|
|
243
297
|
}
|
|
@@ -81,15 +81,19 @@ export declare class SkiaSprite extends AnimatedFramesRenderer {
|
|
|
81
81
|
static LoadSourceAsync(source: string): Promise<Image>;
|
|
82
82
|
SetSpriteSheet(image: Image): void;
|
|
83
83
|
protected RecalculateFrames(): void;
|
|
84
|
+
/** The frame index (position in FrameSequence when one is set) at a time in ms; negative counts back from the end. */
|
|
84
85
|
protected GetFrameNumberFromTime(msTime: number): number;
|
|
85
86
|
protected SetCurrentFrame(frameNumber: number): void;
|
|
86
87
|
/** Transparent borders of a frame, scanned once (C# ScanFrameContentBounds over the bitmap alpha). */
|
|
87
88
|
private GetFrameContentBounds;
|
|
88
89
|
protected OnAnimatorUpdated(value: number): void;
|
|
90
|
+
protected NextChangeMs(value: number): number | undefined;
|
|
89
91
|
protected OnAnimatorSeeking(time: number): void;
|
|
90
92
|
protected OnAnimatorInitializing(): void;
|
|
91
93
|
protected ApplySpeed(): void;
|
|
92
94
|
protected CheckCanStartAnimator(): boolean;
|
|
95
|
+
/** Shows DefaultFrame (a frame index, -1 = last) when not playing. */
|
|
96
|
+
protected ApplyDefaultFrame(): void;
|
|
93
97
|
Start(delayMs?: number): void;
|
|
94
98
|
protected MeasureAbsolute(widthConstraint: number, heightConstraint: number, scale: number): ScaledSize;
|
|
95
99
|
/** C# ResolveFrameMetrics: source rect of the trimmed content and its display rect inside dest. */
|
|
@@ -74,9 +74,6 @@ export class SkiaSprite extends AnimatedFramesRenderer {
|
|
|
74
74
|
set FramesPerSecond(v) { if (this.framesPerSecond !== v) {
|
|
75
75
|
this.framesPerSecond = v;
|
|
76
76
|
this.RecalculateFrames();
|
|
77
|
-
if (this.Animator) {
|
|
78
|
-
this.OnAnimatorInitializing();
|
|
79
|
-
}
|
|
80
77
|
} }
|
|
81
78
|
/** Custom order of frames to play instead of 0..TotalFrames-1. */
|
|
82
79
|
get FrameSequence() { return this.frameSequence; }
|
|
@@ -124,7 +121,11 @@ export class SkiaSprite extends AnimatedFramesRenderer {
|
|
|
124
121
|
const cached = SkiaSprite.CachedSpriteSheets.get(source);
|
|
125
122
|
if (cached)
|
|
126
123
|
return cached;
|
|
127
|
-
const image = await SkiaImageManager.Instance.
|
|
124
|
+
const image = await SkiaImageManager.Instance.LoadImageManagedAsync(source);
|
|
125
|
+
if (!image)
|
|
126
|
+
throw new Error(`DrawnUi: cannot load sprite sheet '${source}'`);
|
|
127
|
+
// the sheets cache holds it for good (the image manager never deletes an image somebody holds)
|
|
128
|
+
SkiaImageManager.Instance.Hold(image);
|
|
128
129
|
SkiaSprite.CachedSpriteSheets.set(source, image);
|
|
129
130
|
return image;
|
|
130
131
|
}
|
|
@@ -160,22 +161,30 @@ export class SkiaSprite extends AnimatedFramesRenderer {
|
|
|
160
161
|
this.DurationMs = this.TotalFrames * this.FrameDurationMs;
|
|
161
162
|
this.lastColumns = this.columns;
|
|
162
163
|
this.lastRows = this.rows;
|
|
164
|
+
if (this.Animator) {
|
|
165
|
+
// FramesPerSecond, FrameSequence, MaxFrames or the grid changed after loading: the animator range and the shown
|
|
166
|
+
// frame follow the new frames
|
|
167
|
+
this.ApplySpeed();
|
|
168
|
+
this.Animator.mMaxValue = this.DurationMs;
|
|
169
|
+
this.SetCurrentFrame(this.currentFrame);
|
|
170
|
+
}
|
|
163
171
|
}
|
|
172
|
+
/** The frame index (position in FrameSequence when one is set) at a time in ms; negative counts back from the end. */
|
|
164
173
|
GetFrameNumberFromTime(msTime) {
|
|
165
174
|
if (this.DurationMs <= 0)
|
|
166
175
|
return 0;
|
|
167
|
-
if (msTime < 0)
|
|
168
|
-
msTime = this.DurationMs + msTime;
|
|
169
176
|
msTime %= this.DurationMs;
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
177
|
+
if (msTime < 0)
|
|
178
|
+
msTime += this.DurationMs;
|
|
179
|
+
// the epsilon keeps the exact start time of a frame on that frame: k * d / d can come out a hair below k
|
|
180
|
+
const frame = Math.floor(msTime / this.FrameDurationMs + 1e-9);
|
|
173
181
|
return Math.min(frame, this.TotalFrames - 1);
|
|
174
182
|
}
|
|
175
183
|
SetCurrentFrame(frameNumber) {
|
|
176
184
|
if (!this.SpriteSheet || this.TotalFrames === 0)
|
|
177
185
|
return;
|
|
178
|
-
frameNumber
|
|
186
|
+
if (frameNumber < 0 || frameNumber >= this.TotalFrames)
|
|
187
|
+
frameNumber = this.TotalFrames - 1; // negative = the last frame
|
|
179
188
|
const actual = this.frameSequence && this.frameSequence.length > 0 ? this.frameSequence[Math.min(frameNumber, this.frameSequence.length - 1)] : frameNumber;
|
|
180
189
|
this.currentFrame = frameNumber;
|
|
181
190
|
const framesX = Math.max(1, this.columns);
|
|
@@ -227,6 +236,10 @@ export class SkiaSprite extends AnimatedFramesRenderer {
|
|
|
227
236
|
}
|
|
228
237
|
// ---- animator ----
|
|
229
238
|
OnAnimatorUpdated(value) { this.Seek(value); }
|
|
239
|
+
NextChangeMs(value) {
|
|
240
|
+
const fd = this.FrameDurationMs;
|
|
241
|
+
return fd > 0 ? (Math.floor(value / fd) + 1) * fd : undefined;
|
|
242
|
+
}
|
|
230
243
|
OnAnimatorSeeking(time) {
|
|
231
244
|
if (!this.SpriteSheet)
|
|
232
245
|
return;
|
|
@@ -245,9 +258,12 @@ export class SkiaSprite extends AnimatedFramesRenderer {
|
|
|
245
258
|
ApplySpeed() {
|
|
246
259
|
if (!this.SpriteSheet || !this.Animator)
|
|
247
260
|
return;
|
|
248
|
-
this.Animator.Speed = this.
|
|
261
|
+
this.Animator.Speed = this.GetPlaybackDurationMs(this.DurationMs);
|
|
249
262
|
}
|
|
250
263
|
CheckCanStartAnimator() { return !!this.SpriteSheet && this.TotalFrames > 0; }
|
|
264
|
+
/** Shows DefaultFrame (a frame index, -1 = last) when not playing. */
|
|
265
|
+
ApplyDefaultFrame() { if (!this.IsPlaying)
|
|
266
|
+
this.SetCurrentFrame(this.DefaultFrame); }
|
|
251
267
|
Start(delayMs = 0) { if (this.SpriteSheet && this.TotalFrames > 0)
|
|
252
268
|
super.Start(delayMs); }
|
|
253
269
|
// ---- measure / draw (C# SpriteFrameImage: AspectFit of the FRAME into the box, then the placement config) ----
|
|
@@ -33,6 +33,10 @@ export declare class SkiaSvg extends SkiaControl {
|
|
|
33
33
|
private Clear;
|
|
34
34
|
protected OnDisposing(): void;
|
|
35
35
|
private DropRaster;
|
|
36
|
+
private tileShader?;
|
|
37
|
+
private tileShaderAt;
|
|
38
|
+
/** Repeat shader of the raster placed at `display`, kept until the raster or its placement changes (C# picture shader). */
|
|
39
|
+
private TileShader;
|
|
36
40
|
private Decode;
|
|
37
41
|
/** Natural size: the decoded image's, else the viewBox (SVGs without width/height decode as 0x0 or 300x150). */
|
|
38
42
|
private static IntrinsicSize;
|
package/dist/controls/SkiaSvg.js
CHANGED
|
@@ -42,7 +42,7 @@ export class SkiaSvg extends SkiaControl {
|
|
|
42
42
|
}
|
|
43
43
|
const generation = ++this.loadGeneration;
|
|
44
44
|
this.IsLoading = true;
|
|
45
|
-
fetch(value)
|
|
45
|
+
fetch(Super.ResolveAssetUrl(value))
|
|
46
46
|
.then((r) => { if (!r.ok)
|
|
47
47
|
throw new Error(`DrawnUi: ${r.status} loading svg '${value}'`); return r.text(); })
|
|
48
48
|
.then((text) => { if (generation === this.loadGeneration)
|
|
@@ -74,10 +74,26 @@ export class SkiaSvg extends SkiaControl {
|
|
|
74
74
|
}
|
|
75
75
|
OnDisposing() { this.loadGeneration++; this.DropRaster(); }
|
|
76
76
|
DropRaster() {
|
|
77
|
+
this.tileShader?.delete();
|
|
78
|
+
this.tileShader = undefined;
|
|
77
79
|
this.raster?.delete();
|
|
78
80
|
this.raster = undefined;
|
|
79
81
|
this.rasterKey = "";
|
|
80
82
|
}
|
|
83
|
+
tileShader;
|
|
84
|
+
tileShaderAt = "";
|
|
85
|
+
/** Repeat shader of the raster placed at `display`, kept until the raster or its placement changes (C# picture shader). */
|
|
86
|
+
TileShader(raster, display) {
|
|
87
|
+
const at = `${display.Left},${display.Top},${display.Width},${display.Height}`;
|
|
88
|
+
if (this.tileShader && this.tileShaderAt === at)
|
|
89
|
+
return this.tileShader;
|
|
90
|
+
this.tileShader?.delete();
|
|
91
|
+
const CK = Super.CK, M = CK.Matrix;
|
|
92
|
+
const local = M.multiply(M.translated(display.Left, display.Top), M.scaled(display.Width / raster.width(), display.Height / raster.height()));
|
|
93
|
+
this.tileShader = raster.makeShaderOptions(CK.TileMode.Repeat, CK.TileMode.Repeat, CK.FilterMode.Linear, CK.MipmapMode.None, local);
|
|
94
|
+
this.tileShaderAt = at;
|
|
95
|
+
return this.tileShader;
|
|
96
|
+
}
|
|
81
97
|
async Decode(svg, sourceName, generation) {
|
|
82
98
|
this.IsLoading = true;
|
|
83
99
|
// browsers refuse to rasterize an <img> SVG whose root has no xmlns (SkiaSharp's parser does not care)
|
|
@@ -154,7 +170,9 @@ export class SkiaSvg extends SkiaControl {
|
|
|
154
170
|
if (!this.element || Width <= 0 || Height <= 0)
|
|
155
171
|
return;
|
|
156
172
|
const dest = ctx.Destination;
|
|
157
|
-
|
|
173
|
+
// Tile: the picture at its natural size (one SVG unit per point), repeated from the aligned copy (C# de5ba4bb)
|
|
174
|
+
const tile = this.Aspect === "Tile";
|
|
175
|
+
const scaled = tile ? { X: ctx.Scale, Y: ctx.Scale } : SkiaImage.RescaleAspect(Width, Height, dest, this.Aspect);
|
|
158
176
|
const display = SkiaImage.CalculateDisplayRect(dest, Width * scaled.X, Height * scaled.Y, this.HorizontalAlignment, this.VerticalAlignment);
|
|
159
177
|
this.DisplayRect = display;
|
|
160
178
|
const raster = this.GetRaster(Math.round(display.Width), Math.round(display.Height));
|
|
@@ -164,7 +182,7 @@ export class SkiaSvg extends SkiaControl {
|
|
|
164
182
|
const canvas = ctx.Context.Canvas;
|
|
165
183
|
const overflows = display.Left < dest.Left || display.Top < dest.Top || display.Right > dest.Right || display.Bottom > dest.Bottom;
|
|
166
184
|
const saved = canvas.save();
|
|
167
|
-
if (overflows)
|
|
185
|
+
if (overflows || tile)
|
|
168
186
|
canvas.clipRect(CK.LTRBRect(dest.Left, dest.Top, dest.Right, dest.Bottom), CK.ClipOp.Intersect, true);
|
|
169
187
|
const paint = new CK.Paint();
|
|
170
188
|
paint.setAntiAlias(true);
|
|
@@ -174,7 +192,13 @@ export class SkiaSvg extends SkiaControl {
|
|
|
174
192
|
paint.setColorFilter(filter);
|
|
175
193
|
filter.delete();
|
|
176
194
|
}
|
|
177
|
-
|
|
195
|
+
if (tile) {
|
|
196
|
+
paint.setShader(this.TileShader(raster, display));
|
|
197
|
+
canvas.drawRect(CK.LTRBRect(dest.Left, dest.Top, dest.Right, dest.Bottom), paint);
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
canvas.drawImageRectOptions(raster, CK.LTRBRect(0, 0, raster.width(), raster.height()), CK.LTRBRect(display.Left, display.Top, display.Right, display.Bottom), CK.FilterMode.Linear, CK.MipmapMode.None, paint);
|
|
201
|
+
}
|
|
178
202
|
paint.delete();
|
|
179
203
|
canvas.restoreToCount(saved);
|
|
180
204
|
}
|
|
@@ -14,7 +14,6 @@ export declare class SkiaSwitch extends SkiaToggle {
|
|
|
14
14
|
private static readonly DefaultTrack;
|
|
15
15
|
private static readonly MaterialOutline;
|
|
16
16
|
protected StyleDefault(name: "ColorThumbOn" | "ColorFrameOn" | "ColorThumbOff" | "ColorFrameOff"): Color | undefined;
|
|
17
|
-
private SetContentSize;
|
|
18
17
|
protected CreateDefaultContent(): void;
|
|
19
18
|
/** C# GetThumbPosForOn: track width minus thumb width and margins, in points. */
|
|
20
19
|
private ThumbPosForOn;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DefaultAccent } from "../core/ControlStyle";
|
|
1
2
|
import { Colors, SkiaShadow, Thickness } from "../core/Types";
|
|
2
3
|
import { Easing } from "../core/Easing";
|
|
3
4
|
import { SkiaShape } from "./SkiaShape";
|
|
@@ -11,7 +12,7 @@ export class SkiaSwitch extends SkiaToggle {
|
|
|
11
12
|
static DefaultAccessibilityRole = "switch";
|
|
12
13
|
Track;
|
|
13
14
|
Thumb;
|
|
14
|
-
static DefaultAccent =
|
|
15
|
+
static DefaultAccent = DefaultAccent;
|
|
15
16
|
static DefaultTrack = "#D7DBE0";
|
|
16
17
|
static MaterialOutline = "#79747E";
|
|
17
18
|
StyleDefault(name) {
|
|
@@ -25,12 +26,6 @@ export class SkiaSwitch extends SkiaToggle {
|
|
|
25
26
|
};
|
|
26
27
|
return table[s]?.[name];
|
|
27
28
|
}
|
|
28
|
-
SetContentSize(w, h) {
|
|
29
|
-
if (this.WidthRequest < 0)
|
|
30
|
-
this.WidthRequest = w;
|
|
31
|
-
if (this.HeightRequest < 0)
|
|
32
|
-
this.HeightRequest = h;
|
|
33
|
-
}
|
|
34
29
|
CreateDefaultContent() {
|
|
35
30
|
const frame = new SkiaShape();
|
|
36
31
|
frame.Tag = "Frame";
|
|
@@ -77,8 +72,9 @@ export class SkiaSwitch extends SkiaToggle {
|
|
|
77
72
|
frame.StrokeColor = "#767676";
|
|
78
73
|
thumb.Margin = new Thickness(5.5);
|
|
79
74
|
break;
|
|
75
|
+
// the Agent Signals switch size (C# 5c1288f7, drawnui-cross 6as): 46 x 22, the thumb inside its 2 pt margin
|
|
80
76
|
default:
|
|
81
|
-
this.SetContentSize(46,
|
|
77
|
+
this.SetContentSize(46, 22);
|
|
82
78
|
frame.CornerRadius = 20;
|
|
83
79
|
thumb.Margin = new Thickness(2);
|
|
84
80
|
break;
|
|
@@ -5,16 +5,25 @@ import { type Color, type ScaledSize } from "../core/Types";
|
|
|
5
5
|
import { SkiaLayout } from "./SkiaLayout";
|
|
6
6
|
/**
|
|
7
7
|
* Mirrors DrawnUi SkiaToggle: base of SkiaSwitch / SkiaCheckbox / SkiaRadioButton. Tapped flips IsToggled,
|
|
8
|
-
* `Toggled` reports user changes, `ControlStyle` selects the look the default content is built with (
|
|
9
|
-
* measure, like C# CreateDefaultContent
|
|
8
|
+
* `Toggled` reports user changes, `ControlStyle` selects the look the default content is built with (at first
|
|
9
|
+
* measure, like C# CreateDefaultContent; a later change rebuilds it, C# RebuildDefaultContent). Colors left unset
|
|
10
|
+
* take the style defaults (C# SetStyleDefault).
|
|
10
11
|
*/
|
|
11
12
|
export declare abstract class SkiaToggle extends SkiaLayout {
|
|
12
|
-
|
|
13
|
+
/** Takes mouse hover unless ReceivesHover is set false (C# ReceivesHoverByDefault): switch, checkbox, radio button. */
|
|
14
|
+
protected ReceivesHoverByDefault(): boolean;
|
|
15
|
+
private controlStyle;
|
|
16
|
+
get ControlStyle(): PrebuiltControlStyle;
|
|
17
|
+
set ControlStyle(v: PrebuiltControlStyle);
|
|
13
18
|
/** Fires on every IsToggled change; C# fires only on user/external changes, not on DefaultValue application. */
|
|
14
19
|
Toggled?: (sender: SkiaToggle, value: boolean) => void;
|
|
15
20
|
DefaultValue: boolean;
|
|
16
21
|
IsAnimated: boolean;
|
|
17
|
-
|
|
22
|
+
private respondsToGestures;
|
|
23
|
+
/** False: a tap or the keyboard does not toggle it (code still can), a tap on it stops there, and it is reported disabled (drawnui-cross 6w). */
|
|
24
|
+
get RespondsToGestures(): boolean;
|
|
25
|
+
set RespondsToGestures(v: boolean);
|
|
26
|
+
protected AcceptsInput(): boolean;
|
|
18
27
|
private isToggled;
|
|
19
28
|
private colorThumbOn?;
|
|
20
29
|
private colorFrameOn?;
|
|
@@ -37,10 +46,21 @@ export declare abstract class SkiaToggle extends SkiaLayout {
|
|
|
37
46
|
/** Per-style color defaults (C# SetStyleDefault); undefined = the SkiaToggle default. */
|
|
38
47
|
protected StyleDefault(_name: "ColorThumbOn" | "ColorFrameOn" | "ColorThumbOff" | "ColorFrameOff"): Color | undefined;
|
|
39
48
|
protected OnToggledChanged(): void;
|
|
40
|
-
/** Builds the look
|
|
49
|
+
/** Builds the look (C# CreateDefaultContent) — subclasses add their views here; called again after a rebuild. */
|
|
41
50
|
protected abstract CreateDefaultContent(): void;
|
|
42
51
|
/** Pushes IsToggled + colors into the views (C# ApplyProperties). */
|
|
43
52
|
abstract ApplyProperties(): void;
|
|
53
|
+
/** Size requests the style pinned (C# SetDefaultContentSize / SetDefaultMinimumContentSize); a rebuild releases only these. */
|
|
54
|
+
private stylePinned;
|
|
55
|
+
/** C# SetDefaultContentSize: the style's size, only where the app left the request unset. */
|
|
56
|
+
protected SetContentSize(w: number, h: number): void;
|
|
57
|
+
/** C# SetDefaultMinimumContentSize (height only): the style's minimum, only where the app left it unset. */
|
|
58
|
+
protected SetMinimumContentHeight(h: number): void;
|
|
59
|
+
/**
|
|
60
|
+
* C# RebuildDefaultContent: drops the content built for the previous style and the sizes it pinned (the app's own
|
|
61
|
+
* requests stay), so the next Measure builds the current style. No-op before the first build.
|
|
62
|
+
*/
|
|
63
|
+
RebuildDefaultContent(): void;
|
|
44
64
|
/** Content (and the size requests the style sets) must exist before Measure reads WidthRequest/HeightRequest. */
|
|
45
65
|
Measure(widthConstraint: number, heightConstraint: number, scale: number): ScaledSize;
|
|
46
66
|
protected DefaultAccessibilityCanInteract(): boolean;
|
|
@@ -3,16 +3,33 @@ import { Colors } from "../core/Types";
|
|
|
3
3
|
import { SkiaLayout } from "./SkiaLayout";
|
|
4
4
|
/**
|
|
5
5
|
* Mirrors DrawnUi SkiaToggle: base of SkiaSwitch / SkiaCheckbox / SkiaRadioButton. Tapped flips IsToggled,
|
|
6
|
-
* `Toggled` reports user changes, `ControlStyle` selects the look the default content is built with (
|
|
7
|
-
* measure, like C# CreateDefaultContent
|
|
6
|
+
* `Toggled` reports user changes, `ControlStyle` selects the look the default content is built with (at first
|
|
7
|
+
* measure, like C# CreateDefaultContent; a later change rebuilds it, C# RebuildDefaultContent). Colors left unset
|
|
8
|
+
* take the style defaults (C# SetStyleDefault).
|
|
8
9
|
*/
|
|
9
10
|
export class SkiaToggle extends SkiaLayout {
|
|
10
|
-
|
|
11
|
+
/** Takes mouse hover unless ReceivesHover is set false (C# ReceivesHoverByDefault): switch, checkbox, radio button. */
|
|
12
|
+
ReceivesHoverByDefault() { return true; }
|
|
13
|
+
controlStyle = "Unset";
|
|
14
|
+
get ControlStyle() { return this.controlStyle; }
|
|
15
|
+
set ControlStyle(v) {
|
|
16
|
+
if (this.controlStyle === v)
|
|
17
|
+
return;
|
|
18
|
+
this.controlStyle = v;
|
|
19
|
+
this.RebuildDefaultContent();
|
|
20
|
+
}
|
|
11
21
|
/** Fires on every IsToggled change; C# fires only on user/external changes, not on DefaultValue application. */
|
|
12
22
|
Toggled;
|
|
13
23
|
DefaultValue = false;
|
|
14
24
|
IsAnimated = true;
|
|
15
|
-
|
|
25
|
+
respondsToGestures = true;
|
|
26
|
+
/** False: a tap or the keyboard does not toggle it (code still can), a tap on it stops there, and it is reported disabled (drawnui-cross 6w). */
|
|
27
|
+
get RespondsToGestures() { return this.respondsToGestures; }
|
|
28
|
+
set RespondsToGestures(v) { if (this.respondsToGestures !== v) {
|
|
29
|
+
this.respondsToGestures = v;
|
|
30
|
+
this.NotifyAccessibility();
|
|
31
|
+
} }
|
|
32
|
+
AcceptsInput() { return this.respondsToGestures; }
|
|
16
33
|
isToggled = false;
|
|
17
34
|
colorThumbOn;
|
|
18
35
|
colorFrameOn;
|
|
@@ -48,6 +65,40 @@ export class SkiaToggle extends SkiaLayout {
|
|
|
48
65
|
this.Toggled?.(this, this.isToggled);
|
|
49
66
|
this.NotifyAccessibility();
|
|
50
67
|
}
|
|
68
|
+
/** Size requests the style pinned (C# SetDefaultContentSize / SetDefaultMinimumContentSize); a rebuild releases only these. */
|
|
69
|
+
stylePinned = [];
|
|
70
|
+
/** C# SetDefaultContentSize: the style's size, only where the app left the request unset. */
|
|
71
|
+
SetContentSize(w, h) {
|
|
72
|
+
if (this.WidthRequest < 0) {
|
|
73
|
+
this.WidthRequest = w;
|
|
74
|
+
this.stylePinned.push("WidthRequest");
|
|
75
|
+
}
|
|
76
|
+
if (this.HeightRequest < 0) {
|
|
77
|
+
this.HeightRequest = h;
|
|
78
|
+
this.stylePinned.push("HeightRequest");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/** C# SetDefaultMinimumContentSize (height only): the style's minimum, only where the app left it unset. */
|
|
82
|
+
SetMinimumContentHeight(h) {
|
|
83
|
+
if (this.MinimumHeightRequest < 0) {
|
|
84
|
+
this.MinimumHeightRequest = h;
|
|
85
|
+
this.stylePinned.push("MinimumHeightRequest");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* C# RebuildDefaultContent: drops the content built for the previous style and the sizes it pinned (the app's own
|
|
90
|
+
* requests stay), so the next Measure builds the current style. No-op before the first build.
|
|
91
|
+
*/
|
|
92
|
+
RebuildDefaultContent() {
|
|
93
|
+
if (!this.contentCreated)
|
|
94
|
+
return;
|
|
95
|
+
this.ClearChildren();
|
|
96
|
+
for (const p of this.stylePinned)
|
|
97
|
+
this[p] = -1;
|
|
98
|
+
this.stylePinned = [];
|
|
99
|
+
this.contentCreated = false;
|
|
100
|
+
this.Update();
|
|
101
|
+
}
|
|
51
102
|
/** Content (and the size requests the style sets) must exist before Measure reads WidthRequest/HeightRequest. */
|
|
52
103
|
Measure(widthConstraint, heightConstraint, scale) {
|
|
53
104
|
if (!this.contentCreated) {
|
|
@@ -62,7 +113,9 @@ export class SkiaToggle extends SkiaLayout {
|
|
|
62
113
|
get AccessibilityIsPressed() { return this.isToggled; }
|
|
63
114
|
set AccessibilityIsPressed(_v) { }
|
|
64
115
|
ProcessGestures(args, apply) {
|
|
65
|
-
if (
|
|
116
|
+
if (!this.respondsToGestures)
|
|
117
|
+
return this.BlockedGestureResult(args); // a tap does not toggle it, nor reach controls under it
|
|
118
|
+
if (args.Type === "Tapped") {
|
|
66
119
|
this.IsToggled = !this.IsToggled;
|
|
67
120
|
return this;
|
|
68
121
|
}
|
|
@@ -11,7 +11,11 @@ import { SkiaLayout } from "./SkiaLayout";
|
|
|
11
11
|
*/
|
|
12
12
|
export declare abstract class SnappingLayout extends SkiaLayout {
|
|
13
13
|
Animated: boolean;
|
|
14
|
-
|
|
14
|
+
private respondsToGestures;
|
|
15
|
+
/** False: neither a swipe nor the keyboard moves it (code still can), and it is reported disabled; its content keeps its own taps (drawnui-cross 6w). */
|
|
16
|
+
get RespondsToGestures(): boolean;
|
|
17
|
+
set RespondsToGestures(v: boolean);
|
|
18
|
+
protected AcceptsInput(): boolean;
|
|
15
19
|
IgnoreWrongDirection: boolean;
|
|
16
20
|
Bounces: boolean;
|
|
17
21
|
RubberDamping: number;
|
|
@@ -50,6 +54,8 @@ export declare abstract class SnappingLayout extends SkiaLayout {
|
|
|
50
54
|
protected StopSnapAnimators(): void;
|
|
51
55
|
/** C# SnappingLayout.Render: the transition state follows the position every frame. */
|
|
52
56
|
Render(ctx: DrawingContext): void;
|
|
57
|
+
/** Hover waits while the content slides (C# InTransition) or follows a pan. */
|
|
58
|
+
MovesContent(): boolean;
|
|
53
59
|
ClampOffset(x: number, y: number, rubber: boolean): SKPoint;
|
|
54
60
|
/** C# GetContentOffsetBounds: the extent covered by the snap points. */
|
|
55
61
|
protected BoundsFromSnapPoints(): SKRect;
|
|
@@ -59,6 +65,11 @@ export declare abstract class SnappingLayout extends SkiaLayout {
|
|
|
59
65
|
protected FindNearestAnchorInternal(current: SKPoint, _velocity: SKPoint): SKPoint;
|
|
60
66
|
/** The closest anchor lying in the direction of the velocity (dot product), else the origin. */
|
|
61
67
|
SelectNextAnchor(origin: SKPoint, velocity: SKPoint): SKPoint;
|
|
68
|
+
/**
|
|
69
|
+
* Release speed, points per second along an axis, under which the snap ignores the velocity and goes to the nearest
|
|
70
|
+
* anchor by distance (C# SnapVelocityThreshold, drawnui-cross 6o): a finger held still before lifting is not a flick.
|
|
71
|
+
*/
|
|
72
|
+
SnapVelocityThreshold: number;
|
|
62
73
|
ScrollToNearestAnchor(location: SKPoint, velocity: SKPoint): void;
|
|
63
74
|
get CanAnimate(): boolean;
|
|
64
75
|
protected GetAutoVelocity(displacement: SKPoint): SKPoint;
|
|
@@ -11,7 +11,14 @@ import { SkiaLayout } from "./SkiaLayout";
|
|
|
11
11
|
*/
|
|
12
12
|
export class SnappingLayout extends SkiaLayout {
|
|
13
13
|
Animated = true;
|
|
14
|
-
|
|
14
|
+
respondsToGestures = true;
|
|
15
|
+
/** False: neither a swipe nor the keyboard moves it (code still can), and it is reported disabled; its content keeps its own taps (drawnui-cross 6w). */
|
|
16
|
+
get RespondsToGestures() { return this.respondsToGestures; }
|
|
17
|
+
set RespondsToGestures(v) { if (this.respondsToGestures !== v) {
|
|
18
|
+
this.respondsToGestures = v;
|
|
19
|
+
this.NotifyAccessibility();
|
|
20
|
+
} }
|
|
21
|
+
AcceptsInput() { return this.respondsToGestures; }
|
|
15
22
|
IgnoreWrongDirection = false;
|
|
16
23
|
Bounces = false;
|
|
17
24
|
RubberDamping = 0.7;
|
|
@@ -63,7 +70,8 @@ export class SnappingLayout extends SkiaLayout {
|
|
|
63
70
|
return; // interrupted / restarted: not a finished transition
|
|
64
71
|
this.InTransition = !this.CheckTransitionEnded();
|
|
65
72
|
this.UpdateReportedPosition(); // subclasses gate reporting on InTransition: report the settled state now
|
|
66
|
-
|
|
73
|
+
if (!this.InTransition)
|
|
74
|
+
this.Stopped?.(this, this.CurrentPosition); // at real rest only (a queued next move keeps it in transition)
|
|
67
75
|
}
|
|
68
76
|
OnDisposing() { this.StopSnapAnimators(); }
|
|
69
77
|
get IsSnapAnimating() { return this.springX.IsRunning || this.springY.IsRunning || this.range.IsRunning; }
|
|
@@ -80,9 +88,12 @@ export class SnappingLayout extends SkiaLayout {
|
|
|
80
88
|
}
|
|
81
89
|
/** C# SnappingLayout.Render: the transition state follows the position every frame. */
|
|
82
90
|
Render(ctx) {
|
|
91
|
+
this.Superview?.Hover?.RegisterMover(this);
|
|
83
92
|
super.Render(ctx);
|
|
84
93
|
this.InTransition = !this.CheckTransitionEnded();
|
|
85
94
|
}
|
|
95
|
+
/** Hover waits while the content slides (C# InTransition) or follows a pan. */
|
|
96
|
+
MovesContent() { return this.InTransition || this.IsUserPanning; }
|
|
86
97
|
// ---- clamping ----
|
|
87
98
|
ClampOffset(x, y, rubber) {
|
|
88
99
|
const b = this.ContentOffsetBounds;
|
|
@@ -135,9 +146,17 @@ export class SnappingLayout extends SkiaLayout {
|
|
|
135
146
|
}
|
|
136
147
|
return origin;
|
|
137
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Release speed, points per second along an axis, under which the snap ignores the velocity and goes to the nearest
|
|
151
|
+
* anchor by distance (C# SnapVelocityThreshold, drawnui-cross 6o): a finger held still before lifting is not a flick.
|
|
152
|
+
*/
|
|
153
|
+
SnapVelocityThreshold = 100;
|
|
138
154
|
ScrollToNearestAnchor(location, velocity) {
|
|
139
155
|
if (this.SnapPoints.length === 0)
|
|
140
156
|
return;
|
|
157
|
+
if (Math.abs(velocity.X) < this.SnapVelocityThreshold || Math.abs(velocity.Y) < this.SnapVelocityThreshold) {
|
|
158
|
+
velocity = new SKPoint(Math.abs(velocity.X) < this.SnapVelocityThreshold ? 0 : velocity.X, Math.abs(velocity.Y) < this.SnapVelocityThreshold ? 0 : velocity.Y);
|
|
159
|
+
}
|
|
141
160
|
const origin = this.FindNearestAnchorInternal(location, velocity);
|
|
142
161
|
const target = this.SelectNextAnchor(origin, velocity);
|
|
143
162
|
if (SnappingLayout.Dist(location, target) >= 0.5)
|