drawnui-react 0.1.0-preview.21 → 0.1.0-preview.23
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/SKIPPED.md +2 -1
- package/dist/controls/SkiaBackdrop.d.ts +4 -4
- package/dist/controls/SkiaBackdrop.js +11 -23
- package/dist/controls/SkiaLayout.d.ts +16 -1
- package/dist/controls/SkiaLayout.js +52 -5
- package/dist/controls/SkiaScroll.js +4 -3
- package/dist/core/SkiaControl.d.ts +0 -5
- package/dist/core/SkiaControl.js +1 -6
- package/dist/core/Types.d.ts +1 -1
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +1 -0
- package/dist/react/reconciler.js +2 -2
- package/package.json +2 -1
package/SKIPPED.md
CHANGED
|
@@ -15,7 +15,7 @@ DrawnUi name and semantics; nothing here is a redesign, only an omission.
|
|
|
15
15
|
| `Opacity`, `TranslationX/Y`, `Rotation`, `ScaleX/Y` (+`Scale`), `SkewX/Y`, `RotationX/Y/Z`, `TranslationZ`, `AnchorX/Y`, `HasTransform`, `RenderTransformMatrix`, `TransformPointToLocalSpace` | ported | Same matrix order as C# `ApplyTransforms` (pivot → rotation → scale/skew → 3D → translation; 3D = C# `Create3dMatrix`, camera 576 px, TranslationZ as depth), image caches drawn smooth once the final matrix distorts them (C# `WillDrawDistorted`, a picture holding image blits records again when its playback turns distorted or straight), opacity = `saveLayer` alpha over the subtree, gestures mapped through the inverse matrix (`IsGestureForChild`, child receives the local point), accessibility rect = transformed bounds. Animations: `AnimateAsync`, `AnimateRangeAsync`, `FadeToAsync`, `ScaleToAsync`, `TranslateToAsync`, `RotateToAsync` as Promises with `AbortSignal` (one running per kind, like the C# per-property cancellation). Not ported: `Perspective1/2`, `CameraAngle`, `LinkTransforms`, `AddTranslationX/Y`, `UseTranslation*` overrides, `CustomizeLayerPaint`, `SkipRenderingOutOfBounds`. |
|
|
16
16
|
| `Left` / `Top` | ported (as a translate) | Same paint-time offset in points, but folded into the render matrix (a `canvas.translate`, hit-testing follows) for every control, cached or not; C# applies them only when blitting a cache. |
|
|
17
17
|
| `AnimatedFramesRenderer` / `SkiaLottie` / `SkiaGif` | ported | `AutoPlay`, `Repeat`, `SpeedRatio`, `DefaultFrame` (-1 = last), `Start(delay)`/`Stop`/`Seek`, `IsPlaying`, `Started`/`Finished`, `PlayWhenAvailable`, `GetFrameAt`. Lottie on CanvasKit Skottie (needs the `full` build, +0.9 MB raw wasm): `Source` (URL / app path, JSON cached per source, in-flight dedup), `ColorTint` / `Colors` (C# `ApplyTint` JSON rewrite), `IsOn` + `DefaultFrameWhenOn` + `ApplyIsOnWhenNotPlaying`, `StopAtCurrentFrame`, `ProcessJson`, `GoToStart`/`GoToEnd`, `SetAnimation`, `LoadSource`, `CreateAnimation`, `TotalFrames`; default cache `Operations` (C# ImageDoubleBuffered, see PARITY "Lottie and GIF default caches"). GIF on CanvasKit AnimatedImage: every frame decoded once (`GifAnimation`: `SeekFrame`, `GetFrameNumber`, `DurationMs`, `TotalFrames`), `Aspect` (AspectFitFill), alignment, `Success`/`Error`, default cache `None` (C# ImageDoubleBuffered). Not ported: `SkiaGif.Display` inner SkiaImage (frames are drawn directly), custom-control ctor `SkiaGif(display)`, `SkiaLottie` Skottie property/slot editing, sound, `ReloadSource` sync file paths, `Dispose` wiring on unmount (no engine hook from the reconciler yet). |
|
|
18
|
-
| `SkiaBackdrop` | ported | `Blur` (5), `Brightness` (gamma), `UseContext`, `BackgroundColor` tint, `HasEffects`, `GetImage`; copies the area it covers through every ancestor transform, drawn back 1:1 (C# 6fd3bae3);
|
|
18
|
+
| `SkiaBackdrop` | ported | `Blur` (5), `Brightness` (gamma), `UseContext`, `BackgroundColor` tint, `HasEffects`, `GetImage`; copies the area it covers through every ancestor transform, drawn back 1:1 (C# 6fd3bae3); recorded into a parent's picture cache it warns once ("Set UseCache = None on its picture-cached parents"; the library never changes a parent's cache, C# cf18cf29; the bcce0739 / fa5956ae guard was ported and reverted); inside an Image-cached ancestor it copies that cache's surface (no warning: C# reverted 9d6ae911, a valid use when what shows through is inside that cache); children drawn first and blurred with the snapshot (C# order); `UseContext` snapshots the surface the pixels end up on (on-screen, or the nearest Image cache surface through its `Origin`), also while an Operations picture is being recorded, since caches record inline; after each paint the ancestors' caches are staled for the next frame (no frame requested) so content that changes beneath without invalidating this branch (an image loading later) is picked up by the next frame. Used by the shell popups/modals (`ShellDefaults.PopupsBackgroundBlur`). Not ported: `CacheSource`, the ghost mode. |
|
|
19
19
|
| Disposal (`Dispose` / `OnDisposing`) | ported | The React renderer calls `Dispose()` when an element leaves the tree (`detachDeletedInstance`): caches, gradient shaders, running `*ToAsync` animations, overlay effects, the accessibility node, then the children (static and templated pool); `SkiaScroll`/`SnappingLayout` stop their animators, `SkiaSvg` drops its raster, `SkiaLottie`/`SkiaGif` free the Skottie animation / frames; `Canvas.Dispose` disposes the content. Not ported: `IsDisposing` staged disposal, `Disposing` event, `OnWillDisposeWithChildren`. |
|
|
20
20
|
| Hover: `ReceivesHover` (opt-in; on by default in SkiaButton, SkiaSlider, the toggles, SkiaRadioButton, SkiaCarousel, SkiaDrawer), `IsHovered`, `HoverChanged` (turns `ReceivesHover` on, as C# `OnHovered`) | ported | drawnui-cross 6m: every opted-in control under the mouse is hovered; nothing changes while a scroll, carousel or drawer moves its content, one check at the last pointer position when it stops and after an add / remove, a rebind, a hidden hovered control or an instant scroll jump; pointerleave clears at once; touch never hovers (`Canvas.Hover`, a `HoverManager`). Not ported: C# `SetHover`, `CheckHovered` / `OnHover` / `IsPointerOver` (no Pointer gestures are routed), SkiaSpinner / wheel picker (no such controls). |
|
|
21
21
|
| `KeyboardManager` | ported | Window-level keydown / keyup capture listeners like `drawnui-keyboard.js`: `KeyDown` / `KeyUp` with the DOM `event.code` ("KeyA", "ArrowLeft"; C# maps the same codes to `InputKey`), `KeyChar` for printable keys without Ctrl / Alt / Meta, `IsShiftPressed` / `IsControlPressed` / `IsAltPressed`, `AttachToKeyboard` (idempotent, pointerdown pulls window focus inside iframes), `BlurExternalTextInput`, `IsOwnedByElement` / `IsInputMethodKey` (React additions: a handler acting on keys skips keys a focused DOM element or the input method owns, C# 845b26e9); `Subscribe` / `Unsubscribe` instead of C# events. Not ported: `InputKey` enum (codes are strings). |
|
|
@@ -70,6 +70,7 @@ DrawnUi name and semantics; nothing here is a redesign, only an omission.
|
|
|
70
70
|
| `ItemsSourceWindow` / `WindowSourceThreshold` (built-in window over huge sources) | not needed | The C# window bounds pipeline work (structures, pools, measures) for `MeasureFirst`/`MeasureAll` over big collections. React `MeasureVisible` measures on demand and keeps only visible cells realized, so the pipeline is already O(visible); memory of the array itself belongs to the app (paginate with `LoadMore*`). Revisit only if `MeasureAll` over 100k+ items becomes a requirement. |
|
|
71
71
|
| `MeasureItemsStrategy="MeasureVisible"` + background measurement | ported | Initial pass measures enough items to fill the viewport (≥ `BackgroundMeasurementBatchSize`), content extent = exact prefix + average × remaining (C# MeasureList estimate), visible cells measured on demand and laid out with their real heights, the prefix grows in `requestIdleCallback` slices (time-budgeted, then one `InvalidateMeasure`), `LastMeasuredIndex`, `DebugString` shows `measured n/N`. Not ported: cancellation/`_pendingStructureChanges` interplay, `UsePreparedViews`, windowed sources, anchor correction when an estimate above the viewport changes (content may shift by the delta). |
|
|
72
72
|
| `SkiaLayout` Wrap (static children) + `SkiaWrap` alias | ported | Left-to-right flow, `Spacing` between items and rows, row height = tallest item. Not ported: `Split`, main-axis `Fill` children sharing a row (1.9.7.4 flex-fill), `UseDynamicColumns`, RTL. |
|
|
73
|
+
| `SkiaLayout` Masonry + `SkiaMasonry` alias (Split 2, horizontal fill) | ported | C# `MeasureMasonry` / `BuildMasonryLayout`: `Split` columns of width round((width - (Split - 1) * Spacing) / Split), every visible item measured unbounded at that width and placed at the bottom of the shortest column (the first on a tie), `Spacing` between columns and items. Children or `ItemsSource` + `ItemTemplate` (recycled slots, taps, `ScrollToIndex` from the slot rect, `LoadMore`); a templated slot keeps its item's size, so an appended page or a changed item is the only one measured and every item is placed again. No items window. Content = used columns wide, tallest column high. `npm run check:masonry` (C# MasonryLayoutTests) |
|
|
73
74
|
| `SkiaLayout` Grid (static children) + `SkiaGrid` alias | ported | Port of `SkiaGridStructure` (MAUI grid manager): `ColumnDefinitions`/`RowDefinitions` as `"*, 2*, Auto, 100"` or arrays, `DefaultColumnDefinition`/`DefaultRowDefinition` (Auto, like C#), `ColumnSpacing`/`RowSpacing`, child `Column`/`Row`/`ColumnSpan`/`RowSpan` (plain props instead of attached properties), implicit tracks, unknown/known measure passes, span resolution, star compression, Fill-child minimums, last-track stretch when the grid fills, remeasure at final cells. Not ported: `Split`/`Invert` (templated grids), `UseDynamicColumns`, `SkiaDecoratedGrid`, `GetOrderedSubviews` ZIndex ordering. |
|
|
74
75
|
| `SkiaLabel` | partial | Word wrap (+ character break for long words), `MaxLines` with tail ellipsis, `LineBreakMode` (NoWrap / wraps / Tail; Head/Middle behave as Tail), `HorizontalTextAlignment` Start/Center/End (Fill* accepted, align Start), `VerticalTextAlignment`, `LineSpacing`, `LineHeight`, `FontWeight` + `FontAttributes` via faces registered per weight (`AddFont(src, alias, weight)`, nearest weight wins, synthetic bold (`setEmbolden`) when the nearest face is lighter than 600 — C# `Font.Embolden`; italic = synthetic skew when no italic face; empty `FontFamily` = the first registered family, weights included), `TextTransform`, `Padding`, `LinesCount`; defaults as C# (`FontSize` 12, `TextColor` GreenYellow). `FontFamilyFallback` ported and extended: comma-separated chain (`"FontSymbols,FontSymbols2"`), per-codepoint run segmentation, spaces always stay on the main font; `fonts.AddSymbols()` (`FontSymbols` = Noto Sans Math subset, `FontSymbols2` = Noto Sans Symbols 2 subset) and `fonts.AddEmojis()` (`FontEmoji` = Noto Color Emoji faces+hands subset) ship the same subsets as DrawnUi.Blazor. `Spans` ported as `<TextSpan>` children: `Text`, `TextColor`/`FontSize`/`FontFamily` (unset = inherit from the label, like C# HasSetColor/HasSetSize/HasSetFont), `FontWeight`, `IsBold`, `IsItalic`, `Underline`/`UnderlineWidth`, `Strikeout`/`StrikeoutWidth`/`StrikeoutColor` (Red default), `BackgroundColor`, `Tapped` + `ForceCaptureInput` (hit-tested through per-fragment `Rects`, ripple on the label, `OnSpanTapped` overridable), mixed sizes on one line share a baseline. TextSpan not ported: `ParagraphColor`, `CommandTapped`, per-span `LineSpacing`/`LineHeight`, `AutoFindFont`, `DrawingOffset`, `Shape`/glyph shaping. `CharacterSpacing` (C#: (value - 1) points after every glyph, measured, wrapped and cut at the drawn width), Chinese / Japanese line breaks between characters with kinsoku (C# FitAtBreak, `CanBreakInsideWord`). Not ported: `AutoFont`, `AutoSize`/`AutoSizeText`, `DropShadow*`, text `StrokeColor`/`StrokeWidth`/`StrokeGradient`, `GradientByLines`, `MonoForDigits`, `KeepSpacesOnLineBreaks`, `Format`, RTL/bidi, hyphenation, `SkiaRichLabel`/markdown. |
|
|
75
76
|
| `SkiaHotspot` | ported | Fill/Fill, `Tapped`, `Down`, `Up`, `LockPanning`, `TouchDown`; consumes only Tapped like the C# one. No `AnimationTapped`/ripple/shimmer. |
|
|
@@ -5,8 +5,9 @@ import { SkiaLayout } from "./SkiaLayout";
|
|
|
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
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)
|
|
9
|
-
*
|
|
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
|
|
10
11
|
* (right when what shows through the glass is inside that cache, wrong when it should show content outside it).
|
|
11
12
|
*/
|
|
12
13
|
export declare class SkiaBackdrop extends SkiaLayout {
|
|
@@ -17,6 +18,7 @@ export declare class SkiaBackdrop extends SkiaLayout {
|
|
|
17
18
|
/** Snapshot the surface currently drawn into (true) or the on-screen surface (false). */
|
|
18
19
|
UseContext: boolean;
|
|
19
20
|
private snapshot?;
|
|
21
|
+
private warnedPicture;
|
|
20
22
|
constructor();
|
|
21
23
|
get HasEffects(): boolean;
|
|
22
24
|
/** The last snapshot taken (C# GetImage hands it over: the caller owns it afterwards). */
|
|
@@ -25,7 +27,5 @@ export declare class SkiaBackdrop extends SkiaLayout {
|
|
|
25
27
|
protected PaintBackground(_ctx: DrawingContext): void;
|
|
26
28
|
protected PaintsBackgroundWithoutColor(): boolean;
|
|
27
29
|
protected Paint(ctx: DrawingContext): void;
|
|
28
|
-
/** C# StopPictureCachesAbove: the picture-cached ancestors draw live from the next frame, which this asks for. */
|
|
29
|
-
protected StopPictureCachesAbove(): void;
|
|
30
30
|
protected OnDisposing(): void;
|
|
31
31
|
}
|
|
@@ -5,8 +5,9 @@ import { SkiaLayout } from "./SkiaLayout";
|
|
|
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
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)
|
|
9
|
-
*
|
|
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
|
|
10
11
|
* (right when what shows through the glass is inside that cache, wrong when it should show content outside it).
|
|
11
12
|
*/
|
|
12
13
|
export class SkiaBackdrop extends SkiaLayout {
|
|
@@ -17,6 +18,7 @@ export class SkiaBackdrop extends SkiaLayout {
|
|
|
17
18
|
/** Snapshot the surface currently drawn into (true) or the on-screen surface (false). */
|
|
18
19
|
UseContext = true;
|
|
19
20
|
snapshot;
|
|
21
|
+
warnedPicture = false;
|
|
20
22
|
constructor() {
|
|
21
23
|
super();
|
|
22
24
|
this.HorizontalOptions = "Fill";
|
|
@@ -42,11 +44,11 @@ export class SkiaBackdrop extends SkiaLayout {
|
|
|
42
44
|
}
|
|
43
45
|
if (!this.HasEffects)
|
|
44
46
|
return;
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
if (ctx.Context.Recording) {
|
|
48
|
-
this.
|
|
49
|
-
|
|
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.`);
|
|
50
52
|
}
|
|
51
53
|
// C# UseContext: snapshot the surface the pixels end up on — the on-screen surface or the nearest Image cache
|
|
52
54
|
// surface. Copied where the backdrop really is on that surface: its rect through the canvas matrix (ancestor
|
|
@@ -99,22 +101,8 @@ export class SkiaBackdrop extends SkiaLayout {
|
|
|
99
101
|
const kill = this.snapshot;
|
|
100
102
|
this.snapshot = image;
|
|
101
103
|
kill?.delete();
|
|
102
|
-
//
|
|
103
|
-
//
|
|
104
|
-
queueMicrotask(() => { let p = this.Parent; while (p) {
|
|
105
|
-
p.InvalidateCache();
|
|
106
|
-
p = p.Parent;
|
|
107
|
-
} });
|
|
108
|
-
}
|
|
109
|
-
/** C# StopPictureCachesAbove: the picture-cached ancestors draw live from the next frame, which this asks for. */
|
|
110
|
-
StopPictureCachesAbove() {
|
|
111
|
-
for (let p = this.Parent; p; p = p.Parent) {
|
|
112
|
-
if (p.UsingCacheType === "Operations") {
|
|
113
|
-
p.HostsBackdrop = true;
|
|
114
|
-
p.InvalidateCache();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
queueMicrotask(() => this.Update());
|
|
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
|
|
118
106
|
}
|
|
119
107
|
OnDisposing() { this.snapshot?.delete(); this.snapshot = undefined; }
|
|
120
108
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type DrawingContext, SkiaControl } from "../core/SkiaControl";
|
|
2
2
|
import { ViewsAdapter } from "../core/ViewsAdapter";
|
|
3
|
-
import { type GridLength, type LayoutType, type MeasuringStrategy, type RecyclingTemplate, ScaledSize, type ShapeType, Thickness } from "../core/Types";
|
|
3
|
+
import { type GridLength, type LayoutType, type MeasuringStrategy, type RecyclingTemplate, SKRect, ScaledSize, type ShapeType, Thickness } from "../core/Types";
|
|
4
4
|
import { SkiaGridStructure } from "./GridStructure";
|
|
5
5
|
/**
|
|
6
6
|
* Mirrors DrawnUi SkiaLayout (Absolute / Column / Row / Wrap / Grid).
|
|
@@ -148,6 +148,17 @@ export declare class SkiaLayout extends SkiaControl {
|
|
|
148
148
|
* Split items; `DynamicColumns` lets a short last row spread over the width.
|
|
149
149
|
*/
|
|
150
150
|
private MeasureWrap;
|
|
151
|
+
private get IsMasonry();
|
|
152
|
+
/**
|
|
153
|
+
* C# MeasureMasonry / BuildMasonryLayout: Split columns of equal width, every item measured unbounded at the column
|
|
154
|
+
* width and put at the bottom of the shortest column (the first on a tie), so items of different heights leave no
|
|
155
|
+
* gaps; Spacing between columns and between items. Every item is laid out (no items window). A templated slot keeps
|
|
156
|
+
* the size of its item, so an appended page or an item that asked to be measured again (an image arrived) is the only
|
|
157
|
+
* one measured, and every item is placed again from the sizes known.
|
|
158
|
+
*/
|
|
159
|
+
private MeasureMasonry;
|
|
160
|
+
/** Masonry: where the slot of item `index` was arranged (pixels), also while no view shows it; undefined otherwise. */
|
|
161
|
+
GetMasonryItemRect(index: number): SKRect | undefined;
|
|
151
162
|
/** Port of C# MeasureGrid: build the structure in points, stretch the last track when the grid fills, remeasure at final cells. */
|
|
152
163
|
private MeasureGrid;
|
|
153
164
|
/** Templated Column: content = padding + sum of item heights + gaps; width = the constraint (cells fill). */
|
|
@@ -214,6 +225,10 @@ export declare class SkiaLayer extends SkiaLayout {
|
|
|
214
225
|
export declare class SkiaGrid extends SkiaLayout {
|
|
215
226
|
constructor();
|
|
216
227
|
}
|
|
228
|
+
/** SkiaLayout Type=Masonry + Split 2 + HorizontalOptions=Fill (DrawnUi alias): columns, each item to the shortest one. */
|
|
229
|
+
export declare class SkiaMasonry extends SkiaLayout {
|
|
230
|
+
constructor();
|
|
231
|
+
}
|
|
217
232
|
/** SkiaLayout Type=Wrap + HorizontalOptions=Fill (DrawnUi alias): responsive flow of fixed-size children. */
|
|
218
233
|
export declare class SkiaWrap extends SkiaLayout {
|
|
219
234
|
constructor();
|
|
@@ -144,7 +144,7 @@ export class SkiaLayout extends SkiaControl {
|
|
|
144
144
|
return;
|
|
145
145
|
const old = this.itemsSource;
|
|
146
146
|
this.itemsSource = value;
|
|
147
|
-
if (value && old && this.IsTemplated && !this.structureDirty && this.ApplyIncrementalChange(old, value)) {
|
|
147
|
+
if (value && old && this.IsTemplated && !this.IsMasonry && !this.structureDirty && this.ApplyIncrementalChange(old, value)) {
|
|
148
148
|
this.InvalidateMeasure();
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
@@ -308,8 +308,11 @@ export class SkiaLayout extends SkiaControl {
|
|
|
308
308
|
return this.views;
|
|
309
309
|
const n = this.itemsSource.length;
|
|
310
310
|
if (this.IsRecycledLayout) {
|
|
311
|
-
if (this.slots?.length !== n)
|
|
312
|
-
|
|
311
|
+
if (this.slots?.length !== n) {
|
|
312
|
+
// a masonry keeps the slots it has: an appended page (LoadMore) measures only the new items
|
|
313
|
+
const keep = this.IsMasonry ? this.slots ?? [] : [];
|
|
314
|
+
this.slots = Array.from({ length: n }, (_, i) => keep[i] ?? new TemplatedSlot(i, this.ChildrenFactory));
|
|
315
|
+
}
|
|
313
316
|
return this.slots;
|
|
314
317
|
}
|
|
315
318
|
const out = [];
|
|
@@ -483,6 +486,10 @@ export class SkiaLayout extends SkiaControl {
|
|
|
483
486
|
const s = this.MeasureWrap(w, scale);
|
|
484
487
|
return ScaledSize.FromPixels(s.w + px, s.h + py, scale);
|
|
485
488
|
}
|
|
489
|
+
if (this.IsMasonry) {
|
|
490
|
+
const s = this.MeasureMasonry(w, scale);
|
|
491
|
+
return ScaledSize.FromPixels(s.w + px, s.h + py, scale);
|
|
492
|
+
}
|
|
486
493
|
if (this.Type === "Grid") {
|
|
487
494
|
const s = this.MeasureGrid(w, h, scale);
|
|
488
495
|
return ScaledSize.FromPixels(s.w + px, s.h + py, scale);
|
|
@@ -573,6 +580,42 @@ export class SkiaLayout extends SkiaControl {
|
|
|
573
580
|
finishRow(true);
|
|
574
581
|
return { w: maxW, h: this.wrapSlots.length ? y + rowH : 0 };
|
|
575
582
|
}
|
|
583
|
+
get IsMasonry() { return this.Type === "Masonry"; }
|
|
584
|
+
/**
|
|
585
|
+
* C# MeasureMasonry / BuildMasonryLayout: Split columns of equal width, every item measured unbounded at the column
|
|
586
|
+
* width and put at the bottom of the shortest column (the first on a tie), so items of different heights leave no
|
|
587
|
+
* gaps; Spacing between columns and between items. Every item is laid out (no items window). A templated slot keeps
|
|
588
|
+
* the size of its item, so an appended page or an item that asked to be measured again (an image arrived) is the only
|
|
589
|
+
* one measured, and every item is placed again from the sizes known.
|
|
590
|
+
*/
|
|
591
|
+
MeasureMasonry(width, scale) {
|
|
592
|
+
const columns = Math.max(1, this.Split);
|
|
593
|
+
const spacing = Math.round(this.Spacing * scale);
|
|
594
|
+
const columnWidth = columns > 1 ? Math.round((width - (columns - 1) * this.Spacing * scale) / columns) : width;
|
|
595
|
+
const bottoms = new Array(columns).fill(0), rows = new Array(columns).fill(0);
|
|
596
|
+
this.wrapSlots = [];
|
|
597
|
+
for (const v of this.LayoutViews()) {
|
|
598
|
+
if (!v.IsVisible)
|
|
599
|
+
continue;
|
|
600
|
+
let column = 0;
|
|
601
|
+
for (let c = 1; c < columns; c++)
|
|
602
|
+
if (bottoms[c] < bottoms[column])
|
|
603
|
+
column = c;
|
|
604
|
+
const h = v.Measure(columnWidth, Infinity, scale).Pixels.Height;
|
|
605
|
+
const x = column * (columnWidth + spacing), y = bottoms[column] + (rows[column]++ > 0 ? spacing : 0);
|
|
606
|
+
this.wrapSlots.push({ view: v, x, y, w: columnWidth, h });
|
|
607
|
+
bottoms[column] = y + h;
|
|
608
|
+
}
|
|
609
|
+
const used = Math.min(columns, this.wrapSlots.length);
|
|
610
|
+
return { w: used > 0 ? used * columnWidth + (used - 1) * spacing : 0, h: Math.max(0, ...bottoms) };
|
|
611
|
+
}
|
|
612
|
+
/** Masonry: where the slot of item `index` was arranged (pixels), also while no view shows it; undefined otherwise. */
|
|
613
|
+
GetMasonryItemRect(index) {
|
|
614
|
+
if (!this.IsMasonry || !this.IsRecycledLayout)
|
|
615
|
+
return undefined;
|
|
616
|
+
const d = this.slots?.[index]?.Destination;
|
|
617
|
+
return d && d.Width > 0 ? d : undefined;
|
|
618
|
+
}
|
|
576
619
|
/** Port of C# MeasureGrid: build the structure in points, stretch the last track when the grid fills, remeasure at final cells. */
|
|
577
620
|
MeasureGrid(widthPx, heightPx, scale) {
|
|
578
621
|
const wPts = widthPx / scale, hPts = heightPx / scale;
|
|
@@ -735,7 +778,7 @@ export class SkiaLayout extends SkiaControl {
|
|
|
735
778
|
* The item's offset and height are real, not estimated (C# LastMeasuredIndexLocal >= index): MeasureVisible knows
|
|
736
779
|
* them once the measured prefix passed the item; the other strategies always do.
|
|
737
780
|
*/
|
|
738
|
-
IsItemMeasured(index) { return this.MeasureItemsStrategy !== "MeasureVisible" || index < this.mvMeasured; }
|
|
781
|
+
IsItemMeasured(index) { return this.IsMasonry || this.MeasureItemsStrategy !== "MeasureVisible" || index < this.mvMeasured; }
|
|
739
782
|
/** Pixel offset of item index from the top of the layout content (inside padding). */
|
|
740
783
|
GetItemOffsetPixels(index) {
|
|
741
784
|
const scale = this.RenderingScale;
|
|
@@ -783,7 +826,7 @@ export class SkiaLayout extends SkiaControl {
|
|
|
783
826
|
const inner = new SKRect(r.Left + p.Left * scale, r.Top + p.Top * scale, r.Right - p.Right * scale, r.Bottom - p.Bottom * scale);
|
|
784
827
|
const gap = this.Spacing * scale;
|
|
785
828
|
let cursor = this.Type === "Row" ? inner.Left : inner.Top;
|
|
786
|
-
if (this.IsWrapFlow) {
|
|
829
|
+
if (this.IsWrapFlow || this.IsMasonry) {
|
|
787
830
|
for (const s of this.wrapSlots)
|
|
788
831
|
s.view.Arrange(SKRect.Create(inner.Left + s.x, inner.Top + s.y, s.w, s.h), s.view.WidthRequest, s.view.HeightRequest, scale);
|
|
789
832
|
return;
|
|
@@ -1014,6 +1057,10 @@ export class SkiaLayer extends SkiaLayout {
|
|
|
1014
1057
|
export class SkiaGrid extends SkiaLayout {
|
|
1015
1058
|
constructor() { super(); this.Type = "Grid"; this.HorizontalOptions = "Fill"; }
|
|
1016
1059
|
}
|
|
1060
|
+
/** SkiaLayout Type=Masonry + Split 2 + HorizontalOptions=Fill (DrawnUi alias): columns, each item to the shortest one. */
|
|
1061
|
+
export class SkiaMasonry extends SkiaLayout {
|
|
1062
|
+
constructor() { super(); this.Type = "Masonry"; this.Split = 2; this.HorizontalOptions = "Fill"; }
|
|
1063
|
+
}
|
|
1017
1064
|
/** SkiaLayout Type=Wrap + HorizontalOptions=Fill (DrawnUi alias): responsive flow of fixed-size children. */
|
|
1018
1065
|
export class SkiaWrap extends SkiaLayout {
|
|
1019
1066
|
constructor() { super(); this.Type = "Wrap"; this.HorizontalOptions = "Fill"; }
|
|
@@ -871,10 +871,11 @@ export class SkiaScroll extends SkiaControl {
|
|
|
871
871
|
else {
|
|
872
872
|
// A templated Row / Wrap / Grid realizes every item (C# non-list layouts are not virtualized): read the cell's
|
|
873
873
|
// arranged rect, like C# reads the structure cell's Destination.
|
|
874
|
-
|
|
875
|
-
|
|
874
|
+
// a masonry's recycled slots know every item's place, shown or not
|
|
875
|
+
const r = layout.GetMasonryItemRect(i) ?? layout.ChildrenFactory.GetViewForIndex(i)?.DrawingRect;
|
|
876
|
+
if (!r)
|
|
876
877
|
return undefined;
|
|
877
|
-
const
|
|
878
|
+
const c = this.content.DrawingRect;
|
|
878
879
|
itemStart = (horizontal ? r.Left - c.Left : r.Top - c.Top) / scale;
|
|
879
880
|
itemSize = (horizontal ? r.Width : r.Height) / scale;
|
|
880
881
|
}
|
|
@@ -157,11 +157,6 @@ export declare class SkiaControl {
|
|
|
157
157
|
/** What to cache for this subtree; see SkiaCacheType. Layouts default to None, SkiaLabel/SkiaSvg to Operations. */
|
|
158
158
|
UseCache: SkiaCacheType;
|
|
159
159
|
/** The cache type actually applied (None while caching is disabled globally). */
|
|
160
|
-
/**
|
|
161
|
-
* C# HostsBackdrop: a SkiaBackdrop inside asked this picture-cached control to draw live (a picture would replay
|
|
162
|
-
* the backdrop's screen copy frozen). Stays set after the backdrop is removed: the control just keeps drawing live.
|
|
163
|
-
*/
|
|
164
|
-
HostsBackdrop: boolean;
|
|
165
160
|
get UsingCacheType(): SkiaCacheType;
|
|
166
161
|
/** C# IsCacheComposite: the offscreen surface is kept and only the changed children are re-recorded. */
|
|
167
162
|
get IsCacheComposite(): boolean;
|
package/dist/core/SkiaControl.js
CHANGED
|
@@ -195,18 +195,13 @@ export class SkiaControl {
|
|
|
195
195
|
/** What to cache for this subtree; see SkiaCacheType. Layouts default to None, SkiaLabel/SkiaSvg to Operations. */
|
|
196
196
|
UseCache = "None";
|
|
197
197
|
/** The cache type actually applied (None while caching is disabled globally). */
|
|
198
|
-
/**
|
|
199
|
-
* C# HostsBackdrop: a SkiaBackdrop inside asked this picture-cached control to draw live (a picture would replay
|
|
200
|
-
* the backdrop's screen copy frozen). Stays set after the backdrop is removed: the control just keeps drawing live.
|
|
201
|
-
*/
|
|
202
|
-
HostsBackdrop = false;
|
|
203
198
|
get UsingCacheType() {
|
|
204
199
|
if (!Super.CacheEnabled)
|
|
205
200
|
return "None";
|
|
206
201
|
switch (this.UseCache) {
|
|
207
202
|
case "None": return "None";
|
|
208
203
|
case "Operations":
|
|
209
|
-
case "OperationsFull": return
|
|
204
|
+
case "OperationsFull": return "Operations";
|
|
210
205
|
case "ImageDoubleBuffered": return "ImageDoubleBuffered";
|
|
211
206
|
case "ImageComposite":
|
|
212
207
|
case "ImageCompositeGPU": return "ImageComposite";
|
package/dist/core/Types.d.ts
CHANGED
|
@@ -75,7 +75,7 @@ export type TextTransform = "None" | "Lowercase" | "Uppercase" | "Titlecase";
|
|
|
75
75
|
/** DrawnUi DrawerDirection: the edge a SkiaDrawer slides from. */
|
|
76
76
|
export type DrawerDirection = "FromBottom" | "FromTop" | "FromLeft" | "FromRight";
|
|
77
77
|
/** DrawnUi LayoutType. */
|
|
78
|
-
export type LayoutType = "Absolute" | "Column" | "Row" | "Wrap" | "Grid";
|
|
78
|
+
export type LayoutType = "Absolute" | "Column" | "Row" | "Wrap" | "Grid" | "Masonry";
|
|
79
79
|
/** MAUI ReturnType: what the keyboard's return key means (SkiaEditor: Send submits a multiline editor). */
|
|
80
80
|
export type ReturnType = "Default" | "Done" | "Go" | "Next" | "Search" | "Send";
|
|
81
81
|
/** DrawnUi SkiaEditor.SkiaEditorKeyboard. */
|
package/dist/react/index.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ export declare const SkiaStack: FC<LayoutProps<SkiaLayoutCtrl>>;
|
|
|
58
58
|
export declare const SkiaRow: FC<LayoutProps<SkiaLayoutCtrl>>;
|
|
59
59
|
export declare const SkiaLayer: FC<LayoutProps<SkiaLayoutCtrl>>;
|
|
60
60
|
export declare const SkiaWrap: FC<LayoutProps<SkiaLayoutCtrl>>;
|
|
61
|
+
export declare const SkiaMasonry: FC<LayoutProps<SkiaLayoutCtrl>>;
|
|
61
62
|
export declare const SkiaGrid: FC<LayoutProps<SkiaLayoutCtrl>>;
|
|
62
63
|
/** Grid drawing gradient separator lines in its spacing (C# SkiaDecoratedGrid). */
|
|
63
64
|
export declare const SkiaDecoratedGrid: FC<LayoutProps<SkiaDecoratedGridCtrl>>;
|
package/dist/react/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export const SkiaStack = "SkiaStack";
|
|
|
12
12
|
export const SkiaRow = "SkiaRow";
|
|
13
13
|
export const SkiaLayer = "SkiaLayer";
|
|
14
14
|
export const SkiaWrap = "SkiaWrap";
|
|
15
|
+
export const SkiaMasonry = "SkiaMasonry";
|
|
15
16
|
export const SkiaGrid = "SkiaGrid";
|
|
16
17
|
/** Grid drawing gradient separator lines in its spacing (C# SkiaDecoratedGrid). */
|
|
17
18
|
export const SkiaDecoratedGrid = "SkiaDecoratedGrid";
|
package/dist/react/reconciler.js
CHANGED
|
@@ -14,7 +14,7 @@ import { SkiaSlider } from "../controls/SkiaSlider";
|
|
|
14
14
|
import { SkiaCarousel } from "../controls/SkiaCarousel";
|
|
15
15
|
import { SkiaShaderCarousel } from "../controls/SkiaShaderCarousel";
|
|
16
16
|
import { SkiaDrawer } from "../controls/SkiaDrawer";
|
|
17
|
-
import { SkiaGrid, SkiaLayer, SkiaLayout, SkiaRow, SkiaStack, SkiaWrap } from "../controls/SkiaLayout";
|
|
17
|
+
import { SkiaGrid, SkiaLayer, SkiaLayout, SkiaMasonry, SkiaRow, SkiaStack, SkiaWrap } from "../controls/SkiaLayout";
|
|
18
18
|
import { SkiaHotspot } from "../controls/SkiaHotspot";
|
|
19
19
|
import { SkiaButton } from "../controls/SkiaButton";
|
|
20
20
|
import { SkiaImage } from "../controls/SkiaImage";
|
|
@@ -33,7 +33,7 @@ import { SkiaScroll } from "../controls/SkiaScroll";
|
|
|
33
33
|
import { SkiaFrame, SkiaShape } from "../controls/SkiaShape";
|
|
34
34
|
/** JSX tag name -> engine class. Add a control here to expose it to React. */
|
|
35
35
|
export const Registry = {
|
|
36
|
-
SkiaLayout, SkiaStack, SkiaRow, SkiaLayer, SkiaWrap, SkiaGrid, SkiaDecoratedGrid, SkiaBackdrop, SkiaEditor, SkiaSprite, SkiaSpriteSet, SkiaLabel, SkiaLabelFps, SkiaRichLabel, TextSpan, SkiaHotspot, SkiaButton, SkiaImage, SkiaImageTiles, SkiaSvg, SkiaLottie, SkiaGif, SkiaScroll, SkiaScrollBar, RefreshIndicator, SkiaShape, SkiaFrame,
|
|
36
|
+
SkiaLayout, SkiaStack, SkiaRow, SkiaLayer, SkiaWrap, SkiaMasonry, SkiaGrid, SkiaDecoratedGrid, SkiaBackdrop, SkiaEditor, SkiaSprite, SkiaSpriteSet, SkiaLabel, SkiaLabelFps, SkiaRichLabel, TextSpan, SkiaHotspot, SkiaButton, SkiaImage, SkiaImageTiles, SkiaSvg, SkiaLottie, SkiaGif, SkiaScroll, SkiaScrollBar, RefreshIndicator, SkiaShape, SkiaFrame,
|
|
37
37
|
SkiaSwitch, SkiaCheckbox, SkiaRadioButton, SkiaProgress, SkiaSlider, SkiaCarousel, SkiaShaderCarousel, SkiaDrawer,
|
|
38
38
|
};
|
|
39
39
|
const SKIP = new Set(["children", "key", "ref"]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drawnui-react",
|
|
3
|
-
"version": "0.1.0-preview.
|
|
3
|
+
"version": "0.1.0-preview.23",
|
|
4
4
|
"description": "DrawnUi for React: the DrawnUi (.NET) drawn-UI engine in TypeScript on CanvasKit (Skia WASM). Same controls, same PascalCase API as DrawnUi.Net.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Nick Kovalsky (AppoMobi)",
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"check:shader-cache": "node dev/check.mjs dev/check-shader-cache.ts",
|
|
80
80
|
"check:shader-content": "node dev/check.mjs dev/check-shader-content.ts",
|
|
81
81
|
"check:backdrop": "node dev/check.mjs dev/check-backdrop.ts",
|
|
82
|
+
"check:masonry": "node dev/check.mjs dev/check-masonry.ts",
|
|
82
83
|
"site:extras": "node dev/site-extras.mjs dist/demo",
|
|
83
84
|
"build:lib": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
|
|
84
85
|
"prepublishOnly": "npm run build:lib",
|