drawnui-react 0.1.0-preview.4 → 0.1.0-preview.41
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 +129 -14
- package/SKIPPED.md +36 -26
- 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 +16 -2
- package/dist/controls/GridStructure.js +40 -4
- 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 +48 -2
- package/dist/controls/SkiaEditor.js +268 -53
- package/dist/controls/SkiaGif.d.ts +7 -0
- package/dist/controls/SkiaGif.js +25 -4
- package/dist/controls/SkiaImage.d.ts +5 -0
- package/dist/controls/SkiaImage.js +48 -14
- package/dist/controls/SkiaLabel.d.ts +117 -9
- package/dist/controls/SkiaLabel.js +526 -80
- package/dist/controls/SkiaLabelFps.d.ts +16 -0
- package/dist/controls/SkiaLabelFps.js +41 -0
- package/dist/controls/SkiaLayout.d.ts +89 -9
- package/dist/controls/SkiaLayout.js +364 -21
- 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 +35 -5
- package/dist/controls/SkiaScroll.js +252 -32
- 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 +13 -2
- package/dist/controls/SkiaShape.js +50 -10
- 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 +22 -10
- 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 +134 -0
- package/dist/core/Accessibility.js +675 -9
- package/dist/core/Animators.d.ts +37 -1
- package/dist/core/Animators.js +102 -9
- package/dist/core/Canvas.d.ts +241 -10
- package/dist/core/Canvas.js +739 -44
- 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 +81 -2
- package/dist/core/Gestures.js +177 -3
- 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 +205 -0
- package/dist/core/ScrollAnimators.js +9 -0
- package/dist/core/Shaping.d.ts +40 -0
- package/dist/core/Shaping.js +224 -0
- package/dist/core/SkiaControl.d.ts +284 -11
- package/dist/core/SkiaControl.js +630 -66
- package/dist/core/SkiaEffect.d.ts +17 -0
- package/dist/core/SkiaEffect.js +43 -8
- package/dist/core/SkiaImageManager.js +1 -1
- package/dist/core/Super.d.ts +29 -2
- package/dist/core/Super.js +54 -3
- 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 +7 -0
- package/dist/index.js +7 -0
- package/dist/react/SkiaShell.js +65 -26
- package/dist/react/index.d.ts +51 -4
- package/dist/react/index.js +180 -18
- package/dist/react/reconciler.d.ts +20 -0
- package/dist/react/reconciler.js +69 -14
- package/dist/vite/index.d.ts +9 -0
- package/dist/vite/index.js +36 -3
- package/package.json +66 -2
|
@@ -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
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DefaultAccent } from "../core/ControlStyle";
|
|
1
2
|
import { Colors, Thickness } from "../core/Types";
|
|
2
3
|
import { SkiaShape } from "./SkiaShape";
|
|
3
4
|
import { SkiaSvg } from "./SkiaSvg";
|
|
@@ -12,7 +13,7 @@ export class SkiaCheckbox extends SkiaToggle {
|
|
|
12
13
|
FrameOn;
|
|
13
14
|
ViewCheckOn;
|
|
14
15
|
colorCheckOn;
|
|
15
|
-
static DefaultAccent =
|
|
16
|
+
static DefaultAccent = DefaultAccent;
|
|
16
17
|
static DefaultOutline = "#8E959D";
|
|
17
18
|
/** Color of the check mark (inner square for the default look). */
|
|
18
19
|
get ColorCheckOn() { return this.colorCheckOn ?? (this.UsingControlStyle === "Unset" ? SkiaCheckbox.DefaultAccent : Colors.White); }
|
|
@@ -27,12 +28,6 @@ export class SkiaCheckbox extends SkiaToggle {
|
|
|
27
28
|
};
|
|
28
29
|
return table[this.UsingControlStyle]?.[name];
|
|
29
30
|
}
|
|
30
|
-
SetContentSize(w, h) {
|
|
31
|
-
if (this.WidthRequest < 0)
|
|
32
|
-
this.WidthRequest = w;
|
|
33
|
-
if (this.HeightRequest < 0)
|
|
34
|
-
this.HeightRequest = h;
|
|
35
|
-
}
|
|
36
31
|
CreateDefaultContent() {
|
|
37
32
|
const off = new SkiaShape();
|
|
38
33
|
off.Tag = "FrameOff";
|
|
@@ -9,6 +9,8 @@ import { SnappingLayout } from "./SnappingLayout";
|
|
|
9
9
|
* so it must be aligned to its edge by the parent (VerticalOptions="End" for FromBottom, etc.).
|
|
10
10
|
*/
|
|
11
11
|
export declare class SkiaDrawer extends SnappingLayout {
|
|
12
|
+
/** Takes mouse hover unless ReceivesHover is set false (C# ReceivesHoverByDefault). */
|
|
13
|
+
protected ReceivesHoverByDefault(): boolean;
|
|
12
14
|
Direction: DrawerDirection;
|
|
13
15
|
/** Points that stay visible when closed. */
|
|
14
16
|
HeaderSize: number;
|
|
@@ -27,6 +29,13 @@ export declare class SkiaDrawer extends SnappingLayout {
|
|
|
27
29
|
constructor();
|
|
28
30
|
get IsOpen(): boolean;
|
|
29
31
|
set IsOpen(v: boolean);
|
|
32
|
+
/**
|
|
33
|
+
* The drawer starts moving from open to closed (IsOpen = false, a swipe release, code): raised once the move is under
|
|
34
|
+
* way, before it ends (C# internal ClosingStarted; SkiaShell takes a modal out of its stack here).
|
|
35
|
+
*/
|
|
36
|
+
ClosingStarted?: (sender: SkiaDrawer) => void;
|
|
37
|
+
private headingOpen;
|
|
38
|
+
protected ScrollToOffset(target: SKPoint, velocity: SKPoint, animate: boolean): boolean;
|
|
30
39
|
Open(): void;
|
|
31
40
|
Close(): void;
|
|
32
41
|
get Horizontal(): boolean;
|
|
@@ -42,5 +51,11 @@ export declare class SkiaDrawer extends SnappingLayout {
|
|
|
42
51
|
private ReportFromSnap;
|
|
43
52
|
CheckTransitionEnded(): boolean;
|
|
44
53
|
ProcessGestures(args: SkiaGesturesParameters, apply: GestureEventProcessingInfo): SkiaControl | null;
|
|
54
|
+
/**
|
|
55
|
+
* A Down stops a running move to a snap, so a pan can take the drawer from where it is. When the touch ends without a
|
|
56
|
+
* pan, the drawer finishes that move to the snap it was sent to (IsOpen changed in code, or a released swipe), instead
|
|
57
|
+
* of staying between its snaps (C# FinishStoppedMove).
|
|
58
|
+
*/
|
|
59
|
+
private FinishStoppedMove;
|
|
45
60
|
protected DefaultAccessibilityLabel(): string | undefined;
|
|
46
61
|
}
|
|
@@ -7,6 +7,8 @@ import { SnappingLayout } from "./SnappingLayout";
|
|
|
7
7
|
* so it must be aligned to its edge by the parent (VerticalOptions="End" for FromBottom, etc.).
|
|
8
8
|
*/
|
|
9
9
|
export class SkiaDrawer extends SnappingLayout {
|
|
10
|
+
/** Takes mouse hover unless ReceivesHover is set false (C# ReceivesHoverByDefault). */
|
|
11
|
+
ReceivesHoverByDefault() { return true; }
|
|
10
12
|
Direction = "FromBottom";
|
|
11
13
|
/** Points that stay visible when closed. */
|
|
12
14
|
HeaderSize = 0;
|
|
@@ -33,6 +35,23 @@ export class SkiaDrawer extends SnappingLayout {
|
|
|
33
35
|
if (this.SnapPoints.length === 2)
|
|
34
36
|
this.ScrollToOffset(v ? this.SnapPoints[0] : this.SnapPoints[1], SKPoint.Empty, this.Animated && this.wasDrawn);
|
|
35
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* The drawer starts moving from open to closed (IsOpen = false, a swipe release, code): raised once the move is under
|
|
40
|
+
* way, before it ends (C# internal ClosingStarted; SkiaShell takes a modal out of its stack here).
|
|
41
|
+
*/
|
|
42
|
+
ClosingStarted;
|
|
43
|
+
// the state of the snap the drawer was last sent to; IsOpen catches up with it when the move ends (C# _headingOpen)
|
|
44
|
+
headingOpen = false;
|
|
45
|
+
ScrollToOffset(target, velocity, animate) {
|
|
46
|
+
const wasHeadingOpen = this.headingOpen;
|
|
47
|
+
if (!super.ScrollToOffset(target, velocity, animate))
|
|
48
|
+
return false;
|
|
49
|
+
const hidden = this.SnapPoints[1];
|
|
50
|
+
this.headingOpen = this.SnapPoints.length < 2 || target.X !== hidden.X || target.Y !== hidden.Y;
|
|
51
|
+
if (wasHeadingOpen && !this.headingOpen)
|
|
52
|
+
this.ClosingStarted?.(this);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
36
55
|
Open() { this.IsOpen = true; }
|
|
37
56
|
Close() { this.IsOpen = false; }
|
|
38
57
|
get Horizontal() { return this.Direction === "FromLeft" || this.Direction === "FromRight"; }
|
|
@@ -106,14 +125,15 @@ export class SkiaDrawer extends SnappingLayout {
|
|
|
106
125
|
const consumedDefault = this.BlockGesturesBelow ? this : null;
|
|
107
126
|
const scale = this.RenderingScale;
|
|
108
127
|
const e = args.Event;
|
|
109
|
-
//
|
|
110
|
-
|
|
111
|
-
const
|
|
128
|
+
// touches outside its content are not ours, also when the drawer is larger than the panel it slides (C# hitContent:
|
|
129
|
+
// CheckChildGestureHit(Content)); a press there closes it with AutoClose
|
|
130
|
+
const point = new SKPoint(apply.MappedLocation.X + apply.ChildOffset.X, apply.MappedLocation.Y + apply.ChildOffset.Y);
|
|
131
|
+
const hitContent = this.GetGestureListeners().some((c) => c.IsVisible && !c.InputTransparent && this.IsGestureForChild(c, point));
|
|
112
132
|
if (!this.hadDown && args.Type !== "Up") {
|
|
113
|
-
if (!
|
|
114
|
-
if (this.AutoClose && this.isOpen && !this.InTransition)
|
|
133
|
+
if (!hitContent) {
|
|
134
|
+
if (this.AutoClose && this.isOpen && !this.InTransition && (args.Type === "Down" || args.Type === "Tapped"))
|
|
115
135
|
this.IsOpen = false;
|
|
116
|
-
return
|
|
136
|
+
return consumedDefault; // a drawer that blocks gestures below still does (C# OnSkiaGestureEvent)
|
|
117
137
|
}
|
|
118
138
|
}
|
|
119
139
|
let passed = false;
|
|
@@ -190,8 +210,10 @@ export class SkiaDrawer extends SnappingLayout {
|
|
|
190
210
|
}
|
|
191
211
|
case "Up": {
|
|
192
212
|
this.hadDown = false;
|
|
193
|
-
if (this.childWasTapped || !this.IsUserPanning)
|
|
213
|
+
if (this.childWasTapped || !this.IsUserPanning) {
|
|
214
|
+
this.FinishStoppedMove();
|
|
194
215
|
break;
|
|
216
|
+
}
|
|
195
217
|
const final = this.velocityAccumulator.CalculateFinalVelocity(3000);
|
|
196
218
|
const v = this.Horizontal ? new SKPoint(final.X, 0) : new SKPoint(0, final.Y);
|
|
197
219
|
this.CurrentSnap = this.CurrentPosition;
|
|
@@ -208,5 +230,18 @@ export class SkiaDrawer extends SnappingLayout {
|
|
|
208
230
|
return passToChildren();
|
|
209
231
|
return consumedDefault;
|
|
210
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* A Down stops a running move to a snap, so a pan can take the drawer from where it is. When the touch ends without a
|
|
235
|
+
* pan, the drawer finishes that move to the snap it was sent to (IsOpen changed in code, or a released swipe), instead
|
|
236
|
+
* of staying between its snaps (C# FinishStoppedMove).
|
|
237
|
+
*/
|
|
238
|
+
FinishStoppedMove() {
|
|
239
|
+
const target = this.CurrentSnap, at = this.CurrentPosition;
|
|
240
|
+
if (this.IsSnapAnimating || !this.SnapPoints.some((p) => p.X === target.X && p.Y === target.Y)
|
|
241
|
+
|| (Math.abs(at.X - target.X) <= 1 && Math.abs(at.Y - target.Y) <= 1))
|
|
242
|
+
return;
|
|
243
|
+
this.CurrentSnap = at;
|
|
244
|
+
this.ScrollToOffset(target, SKPoint.Empty, this.CanAnimate);
|
|
245
|
+
}
|
|
211
246
|
DefaultAccessibilityLabel() { return this.isOpen ? "Drawer open" : "Drawer closed"; }
|
|
212
247
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type DrawingContext, type SkiaControl } from "../core/SkiaControl";
|
|
2
2
|
import { type GestureEventProcessingInfo, type SkiaGesturesParameters } from "../core/Gestures";
|
|
3
3
|
import { type PrebuiltControlStyle } from "../core/ControlStyle";
|
|
4
4
|
import { type Color, type DrawTextAlignment, type ReturnType, ScaledSize, type SkiaEditorKeyboard, type SkiaGradient, type TextAlignment } from "../core/Types";
|
|
@@ -51,6 +51,8 @@ export declare class SkiaEditor extends SkiaShape {
|
|
|
51
51
|
CanShowCursor: boolean;
|
|
52
52
|
SelectionColor: Color;
|
|
53
53
|
private cursorPosition;
|
|
54
|
+
/** A caret position was given (by the app, a tap, a selection): focusing keeps it; otherwise focusing puts the caret at the end. */
|
|
55
|
+
private cursorPlaced;
|
|
54
56
|
private selectionLength;
|
|
55
57
|
private isFocused;
|
|
56
58
|
private controlStyle;
|
|
@@ -58,7 +60,8 @@ export declare class SkiaEditor extends SkiaShape {
|
|
|
58
60
|
private readonly placeholder;
|
|
59
61
|
private scrollX;
|
|
60
62
|
private scrollY;
|
|
61
|
-
|
|
63
|
+
/** The caret blinks on a timer, asleep between blinks: no frame runs while it waits (DrawnUi.Rust editor_rules). */
|
|
64
|
+
private blinkTimer;
|
|
62
65
|
private caretVisible;
|
|
63
66
|
private subscribed;
|
|
64
67
|
private stubSelectionStop;
|
|
@@ -70,6 +73,12 @@ export declare class SkiaEditor extends SkiaShape {
|
|
|
70
73
|
private styleApplied;
|
|
71
74
|
private layoutVersion;
|
|
72
75
|
private boxes;
|
|
76
|
+
/** The glyph box starting at a text index, and the one ending at it. */
|
|
77
|
+
private readonly boxAt;
|
|
78
|
+
private readonly boxEnd;
|
|
79
|
+
/** Grapheme boundaries of the text, the places a caret may stand. */
|
|
80
|
+
private stops;
|
|
81
|
+
private stopsText;
|
|
73
82
|
constructor();
|
|
74
83
|
get Text(): string;
|
|
75
84
|
set Text(v: string);
|
|
@@ -99,9 +108,14 @@ export declare class SkiaEditor extends SkiaShape {
|
|
|
99
108
|
get ShouldSubmitOnEnter(): boolean;
|
|
100
109
|
/** Caret index (UTF-16 units) = the left edge of the selection when one exists. */
|
|
101
110
|
get CursorPosition(): number;
|
|
111
|
+
/** A position from app code as a whole number: beyond the text (MAX_SAFE_INTEGER, Infinity) is the end, NaN is 0. */
|
|
112
|
+
private static Whole;
|
|
102
113
|
set CursorPosition(v: number);
|
|
103
114
|
get SelectionLength(): number;
|
|
104
115
|
set SelectionLength(v: number);
|
|
116
|
+
/** Shows the caret for a full half second, then blinks every 500 ms; while the window is inactive no caret, no timer. */
|
|
117
|
+
private StartBlink;
|
|
118
|
+
private StopBlink;
|
|
105
119
|
private OnCursorMoved;
|
|
106
120
|
get IsFocused(): boolean;
|
|
107
121
|
set IsFocused(v: boolean);
|
|
@@ -121,14 +135,36 @@ export declare class SkiaEditor extends SkiaShape {
|
|
|
121
135
|
/** Keeps the caret inside the padded box by scrolling the label (C#: SkiaScroll under the label). */
|
|
122
136
|
private ScrollToCaret;
|
|
123
137
|
private Boxes;
|
|
138
|
+
private Stops;
|
|
139
|
+
/** The laid-out line a caret index belongs to: the line holding the character before it, else the one starting at it. */
|
|
140
|
+
private static LineOf;
|
|
141
|
+
/** Where the caret before character `index` stands (label pixels): its x, the direction of the text there, its line box. */
|
|
142
|
+
private CaretPlace;
|
|
124
143
|
/** Rect of the caret before character `index` (label pixels), or undefined before the first layout. */
|
|
125
144
|
private CaretRectLabelPx;
|
|
145
|
+
/** The grapheme boundary of a line whose caret x is nearest to `x` (a tie: the smaller index). */
|
|
146
|
+
private NearestStop;
|
|
126
147
|
/** C# GetCursorPosition: the text index nearest to a point in label pixels. */
|
|
127
148
|
private HitTestIndex;
|
|
149
|
+
/**
|
|
150
|
+
* Left / Right from a caret index: the grapheme boundary on its line whose caret x is nearest that way (equal x: the
|
|
151
|
+
* one logically nearest); at the visual edge of the line one grapheme logically, forward for Right in a
|
|
152
|
+
* left-to-right paragraph and backward in a right-to-left one (Left the other way round).
|
|
153
|
+
*/
|
|
154
|
+
private VisualTarget;
|
|
128
155
|
private LabelPoint;
|
|
129
156
|
protected Paint(ctx: DrawingContext): void;
|
|
130
157
|
ProcessGestures(args: SkiaGesturesParameters, apply: GestureEventProcessingInfo): SkiaControl | null;
|
|
158
|
+
/** The canvas gives or takes the focus (a tap elsewhere): an editor always takes it. */
|
|
159
|
+
SetFrameworkFocus(focus: boolean): boolean;
|
|
160
|
+
/** A text field is a Tab stop by default, like a native text box, with no Tapped handler needed. */
|
|
161
|
+
protected DefaultAccessibilityCanInteract(): boolean;
|
|
162
|
+
/** Keyboard navigation reached the field (Tab) or left it: take the caret and the input sink like a native text box, or release them. */
|
|
163
|
+
OnAccessibilityFocused(focused: boolean): void;
|
|
164
|
+
/** Enter / Space on the field while it has no caret start editing; while editing they are text. */
|
|
131
165
|
OnAccessibilityActivated(): void;
|
|
166
|
+
/** While editing, arrows, Home / End and PageUp / PageDown belong to the text: they never move a surrounding group. */
|
|
167
|
+
OnAccessibilityKey(_key: string): boolean;
|
|
132
168
|
protected DefaultAccessibilityLabel(): string | undefined;
|
|
133
169
|
Submit(): void;
|
|
134
170
|
private ExecuteSubmit;
|
|
@@ -144,6 +180,11 @@ export declare class SkiaEditor extends SkiaShape {
|
|
|
144
180
|
PasteFromClipboard(): void;
|
|
145
181
|
private ReplaceSelection;
|
|
146
182
|
private SetFocusNative;
|
|
183
|
+
private windowCanvas?;
|
|
184
|
+
/** The window lost the keyboard: the caret hides and stops blinking (no redraws); back: it shows again in this field. */
|
|
185
|
+
private readonly onWindowActive;
|
|
186
|
+
/** Removed from the canvas while focused: the editing ends (caret timer, keys, text proxy). */
|
|
187
|
+
OnLeftCanvas(): void;
|
|
147
188
|
private OnKeyDown;
|
|
148
189
|
StubTypeText(value: string): void;
|
|
149
190
|
StubPressEnter(splitLine?: boolean, shift?: boolean): void;
|
|
@@ -151,6 +192,11 @@ export declare class SkiaEditor extends SkiaShape {
|
|
|
151
192
|
StubDelete(count?: number): void;
|
|
152
193
|
/** Arrow / Home / End: the anchor stays, the moving edge follows (shift), or the selection collapses in the move direction. */
|
|
153
194
|
StubMoveCursor(delta: number, extendSelection?: boolean): void;
|
|
195
|
+
/**
|
|
196
|
+
* Arrow Left (-1) / Right (1): visual moves, as native text fields (see VisualTarget). Without Shift a selection
|
|
197
|
+
* collapses to its visually left (Left) or right (Right) edge; with Shift its moving edge moves.
|
|
198
|
+
*/
|
|
199
|
+
MoveVisual(dir: -1 | 1, extendSelection?: boolean): void;
|
|
154
200
|
StubSelectRange(start: number, length: number): void;
|
|
155
201
|
StubSelectAll(): void;
|
|
156
202
|
/** Up / Down keep the caret x on the neighbouring line (C# HandleVerticalArrow). */
|