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
|
@@ -88,7 +88,7 @@ export class SkiaGridStructure {
|
|
|
88
88
|
spans = new Map();
|
|
89
89
|
explicitWidth;
|
|
90
90
|
explicitHeight;
|
|
91
|
-
constructor(grid, widthConstraint, heightConstraint, scale) {
|
|
91
|
+
constructor(grid, widthConstraint, heightConstraint, scale, children = grid.Views) {
|
|
92
92
|
this.grid = grid;
|
|
93
93
|
this.widthConstraint = widthConstraint;
|
|
94
94
|
this.heightConstraint = heightConstraint;
|
|
@@ -99,7 +99,7 @@ export class SkiaGridStructure {
|
|
|
99
99
|
this.explicitHeight = grid.HeightRequest;
|
|
100
100
|
this.Rows = this.InitializeTracks(grid.RowDefinitions, grid.DefaultRowDefinition);
|
|
101
101
|
this.Columns = this.InitializeTracks(grid.ColumnDefinitions, grid.DefaultColumnDefinition);
|
|
102
|
-
this.children =
|
|
102
|
+
this.children = children.filter((v) => v.IsVisible);
|
|
103
103
|
this.InitializeCells();
|
|
104
104
|
this.MeasureCells();
|
|
105
105
|
}
|
|
@@ -294,7 +294,20 @@ export class SkiaGridStructure {
|
|
|
294
294
|
ResolveStarRows(heightConstraint) {
|
|
295
295
|
this.ResolveStars(this.Rows, heightConstraint - this.GridHeight(), (c) => c.IsRowSpanStar, (v) => v.MeasuredSize.Units.Height);
|
|
296
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* C# SizesAutoRow: the child decides the height of its single Auto row, so it is measured with the height that row
|
|
299
|
+
* could still grow to, not with the row's current size (drawnui-cross 6p).
|
|
300
|
+
*/
|
|
301
|
+
SizesAutoRow(cell) { return cell.RowSpan === 1 && this.Rows[cell.Row].IsAuto; }
|
|
302
|
+
static NeedFillY(child) { return child.VerticalOptions === "Fill" && child.HeightRequest < 0; }
|
|
303
|
+
/**
|
|
304
|
+
* C# HeightOnAutoRow: the height the single Auto row could still grow to, unbounded for a vertical Fill child (which
|
|
305
|
+
* would take the whole constraint). The row's size so far came from a first pass at the grid's whole width, so a
|
|
306
|
+
* label wrapping in a star column was measured against its one-line height.
|
|
307
|
+
*/
|
|
308
|
+
HeightOnAutoRow(cell, child) { return SkiaGridStructure.NeedFillY(child) ? Infinity : this.AvailableHeight(cell); }
|
|
297
309
|
MeasureKnownCells() {
|
|
310
|
+
let autoRowGrew = false;
|
|
298
311
|
for (const cell of this.cells) {
|
|
299
312
|
if (!cell.NeedsKnownMeasurePass)
|
|
300
313
|
continue;
|
|
@@ -307,12 +320,30 @@ export class SkiaGridStructure {
|
|
|
307
320
|
continue;
|
|
308
321
|
const child = this.children[cell.ViewIndex];
|
|
309
322
|
const rect = this.GetCellBoundsFor(child);
|
|
310
|
-
|
|
323
|
+
if (child.IsVisible && this.SizesAutoRow(cell)) {
|
|
324
|
+
// the row grows to the child at its real width, within the room the grid has left
|
|
325
|
+
let grown = this.MeasurePx(child, rect.Width, this.HeightOnAutoRow(cell, child)).Height;
|
|
326
|
+
const available = this.AvailableHeight(cell);
|
|
327
|
+
if (isFinite(available) && grown > available)
|
|
328
|
+
grown = available;
|
|
329
|
+
if (grown > this.Rows[cell.Row].Size) {
|
|
330
|
+
this.Rows[cell.Row].Update(grown);
|
|
331
|
+
autoRowGrew = true;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
else
|
|
335
|
+
this.MeasurePx(child, rect.Width, rect.Height);
|
|
311
336
|
if (cell.IsColumnSpanStar && cell.ColumnSpan > 1)
|
|
312
337
|
this.TrackSpan({ Key: `c${cell.Column}:${cell.ColumnSpan}`, Start: cell.Column, Length: cell.ColumnSpan, IsColumn: true, Requested: rect.Width });
|
|
313
338
|
if (cell.IsRowSpanStar && cell.RowSpan > 1)
|
|
314
339
|
this.TrackSpan({ Key: `r${cell.Row}:${cell.RowSpan}`, Start: cell.Row, Length: cell.RowSpan, IsColumn: false, Requested: rect.Height });
|
|
315
340
|
}
|
|
341
|
+
if (autoRowGrew) {
|
|
342
|
+
// star rows were resolved against the smaller Auto rows: they get what is left now, nothing when Auto took it all
|
|
343
|
+
SkiaGridStructure.ZeroOutStars(this.Rows);
|
|
344
|
+
if (this.heightConstraint - this.GridHeight() > 0)
|
|
345
|
+
this.ResolveStarRows(this.heightConstraint);
|
|
346
|
+
}
|
|
316
347
|
}
|
|
317
348
|
AvailableWidth(cell) {
|
|
318
349
|
let w = 0, absolute = true;
|
|
@@ -386,18 +417,63 @@ export class SkiaGridStructure {
|
|
|
386
417
|
static ZeroOutStars(defs) { for (const d of defs)
|
|
387
418
|
if (d.IsStar)
|
|
388
419
|
d.Size = 0; }
|
|
389
|
-
/**
|
|
420
|
+
/**
|
|
421
|
+
* Final measure pass (C# RemeasureChildrenAtFinalCells, 5acd8ae4), run once every track has its final size. Auto rows
|
|
422
|
+
* first, measured at their final width with the star rows yielding: an Auto column that got the grid's width only now
|
|
423
|
+
* (wrapped text, a wrap of buttons on several lines) can make its rows taller than the first pass did, and the star rows
|
|
424
|
+
* were already given the rest of the height. When an Auto row grew the star rows get what is left now, nothing when the
|
|
425
|
+
* Auto rows took it all. Then every visible child is measured at the cell it will be arranged in.
|
|
426
|
+
*/
|
|
390
427
|
RemeasureChildrenAtFinalCells() {
|
|
428
|
+
if (this.Rows.some((r) => r.IsStar) && isFinite(this.heightConstraint)) {
|
|
429
|
+
const starSizes = this.Rows.map((r) => r.Size);
|
|
430
|
+
SkiaGridStructure.ZeroOutStars(this.Rows);
|
|
431
|
+
if (this.MeasureAtFinalCells(true)) {
|
|
432
|
+
if (this.heightConstraint - this.GridHeight() > 0)
|
|
433
|
+
this.ResolveStarRows(this.heightConstraint);
|
|
434
|
+
}
|
|
435
|
+
else {
|
|
436
|
+
for (let n = 0; n < this.Rows.length; n++)
|
|
437
|
+
if (this.Rows[n].IsStar)
|
|
438
|
+
this.Rows[n].Size = starSizes[n];
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
this.MeasureAtFinalCells(false);
|
|
442
|
+
}
|
|
443
|
+
/** Measures the visible children at their cells (only those on single Auto rows when autoRowsOnly); true when an Auto row grew. */
|
|
444
|
+
MeasureAtFinalCells(autoRowsOnly) {
|
|
445
|
+
let autoRowGrew = false;
|
|
391
446
|
for (const cell of this.cells) {
|
|
392
447
|
const child = this.children[cell.ViewIndex];
|
|
448
|
+
if (!child.IsVisible)
|
|
449
|
+
continue;
|
|
450
|
+
if (autoRowsOnly && !this.SizesAutoRow(cell))
|
|
451
|
+
continue;
|
|
393
452
|
const rect = this.GetCellBoundsFor(child);
|
|
394
453
|
if (rect.Width <= 0 || rect.Height <= 0)
|
|
395
454
|
continue;
|
|
396
|
-
|
|
455
|
+
if (autoRowsOnly) {
|
|
456
|
+
// the height the row can grow to, as in MeasureKnownCells: unbounded for a vertical Fill child (it would take the
|
|
457
|
+
// whole constraint), the result held to the space the row can have
|
|
458
|
+
let grown = this.MeasurePx(child, rect.Width, this.HeightOnAutoRow(cell, child)).Height;
|
|
459
|
+
const available = this.AvailableHeight(cell);
|
|
460
|
+
if (isFinite(available) && grown > available)
|
|
461
|
+
grown = available;
|
|
462
|
+
if (grown > this.Rows[cell.Row].Size) {
|
|
463
|
+
this.Rows[cell.Row].Update(grown);
|
|
464
|
+
autoRowGrew = true;
|
|
465
|
+
}
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
// on an Auto row a child that is not Fill vertically keeps the height the row can grow to, as in
|
|
469
|
+
// MeasureKnownCells: the same request returns at once, and wrapped text is not cut to the row
|
|
470
|
+
const height = this.SizesAutoRow(cell) && !SkiaGridStructure.NeedFillY(child) ? Math.max(rect.Height, this.AvailableHeight(cell)) : rect.Height;
|
|
471
|
+
const m = this.MeasurePx(child, rect.Width, height);
|
|
397
472
|
if (cell.ColumnSpan === 1 && this.Columns[cell.Column].IsAuto && m.Width > this.Columns[cell.Column].Size)
|
|
398
473
|
this.Columns[cell.Column].Update(m.Width);
|
|
399
474
|
if (cell.RowSpan === 1 && this.Rows[cell.Row].IsAuto && m.Height > this.Rows[cell.Row].Size)
|
|
400
475
|
this.Rows[cell.Row].Update(m.Height);
|
|
401
476
|
}
|
|
477
|
+
return autoRowGrew;
|
|
402
478
|
}
|
|
403
479
|
}
|
|
@@ -4,15 +4,21 @@ import { SkiaLayout } from "./SkiaLayout";
|
|
|
4
4
|
/**
|
|
5
5
|
* Mirrors DrawnUi SkiaBackdrop: draws what is already painted beneath its box through `Blur` (points, default 5)
|
|
6
6
|
* and `Brightness` (gamma, 1 = unchanged), tinted by `BackgroundColor`; children draw first and are blurred too.
|
|
7
|
-
* The snapshot comes from the surface being drawn (`UseContext
|
|
8
|
-
*
|
|
7
|
+
* The snapshot comes from the surface being drawn (`UseContext`, the area it covers there through every ancestor
|
|
8
|
+
* transform) or the on-screen surface. Not cached (re-blurs on every frame it is drawn in). Its picture-cached parents
|
|
9
|
+
* should use `UseCache = None` (the app sets it, the library never changes a parent's cache; a one-time console warning
|
|
10
|
+
* names the case); inside an Image-cached ancestor it copies that cache's surface
|
|
11
|
+
* (right when what shows through the glass is inside that cache, wrong when it should show content outside it).
|
|
9
12
|
*/
|
|
10
13
|
export declare class SkiaBackdrop extends SkiaLayout {
|
|
14
|
+
/** Samples what is drawn below: a composite above redraws it whole when something inside changes (drawnui-cross 6m). */
|
|
15
|
+
protected get SamplesContent(): boolean;
|
|
11
16
|
Blur: number;
|
|
12
17
|
Brightness: number;
|
|
13
18
|
/** Snapshot the surface currently drawn into (true) or the on-screen surface (false). */
|
|
14
19
|
UseContext: boolean;
|
|
15
20
|
private snapshot?;
|
|
21
|
+
private warnedPicture;
|
|
16
22
|
constructor();
|
|
17
23
|
get HasEffects(): boolean;
|
|
18
24
|
/** The last snapshot taken (C# GetImage hands it over: the caller owns it afterwards). */
|
|
@@ -4,15 +4,21 @@ import { SkiaLayout } from "./SkiaLayout";
|
|
|
4
4
|
/**
|
|
5
5
|
* Mirrors DrawnUi SkiaBackdrop: draws what is already painted beneath its box through `Blur` (points, default 5)
|
|
6
6
|
* and `Brightness` (gamma, 1 = unchanged), tinted by `BackgroundColor`; children draw first and are blurred too.
|
|
7
|
-
* The snapshot comes from the surface being drawn (`UseContext
|
|
8
|
-
*
|
|
7
|
+
* The snapshot comes from the surface being drawn (`UseContext`, the area it covers there through every ancestor
|
|
8
|
+
* transform) or the on-screen surface. Not cached (re-blurs on every frame it is drawn in). Its picture-cached parents
|
|
9
|
+
* should use `UseCache = None` (the app sets it, the library never changes a parent's cache; a one-time console warning
|
|
10
|
+
* names the case); inside an Image-cached ancestor it copies that cache's surface
|
|
11
|
+
* (right when what shows through the glass is inside that cache, wrong when it should show content outside it).
|
|
9
12
|
*/
|
|
10
13
|
export class SkiaBackdrop extends SkiaLayout {
|
|
14
|
+
/** Samples what is drawn below: a composite above redraws it whole when something inside changes (drawnui-cross 6m). */
|
|
15
|
+
get SamplesContent() { return true; }
|
|
11
16
|
Blur = 5;
|
|
12
17
|
Brightness = 1;
|
|
13
18
|
/** Snapshot the surface currently drawn into (true) or the on-screen surface (false). */
|
|
14
19
|
UseContext = true;
|
|
15
20
|
snapshot;
|
|
21
|
+
warnedPicture = false;
|
|
16
22
|
constructor() {
|
|
17
23
|
super();
|
|
18
24
|
this.HorizontalOptions = "Fill";
|
|
@@ -38,16 +44,36 @@ export class SkiaBackdrop extends SkiaLayout {
|
|
|
38
44
|
}
|
|
39
45
|
if (!this.HasEffects)
|
|
40
46
|
return;
|
|
47
|
+
// recorded into a parent's picture cache: its copy of what is behind goes into the picture. The library never
|
|
48
|
+
// changes a parent's cache (Nick, C# cf18cf29): it says so once, the app sets UseCache = None on those parents
|
|
49
|
+
if (ctx.Context.Recording && !this.warnedPicture) {
|
|
50
|
+
this.warnedPicture = true;
|
|
51
|
+
console.warn(`[SkiaBackdrop]${this.Tag ? ` ${this.Tag}` : ""} is recorded into a parent's picture cache (Operations / OperationsFull, the default of SkiaShape): its copy of what is behind goes into the picture. Set UseCache = None on its picture-cached parents.`);
|
|
52
|
+
}
|
|
41
53
|
// C# UseContext: snapshot the surface the pixels end up on — the on-screen surface or the nearest Image cache
|
|
42
|
-
// surface
|
|
43
|
-
//
|
|
54
|
+
// surface. Copied where the backdrop really is on that surface: its rect through the canvas matrix (ancestor
|
|
55
|
+
// scale, move, rotation, 3D, the cache origin), rounded out, clamped to the surface, and drawn back 1:1 with the
|
|
56
|
+
// matrix undone, clipped to the backdrop's own (maybe turned) rect: the blur stays the same on screen while an
|
|
57
|
+
// ancestor scales (C# 6fd3bae3). The global surface (UseContext false) is copied at the layout rect.
|
|
44
58
|
const surface = this.UseContext ? ctx.Context.Surface : this.Superview?.Surface;
|
|
45
59
|
if (!surface)
|
|
46
60
|
return;
|
|
47
61
|
surface.flush();
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
62
|
+
let l = Math.floor(d.Left), t = Math.floor(d.Top), r = Math.ceil(d.Right), b = Math.ceil(d.Bottom);
|
|
63
|
+
let device = null;
|
|
64
|
+
if (this.UseContext) {
|
|
65
|
+
const m = canvas.getTotalMatrix();
|
|
66
|
+
const p = CK.Matrix.mapPoints(m, [d.Left, d.Top, d.Right, d.Top, d.Right, d.Bottom, d.Left, d.Bottom]);
|
|
67
|
+
l = Math.max(0, Math.floor(Math.min(p[0], p[2], p[4], p[6])));
|
|
68
|
+
t = Math.max(0, Math.floor(Math.min(p[1], p[3], p[5], p[7])));
|
|
69
|
+
r = Math.min(surface.width(), Math.ceil(Math.max(p[0], p[2], p[4], p[6])));
|
|
70
|
+
b = Math.min(surface.height(), Math.ceil(Math.max(p[1], p[3], p[5], p[7])));
|
|
71
|
+
if (r <= l || b <= t)
|
|
72
|
+
return;
|
|
73
|
+
device = CK.Matrix.invert(m);
|
|
74
|
+
if (!device)
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
51
77
|
// whole-surface snapshot, sub-rect on draw: a bounded snapshot of a GPU surface is not origin-safe in CanvasKit
|
|
52
78
|
const image = surface.makeImageSnapshot();
|
|
53
79
|
if (!image)
|
|
@@ -61,7 +87,13 @@ export class SkiaBackdrop extends SkiaLayout {
|
|
|
61
87
|
paint.setColorFilter(gamma);
|
|
62
88
|
const saved = canvas.save();
|
|
63
89
|
canvas.clipRect(CK.LTRBRect(d.Left, d.Top, d.Right, d.Bottom), CK.ClipOp.Intersect, true);
|
|
64
|
-
|
|
90
|
+
if (device) {
|
|
91
|
+
canvas.concat(device);
|
|
92
|
+
canvas.drawImageRectOptions(image, CK.LTRBRect(l, t, r, b), CK.LTRBRect(l, t, r, b), CK.FilterMode.Nearest, CK.MipmapMode.None, paint);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
canvas.drawImageRectOptions(image, CK.LTRBRect(l, t, r, b), CK.LTRBRect(d.Left, d.Top, d.Right, d.Bottom), CK.FilterMode.Linear, CK.MipmapMode.None, paint);
|
|
96
|
+
}
|
|
65
97
|
canvas.restoreToCount(saved);
|
|
66
98
|
blur?.delete();
|
|
67
99
|
gamma?.delete();
|
|
@@ -69,12 +101,8 @@ export class SkiaBackdrop extends SkiaLayout {
|
|
|
69
101
|
const kill = this.snapshot;
|
|
70
102
|
this.snapshot = image;
|
|
71
103
|
kill?.delete();
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
queueMicrotask(() => { let p = this.Parent; while (p) {
|
|
75
|
-
p.InvalidateCache();
|
|
76
|
-
p = p.Parent;
|
|
77
|
-
} });
|
|
104
|
+
// the library never changes how a parent's cache behaves (Nick, 2026-10-25): a cached parent replays the copy it
|
|
105
|
+
// recorded, as in C#; the app sets UseCache = None on the parents of a backdrop that must follow what is behind
|
|
78
106
|
}
|
|
79
107
|
OnDisposing() { this.snapshot?.delete(); this.snapshot = undefined; }
|
|
80
108
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Path } from "canvaskit-wasm";
|
|
2
|
-
import
|
|
2
|
+
import { SkiaControl } from "../core/SkiaControl";
|
|
3
3
|
import { type Color, type CornerRadius, ScaledSize, type SkiaTouchAnimation } from "../core/Types";
|
|
4
4
|
import { type GestureEventProcessingInfo, type SkiaGesturesParameters } from "../core/Gestures";
|
|
5
5
|
import { SkiaLayout } from "./SkiaLayout";
|
|
@@ -10,6 +10,8 @@ import { type PrebuiltControlStyle, type ResolvedControlStyle } from "../core/Co
|
|
|
10
10
|
* PanThreshold. Press feedback = ApplyEffect (ripple), no darkening.
|
|
11
11
|
*/
|
|
12
12
|
export declare class SkiaButton extends SkiaLayout {
|
|
13
|
+
/** Takes mouse hover unless ReceivesHover is set false (C# ReceivesHoverByDefault). */
|
|
14
|
+
protected ReceivesHoverByDefault(): boolean;
|
|
13
15
|
static PanThreshold: number;
|
|
14
16
|
Text: string;
|
|
15
17
|
/** Look of the default content (C# SkiaButton.ControlStyle): background, corners, font, minimum size when left unset. */
|
|
@@ -24,7 +26,17 @@ export declare class SkiaButton extends SkiaLayout {
|
|
|
24
26
|
StrokeColor: Color;
|
|
25
27
|
StrokeWidth: number;
|
|
26
28
|
IsPressed: boolean;
|
|
27
|
-
|
|
29
|
+
private respondsToGestures;
|
|
30
|
+
/**
|
|
31
|
+
* False switches the button off for the user: taps, presses and keyboard activation do nothing (no Tapped, Down, Up),
|
|
32
|
+
* a tap on it does not reach controls under it, and screen readers report it disabled. Code can still change it.
|
|
33
|
+
* Same property as on toggles, sliders, scrolls and drawers (drawnui-cross 6w). Default true.
|
|
34
|
+
*/
|
|
35
|
+
get RespondsToGestures(): boolean;
|
|
36
|
+
set RespondsToGestures(v: boolean);
|
|
37
|
+
/** @deprecated The opposite of RespondsToGestures, which every control uses: set `RespondsToGestures = false`. */
|
|
38
|
+
get IsDisabled(): boolean;
|
|
39
|
+
set IsDisabled(v: boolean);
|
|
28
40
|
LockPanning: boolean;
|
|
29
41
|
/** Touch feedback played on Down (DrawnUi SkiaButton.ApplyEffect). */
|
|
30
42
|
ApplyEffect: SkiaTouchAnimation;
|
|
@@ -41,6 +53,8 @@ export declare class SkiaButton extends SkiaLayout {
|
|
|
41
53
|
static DefaultAccessibilityRole?: string;
|
|
42
54
|
protected DefaultAccessibilityLabel(): string | undefined;
|
|
43
55
|
protected DefaultAccessibilityCanInteract(): boolean;
|
|
56
|
+
/** With RespondsToGestures = false the button ignores taps, keyboard navigation skips it and it is reported disabled. */
|
|
57
|
+
protected AcceptsInput(): boolean;
|
|
44
58
|
/** The button's own BackgroundColor/CornerRadius/Stroke are the frame's; the button itself paints nothing. */
|
|
45
59
|
protected PaintBackground(): void;
|
|
46
60
|
get UsingControlStyle(): ResolvedControlStyle;
|
|
@@ -55,7 +69,7 @@ export declare class SkiaButton extends SkiaLayout {
|
|
|
55
69
|
/** Ripple clipped to the rounded frame. */
|
|
56
70
|
CreateClip(): Path;
|
|
57
71
|
/** DrawnUi SkiaButton.OnDown: press feedback; true = consume Down. */
|
|
58
|
-
protected OnDown(
|
|
72
|
+
protected OnDown(args: SkiaGesturesParameters, apply: GestureEventProcessingInfo): boolean;
|
|
59
73
|
private SetUp;
|
|
60
74
|
ProcessGestures(args: SkiaGesturesParameters, apply: GestureEventProcessingInfo): SkiaControl | null;
|
|
61
75
|
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import { SkiaControl } from "../core/SkiaControl";
|
|
1
2
|
import { Colors, SKRect, ScaledSize, SkiaShadow, Thickness } from "../core/Types";
|
|
2
3
|
import { SKPoint } from "../core/Gestures";
|
|
3
4
|
import { SkiaLayout } from "./SkiaLayout";
|
|
4
5
|
import { SkiaLabel } from "./SkiaLabel";
|
|
5
6
|
import { SkiaShape } from "./SkiaShape";
|
|
6
|
-
import { ResolveControlStyle } from "../core/ControlStyle";
|
|
7
|
+
import { DefaultAccent, ResolveControlStyle } from "../core/ControlStyle";
|
|
7
8
|
/**
|
|
8
9
|
* Mirrors DrawnUi SkiaButton (default style): a SkiaShape frame tagged "BtnShape" + a centered SkiaLabel
|
|
9
10
|
* tagged "BtnText". Consumes Down/Up/Tapped inside its rect; releases the pressed state when a pan exceeds
|
|
10
11
|
* PanThreshold. Press feedback = ApplyEffect (ripple), no darkening.
|
|
11
12
|
*/
|
|
12
13
|
export class SkiaButton extends SkiaLayout {
|
|
14
|
+
/** Takes mouse hover unless ReceivesHover is set false (C# ReceivesHoverByDefault). */
|
|
15
|
+
ReceivesHoverByDefault() { return true; }
|
|
13
16
|
static PanThreshold = 5;
|
|
14
17
|
Text = "";
|
|
15
18
|
/** Look of the default content (C# SkiaButton.ControlStyle): background, corners, font, minimum size when left unset. */
|
|
@@ -24,7 +27,20 @@ export class SkiaButton extends SkiaLayout {
|
|
|
24
27
|
StrokeColor = Colors.Transparent;
|
|
25
28
|
StrokeWidth = 0;
|
|
26
29
|
IsPressed = false;
|
|
27
|
-
|
|
30
|
+
respondsToGestures = true;
|
|
31
|
+
/**
|
|
32
|
+
* False switches the button off for the user: taps, presses and keyboard activation do nothing (no Tapped, Down, Up),
|
|
33
|
+
* a tap on it does not reach controls under it, and screen readers report it disabled. Code can still change it.
|
|
34
|
+
* Same property as on toggles, sliders, scrolls and drawers (drawnui-cross 6w). Default true.
|
|
35
|
+
*/
|
|
36
|
+
get RespondsToGestures() { return this.respondsToGestures; }
|
|
37
|
+
set RespondsToGestures(v) { if (this.respondsToGestures !== v) {
|
|
38
|
+
this.respondsToGestures = v;
|
|
39
|
+
this.NotifyAccessibility();
|
|
40
|
+
} }
|
|
41
|
+
/** @deprecated The opposite of RespondsToGestures, which every control uses: set `RespondsToGestures = false`. */
|
|
42
|
+
get IsDisabled() { return !this.respondsToGestures; }
|
|
43
|
+
set IsDisabled(v) { this.RespondsToGestures = !v; }
|
|
28
44
|
LockPanning = false;
|
|
29
45
|
/** Touch feedback played on Down (DrawnUi SkiaButton.ApplyEffect). */
|
|
30
46
|
ApplyEffect = "Ripple"; // C# default
|
|
@@ -58,7 +74,9 @@ export class SkiaButton extends SkiaLayout {
|
|
|
58
74
|
/** Set to `Aria.RoleButton` to expose every button (React extension). */
|
|
59
75
|
static DefaultAccessibilityRole;
|
|
60
76
|
DefaultAccessibilityLabel() { return this.Text || undefined; }
|
|
61
|
-
DefaultAccessibilityCanInteract() { return
|
|
77
|
+
DefaultAccessibilityCanInteract() { return this.respondsToGestures; }
|
|
78
|
+
/** With RespondsToGestures = false the button ignores taps, keyboard navigation skips it and it is reported disabled. */
|
|
79
|
+
AcceptsInput() { return this.respondsToGestures; }
|
|
62
80
|
/** The button's own BackgroundColor/CornerRadius/Stroke are the frame's; the button itself paints nothing. */
|
|
63
81
|
PaintBackground() { }
|
|
64
82
|
get UsingControlStyle() { return ResolveControlStyle(this.ControlStyle); }
|
|
@@ -72,7 +90,7 @@ export class SkiaButton extends SkiaLayout {
|
|
|
72
90
|
case "Material": return { bg: "#2196F3", radius: 4, font: 14, weight: 0, minW: 100, minH: 40, shadow: new SkiaShadow({ X: 0, Y: 2, Blur: 4, Opacity: 0.3, Color: Colors.Black }) };
|
|
73
91
|
case "Material3": return { bg: "#6750A4", radius: 20, font: 14, weight: 0, minW: 100, minH: 40 };
|
|
74
92
|
case "Windows": return { bg: "#0078D7", radius: 4, font: 15, weight: 500, minW: 100, minH: 32, shadow: new SkiaShadow({ X: 0, Y: 1, Blur: 1, Opacity: 0.2, Color: Colors.Black }) };
|
|
75
|
-
default: return { bg:
|
|
93
|
+
default: return { bg: DefaultAccent, radius: 8, font: 15, weight: 0, minW: 100, minH: 41 };
|
|
76
94
|
}
|
|
77
95
|
}
|
|
78
96
|
MeasureAbsolute(w, h, scale) {
|
|
@@ -112,8 +130,8 @@ export class SkiaButton extends SkiaLayout {
|
|
|
112
130
|
/** Ripple clipped to the rounded frame. */
|
|
113
131
|
CreateClip() { return this.frame.CreateClip(); }
|
|
114
132
|
/** DrawnUi SkiaButton.OnDown: press feedback; true = consume Down. */
|
|
115
|
-
OnDown(
|
|
116
|
-
if (this.ApplyEffect === "Ripple") {
|
|
133
|
+
OnDown(args, apply) {
|
|
134
|
+
if (this.ApplyEffect === "Ripple" && SkiaControl.IsPrimaryPointer(args)) {
|
|
117
135
|
const pts = this.GetOffsetInsideControlInPoints(apply.MappedLocation, apply.ChildOffset);
|
|
118
136
|
this.PlayRippleAnimation(this.TouchEffectColor, pts.X, pts.Y);
|
|
119
137
|
}
|
|
@@ -126,8 +144,8 @@ export class SkiaButton extends SkiaLayout {
|
|
|
126
144
|
this.Repaint();
|
|
127
145
|
}
|
|
128
146
|
ProcessGestures(args, apply) {
|
|
129
|
-
if (this.
|
|
130
|
-
return
|
|
147
|
+
if (!this.respondsToGestures)
|
|
148
|
+
return this.BlockedGestureResult(args); // no press, no Down / Up / Tapped; a tap on it stops here
|
|
131
149
|
const point = args.Event.Location;
|
|
132
150
|
if (args.Type === "Down") {
|
|
133
151
|
this.IsPressed = true;
|
|
@@ -15,6 +15,8 @@ export interface SnapPoint {
|
|
|
15
15
|
* `DynamicSize` sizes an auto-sized carousel from the selected slide, `SwipeSpeed` / `LinearSpeedMs` tune the snap.
|
|
16
16
|
*/
|
|
17
17
|
export declare class SkiaCarousel extends SnappingLayout {
|
|
18
|
+
/** Takes mouse hover unless ReceivesHover is set false (C# ReceivesHoverByDefault). */
|
|
19
|
+
protected ReceivesHoverByDefault(): boolean;
|
|
18
20
|
IsVertical: boolean;
|
|
19
21
|
/** Side padding in points so the previous/next slides peek in. */
|
|
20
22
|
SidesOffset: number;
|
|
@@ -99,13 +101,24 @@ export declare class SkiaCarousel extends SnappingLayout {
|
|
|
99
101
|
private GetVirtualSnapPoints;
|
|
100
102
|
protected GetVirtualAnchor(current: SKPoint): SnapPoint;
|
|
101
103
|
protected FindNearestAnchorInternal(current: SKPoint, velocity: SKPoint): SKPoint;
|
|
102
|
-
/** C# SkiaCarousel.ScrollToNearestAnchor: velocity below
|
|
104
|
+
/** C# SkiaCarousel.ScrollToNearestAnchor: velocity below SnapVelocityThreshold counts as none; looped snaps around virtual anchors. */
|
|
103
105
|
ScrollToNearestAnchor(location: SKPoint, velocity: SKPoint): void;
|
|
104
|
-
/** C# SkiaCarousel.SelectNextAnchor:
|
|
106
|
+
/** C# SkiaCarousel.SelectNextAnchor: the choice below, at most one slide from where a finger gesture started. */
|
|
105
107
|
SelectNextAnchor(origin: SKPoint, velocity: SKPoint): SKPoint;
|
|
108
|
+
/**
|
|
109
|
+
* A finger release moves at most one slide from the slide its gesture started on, as iOS paging and the Android
|
|
110
|
+
* ViewPager do (C# 1070e0db): a drag past the middle makes the next slide the nearest one, and the flick then went one
|
|
111
|
+
* further. Code moves (ScrollTo, SelectedIndex) are not limited: releaseHome is set only while a release snaps.
|
|
112
|
+
*/
|
|
113
|
+
private LimitToNeighbours;
|
|
114
|
+
/** The slide a finger gesture started on (the target when it caught a snap in flight), see LimitToNeighbours. */
|
|
115
|
+
private gestureHome?;
|
|
116
|
+
private releaseHome?;
|
|
117
|
+
/** Base choice, plus a wrap to the virtual anchor at the strip borders when looped. */
|
|
118
|
+
private SelectNextAnchorInternal;
|
|
106
119
|
/** C# FixIndex: a virtual anchor becomes the real one, the position keeps its offset (visually identical, looped drawing wraps). */
|
|
107
120
|
private FixIndex;
|
|
108
|
-
|
|
121
|
+
protected FixPosition(): void;
|
|
109
122
|
protected OnTransitionChanged(): void;
|
|
110
123
|
protected ScaleSnapVelocity(velocity: SKPoint): SKPoint;
|
|
111
124
|
protected CreateSnapSpring(): Spring;
|
|
@@ -127,6 +140,12 @@ export declare class SkiaCarousel extends SnappingLayout {
|
|
|
127
140
|
/** C# RenderViewsList: position every slide, draw the visible ones (+ neighbours when PreloadNeighboors), release the rest. */
|
|
128
141
|
protected Paint(ctx: DrawingContext): void;
|
|
129
142
|
private SlideRect;
|
|
143
|
+
/**
|
|
144
|
+
* Whether the slide at `index` takes part in hit-testing for the frame being rendered (C# IsSlideHitTestable).
|
|
145
|
+
* Every slide drawn on screen does by default; a carousel whose slides share one rect (SkiaShaderCarousel) narrows
|
|
146
|
+
* this to the slide the user actually sees.
|
|
147
|
+
*/
|
|
148
|
+
protected IsSlideHitTestable(_index: number): boolean;
|
|
130
149
|
protected GetGestureListeners(): readonly SkiaControl[];
|
|
131
150
|
ProcessGestures(args: SkiaGesturesParameters, apply: GestureEventProcessingInfo): SkiaControl | null;
|
|
132
151
|
protected DefaultAccessibilityLabel(): string | undefined;
|
|
@@ -11,6 +11,8 @@ import { SnappingLayout } from "./SnappingLayout";
|
|
|
11
11
|
* `DynamicSize` sizes an auto-sized carousel from the selected slide, `SwipeSpeed` / `LinearSpeedMs` tune the snap.
|
|
12
12
|
*/
|
|
13
13
|
export class SkiaCarousel extends SnappingLayout {
|
|
14
|
+
/** Takes mouse hover unless ReceivesHover is set false (C# ReceivesHoverByDefault). */
|
|
15
|
+
ReceivesHoverByDefault() { return true; }
|
|
14
16
|
IsVertical = false;
|
|
15
17
|
/** Side padding in points so the previous/next slides peek in. */
|
|
16
18
|
SidesOffset = 0;
|
|
@@ -230,9 +232,30 @@ export class SkiaCarousel extends SnappingLayout {
|
|
|
230
232
|
}
|
|
231
233
|
return super.FindNearestAnchorInternal(current, velocity);
|
|
232
234
|
}
|
|
233
|
-
/** C# SkiaCarousel.ScrollToNearestAnchor: velocity below
|
|
235
|
+
/** C# SkiaCarousel.ScrollToNearestAnchor: velocity below SnapVelocityThreshold counts as none; looped snaps around virtual anchors. */
|
|
234
236
|
ScrollToNearestAnchor(location, velocity) {
|
|
235
|
-
|
|
237
|
+
const t = this.SnapVelocityThreshold;
|
|
238
|
+
velocity = new SKPoint(Math.abs(velocity.X) < t ? 0 : velocity.X, Math.abs(velocity.Y) < t ? 0 : velocity.Y);
|
|
239
|
+
const home = this.releaseHome;
|
|
240
|
+
if (this.ApplyLoopedLogic && home && this.SnapPoints.length > 1) {
|
|
241
|
+
// a finger release on a looped carousel: one slide at most from the slide the gesture started on, counted along the
|
|
242
|
+
// strip, so across the edge it is the virtual slot next to it. A flick goes one slide its way, a slow drag to the
|
|
243
|
+
// nearest of that slide and its two neighbours. Measured from the slide nearest the release instead, a drag past
|
|
244
|
+
// the middle went the wrong way at the wrap (C# 11196529)
|
|
245
|
+
const step = new SKPoint(this.SnapPoints[1].X - this.SnapPoints[0].X, this.SnapPoints[1].Y - this.SnapPoints[0].Y);
|
|
246
|
+
const stepAxis = this.IsVertical ? step.Y : step.X;
|
|
247
|
+
if (stepAxis !== 0) {
|
|
248
|
+
const vel = this.IsVertical ? velocity.Y : velocity.X;
|
|
249
|
+
const moved = this.IsVertical ? location.Y - home.Y : location.X - home.X;
|
|
250
|
+
const k = vel !== 0 ? Math.sign(vel) * Math.sign(stepAxis) : Math.max(-1, Math.min(1, Math.round(moved / stepAxis)));
|
|
251
|
+
const target = new SKPoint(home.X + step.X * k, home.Y + step.Y * k);
|
|
252
|
+
if (SnappingLayout.Dist(location, target) >= 0.5)
|
|
253
|
+
this.ScrollToOffset(target, velocity, this.CanAnimate);
|
|
254
|
+
else
|
|
255
|
+
this.UpdateReportedPosition();
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
236
259
|
if (this.ApplyLoopedLogic) {
|
|
237
260
|
const origin = this.FindNearestAnchorInternal(location, velocity);
|
|
238
261
|
const target = this.SelectNextAnchor(origin, velocity);
|
|
@@ -244,8 +267,30 @@ export class SkiaCarousel extends SnappingLayout {
|
|
|
244
267
|
}
|
|
245
268
|
super.ScrollToNearestAnchor(location, velocity);
|
|
246
269
|
}
|
|
247
|
-
/** C# SkiaCarousel.SelectNextAnchor:
|
|
270
|
+
/** C# SkiaCarousel.SelectNextAnchor: the choice below, at most one slide from where a finger gesture started. */
|
|
248
271
|
SelectNextAnchor(origin, velocity) {
|
|
272
|
+
return this.LimitToNeighbours(this.SelectNextAnchorInternal(origin, velocity));
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* A finger release moves at most one slide from the slide its gesture started on, as iOS paging and the Android
|
|
276
|
+
* ViewPager do (C# 1070e0db): a drag past the middle makes the next slide the nearest one, and the flick then went one
|
|
277
|
+
* further. Code moves (ScrollTo, SelectedIndex) are not limited: releaseHome is set only while a release snaps.
|
|
278
|
+
*/
|
|
279
|
+
LimitToNeighbours(target) {
|
|
280
|
+
const home = this.releaseHome;
|
|
281
|
+
if (!home)
|
|
282
|
+
return target;
|
|
283
|
+
const at = (p) => this.SnapPoints.findIndex((s) => Math.abs(s.X - p.X) <= 1 && Math.abs(s.Y - p.Y) <= 1);
|
|
284
|
+
const from = at(home), to = at(target);
|
|
285
|
+
if (from < 0 || to < 0 || Math.abs(to - from) <= 1)
|
|
286
|
+
return target; // a looped wrap goes to a virtual point next to the edge: one slide already
|
|
287
|
+
return this.SnapPoints[from + Math.sign(to - from)];
|
|
288
|
+
}
|
|
289
|
+
/** The slide a finger gesture started on (the target when it caught a snap in flight), see LimitToNeighbours. */
|
|
290
|
+
gestureHome;
|
|
291
|
+
releaseHome;
|
|
292
|
+
/** Base choice, plus a wrap to the virtual anchor at the strip borders when looped. */
|
|
293
|
+
SelectNextAnchorInternal(origin, velocity) {
|
|
249
294
|
if (!this.ApplyLoopedLogic)
|
|
250
295
|
return super.SelectNextAnchor(origin, velocity);
|
|
251
296
|
const baseTarget = super.SelectNextAnchor(origin, velocity);
|
|
@@ -280,9 +325,17 @@ export class SkiaCarousel extends SnappingLayout {
|
|
|
280
325
|
/** C# FixIndex: a virtual anchor becomes the real one, the position keeps its offset (visually identical, looped drawing wraps). */
|
|
281
326
|
FixIndex() {
|
|
282
327
|
if (this.IsLooped && this.SnapPoints.length > 1 && this.selectedIndex >= 0 && this.selectedIndex < this.SnapPoints.length) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
328
|
+
// the offset is measured from the anchor that stands for the selected slide where the position is now: the slide
|
|
329
|
+
// itself or its virtual copy past an edge. From the nearest anchor of another slide it moved a wrap in progress (the
|
|
330
|
+
// last slide 3% toward the first) onto another pair (C# b75f233a)
|
|
331
|
+
const real = this.SnapPoints[this.selectedIndex], last = this.MaxIndex;
|
|
332
|
+
let anchor = real;
|
|
333
|
+
for (const v of this.GetVirtualSnapPoints()) {
|
|
334
|
+
const standsFor = v.Id === this.selectedIndex || (v.Id === -1 && this.selectedIndex === last) || (v.Id === -2 && this.selectedIndex === 0);
|
|
335
|
+
if (standsFor && SnappingLayout.Dist(v.Location, this.CurrentPosition) < SnappingLayout.Dist(anchor, this.CurrentPosition))
|
|
336
|
+
anchor = v.Location;
|
|
337
|
+
}
|
|
338
|
+
const ox = this.CurrentPosition.X - anchor.X, oy = this.CurrentPosition.Y - anchor.Y;
|
|
286
339
|
this.CurrentSnap = real;
|
|
287
340
|
this.CurrentPosition = new SKPoint(real.X + ox, real.Y + oy);
|
|
288
341
|
}
|
|
@@ -504,7 +557,7 @@ export class SkiaCarousel extends SnappingLayout {
|
|
|
504
557
|
view.Measure(inner.Width, inner.Height, scale); // recycled cells carry new content
|
|
505
558
|
view.Arrange(this.SlideRect(inner, this.SlideOffset(cell.offset), scale), view.WidthRequest, view.HeightRequest, scale);
|
|
506
559
|
view.Render(ctx);
|
|
507
|
-
if (cell.visible)
|
|
560
|
+
if (cell.visible && this.IsSlideHitTestable(cell.index))
|
|
508
561
|
visible.push(view);
|
|
509
562
|
}
|
|
510
563
|
this.visibleViews = visible;
|
|
@@ -514,6 +567,12 @@ export class SkiaCarousel extends SnappingLayout {
|
|
|
514
567
|
? SKRect.Create(inner.Left, inner.Top + offset.Y * scale, inner.Width, inner.Height)
|
|
515
568
|
: SKRect.Create(inner.Left + offset.X * scale, inner.Top, inner.Width, inner.Height);
|
|
516
569
|
}
|
|
570
|
+
/**
|
|
571
|
+
* Whether the slide at `index` takes part in hit-testing for the frame being rendered (C# IsSlideHitTestable).
|
|
572
|
+
* Every slide drawn on screen does by default; a carousel whose slides share one rect (SkiaShaderCarousel) narrows
|
|
573
|
+
* this to the slide the user actually sees.
|
|
574
|
+
*/
|
|
575
|
+
IsSlideHitTestable(_index) { return true; }
|
|
517
576
|
GetGestureListeners() { return this.visibleViews; }
|
|
518
577
|
// ---- gestures (port of C# SkiaCarousel.ProcessGestures) ----
|
|
519
578
|
ProcessGestures(args, apply) {
|
|
@@ -525,8 +584,11 @@ export class SkiaCarousel extends SnappingLayout {
|
|
|
525
584
|
consumed = passToChildren();
|
|
526
585
|
if (consumed === this)
|
|
527
586
|
consumed = null;
|
|
528
|
-
if (consumed && !(args.Type === "Up" && this.snapIfNoPanOnUp))
|
|
587
|
+
if (consumed && !(args.Type === "Up" && this.snapIfNoPanOnUp)) {
|
|
588
|
+
if (args.Type === "Up")
|
|
589
|
+
this.IsUserFocused = false; // the finger left, also when a slide took the tap (C# dbf507fd)
|
|
529
590
|
return consumed;
|
|
591
|
+
}
|
|
530
592
|
}
|
|
531
593
|
if (!this.RespondsToGestures || this.ChildrenTotal < 2)
|
|
532
594
|
return consumedDefault;
|
|
@@ -542,6 +604,9 @@ export class SkiaCarousel extends SnappingLayout {
|
|
|
542
604
|
this.FixPosition();
|
|
543
605
|
this.panningOffset = this.CurrentPosition;
|
|
544
606
|
this.panningStart = this.CurrentPosition;
|
|
607
|
+
// a swipe that catches a snap in flight starts from the slide that snap was going to
|
|
608
|
+
const going = this.snapIfNoPanOnUp ? this.SnapPoints.find((s) => Math.abs(s.X - this.CurrentSnap.X) <= 1 && Math.abs(s.Y - this.CurrentSnap.Y) <= 1) : undefined;
|
|
609
|
+
this.gestureHome = going ?? (this.SnapPoints.length > 0 ? this.FindNearestAnchor(this.CurrentPosition) : undefined);
|
|
545
610
|
};
|
|
546
611
|
switch (args.Type) {
|
|
547
612
|
case "Down":
|
|
@@ -555,6 +620,10 @@ export class SkiaCarousel extends SnappingLayout {
|
|
|
555
620
|
if (!this.IsUserPanning) {
|
|
556
621
|
const movex = Math.abs(e.Distance.Total.X), movey = Math.abs(e.Distance.Total.Y);
|
|
557
622
|
const along = this.IsVertical ? movey : movex, across = this.IsVertical ? movex : movey;
|
|
623
|
+
// a first move too short to tell the direction decides nothing yet (a 1 CSS px move at devicePixelRatio 2):
|
|
624
|
+
// marking it wrong kept the whole drag dead until the next press (DrawnUi.Rust c6b22e3; C# decides on every move)
|
|
625
|
+
if (along < scale * 2 && across < scale * 2)
|
|
626
|
+
return consumedDefault;
|
|
558
627
|
if (along < scale * 2 || across > along) {
|
|
559
628
|
this.wrongDirection = true;
|
|
560
629
|
return consumedDefault;
|
|
@@ -578,7 +647,13 @@ export class SkiaCarousel extends SnappingLayout {
|
|
|
578
647
|
consumed = this;
|
|
579
648
|
const final = this.velocityAccumulator.CalculateFinalVelocity(500);
|
|
580
649
|
this.CurrentSnap = this.CurrentPosition;
|
|
581
|
-
this.
|
|
650
|
+
this.releaseHome = this.gestureHome;
|
|
651
|
+
try {
|
|
652
|
+
this.ScrollToNearestAnchor(this.CurrentSnap, new SKPoint(final.X, final.Y));
|
|
653
|
+
}
|
|
654
|
+
finally {
|
|
655
|
+
this.releaseHome = undefined;
|
|
656
|
+
}
|
|
582
657
|
this.IsUserPanning = false;
|
|
583
658
|
this.IsUserFocused = false;
|
|
584
659
|
this.snapIfNoPanOnUp = false;
|
|
@@ -591,6 +666,7 @@ export class SkiaCarousel extends SnappingLayout {
|
|
|
591
666
|
this.IsUserPanning = false;
|
|
592
667
|
this.snapIfNoPanOnUp = false;
|
|
593
668
|
}
|
|
669
|
+
this.IsUserFocused = false; // every Up ends the finger's hold, a tap included (C# dbf507fd)
|
|
594
670
|
break;
|
|
595
671
|
}
|
|
596
672
|
if (consumed || this.IsUserPanning)
|
|
@@ -15,7 +15,6 @@ export declare class SkiaCheckbox extends SkiaToggle {
|
|
|
15
15
|
get ColorCheckOn(): Color;
|
|
16
16
|
set ColorCheckOn(v: Color);
|
|
17
17
|
protected StyleDefault(name: "ColorThumbOn" | "ColorFrameOn" | "ColorThumbOff" | "ColorFrameOff"): Color | undefined;
|
|
18
|
-
private SetContentSize;
|
|
19
18
|
protected CreateDefaultContent(): void;
|
|
20
19
|
ApplyProperties(): void;
|
|
21
20
|
}
|