drawnui-react 0.1.0-preview.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/PARITY.md +287 -0
- package/README.md +92 -0
- package/SKIPPED.md +107 -0
- package/dist/controls/AnimatedFramesRenderer.d.ts +58 -0
- package/dist/controls/AnimatedFramesRenderer.js +133 -0
- package/dist/controls/GridStructure.d.ts +79 -0
- package/dist/controls/GridStructure.js +403 -0
- package/dist/controls/RefreshIndicator.d.ts +35 -0
- package/dist/controls/RefreshIndicator.js +82 -0
- package/dist/controls/SkiaBackdrop.d.ts +25 -0
- package/dist/controls/SkiaBackdrop.js +80 -0
- package/dist/controls/SkiaButton.d.ts +58 -0
- package/dist/controls/SkiaButton.js +148 -0
- package/dist/controls/SkiaCarousel.d.ts +133 -0
- package/dist/controls/SkiaCarousel.js +603 -0
- package/dist/controls/SkiaCheckbox.d.ts +21 -0
- package/dist/controls/SkiaCheckbox.js +118 -0
- package/dist/controls/SkiaDecoratedGrid.d.ts +15 -0
- package/dist/controls/SkiaDecoratedGrid.js +46 -0
- package/dist/controls/SkiaDrawer.d.ts +46 -0
- package/dist/controls/SkiaDrawer.js +212 -0
- package/dist/controls/SkiaDynamicDrawnCell.d.ts +11 -0
- package/dist/controls/SkiaDynamicDrawnCell.js +17 -0
- package/dist/controls/SkiaEditor.d.ts +163 -0
- package/dist/controls/SkiaEditor.js +803 -0
- package/dist/controls/SkiaGif.d.ts +54 -0
- package/dist/controls/SkiaGif.js +206 -0
- package/dist/controls/SkiaHotspot.d.ts +13 -0
- package/dist/controls/SkiaHotspot.js +36 -0
- package/dist/controls/SkiaImage.d.ts +75 -0
- package/dist/controls/SkiaImage.js +222 -0
- package/dist/controls/SkiaImageTiles.d.ts +27 -0
- package/dist/controls/SkiaImageTiles.js +76 -0
- package/dist/controls/SkiaLabel.d.ts +160 -0
- package/dist/controls/SkiaLabel.js +580 -0
- package/dist/controls/SkiaLayout.d.ts +163 -0
- package/dist/controls/SkiaLayout.js +723 -0
- package/dist/controls/SkiaLottie.d.ts +75 -0
- package/dist/controls/SkiaLottie.js +290 -0
- package/dist/controls/SkiaProgress.d.ts +40 -0
- package/dist/controls/SkiaProgress.js +80 -0
- package/dist/controls/SkiaRadioButton.d.ts +32 -0
- package/dist/controls/SkiaRadioButton.js +157 -0
- package/dist/controls/SkiaRichLabel.d.ts +77 -0
- package/dist/controls/SkiaRichLabel.js +274 -0
- package/dist/controls/SkiaScroll.d.ts +231 -0
- package/dist/controls/SkiaScroll.js +958 -0
- package/dist/controls/SkiaScrollBar.d.ts +56 -0
- package/dist/controls/SkiaScrollBar.js +158 -0
- package/dist/controls/SkiaShaderCarousel.d.ts +67 -0
- package/dist/controls/SkiaShaderCarousel.js +246 -0
- package/dist/controls/SkiaShape.d.ts +63 -0
- package/dist/controls/SkiaShape.js +317 -0
- package/dist/controls/SkiaSlider.d.ts +74 -0
- package/dist/controls/SkiaSlider.js +243 -0
- package/dist/controls/SkiaSprite.d.ts +99 -0
- package/dist/controls/SkiaSprite.js +324 -0
- package/dist/controls/SkiaSpriteSet.d.ts +27 -0
- package/dist/controls/SkiaSpriteSet.js +75 -0
- package/dist/controls/SkiaSvg.d.ts +43 -0
- package/dist/controls/SkiaSvg.js +181 -0
- package/dist/controls/SkiaSwitch.d.ts +26 -0
- package/dist/controls/SkiaSwitch.js +147 -0
- package/dist/controls/SkiaToggle.d.ts +50 -0
- package/dist/controls/SkiaToggle.js +71 -0
- package/dist/controls/SnappingLayout.d.ts +78 -0
- package/dist/controls/SnappingLayout.js +217 -0
- package/dist/controls/TextSpan.d.ts +70 -0
- package/dist/controls/TextSpan.js +76 -0
- package/dist/core/Accessibility.d.ts +104 -0
- package/dist/core/Accessibility.js +150 -0
- package/dist/core/Animators.d.ts +82 -0
- package/dist/core/Animators.js +247 -0
- package/dist/core/Canvas.d.ts +89 -0
- package/dist/core/Canvas.js +328 -0
- package/dist/core/ControlStyle.d.ts +6 -0
- package/dist/core/ControlStyle.js +11 -0
- package/dist/core/Easing.d.ts +13 -0
- package/dist/core/Easing.js +15 -0
- package/dist/core/Gestures.d.ts +74 -0
- package/dist/core/Gestures.js +104 -0
- package/dist/core/ImageEffects.d.ts +29 -0
- package/dist/core/ImageEffects.js +55 -0
- package/dist/core/KeyboardManager.d.ts +25 -0
- package/dist/core/KeyboardManager.js +54 -0
- package/dist/core/ScrollAnimators.d.ts +90 -0
- package/dist/core/ScrollAnimators.js +244 -0
- package/dist/core/SkiaControl.d.ts +401 -0
- package/dist/core/SkiaControl.js +1239 -0
- package/dist/core/SkiaEffect.d.ts +216 -0
- package/dist/core/SkiaEffect.js +571 -0
- package/dist/core/SkiaImageManager.d.ts +43 -0
- package/dist/core/SkiaImageManager.js +122 -0
- package/dist/core/Super.d.ts +61 -0
- package/dist/core/Super.js +178 -0
- package/dist/core/TextInputProxy.d.ts +31 -0
- package/dist/core/TextInputProxy.js +144 -0
- package/dist/core/Types.d.ts +177 -0
- package/dist/core/Types.js +122 -0
- package/dist/core/ViewsAdapter.d.ts +41 -0
- package/dist/core/ViewsAdapter.js +113 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +48 -0
- package/dist/react/SkiaShell.d.ts +144 -0
- package/dist/react/SkiaShell.js +490 -0
- package/dist/react/index.d.ts +110 -0
- package/dist/react/index.js +158 -0
- package/dist/react/reconciler.d.ts +14 -0
- package/dist/react/reconciler.js +160 -0
- package/package.json +60 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { SKRect } from "../core/Types";
|
|
2
|
+
import { SkiaImage } from "./SkiaImage";
|
|
3
|
+
/**
|
|
4
|
+
* Mirrors DrawnUi SkiaImageTiles: the loaded source is drawn as a cached tile of `TileWidth` x `TileHeight` points
|
|
5
|
+
* (`TileAspect` inside the tile, default AspectCover) repeated over the box, shifted by `TileOffsetX` / `TileOffsetY`
|
|
6
|
+
* (points, wrap around — animate them for a scrolling background). Nothing is drawn until both tile sizes are set.
|
|
7
|
+
*/
|
|
8
|
+
export class SkiaImageTiles extends SkiaImage {
|
|
9
|
+
TileAspect = "AspectCover";
|
|
10
|
+
TileWidth = 0;
|
|
11
|
+
TileHeight = 0;
|
|
12
|
+
TileOffsetX = 0;
|
|
13
|
+
TileOffsetY = 0;
|
|
14
|
+
/** Cache of the tile image (C# default Image). */
|
|
15
|
+
TileCacheType = "Image";
|
|
16
|
+
/** Cached image used as the tile (C# Tile). */
|
|
17
|
+
Tile;
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
this.IsClippedToBounds = true; // C# WillClipBounds
|
|
21
|
+
}
|
|
22
|
+
/** C# CreateTile: a SkiaImage sharing the decoded source, sized to one tile. */
|
|
23
|
+
CreateTile(width, height) {
|
|
24
|
+
const tile = new SkiaImage();
|
|
25
|
+
tile.Aspect = this.TileAspect;
|
|
26
|
+
tile.WidthRequest = width;
|
|
27
|
+
tile.HeightRequest = height;
|
|
28
|
+
tile.HorizontalOptions = "Fill";
|
|
29
|
+
tile.VerticalOptions = "Fill";
|
|
30
|
+
tile.UseCache = this.TileCacheType;
|
|
31
|
+
tile.Parent = this;
|
|
32
|
+
return tile;
|
|
33
|
+
}
|
|
34
|
+
tileKey = "";
|
|
35
|
+
/** C# SetupTiles: (re)creates the tile when the source or the tile geometry changed. */
|
|
36
|
+
SetupTiles() {
|
|
37
|
+
const image = this.LoadedSource;
|
|
38
|
+
const key = `${this.TileWidth}|${this.TileHeight}|${this.TileAspect}|${this.TileCacheType}`;
|
|
39
|
+
if (this.TileWidth > 0 && this.TileHeight > 0 && image) {
|
|
40
|
+
if (!this.Tile || this.tileKey !== key) {
|
|
41
|
+
this.Tile?.Dispose();
|
|
42
|
+
this.Tile = this.CreateTile(this.TileWidth, this.TileHeight);
|
|
43
|
+
this.tileKey = key;
|
|
44
|
+
}
|
|
45
|
+
if (this.Tile.ImageBitmap !== image)
|
|
46
|
+
this.Tile.ImageBitmap = image;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
Paint(ctx) {
|
|
50
|
+
this.SetupTiles();
|
|
51
|
+
const tile = this.Tile;
|
|
52
|
+
if (!tile || !this.LoadedSource)
|
|
53
|
+
return;
|
|
54
|
+
const dest = ctx.Destination, scale = ctx.Scale;
|
|
55
|
+
const tw = Math.round(this.TileWidth * scale), th = Math.round(this.TileHeight * scale);
|
|
56
|
+
if (tw <= 0 || th <= 0)
|
|
57
|
+
return;
|
|
58
|
+
// C# DrawSource: offsets wrap inside one tile, the grid starts one tile before the box when shifted
|
|
59
|
+
const useOffsetX = -this.TileOffsetX % this.TileWidth, useOffsetY = -this.TileOffsetY % this.TileHeight;
|
|
60
|
+
const offsetX = useOffsetX > 0 ? Math.round(useOffsetX * scale) : tw + Math.round(useOffsetX * scale);
|
|
61
|
+
const offsetY = useOffsetY > 0 ? Math.round(useOffsetY * scale) : th + Math.round(useOffsetY * scale);
|
|
62
|
+
const tilesX = Math.ceil((dest.Width + offsetX) / tw), tilesY = Math.ceil((dest.Height + Math.abs(offsetY)) / th);
|
|
63
|
+
const startX = dest.Left - offsetX, startY = dest.Top - offsetY;
|
|
64
|
+
this.DisplayRect = dest;
|
|
65
|
+
for (let x = 0; x < tilesX; x++) {
|
|
66
|
+
for (let y = 0; y < tilesY; y++) {
|
|
67
|
+
const left = startX + x * tw, top = startY + y * th;
|
|
68
|
+
const r = new SKRect(left, top, left + tw, top + th);
|
|
69
|
+
tile.Measure(tw, th, scale);
|
|
70
|
+
tile.Arrange(r, tile.WidthRequest, tile.HeightRequest, scale);
|
|
71
|
+
tile.Render(ctx);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
OnDisposing() { this.Tile?.Dispose(); this.Tile = undefined; super.OnDisposing(); }
|
|
76
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { type DrawingContext, SkiaControl } from "../core/SkiaControl";
|
|
2
|
+
import { type GestureEventProcessingInfo, type SkiaGesturesParameters } from "../core/Gestures";
|
|
3
|
+
import { type Color, type DrawTextAlignment, type FontAttributes, type LineBreakMode, ScaledSize, type SkiaGradient, type TextAlignment, type TextTransform, Thickness } from "../core/Types";
|
|
4
|
+
import { TextSpan } from "./TextSpan";
|
|
5
|
+
/** One code point of the laid-out text: its UTF-16 index/length in Text and its box in pixels relative to DrawingRect. */
|
|
6
|
+
export interface GlyphBox {
|
|
7
|
+
Index: number;
|
|
8
|
+
Length: number;
|
|
9
|
+
Line: number;
|
|
10
|
+
Left: number;
|
|
11
|
+
Top: number;
|
|
12
|
+
Width: number;
|
|
13
|
+
Height: number;
|
|
14
|
+
}
|
|
15
|
+
/** A laid-out line: first text index, box in pixels relative to DrawingRect. */
|
|
16
|
+
export interface LineBox {
|
|
17
|
+
Line: number;
|
|
18
|
+
Start: number;
|
|
19
|
+
End: number;
|
|
20
|
+
Left: number;
|
|
21
|
+
Top: number;
|
|
22
|
+
Width: number;
|
|
23
|
+
Height: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Mirrors DrawnUi SkiaLabel: multi-line text with word wrapping, MaxLines + tail ellipsis, horizontal /
|
|
27
|
+
* vertical alignment, LineSpacing / LineHeight, weights and attributes resolved through the font registry,
|
|
28
|
+
* the opt-in per-codepoint FontFamilyFallback (symbols/emoji missing from the main face) and `Spans`
|
|
29
|
+
* (TextSpan children: per-fragment color/size/weight/italic/underline/strikeout/background/Tapped).
|
|
30
|
+
* Cached as Operations by default, like DrawnUi. Every text property invalidates like a bindable property.
|
|
31
|
+
*/
|
|
32
|
+
export declare class SkiaLabel extends SkiaControl {
|
|
33
|
+
private text;
|
|
34
|
+
private fontSize;
|
|
35
|
+
private textColor;
|
|
36
|
+
private fontFamily;
|
|
37
|
+
private fontFamilyFallback;
|
|
38
|
+
private fontWeight;
|
|
39
|
+
private fontAttributes;
|
|
40
|
+
private maxLines;
|
|
41
|
+
private lineBreakMode;
|
|
42
|
+
private horizontalTextAlignment;
|
|
43
|
+
private verticalTextAlignment;
|
|
44
|
+
private lineSpacing;
|
|
45
|
+
private lineHeight;
|
|
46
|
+
private textTransform;
|
|
47
|
+
private padding;
|
|
48
|
+
/** Styled fragments; when not empty they replace `Text` (same precedence as C#). */
|
|
49
|
+
readonly Spans: TextSpan[];
|
|
50
|
+
/** Set to `Aria.RoleText` to expose every label to screen readers (React extension; C# is opt-in per control). */
|
|
51
|
+
static DefaultAccessibilityRole?: string;
|
|
52
|
+
/** Like C# OnTextInternalChanged: the spoken label is the text (or the joined spans) unless AccessibilityLabel is set. */
|
|
53
|
+
protected DefaultAccessibilityLabel(): string | undefined;
|
|
54
|
+
constructor();
|
|
55
|
+
private Set;
|
|
56
|
+
get Text(): string;
|
|
57
|
+
set Text(v: string);
|
|
58
|
+
get FontSize(): number;
|
|
59
|
+
set FontSize(v: number);
|
|
60
|
+
get TextColor(): Color;
|
|
61
|
+
set TextColor(v: Color);
|
|
62
|
+
get FontFamily(): string;
|
|
63
|
+
set FontFamily(v: string);
|
|
64
|
+
/**
|
|
65
|
+
* Alias (or comma-separated chain of aliases) tried per codepoint when the main font has no glyph,
|
|
66
|
+
* e.g. "FontSymbols,FontSymbols2" from `AddSymbols()`. Same idea as C# FontFamilyFallback, extended to a chain.
|
|
67
|
+
*/
|
|
68
|
+
get FontFamilyFallback(): string;
|
|
69
|
+
set FontFamilyFallback(v: string);
|
|
70
|
+
get FontWeight(): number;
|
|
71
|
+
set FontWeight(v: number);
|
|
72
|
+
get FontAttributes(): FontAttributes;
|
|
73
|
+
set FontAttributes(v: FontAttributes);
|
|
74
|
+
get MaxLines(): number;
|
|
75
|
+
set MaxLines(v: number);
|
|
76
|
+
get LineBreakMode(): LineBreakMode;
|
|
77
|
+
set LineBreakMode(v: LineBreakMode);
|
|
78
|
+
get HorizontalTextAlignment(): DrawTextAlignment;
|
|
79
|
+
set HorizontalTextAlignment(v: DrawTextAlignment);
|
|
80
|
+
get VerticalTextAlignment(): TextAlignment;
|
|
81
|
+
set VerticalTextAlignment(v: TextAlignment);
|
|
82
|
+
get LineSpacing(): number;
|
|
83
|
+
set LineSpacing(v: number);
|
|
84
|
+
/** Multiplier applied to the natural line height (ascent + descent). */
|
|
85
|
+
get LineHeight(): number;
|
|
86
|
+
set LineHeight(v: number);
|
|
87
|
+
get TextTransform(): TextTransform;
|
|
88
|
+
set TextTransform(v: TextTransform);
|
|
89
|
+
get Padding(): Thickness;
|
|
90
|
+
set Padding(v: Thickness);
|
|
91
|
+
/** Number of laid-out lines after the last measure. */
|
|
92
|
+
get LinesCount(): number;
|
|
93
|
+
AddSubView(control: SkiaControl | TextSpan): void;
|
|
94
|
+
InsertSubView(index: number, control: SkiaControl | TextSpan): void;
|
|
95
|
+
RemoveSubView(control: SkiaControl | TextSpan): void;
|
|
96
|
+
private lines;
|
|
97
|
+
private mainFonts?;
|
|
98
|
+
private readonly fontsCache;
|
|
99
|
+
private readonly runCache;
|
|
100
|
+
private ResolveFonts;
|
|
101
|
+
/** The label's own style, and the base every span inherits from. */
|
|
102
|
+
private ResolveMainFonts;
|
|
103
|
+
private ResolveSpanFonts;
|
|
104
|
+
private static Advance;
|
|
105
|
+
/**
|
|
106
|
+
* Splits text into runs by glyph availability: the main font, or the first fallback that has a glyph where the
|
|
107
|
+
* main font has glyph 0. Spaces always stay on the main font (fallback faces often carry very wide spaces).
|
|
108
|
+
*/
|
|
109
|
+
private Segment;
|
|
110
|
+
private Width;
|
|
111
|
+
private Transform;
|
|
112
|
+
/**
|
|
113
|
+
* Paragraphs (split on "\n") of wrap tokens, built from Spans when present, else from Text.
|
|
114
|
+
* A fragment that does not start with a space glues to the previous word (no break opportunity is added).
|
|
115
|
+
*/
|
|
116
|
+
private Tokenize;
|
|
117
|
+
private NewLine;
|
|
118
|
+
private Append;
|
|
119
|
+
/** Word-wraps tokens into lines that fit maxWidth (Infinity = no wrap), applies MaxLines with a tail ellipsis. */
|
|
120
|
+
private LayoutLines;
|
|
121
|
+
private LineHeightPx;
|
|
122
|
+
private BlockHeight;
|
|
123
|
+
protected MeasureAbsolute(widthConstraint: number, _heightConstraint: number, scale: number): ScaledSize;
|
|
124
|
+
/** C# GradientByLines: FillGradient spans each line's bounds (default) instead of the whole text block. */
|
|
125
|
+
GradientByLines: boolean;
|
|
126
|
+
/** C# KeepSpacesOnLineBreaks / NeedsGlyphPositions: accepted; glyph boxes are always available through GetGlyphBoxes. */
|
|
127
|
+
KeepSpacesOnLineBreaks: boolean;
|
|
128
|
+
NeedsGlyphPositions: boolean;
|
|
129
|
+
/** Bumped on every measure: consumers cache GetGlyphBoxes() against it. */
|
|
130
|
+
LayoutVersion: number;
|
|
131
|
+
/** Height of the first laid-out line in pixels (C# MeasuredLineHeight); 0 before the first measure. */
|
|
132
|
+
get MeasuredLineHeight(): number;
|
|
133
|
+
/** Line origins relative to DrawingRect, same alignment math as Paint. */
|
|
134
|
+
private LineGeometry;
|
|
135
|
+
/** Lines as CSS text for the accessibility overlay (AccessibilityTextSelectable): font alias chain, weight and px size. */
|
|
136
|
+
GetAccessibilityTextLines(scale: number): import("../core/Accessibility").AccessibilityTextLine[];
|
|
137
|
+
/** Laid-out lines with their text index range (a wrapped-away space or line break sits between two lines). */
|
|
138
|
+
GetLineBoxes(): LineBox[];
|
|
139
|
+
/** Every code point of the laid-out text with its box (editor caret / selection / hit testing). */
|
|
140
|
+
GetGlyphBoxes(): GlyphBox[];
|
|
141
|
+
/** Outline around the glyphs, drawn under the fill (C# StrokeColor / StrokeWidth in points; Transparent = none). */
|
|
142
|
+
StrokeColor: Color;
|
|
143
|
+
StrokeWidth: number;
|
|
144
|
+
StrokeGradient?: SkiaGradient;
|
|
145
|
+
/** Drop shadow: a stroked copy of the text offset by DropShadowOffsetX/Y points (C# DropShadow*). */
|
|
146
|
+
DropShadowColor: Color;
|
|
147
|
+
DropShadowSize: number;
|
|
148
|
+
DropShadowOffsetX: number;
|
|
149
|
+
DropShadowOffsetY: number;
|
|
150
|
+
private HasStroke;
|
|
151
|
+
private HasDropShadow;
|
|
152
|
+
/** C# measurement: stroke adds StrokeWidth*2 on each axis, the shadow adds DropShadowSize + offset (pixels). */
|
|
153
|
+
private EffectsExtra;
|
|
154
|
+
/** C# SkiaLabel.SetupBackgroundPaint: no BackgroundColor = no background, the gradient goes on the glyphs. */
|
|
155
|
+
protected FillGradientPaintsBackground(): boolean;
|
|
156
|
+
protected Paint(ctx: DrawingContext): void;
|
|
157
|
+
ProcessGestures(args: SkiaGesturesParameters, apply: GestureEventProcessingInfo): SkiaControl | null;
|
|
158
|
+
/** Return null to not consume the tap. */
|
|
159
|
+
protected OnSpanTapped(span: TextSpan, args: SkiaGesturesParameters, apply: GestureEventProcessingInfo): SkiaControl | null;
|
|
160
|
+
}
|