drawnui-react 0.1.0-preview.41 → 0.1.0-preview.43
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 +89 -7
- package/SKIPPED.md +7 -7
- package/dist/controls/GridStructure.d.ts +9 -1
- package/dist/controls/GridStructure.js +41 -1
- package/dist/controls/SkiaEditor.d.ts +4 -1
- package/dist/controls/SkiaEditor.js +25 -6
- package/dist/controls/SkiaImage.d.ts +5 -0
- package/dist/controls/SkiaImage.js +32 -5
- package/dist/controls/SkiaLabel.d.ts +85 -4
- package/dist/controls/SkiaLabel.js +406 -20
- package/dist/controls/SkiaLabelFps.d.ts +0 -3
- package/dist/controls/SkiaLabelFps.js +1 -11
- package/dist/controls/SkiaLayout.js +33 -2
- package/dist/controls/SkiaScroll.d.ts +51 -2
- package/dist/controls/SkiaScroll.js +150 -9
- package/dist/controls/SkiaShape.d.ts +2 -0
- package/dist/controls/SkiaShape.js +7 -0
- package/dist/controls/SkiaShell.d.ts +282 -0
- package/dist/controls/SkiaShell.js +972 -0
- package/dist/controls/SkiaSprite.js +5 -1
- package/dist/core/Accessibility.d.ts +30 -13
- package/dist/core/Accessibility.js +237 -43
- package/dist/core/Canvas.d.ts +122 -14
- package/dist/core/Canvas.js +585 -47
- package/dist/core/Gestures.d.ts +11 -1
- package/dist/core/Gestures.js +12 -1
- package/dist/core/PopupWindows.js +2 -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 +7 -1
- package/dist/core/SkiaControl.d.ts +24 -4
- package/dist/core/SkiaControl.js +59 -13
- package/dist/core/SkiaEffect.d.ts +12 -1
- package/dist/core/SkiaEffect.js +35 -8
- 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 +4 -0
- package/dist/core/Super.js +4 -9
- package/dist/core/TextInputProxy.d.ts +31 -1
- package/dist/core/TextInputProxy.js +97 -15
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/react/SkiaShell.d.ts +8 -74
- package/dist/react/SkiaShell.js +163 -514
- package/dist/react/index.d.ts +6 -1
- package/dist/react/index.js +51 -40
- package/dist/react/reconciler.d.ts +12 -0
- package/dist/react/reconciler.js +22 -46
- package/package.json +37 -4
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { DrawingContext } from "../core/SkiaControl";
|
|
2
|
-
import type { SKRect } from "../core/Types";
|
|
3
2
|
import { SkiaLabel } from "./SkiaLabel";
|
|
4
3
|
/**
|
|
5
4
|
* Mirrors DrawnUi SkiaLabelFps: a label showing the canvas FPS, drawn above its siblings, input-transparent, never
|
|
@@ -10,7 +9,5 @@ import { SkiaLabel } from "./SkiaLabel";
|
|
|
10
9
|
*/
|
|
11
10
|
export declare class SkiaLabelFps extends SkiaLabel {
|
|
12
11
|
constructor();
|
|
13
|
-
private arrangedIn?;
|
|
14
|
-
Arrange(destination: SKRect, widthRequest: number, heightRequest: number, scale: number): void;
|
|
15
12
|
Render(ctx: DrawingContext): void;
|
|
16
13
|
}
|
|
@@ -20,22 +20,12 @@ export class SkiaLabelFps extends SkiaLabel {
|
|
|
20
20
|
this.InputTransparent = true;
|
|
21
21
|
this.ZIndex = Number.MAX_SAFE_INTEGER;
|
|
22
22
|
}
|
|
23
|
-
arrangedIn;
|
|
24
|
-
Arrange(destination, widthRequest, heightRequest, scale) {
|
|
25
|
-
this.arrangedIn = destination;
|
|
26
|
-
super.Arrange(destination, widthRequest, heightRequest, scale);
|
|
27
|
-
}
|
|
28
23
|
Render(ctx) {
|
|
29
24
|
const view = this.Superview;
|
|
30
25
|
// the frame this asks for is requested anyway by the running animators
|
|
31
26
|
if (view && view.AnimatingControls.size > 0)
|
|
32
27
|
this.Text = `FPS ${view.FPS.toFixed(1).padStart(4, "0")}`;
|
|
33
|
-
// parent-independent:
|
|
34
|
-
const d = this.arrangedIn;
|
|
35
|
-
if (this.NeedMeasure && d) {
|
|
36
|
-
this.Measure(d.Width, d.Height, ctx.Scale);
|
|
37
|
-
this.Arrange(d, this.WidthRequest, this.HeightRequest, ctx.Scale);
|
|
38
|
-
}
|
|
28
|
+
// parent-independent: it measures itself again in its slot as it draws (SkiaControl.Render)
|
|
39
29
|
super.Render(ctx);
|
|
40
30
|
}
|
|
41
31
|
}
|
|
@@ -554,6 +554,33 @@ export class SkiaLayout extends SkiaControl {
|
|
|
554
554
|
cw += (v.VerticalOptions === "Fill" && v.HeightRequest < 0 ? v.Measure(Infinity, size, scale) : v.MeasuredSize).Pixels.Width;
|
|
555
555
|
}
|
|
556
556
|
}
|
|
557
|
+
else if (this.Type !== "Column" && this.Type !== "Row" && this.LockRatio === 0) {
|
|
558
|
+
// a layer without its own size on an axis is as big as its children there, where a Fill child with no content of
|
|
559
|
+
// its own (a background shape, a backdrop) counts only with its requests: it takes the layer's size, measured again
|
|
560
|
+
// at it (as DrawnUI for Rust and .NET). A Fill child with content still sizes the layer as before.
|
|
561
|
+
const autoW = (this.HorizontalOptions !== "Fill" || !isFinite(w)) && this.WidthRequest < 0;
|
|
562
|
+
const autoH = (this.VerticalOptions !== "Fill" || !isFinite(h)) && this.HeightRequest < 0;
|
|
563
|
+
if (autoW || autoH) {
|
|
564
|
+
const emptyX = (v) => v.HorizontalOptions === "Fill" && v.WidthRequest < 0 && v.FitPixels.Width - v.Margin.HorizontalThickness * scale <= 0;
|
|
565
|
+
const emptyY = (v) => v.VerticalOptions === "Fill" && v.HeightRequest < 0 && v.FitPixels.Height - v.Margin.VerticalThickness * scale <= 0;
|
|
566
|
+
let sw = 0, sh = 0;
|
|
567
|
+
for (const v of visible) {
|
|
568
|
+
sw = Math.max(sw, emptyX(v) ? v.FitPixels.Width : v.MeasuredSize.Pixels.Width);
|
|
569
|
+
sh = Math.max(sh, emptyY(v) ? v.FitPixels.Height : v.MeasuredSize.Pixels.Height);
|
|
570
|
+
}
|
|
571
|
+
if (!autoW)
|
|
572
|
+
sw = cw;
|
|
573
|
+
if (!autoH)
|
|
574
|
+
sh = ch;
|
|
575
|
+
if (sw !== cw || sh !== ch) {
|
|
576
|
+
cw = sw;
|
|
577
|
+
ch = sh;
|
|
578
|
+
for (const v of visible)
|
|
579
|
+
if ((autoW && emptyX(v)) || (autoH && emptyY(v)))
|
|
580
|
+
v.Measure(autoW ? sw : w, autoH ? sh : h, scale);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
557
584
|
const gaps = Math.max(0, n - 1) * gap;
|
|
558
585
|
if (this.Type === "Column")
|
|
559
586
|
ch += gaps;
|
|
@@ -905,17 +932,21 @@ export class SkiaLayout extends SkiaControl {
|
|
|
905
932
|
}
|
|
906
933
|
return;
|
|
907
934
|
}
|
|
935
|
+
// main axis of a stack: an End child gets the room up to the end of the stack, so it sits there (a button after a
|
|
936
|
+
// text in a full-width row); every child still takes only its measured size from the flow (DrawnUI for Rust)
|
|
908
937
|
for (const v of this.LayoutViews()) {
|
|
909
938
|
if (!v.IsVisible)
|
|
910
939
|
continue;
|
|
911
940
|
if (this.Type === "Column") {
|
|
912
941
|
const h = v.MeasuredSize.Pixels.Height;
|
|
913
|
-
v.
|
|
942
|
+
const end = v.VerticalOptions === "End" ? Math.max(inner.Bottom, cursor + h) : cursor + h;
|
|
943
|
+
v.Arrange(new SKRect(inner.Left, cursor, inner.Right, end), v.WidthRequest, v.HeightRequest, scale);
|
|
914
944
|
cursor += h + gap;
|
|
915
945
|
}
|
|
916
946
|
else if (this.Type === "Row") {
|
|
917
947
|
const w = v.MeasuredSize.Pixels.Width;
|
|
918
|
-
v.
|
|
948
|
+
const end = v.HorizontalOptions === "End" ? Math.max(inner.Right, cursor + w) : cursor + w;
|
|
949
|
+
v.Arrange(new SKRect(cursor, inner.Top, end, inner.Bottom), v.WidthRequest, v.HeightRequest, scale);
|
|
919
950
|
cursor += w + gap;
|
|
920
951
|
}
|
|
921
952
|
else {
|
|
@@ -16,6 +16,11 @@ export interface ScaledPoint {
|
|
|
16
16
|
*/
|
|
17
17
|
export declare class SkiaScroll extends SkiaControl {
|
|
18
18
|
static WheelLineSize: number;
|
|
19
|
+
/**
|
|
20
|
+
* Wheel events closer than this (ms) are one wheel gesture: they keep the scroll they started on, as browsers latch a
|
|
21
|
+
* scroller (C# SkiaScroll.WheelGestureGapMs, drawnui-cross 6bo).
|
|
22
|
+
*/
|
|
23
|
+
static WheelGestureGapMs: number;
|
|
19
24
|
static ThesholdSwipeOnUp: number;
|
|
20
25
|
static ScrollVelocityThreshold: number;
|
|
21
26
|
Orientation: ScrollOrientation;
|
|
@@ -192,6 +197,35 @@ export declare class SkiaScroll extends SkiaControl {
|
|
|
192
197
|
/** Content gets an infinite constraint along the scroll axis; the scroll itself takes the box it is given. */
|
|
193
198
|
protected MeasureAbsolute(widthConstraint: number, heightConstraint: number, scale: number): ScaledSize;
|
|
194
199
|
protected OnLayoutChanged(): void;
|
|
200
|
+
/**
|
|
201
|
+
* When true, the canvas keeps the focused text field of this scroll above the on-screen keyboard by itself (it sets
|
|
202
|
+
* AdaptToKeyboardFor and AdaptToKeyboardSize), and while the keyboard is up the part of the viewport it covers is room at
|
|
203
|
+
* the content end, so the last fields rise above it too. Off by default: an app that wires those two itself keeps doing so.
|
|
204
|
+
*/
|
|
205
|
+
AdaptToKeyboardAuto: boolean;
|
|
206
|
+
/** Points kept between the bottom of AdaptToKeyboardFor and the keyboard's top (8 by default). */
|
|
207
|
+
AdaptToKeyboardGap: number;
|
|
208
|
+
private adaptFor?;
|
|
209
|
+
private adaptSize;
|
|
210
|
+
private keyboardInset;
|
|
211
|
+
private adaptPending;
|
|
212
|
+
/** The field to keep above the keyboard (set by the app, or by the canvas with AdaptToKeyboardAuto). */
|
|
213
|
+
get AdaptToKeyboardFor(): SkiaControl | undefined;
|
|
214
|
+
set AdaptToKeyboardFor(v: SkiaControl | undefined);
|
|
215
|
+
/** Points of the canvas, from its bottom, the keyboard covers (0 = no keyboard). */
|
|
216
|
+
get AdaptToKeyboardSize(): number;
|
|
217
|
+
set AdaptToKeyboardSize(v: number);
|
|
218
|
+
/**
|
|
219
|
+
* After the keyboard or the focused field changed: scrolls so the field shows above the keyboard. A field already
|
|
220
|
+
* visible, or the keyboard closing, leaves the page where it is (the keyboard closing settles a page scrolled into the
|
|
221
|
+
* keyboard's room at the content end). One adaptation for the field and the size set together.
|
|
222
|
+
*/
|
|
223
|
+
AdaptToKeyboard(): void;
|
|
224
|
+
/** The keyboard's top in canvas points, from AdaptToKeyboardSize; NaN without one. */
|
|
225
|
+
private KeyboardTopPts;
|
|
226
|
+
private UpdateKeyboardInset;
|
|
227
|
+
/** Where the scroll must go so the field's bottom sits AdaptToKeyboardGap above the keyboard; NaN = nothing to move. */
|
|
228
|
+
CalculateNeededScrollForKeyboard(): number;
|
|
195
229
|
/** Places Content at the current offset; called on layout and every frame while the offset moves. */
|
|
196
230
|
private ArrangeContent;
|
|
197
231
|
/** Header: sticky = pinned at the viewport start, else scrolled at HeaderParallaxRatio of the offset; footer after the content. */
|
|
@@ -206,9 +240,10 @@ export declare class SkiaScroll extends SkiaControl {
|
|
|
206
240
|
/** Scroll to an offset in points; maxSpeedSecs > 0 animates along the deceleration curve. */
|
|
207
241
|
/**
|
|
208
242
|
* Scrolls every SkiaScroll ancestor of `control` so its DrawingRect lies inside the viewport (React extension,
|
|
209
|
-
* used by the accessibility overlay when keyboard focus lands on an off-screen node). Offsets are points.
|
|
243
|
+
* used by the accessibility overlay when keyboard focus lands on an off-screen node). Offsets are points. Returns the
|
|
244
|
+
* scrolls that move.
|
|
210
245
|
*/
|
|
211
|
-
static EnsureVisible(control: SkiaControl, maxTimeSecs?: number, paddingPts?: number):
|
|
246
|
+
static EnsureVisible(control: SkiaControl, maxTimeSecs?: number, paddingPts?: number): SkiaScroll[];
|
|
212
247
|
/** Destination of the running ScrollTo per axis: the deceleration curve stops within its threshold, the exact value is applied when it finishes. */
|
|
213
248
|
private scrollToTargetX;
|
|
214
249
|
private scrollToTargetY;
|
|
@@ -240,6 +275,8 @@ export declare class SkiaScroll extends SkiaControl {
|
|
|
240
275
|
private ResetPan;
|
|
241
276
|
private draggedScrollBar?;
|
|
242
277
|
private scrollBarOwnsGesture;
|
|
278
|
+
/** The gesture going on started on a draggable scroll bar: it is the bar's (a page text selection does not start there). */
|
|
279
|
+
get ScrollBarOwnsGesture(): boolean;
|
|
243
280
|
/**
|
|
244
281
|
* Thumb drag and track press on a ScrollBar / ScrollBarHorizontal with IsDraggable set (C# ProcessScrollBarGestures).
|
|
245
282
|
* A gesture that starts on the bar belongs to it until the next down: the content neither pans nor gets the tap.
|
|
@@ -257,5 +294,17 @@ export declare class SkiaScroll extends SkiaControl {
|
|
|
257
294
|
* aaa871c3); an event under half a notch moves the content at once (no glide). Events arriving while the previous one is still animating add onto its target, so a fast wheel spin
|
|
258
295
|
* travels N steps instead of restarting from the barely-moved current offset.
|
|
259
296
|
*/
|
|
297
|
+
/**
|
|
298
|
+
* drawnui-cross 6bo (DrawnUi.Rust leaves_drag_to_outer), asked once, when this scroll would take a drag: already at its
|
|
299
|
+
* end in the drag's direction (at its start dragged back, at its end dragged on) with a scroll around it moving on the
|
|
300
|
+
* same axis, the outer scroll takes the whole drag. Never toward the start with pull to refresh on; a scroll with nothing
|
|
301
|
+
* around it keeps its edge bounce. Otherwise this scroll keeps the drag to its end.
|
|
302
|
+
*/
|
|
303
|
+
private LeavesDragToOuter;
|
|
304
|
+
private static Contains;
|
|
305
|
+
/** The scroll the current wheel gesture belongs to, and its last event time. */
|
|
306
|
+
private static wheelLatch?;
|
|
307
|
+
/** It scrolls with the wheel on this axis (a vertical scroll leaves the sideways part of a diagonal swipe to what is around it). */
|
|
308
|
+
private WheelUsable;
|
|
260
309
|
private ApplyWheelScroll;
|
|
261
310
|
}
|
|
@@ -13,6 +13,11 @@ import { RubberBandUtils, ScrollFlingAnimator, Spring, SpringWithVelocityAnimato
|
|
|
13
13
|
*/
|
|
14
14
|
export class SkiaScroll extends SkiaControl {
|
|
15
15
|
static WheelLineSize = 150;
|
|
16
|
+
/**
|
|
17
|
+
* Wheel events closer than this (ms) are one wheel gesture: they keep the scroll they started on, as browsers latch a
|
|
18
|
+
* scroller (C# SkiaScroll.WheelGestureGapMs, drawnui-cross 6bo).
|
|
19
|
+
*/
|
|
20
|
+
static WheelGestureGapMs = 300;
|
|
16
21
|
static ThesholdSwipeOnUp = 20;
|
|
17
22
|
static ScrollVelocityThreshold = 5;
|
|
18
23
|
Orientation = "Vertical";
|
|
@@ -584,7 +589,8 @@ export class SkiaScroll extends SkiaControl {
|
|
|
584
589
|
const viewportW = this.DrawingRect.Width / scale, viewportH = this.DrawingRect.Height / scale;
|
|
585
590
|
const extra = this.HeaderExtentPts + this.FooterExtentPts;
|
|
586
591
|
const width = Math.max(0, this.ContentSize.Units.Width + (this.Orientation === "Horizontal" ? extra : 0) - viewportW);
|
|
587
|
-
|
|
592
|
+
// with the keyboard up (AdaptToKeyboardAuto), its cover of the viewport is room at the content end
|
|
593
|
+
const height = Math.max(0, this.ContentSize.Units.Height + (this.Orientation !== "Horizontal" ? extra + this.keyboardInset : 0) - viewportH);
|
|
588
594
|
this.ContentOffsetBounds = new SKRect(-width, -height, 0, 0);
|
|
589
595
|
// C# InitializeViewport: pull an offset the new bounds no longer contain back inside them, here where
|
|
590
596
|
// the bounds change. Shrinking content (fewer items) otherwise leaves the viewport parked past its end
|
|
@@ -598,6 +604,94 @@ export class SkiaScroll extends SkiaControl {
|
|
|
598
604
|
this.ArrangeContent();
|
|
599
605
|
this.CheckLoadMore();
|
|
600
606
|
}
|
|
607
|
+
// ---- the on-screen keyboard (C# SkiaScroll ScrollViewKeyboardAwareBehavior, drawnui-cross 6cj) ----
|
|
608
|
+
/**
|
|
609
|
+
* When true, the canvas keeps the focused text field of this scroll above the on-screen keyboard by itself (it sets
|
|
610
|
+
* AdaptToKeyboardFor and AdaptToKeyboardSize), and while the keyboard is up the part of the viewport it covers is room at
|
|
611
|
+
* the content end, so the last fields rise above it too. Off by default: an app that wires those two itself keeps doing so.
|
|
612
|
+
*/
|
|
613
|
+
AdaptToKeyboardAuto = false;
|
|
614
|
+
/** Points kept between the bottom of AdaptToKeyboardFor and the keyboard's top (8 by default). */
|
|
615
|
+
AdaptToKeyboardGap = 8;
|
|
616
|
+
adaptFor;
|
|
617
|
+
adaptSize = 0;
|
|
618
|
+
keyboardInset = 0;
|
|
619
|
+
adaptPending = false;
|
|
620
|
+
/** The field to keep above the keyboard (set by the app, or by the canvas with AdaptToKeyboardAuto). */
|
|
621
|
+
get AdaptToKeyboardFor() { return this.adaptFor; }
|
|
622
|
+
set AdaptToKeyboardFor(v) { if (this.adaptFor !== v) {
|
|
623
|
+
this.adaptFor = v;
|
|
624
|
+
this.AdaptToKeyboard();
|
|
625
|
+
} }
|
|
626
|
+
/** Points of the canvas, from its bottom, the keyboard covers (0 = no keyboard). */
|
|
627
|
+
get AdaptToKeyboardSize() { return this.adaptSize; }
|
|
628
|
+
set AdaptToKeyboardSize(v) { if (this.adaptSize !== v) {
|
|
629
|
+
this.adaptSize = v;
|
|
630
|
+
this.AdaptToKeyboard();
|
|
631
|
+
} }
|
|
632
|
+
/**
|
|
633
|
+
* After the keyboard or the focused field changed: scrolls so the field shows above the keyboard. A field already
|
|
634
|
+
* visible, or the keyboard closing, leaves the page where it is (the keyboard closing settles a page scrolled into the
|
|
635
|
+
* keyboard's room at the content end). One adaptation for the field and the size set together.
|
|
636
|
+
*/
|
|
637
|
+
AdaptToKeyboard() {
|
|
638
|
+
if (this.adaptPending)
|
|
639
|
+
return;
|
|
640
|
+
this.adaptPending = true;
|
|
641
|
+
setTimeout(() => {
|
|
642
|
+
this.adaptPending = false;
|
|
643
|
+
if (this.IsDisposed)
|
|
644
|
+
return;
|
|
645
|
+
this.UpdateKeyboardInset();
|
|
646
|
+
const to = this.CalculateNeededScrollForKeyboard();
|
|
647
|
+
if (!Number.isNaN(to)) {
|
|
648
|
+
this.ViewportOffsetY = to;
|
|
649
|
+
this.Repaint();
|
|
650
|
+
}
|
|
651
|
+
}, 150);
|
|
652
|
+
}
|
|
653
|
+
/** The keyboard's top in canvas points, from AdaptToKeyboardSize; NaN without one. */
|
|
654
|
+
KeyboardTopPts() {
|
|
655
|
+
const canvas = this.Superview;
|
|
656
|
+
if (!canvas || this.adaptSize <= 0)
|
|
657
|
+
return Number.NaN;
|
|
658
|
+
return canvas.Element.height / (this.RenderingScale || 1) - this.adaptSize;
|
|
659
|
+
}
|
|
660
|
+
UpdateKeyboardInset() {
|
|
661
|
+
let inset = 0;
|
|
662
|
+
const top = this.KeyboardTopPts();
|
|
663
|
+
if (this.AdaptToKeyboardAuto && !Number.isNaN(top) && this.Orientation === "Vertical") {
|
|
664
|
+
const covered = this.GetAccessibilityPixelRect().Bottom / (this.RenderingScale || 1) - top;
|
|
665
|
+
// the gap too: the last field rests that far above the keyboard
|
|
666
|
+
if (covered > 0)
|
|
667
|
+
inset = covered + Math.max(0, this.AdaptToKeyboardGap);
|
|
668
|
+
}
|
|
669
|
+
if (Math.abs(inset - this.keyboardInset) < 0.5)
|
|
670
|
+
return;
|
|
671
|
+
const shrinking = inset < this.keyboardInset;
|
|
672
|
+
this.keyboardInset = inset;
|
|
673
|
+
const viewportH = this.DrawingRect.Height / (this.RenderingScale || 1);
|
|
674
|
+
const height = Math.max(0, this.ContentSize.Units.Height + this.HeaderExtentPts + this.FooterExtentPts + inset - viewportH);
|
|
675
|
+
this.ContentOffsetBounds = new SKRect(this.ContentOffsetBounds.Left, -height, this.ContentOffsetBounds.Right, 0);
|
|
676
|
+
// the keyboard closed: content past the new end settles at the end, animated, as native scroll views do
|
|
677
|
+
if (shrinking && this.offsetY < -height && !this.IsUserPanning)
|
|
678
|
+
this.ScrollTo(this.offsetX, -height, this.AutoScrollingSpeedMs / 1000, true);
|
|
679
|
+
this.Repaint();
|
|
680
|
+
}
|
|
681
|
+
/** Where the scroll must go so the field's bottom sits AdaptToKeyboardGap above the keyboard; NaN = nothing to move. */
|
|
682
|
+
CalculateNeededScrollForKeyboard() {
|
|
683
|
+
const field = this.adaptFor, top = this.KeyboardTopPts();
|
|
684
|
+
if (!field || Number.isNaN(top) || !this.Superview)
|
|
685
|
+
return Number.NaN;
|
|
686
|
+
this.StopScrolling();
|
|
687
|
+
const k = this.RenderingScale || 1;
|
|
688
|
+
const f = field.GetAccessibilityPixelRect(), viewport = this.GetAccessibilityPixelRect();
|
|
689
|
+
if (f.Width <= 0 || f.Height <= 0)
|
|
690
|
+
return Number.NaN;
|
|
691
|
+
const visibleBottom = Math.min(viewport.Bottom, top * k);
|
|
692
|
+
const need = (f.Bottom - visibleBottom) / k + this.AdaptToKeyboardGap;
|
|
693
|
+
return need > 0 ? this.offsetY - need : Number.NaN;
|
|
694
|
+
}
|
|
601
695
|
/** Places Content at the current offset; called on layout and every frame while the offset moves. */
|
|
602
696
|
ArrangeContent() {
|
|
603
697
|
const c = this.content;
|
|
@@ -714,9 +808,11 @@ export class SkiaScroll extends SkiaControl {
|
|
|
714
808
|
/** Scroll to an offset in points; maxSpeedSecs > 0 animates along the deceleration curve. */
|
|
715
809
|
/**
|
|
716
810
|
* Scrolls every SkiaScroll ancestor of `control` so its DrawingRect lies inside the viewport (React extension,
|
|
717
|
-
* used by the accessibility overlay when keyboard focus lands on an off-screen node). Offsets are points.
|
|
811
|
+
* used by the accessibility overlay when keyboard focus lands on an off-screen node). Offsets are points. Returns the
|
|
812
|
+
* scrolls that move.
|
|
718
813
|
*/
|
|
719
814
|
static EnsureVisible(control, maxTimeSecs = 0.25, paddingPts = 8) {
|
|
815
|
+
const moved = [];
|
|
720
816
|
let p = control.Parent;
|
|
721
817
|
while (p) {
|
|
722
818
|
if (p instanceof SkiaScroll) {
|
|
@@ -731,11 +827,14 @@ export class SkiaScroll extends SkiaControl {
|
|
|
731
827
|
dx = (v.Left - r.Left) / scale + paddingPts;
|
|
732
828
|
else if (r.Right > v.Right)
|
|
733
829
|
dx = -((r.Right - v.Right) / scale + paddingPts);
|
|
734
|
-
if (dx !== 0 || dy !== 0)
|
|
830
|
+
if (dx !== 0 || dy !== 0) {
|
|
735
831
|
p.ScrollTo(p.offsetX + dx, p.offsetY + dy, maxTimeSecs);
|
|
832
|
+
moved.push(p);
|
|
833
|
+
}
|
|
736
834
|
}
|
|
737
835
|
p = p.Parent;
|
|
738
836
|
}
|
|
837
|
+
return moved;
|
|
739
838
|
}
|
|
740
839
|
/** Destination of the running ScrollTo per axis: the deceleration curve stops within its threshold, the exact value is applied when it finishes. */
|
|
741
840
|
scrollToTargetX = null;
|
|
@@ -918,6 +1017,8 @@ export class SkiaScroll extends SkiaControl {
|
|
|
918
1017
|
}
|
|
919
1018
|
draggedScrollBar;
|
|
920
1019
|
scrollBarOwnsGesture = false;
|
|
1020
|
+
/** The gesture going on started on a draggable scroll bar: it is the bar's (a page text selection does not start there). */
|
|
1021
|
+
get ScrollBarOwnsGesture() { return this.scrollBarOwnsGesture; }
|
|
921
1022
|
/**
|
|
922
1023
|
* Thumb drag and track press on a ScrollBar / ScrollBarHorizontal with IsDraggable set (C# ProcessScrollBarGestures).
|
|
923
1024
|
* A gesture that starts on the bar belongs to it until the next down: the content neither pans nor gets the tap.
|
|
@@ -989,17 +1090,26 @@ export class SkiaScroll extends SkiaControl {
|
|
|
989
1090
|
return super.ProcessGestures(args, apply) ?? consumedDefault; // children see Down (buttons press)
|
|
990
1091
|
}
|
|
991
1092
|
if (args.Type === "Wheel") {
|
|
1093
|
+
// one wheel gesture keeps the scroll it started on (6bo): a scroll inside this one that took it keeps it, also at
|
|
1094
|
+
// its end (the page waits for the next gesture); one this scroll took is not given to a list that comes under the pointer
|
|
1095
|
+
const now = performance.now(), latch = SkiaScroll.wheelLatch;
|
|
1096
|
+
const latched = latch && now - latch.At < SkiaScroll.WheelGestureGapMs && !latch.Scroll.IsDisposed && latch.Scroll.Superview ? latch.Scroll : undefined;
|
|
1097
|
+
if (latched && latched !== this && SkiaScroll.Contains(this, latched)) {
|
|
1098
|
+
latch.At = now;
|
|
1099
|
+
if (latched.WheelUsable(e.Wheel.IsHorizontal))
|
|
1100
|
+
latched.ApplyWheelScroll(e.Wheel.Delta);
|
|
1101
|
+
e.Handled = true;
|
|
1102
|
+
return latched;
|
|
1103
|
+
}
|
|
992
1104
|
// a nested scroll under the pointer takes the wheel first; the outer one scrolls when the inner is at its edge
|
|
993
|
-
const child = super.ProcessGestures(args, apply);
|
|
1105
|
+
const child = latched === this ? null : super.ProcessGestures(args, apply);
|
|
994
1106
|
if (child && child !== this)
|
|
995
1107
|
return child;
|
|
996
|
-
if (!this.
|
|
997
|
-
return child ?? consumedDefault; //
|
|
998
|
-
// a vertical scroll leaves horizontal events (the sideways part of a diagonal swipe) to whatever is around it
|
|
999
|
-
if (e.Wheel.IsHorizontal && this.Orientation === "Vertical")
|
|
1000
|
-
return child ?? consumedDefault;
|
|
1108
|
+
if (!this.WheelUsable(e.Wheel.IsHorizontal))
|
|
1109
|
+
return child ?? consumedDefault; // not used, a parent scroll may take it
|
|
1001
1110
|
if (!this.ApplyWheelScroll(e.Wheel.Delta))
|
|
1002
1111
|
return consumedDefault; // at its edge: not used, the page may take it
|
|
1112
|
+
SkiaScroll.wheelLatch = { Scroll: this, At: now };
|
|
1003
1113
|
e.Handled = true;
|
|
1004
1114
|
return this;
|
|
1005
1115
|
}
|
|
@@ -1024,6 +1134,8 @@ export class SkiaScroll extends SkiaControl {
|
|
|
1024
1134
|
const v = this.Orientation === "Vertical" ? this.velocityY : this.Orientation === "Horizontal" ? this.velocityX : Math.max(Math.abs(this.velocityX), Math.abs(this.velocityY));
|
|
1025
1135
|
if (Math.abs(v) <= SkiaScroll.ScrollVelocityThreshold)
|
|
1026
1136
|
return consumedDefault;
|
|
1137
|
+
if (this.LeavesDragToOuter(e.Distance.Total))
|
|
1138
|
+
return null; // not used: the scroll around it takes the whole drag
|
|
1027
1139
|
}
|
|
1028
1140
|
if (!this.IsUserFocused)
|
|
1029
1141
|
this.ResetPan();
|
|
@@ -1143,6 +1255,35 @@ export class SkiaScroll extends SkiaControl {
|
|
|
1143
1255
|
* aaa871c3); an event under half a notch moves the content at once (no glide). Events arriving while the previous one is still animating add onto its target, so a fast wheel spin
|
|
1144
1256
|
* travels N steps instead of restarting from the barely-moved current offset.
|
|
1145
1257
|
*/
|
|
1258
|
+
/**
|
|
1259
|
+
* drawnui-cross 6bo (DrawnUi.Rust leaves_drag_to_outer), asked once, when this scroll would take a drag: already at its
|
|
1260
|
+
* end in the drag's direction (at its start dragged back, at its end dragged on) with a scroll around it moving on the
|
|
1261
|
+
* same axis, the outer scroll takes the whole drag. Never toward the start with pull to refresh on; a scroll with nothing
|
|
1262
|
+
* around it keeps its edge bounce. Otherwise this scroll keeps the drag to its end.
|
|
1263
|
+
*/
|
|
1264
|
+
LeavesDragToOuter(total) {
|
|
1265
|
+
const vertical = this.Orientation === "Vertical" || (this.Orientation === "Both" && Math.abs(total.Y) >= Math.abs(total.X));
|
|
1266
|
+
const d = vertical ? total.Y : total.X; // finger down / right = toward the start (offset grows to 0)
|
|
1267
|
+
if (d === 0 || (d > 0 && this.RefreshEnabled))
|
|
1268
|
+
return false;
|
|
1269
|
+
const b = this.ContentOffsetBounds;
|
|
1270
|
+
const offset = vertical ? this.offsetY : this.offsetX;
|
|
1271
|
+
if (d > 0 ? offset < (vertical ? b.Bottom : b.Right) : offset > (vertical ? b.Top : b.Left))
|
|
1272
|
+
return false;
|
|
1273
|
+
for (let p = this.Parent; p; p = p.Parent)
|
|
1274
|
+
if (p instanceof SkiaScroll && p.RespondsToGestures && p.Orientation !== "Neither" && p.Orientation !== (vertical ? "Horizontal" : "Vertical"))
|
|
1275
|
+
return true;
|
|
1276
|
+
return false;
|
|
1277
|
+
}
|
|
1278
|
+
static Contains(root, c) { for (let p = c.Parent; p; p = p.Parent)
|
|
1279
|
+
if (p === root)
|
|
1280
|
+
return true; return false; }
|
|
1281
|
+
/** The scroll the current wheel gesture belongs to, and its last event time. */
|
|
1282
|
+
static wheelLatch;
|
|
1283
|
+
/** It scrolls with the wheel on this axis (a vertical scroll leaves the sideways part of a diagonal swipe to what is around it). */
|
|
1284
|
+
WheelUsable(horizontal) {
|
|
1285
|
+
return this.RespondsToGestures && this.Orientation !== "Neither" && !(horizontal && this.Orientation === "Vertical");
|
|
1286
|
+
}
|
|
1146
1287
|
ApplyWheelScroll(delta) {
|
|
1147
1288
|
const perNotch = this.Superview?.WheelDeltaPerNotch ?? 0;
|
|
1148
1289
|
const lines = perNotch > 0 ? delta / perNotch : Math.sign(delta);
|
|
@@ -64,6 +64,8 @@ export declare class SkiaShape extends SkiaLayout {
|
|
|
64
64
|
/** Clip for overlay effects (ripple) and children: the shape itself, inset by the stroke. */
|
|
65
65
|
CreateClip(): Path;
|
|
66
66
|
protected OnLayoutChanged(): void;
|
|
67
|
+
/** C# SkiaShape: the fill's blend mode is the shape's FillBlendMode, also over a FillGradient's own. */
|
|
68
|
+
protected CreateBackgroundPaint(rect: SKRect): import("canvaskit-wasm").Paint;
|
|
67
69
|
protected PaintBackground(ctx: DrawingContext): void;
|
|
68
70
|
/** C# PaintBevelEffect: two stroked edge paths (top/left and bottom/right) in the light / shadow colors. */
|
|
69
71
|
private PaintBevelEffect;
|
|
@@ -164,6 +164,13 @@ export class SkiaShape extends SkiaLayout {
|
|
|
164
164
|
this.DrawingRect = saved;
|
|
165
165
|
}
|
|
166
166
|
// ---- paint ----
|
|
167
|
+
/** C# SkiaShape: the fill's blend mode is the shape's FillBlendMode, also over a FillGradient's own. */
|
|
168
|
+
CreateBackgroundPaint(rect) {
|
|
169
|
+
const paint = super.CreateBackgroundPaint(rect);
|
|
170
|
+
if (this.FillBlendMode !== "SrcOver")
|
|
171
|
+
paint.setBlendMode(Super.CK.BlendMode[this.FillBlendMode]);
|
|
172
|
+
return paint;
|
|
173
|
+
}
|
|
167
174
|
PaintBackground(ctx) {
|
|
168
175
|
const type = this.Type;
|
|
169
176
|
if (type === "Arc" || type === "Line")
|