drawnui-react 0.1.0-preview.35 → 0.1.0-preview.37

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.
Files changed (42) hide show
  1. package/SKIPPED.md +3 -0
  2. package/dist/controls/SkiaButton.js +2 -2
  3. package/dist/controls/SkiaCarousel.js +31 -3
  4. package/dist/controls/SkiaCheckbox.js +2 -1
  5. package/dist/controls/SkiaEditor.d.ts +4 -0
  6. package/dist/controls/SkiaEditor.js +16 -4
  7. package/dist/controls/SkiaLabel.d.ts +2 -0
  8. package/dist/controls/SkiaLabel.js +2 -0
  9. package/dist/controls/SkiaLayout.d.ts +2 -0
  10. package/dist/controls/SkiaLayout.js +2 -0
  11. package/dist/controls/SkiaProgress.js +2 -2
  12. package/dist/controls/SkiaRadioButton.js +2 -1
  13. package/dist/controls/SkiaShaderCarousel.js +5 -0
  14. package/dist/controls/SkiaSlider.js +2 -2
  15. package/dist/controls/SkiaSwitch.js +4 -2
  16. package/dist/controls/TooltipStyle.d.ts +52 -0
  17. package/dist/controls/TooltipStyle.js +88 -0
  18. package/dist/core/Accessibility.d.ts +30 -0
  19. package/dist/core/Accessibility.js +162 -3
  20. package/dist/core/Canvas.d.ts +76 -3
  21. package/dist/core/Canvas.js +239 -8
  22. package/dist/core/ControlStyle.d.ts +2 -0
  23. package/dist/core/ControlStyle.js +2 -0
  24. package/dist/core/Hover.d.ts +4 -0
  25. package/dist/core/Hover.js +6 -0
  26. package/dist/core/KeyboardManager.d.ts +7 -0
  27. package/dist/core/KeyboardManager.js +35 -4
  28. package/dist/core/PopupWindows.d.ts +92 -0
  29. package/dist/core/PopupWindows.js +203 -0
  30. package/dist/core/SkiaControl.d.ts +30 -0
  31. package/dist/core/SkiaControl.js +60 -3
  32. package/dist/core/Super.d.ts +7 -0
  33. package/dist/core/Super.js +7 -0
  34. package/dist/core/Tooltips.d.ts +71 -0
  35. package/dist/core/Tooltips.js +205 -0
  36. package/dist/index.d.ts +3 -0
  37. package/dist/index.js +3 -0
  38. package/dist/react/index.d.ts +16 -1
  39. package/dist/react/index.js +51 -11
  40. package/dist/react/reconciler.d.ts +2 -0
  41. package/dist/react/reconciler.js +5 -0
  42. package/package.json +3 -1
package/SKIPPED.md CHANGED
@@ -53,6 +53,9 @@ DrawnUi name and semantics; nothing here is a redesign, only an omission.
53
53
  | `Gestures` param | ported | Touch: `Lock` applies `touch-action:none`; `Enabled` behaves like MAUI's Enabled inside a native scroll view: `touch-action` is the axes the page (or a scrolling ancestor) can scroll (`pan-y` / `pan-x` / both, `none` when it cannot; inside an iframe the vertical axis always counts, because the embedding page cannot be inspected cross-origin), recomputed on attach, on window / html / body resize and after every touch, so a finger pan along a page axis scrolls the page and the canvas pointer is cancelled (a cancelled pointer never flings a `SkiaScroll`), taps and the other axis stay on the canvas, and a full-page app keeps every touch. `user-select:none` in both. Claimed touches: in `Enabled` a touch or pen Down is processed immediately (queued gestures first) and, when a control used it (same rule as the wheel: marked `Handled`, or a consumer that is not a `BlockGesturesBelow` layer), the touch is claimed and its `touchmove` events are default-prevented until it ends, so the page cannot take that drag mid-gesture (iOS Safari ignores `touch-action` for off-axis drags, w3c/pointerevents#303); unclaimed touches share the page as before. Controls that use a Down: `ConsumeGestures` handlers that set `Consumed`, `SkiaCarousel` (always), `SkiaSlider`, `SkiaEditor`, `SkiaButton` when `OnDown` accepts; `SkiaScroll` and plain `Tapped` controls do not. Mouse wheel: `Enabled` shares it with the page like Blazor's `TouchHandlingStyle.Manual` (the wheel is processed in the DOM handler and the browser default is prevented only when a control used it: a scroll that moved, a `ConsumeGestures` handler that consumed, or any other consumer that is not a `BlockGesturesBelow` layer merely blocking the controls below, so an embedded canvas lets the page scroll over anything that does not scroll, including a shell page, and a scroll at its edge hands the wheel to the page; `TouchActionEventArgs.Handled` is the AppoMobi marker for that use); `Lock` prevents every wheel and also blocks `touchmove` default. Not ported: Blazor's pointer capture policy for `Enabled` (capture only while locked, release when a pan is not consumed); React captures every press. |
54
54
  | Mouse cursor over interactive controls (Blazor `Canvas.razor` `.xaml-a11y-interactive { cursor: pointer }`) | ported (differently) | The overlay here is `pointer-events: none`, so `Canvas.UpdateCursor` hit-tests mouse moves with no active pointer against the accessibility snapshot rects (`CanInteract` = has `Tapped`, buttons, links) and asks each hit control `WantsPointerCursor(x, y)` (default `AccessibilityCanInteract`; `SkiaLabel` also answers for its tappable `TextSpan`s), setting the canvas element's `cursor` only when the answer changes. Touch pointers do nothing. Engine hover (`IsHovered` / `OnHover`, `TouchActionResult.Pointer`) stays skipped, see Gestures. |
55
55
  | `ContextMenu` (right click / long press / Menu key, React extension) | ported (web-only) | `SkiaControl.ContextMenu` / `Canvas.ContextMenu` handlers with `ContextMenuEventArgs` (`Location` points, `Pixels`, `Local` px in the control, `Source`, `Native`); the DOM `contextmenu` event is routed like a tap (`ProcessContextMenu`: visible non-transparent children top-most first through `TransformPointToLocalSpace`, then the control, then the canvas). `true` = handled, browser menu suppressed; nothing handled = browser menu. Not in DrawnUi.Net. |
56
+ | Tooltips (`SkiaControl.Tooltip`, `Super.TooltipsFromAccessibility`, `TooltipStyle`) | ported | drawnui-cross 6ar: shows after `ShowDelayMs` on the innermost control with tooltip text, the next one at once within `FollowWindowMs`; attached to the control (centered 6 pt above, below where there is no room) or `AtCursor`, `OffsetX` / `OffsetY`, anchored on screen now, kept inside the canvas; closes on leave, press, wheel, key, content moving under the pointer and window blur, never on touch; no hover, no accessibility node; `CreateTooltip` for custom content. Drawn in the canvas only (a browser page has no windows past its edge). |
57
+ | Popup windows (`Canvas.OpenPopupWindow` / `ClosePopupWindow` / `ClosePopupWindows` / `IsPopupWindowOpen`, `PopupAnchor`, `PopupWindowOptions`, `PopupWindowClosed`) | ported | drawnui-cross 6at, the DrawnUi.Rust / .NET API (C# names): anchor a point, a rect or a control (below it, flipped where it does not fit, kept inside); drawn over everything, given input and hover first; closes on a press outside (the rest of that press goes nowhere), Escape, the wheel outside, window blur and from code; options `Size`, `CloseOnPointerLeave`, `Passive`; `OnCanvas` / `Cpu` accepted, always on the canvas. React extra: `OpenPopupWindow(canvas, jsx, anchor, options)` renders JSX content and unmounts it on close. |
58
+ | `AccessibilityModal`, `Canvas.ArrowsStartKeyboardNavigation` | ported | drawnui-cross 6av, C# 6e87c9ae / 914428d2 / 981ff09e / 86467ece / 77d1dca4 / 6aee5c51: a shown modal limits screen readers and Tab to its subtree plus popup windows (topmost wins), reads as a dialog with its name, takes the keyboard when it appears with the keyboard in use and gives it back when it goes; the flat overlay's container is the dialog (role, name, aria-modal). With nothing focused (or only a control behind the modal) and the canvas option on, an arrow starts keyboard navigation. Shell popups and modals do not set the flag yet. |
56
59
  | Keyboard navigation (drawnui-cross 6c) | ported | Through the accessibility overlay, the DrawnUi.Blazor way: Tab / Shift+Tab walk the interactive nodes in reading order, Enter / Space activate (`SkiaAccessibilityManager.Activate`), ArrowLeft / Right / Up / Down, Home / End, PageUp / PageDown go to the focused control first (`OnAccessibilityKey`, `SkiaAccessibilityManager.Key`: `SkiaSlider` steps, `SkiaEditor` keeps them while editing), then to its arrow-key group (`MoveInGroup`). A container with a composite role (`Aria.IsCompositeRole`: list, listbox, grid, toolbar, radiogroup, tablist, menu, menubar) is one Tab stop (roving tabindex, `IsTabStop`, entered on the item focused last); the arrows move by item index (Column: Up / Down, Row: Left / Right, Wrap / Grid / Split: all four, Up / Down by a row), no wrap, items not realized are scrolled in with `ScrollToIndex` and focused once drawn (`OnKeyboardFocusRequested`). `SkiaEditor` is a Tab stop: Tab in takes the caret, Tab / Shift+Tab leave it for the next node (also after a click into it). Focus ring = the overlay element's `:focus-visible` outline; focus scrolls the node into view in every enclosing scroll. Not ported: `FocusedChild` / canvas `KeyboardFocusNode`, Escape leaving the drawn nodes, a canvas-drawn focus ring. |
57
60
  | Canvas draw events | ported | `WillFirstTimeDraw` (once, right before the first frame drawn on a ready surface, with that frame's `{ Canvas, Surface }`), `WasDrawn` (after every frame, no context, like the C# `null`), `WasRendered` (set after the first frame completes, so the first `WasDrawn` still sees `false`, C# order), `CanRender` (surface ready). JSX: `<Canvas WillFirstTimeDraw WasDrawn>`; the engine draws frame 1 in its constructor, so the component hands both callbacks to the constructor's `init`. Not ported: `WillDraw`. |
58
61
  | Rendering stats | partial | `Canvas.FPS` (frames drawn over the last second) and `Canvas.FrameTime` (ms of the last measure + arrange + render, GPU flush excluded) are computed every frame and reachable from React through the `<Canvas>` ref. `SkiaLabelFps` ported (label on top, input-transparent, parent-independent, re-measures itself on draw; its value changes only on frames that running animators request, see PARITY). Not ported: `SkiaLabelFps.ForceRefresh` / `Format` / `MonoForDigits`, `Super.EnableRenderingStats`. |
@@ -3,7 +3,7 @@ import { SKPoint } from "../core/Gestures";
3
3
  import { SkiaLayout } from "./SkiaLayout";
4
4
  import { SkiaLabel } from "./SkiaLabel";
5
5
  import { SkiaShape } from "./SkiaShape";
6
- import { ResolveControlStyle } from "../core/ControlStyle";
6
+ import { DefaultAccent, ResolveControlStyle } from "../core/ControlStyle";
7
7
  /**
8
8
  * Mirrors DrawnUi SkiaButton (default style): a SkiaShape frame tagged "BtnShape" + a centered SkiaLabel
9
9
  * tagged "BtnText". Consumes Down/Up/Tapped inside its rect; releases the pressed state when a pan exceeds
@@ -89,7 +89,7 @@ export class SkiaButton extends SkiaLayout {
89
89
  case "Material": return { bg: "#2196F3", radius: 4, font: 14, weight: 0, minW: 100, minH: 40, shadow: new SkiaShadow({ X: 0, Y: 2, Blur: 4, Opacity: 0.3, Color: Colors.Black }) };
90
90
  case "Material3": return { bg: "#6750A4", radius: 20, font: 14, weight: 0, minW: 100, minH: 40 };
91
91
  case "Windows": return { bg: "#0078D7", radius: 4, font: 15, weight: 500, minW: 100, minH: 32, shadow: new SkiaShadow({ X: 0, Y: 1, Blur: 1, Opacity: 0.2, Color: Colors.Black }) };
92
- default: return { bg: "#DC143C", radius: 8, font: 15, weight: 0, minW: 100, minH: 41 };
92
+ default: return { bg: DefaultAccent, radius: 8, font: 15, weight: 0, minW: 100, minH: 41 };
93
93
  }
94
94
  }
95
95
  MeasureAbsolute(w, h, scale) {
@@ -236,6 +236,26 @@ export class SkiaCarousel extends SnappingLayout {
236
236
  ScrollToNearestAnchor(location, velocity) {
237
237
  const t = this.SnapVelocityThreshold;
238
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
+ }
239
259
  if (this.ApplyLoopedLogic) {
240
260
  const origin = this.FindNearestAnchorInternal(location, velocity);
241
261
  const target = this.SelectNextAnchor(origin, velocity);
@@ -305,9 +325,17 @@ export class SkiaCarousel extends SnappingLayout {
305
325
  /** C# FixIndex: a virtual anchor becomes the real one, the position keeps its offset (visually identical, looped drawing wraps). */
306
326
  FixIndex() {
307
327
  if (this.IsLooped && this.SnapPoints.length > 1 && this.selectedIndex >= 0 && this.selectedIndex < this.SnapPoints.length) {
308
- const snap = this.GetVirtualAnchor(this.CurrentPosition);
309
- const ox = this.CurrentPosition.X - snap.Location.X, oy = this.CurrentPosition.Y - snap.Location.Y;
310
- const real = this.SnapPoints[this.selectedIndex];
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;
311
339
  this.CurrentSnap = real;
312
340
  this.CurrentPosition = new SKPoint(real.X + ox, real.Y + oy);
313
341
  }
@@ -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 = "#DC143C";
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); }
@@ -108,6 +108,8 @@ export declare class SkiaEditor extends SkiaShape {
108
108
  get ShouldSubmitOnEnter(): boolean;
109
109
  /** Caret index (UTF-16 units) = the left edge of the selection when one exists. */
110
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;
111
113
  set CursorPosition(v: number);
112
114
  get SelectionLength(): number;
113
115
  set SelectionLength(v: number);
@@ -153,6 +155,8 @@ export declare class SkiaEditor extends SkiaShape {
153
155
  private LabelPoint;
154
156
  protected Paint(ctx: DrawingContext): void;
155
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;
156
160
  /** A text field is a Tab stop by default, like a native text box, with no Tapped handler needed. */
157
161
  protected DefaultAccessibilityCanInteract(): boolean;
158
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. */
@@ -1,6 +1,6 @@
1
1
  import { SKPoint } from "../core/Gestures";
2
2
  import { Super } from "../core/Super";
3
- import { ResolveControlStyle } from "../core/ControlStyle";
3
+ import { DefaultAccent, ResolveControlStyle } from "../core/ControlStyle";
4
4
  import { KeyboardManager } from "../core/KeyboardManager";
5
5
  import { TextInputProxy } from "../core/TextInputProxy";
6
6
  import { Colors, ScaledSize, SKRect, Thickness } from "../core/Types";
@@ -181,9 +181,11 @@ export class SkiaEditor extends SkiaShape {
181
181
  get ShouldSubmitOnEnter() { return this.IsMultiline && this.ReturnType === "Send"; }
182
182
  /** Caret index (UTF-16 units) = the left edge of the selection when one exists. */
183
183
  get CursorPosition() { return this.cursorPosition; }
184
+ /** A position from app code as a whole number: beyond the text (MAX_SAFE_INTEGER, Infinity) is the end, NaN is 0. */
185
+ static Whole(v) { return Number.isNaN(v) ? 0 : Math.trunc(v); }
184
186
  set CursorPosition(v) {
185
187
  this.cursorPlaced = true;
186
- const p = Math.max(0, Math.min(this.text.length, v | 0));
188
+ const p = Math.max(0, Math.min(this.text.length, SkiaEditor.Whole(v)));
187
189
  if (p === this.cursorPosition)
188
190
  return;
189
191
  this.cursorPosition = p;
@@ -191,7 +193,7 @@ export class SkiaEditor extends SkiaShape {
191
193
  }
192
194
  get SelectionLength() { return this.selectionLength; }
193
195
  set SelectionLength(v) {
194
- const l = Math.max(0, Math.min(this.text.length - this.cursorPosition, v | 0));
196
+ const l = Math.max(0, Math.min(this.text.length - this.cursorPosition, SkiaEditor.Whole(v)));
195
197
  if (l === this.selectionLength)
196
198
  return;
197
199
  this.selectionLength = l;
@@ -248,6 +250,14 @@ export class SkiaEditor extends SkiaShape {
248
250
  this.StopBlink();
249
251
  this.SetFocusNative(false);
250
252
  }
253
+ // the canvas focus follows the editor's own (a press, Tab, code), so a tap elsewhere can end the editing (6ap)
254
+ const canvas = this.Superview;
255
+ if (canvas) {
256
+ if (v)
257
+ canvas.ReportFocus(this, this);
258
+ else if (canvas.FocusedChild === this)
259
+ canvas.ReportFocus(undefined, this);
260
+ }
251
261
  this.FocusChanged?.(this, v);
252
262
  this.NotifyAccessibility();
253
263
  this.InvalidateCache();
@@ -266,7 +276,7 @@ export class SkiaEditor extends SkiaShape {
266
276
  : style === "Material" ? { bg: "#EFEBF4", corner: 4, stroke: Colors.Transparent, strokeW: 0, cursor: "#2196F3" }
267
277
  : style === "Material3" ? { bg: "#E6E0E9", corner: 4, stroke: Colors.Transparent, strokeW: 0, cursor: "#6750A4" }
268
278
  : style === "Windows" ? { bg: "#FFFFFF", corner: 2, stroke: "#8A8A8A", strokeW: 1, cursor: "#0078D4" }
269
- : { bg: "#F2F3F5", corner: 8, stroke: Colors.Transparent, strokeW: 0, cursor: "#DC143C" };
279
+ : { bg: "#F2F3F5", corner: 8, stroke: Colors.Transparent, strokeW: 0, cursor: DefaultAccent };
270
280
  const apply = (key, current, next, set) => {
271
281
  if (!(key in this.styleApplied) || this.styleApplied[key] === current) {
272
282
  set();
@@ -631,6 +641,8 @@ export class SkiaEditor extends SkiaShape {
631
641
  }
632
642
  return this;
633
643
  }
644
+ /** The canvas gives or takes the focus (a tap elsewhere): an editor always takes it. */
645
+ SetFrameworkFocus(focus) { this.IsFocused = focus; return true; }
634
646
  /** A text field is a Tab stop by default, like a native text box, with no Tapped handler needed. */
635
647
  DefaultAccessibilityCanInteract() { return true; }
636
648
  /** Keyboard navigation reached the field (Tab) or left it: take the caret and the input sink like a native text box, or release them. */
@@ -105,6 +105,8 @@ export declare class SkiaLabel extends SkiaControl {
105
105
  set TextTransform(v: TextTransform);
106
106
  get Padding(): Thickness;
107
107
  set Padding(v: ThicknessValue);
108
+ /** A label with text, in Text or in its spans, shows text of its own (no accessibility-label tooltip). */
109
+ ShowsText(): boolean;
108
110
  /** Number of laid-out lines after the last measure. */
109
111
  get LinesCount(): number;
110
112
  AddSubView(control: SkiaControl | TextSpan): void;
@@ -98,6 +98,8 @@ export class SkiaLabel extends SkiaControl {
98
98
  set TextTransform(v) { this.Set("textTransform", v); }
99
99
  get Padding() { return this.padding; }
100
100
  set Padding(v) { this.Set("padding", Thickness.From(v)); }
101
+ /** A label with text, in Text or in its spans, shows text of its own (no accessibility-label tooltip). */
102
+ ShowsText() { return !!this.text || this.Spans.some((s) => !!s.Text); }
101
103
  /** Number of laid-out lines after the last measure. */
102
104
  get LinesCount() { return this.lines.length; }
103
105
  // ---- spans as children (reconciler AddSubView / InsertSubView / RemoveSubView) ----
@@ -129,6 +129,8 @@ export declare class SkiaLayout extends SkiaControl {
129
129
  InsertChild(child: SkiaControl, before?: SkiaControl): void;
130
130
  /** C# OrderViews: the given children, in their order, inside the slots they occupy in the views; nothing else moves. */
131
131
  private OrderChildren;
132
+ /** A child showing text (a caption inside a button) is text of its own: the accessibility label then makes no tooltip. */
133
+ ShowsText(): boolean;
132
134
  /** C# ClearChildren: removes every subview, the control's own parts included. */
133
135
  ClearChildren(): void;
134
136
  private orderedViews?;
@@ -427,6 +427,8 @@ export class SkiaLayout extends SkiaControl {
427
427
  this.InvalidateMeasure();
428
428
  }
429
429
  }
430
+ /** A child showing text (a caption inside a button) is text of its own: the accessibility label then makes no tooltip. */
431
+ ShowsText() { return this.views.some((v) => v.ShowsText()); }
430
432
  /** C# ClearChildren: removes every subview, the control's own parts included. */
431
433
  ClearChildren() {
432
434
  for (const v of [...this.views])
@@ -1,6 +1,6 @@
1
1
  import { SkiaControl } from "../core/SkiaControl";
2
2
  import { Super } from "../core/Super";
3
- import { ResolveControlStyle } from "../core/ControlStyle";
3
+ import { DefaultAccent, ResolveControlStyle } from "../core/ControlStyle";
4
4
  import { ScaledSize } from "../core/Types";
5
5
  /**
6
6
  * Mirrors DrawnUi SkiaProgress (SkiaRangeBase): a horizontal track with a progress trail, per-style track height and
@@ -43,7 +43,7 @@ export class SkiaProgress extends SkiaControl {
43
43
  case "Material": return { track: "#E8EAED", progress: "#2196F3", height: 4, radius: 2 };
44
44
  case "Material3": return { track: "#E6E0E9", progress: "#6750A4", height: 4, radius: 2 };
45
45
  case "Windows": return { track: "#F3F2F1", progress: "#0078D4", height: 6, radius: 3 };
46
- default: return { track: "#D7DBE0", progress: "#DC143C", height: 8, radius: 4 };
46
+ default: return { track: "#D7DBE0", progress: DefaultAccent, height: 8, radius: 4 };
47
47
  }
48
48
  }
49
49
  get Ratio() { return this.max > this.min ? Math.max(0, Math.min(1, (this.value - this.min) / (this.max - this.min))) : 0; }
@@ -1,3 +1,4 @@
1
+ import { DefaultAccent } from "../core/ControlStyle";
1
2
  import { Colors, Thickness } from "../core/Types";
2
3
  import { SkiaLayout } from "./SkiaLayout";
3
4
  import { SkiaLabel } from "./SkiaLabel";
@@ -13,7 +14,7 @@ export class SkiaRadioButton extends SkiaToggle {
13
14
  groupKey;
14
15
  ViewOn;
15
16
  ViewText;
16
- static DefaultAccent = "#DC143C";
17
+ static DefaultAccent = DefaultAccent;
17
18
  static DefaultOutline = "#8E959D";
18
19
  constructor(text = "") {
19
20
  super();
@@ -203,6 +203,11 @@ export class SkiaShaderCarousel extends SkiaCarousel {
203
203
  if (!this.wasInTransitionAtDown)
204
204
  return super.ScrollToOffset(targetOffset, velocity, animate);
205
205
  this.wasInTransitionAtDown = false;
206
+ // a swipe back against the interrupted transition goes straight to its slide: wrapping that transition up first ran
207
+ // it on to its end and then back, a visible jump forward and back (C# b75f233a)
208
+ const heading = axis(this.gestureOrigin) - axis(this.gestureFrom), turn = axis(targetOffset) - axis(this.gestureOrigin);
209
+ if (heading !== 0 && turn !== 0 && Math.sign(heading) !== Math.sign(turn))
210
+ return super.ScrollToOffset(targetOffset, velocity, animate);
206
211
  // the pan may already have carried the position PAST the interrupted transition's destination toward the new
207
212
  // target: wrapping it up would animate backward first. Only run phase 1 while that destination is still ahead.
208
213
  const toOrigin = axis(this.gestureOrigin) - axis(this.CurrentPosition);
@@ -1,6 +1,6 @@
1
1
  import { SkiaControl } from "../core/SkiaControl";
2
2
  import { Super } from "../core/Super";
3
- import { ResolveControlStyle } from "../core/ControlStyle";
3
+ import { DefaultAccent, ResolveControlStyle } from "../core/ControlStyle";
4
4
  import { Colors, ScaledSize, SkiaShadow, Thickness } from "../core/Types";
5
5
  import { SkiaShape } from "./SkiaShape";
6
6
  /**
@@ -81,7 +81,7 @@ export class SkiaSlider extends SkiaControl {
81
81
  case "Material": return { thumb: 20, trackH: 4, track: "#E8EAED", selected: "#2196F3", thumbColor: "#2196F3", shadow: new SkiaShadow({ X: 0, Y: 1, Blur: 2, Opacity: 0.3, Color: Colors.Black }) };
82
82
  case "Material3": return { thumb: 20, trackH: 4, track: "#E6E0E9", selected: "#6750A4", thumbColor: "#6750A4", shadow: new SkiaShadow({ X: 0, Y: 1, Blur: 2, Opacity: 0.3, Color: Colors.Black }) };
83
83
  case "Windows": return { thumb: 20, trackH: 4, track: "#C6C6C6", selected: "#0078D4", thumbColor: "#0078D4", shadow: new SkiaShadow({ X: 0, Y: 1, Blur: 2, Opacity: 0.25, Color: Colors.Black }) };
84
- default: return { thumb: 35, trackH: 6, track: "#D7DBE0", selected: "#DC143C", thumbColor: "#DC143C", shadow: new SkiaShadow({ X: 0, Y: 1, Blur: 3, Opacity: 0.25, Color: Colors.Black }) };
84
+ default: return { thumb: 35, trackH: 6, track: "#D7DBE0", selected: DefaultAccent, thumbColor: DefaultAccent, shadow: new SkiaShadow({ X: 0, Y: 1, Blur: 3, Opacity: 0.25, Color: Colors.Black }) };
85
85
  }
86
86
  }
87
87
  /** Thumb shadows paint outside the box: the cache must include them. */
@@ -1,3 +1,4 @@
1
+ import { DefaultAccent } from "../core/ControlStyle";
1
2
  import { Colors, SkiaShadow, Thickness } from "../core/Types";
2
3
  import { Easing } from "../core/Easing";
3
4
  import { SkiaShape } from "./SkiaShape";
@@ -11,7 +12,7 @@ export class SkiaSwitch extends SkiaToggle {
11
12
  static DefaultAccessibilityRole = "switch";
12
13
  Track;
13
14
  Thumb;
14
- static DefaultAccent = "#DC143C"; // Crimson
15
+ static DefaultAccent = DefaultAccent;
15
16
  static DefaultTrack = "#D7DBE0";
16
17
  static MaterialOutline = "#79747E";
17
18
  StyleDefault(name) {
@@ -71,8 +72,9 @@ export class SkiaSwitch extends SkiaToggle {
71
72
  frame.StrokeColor = "#767676";
72
73
  thumb.Margin = new Thickness(5.5);
73
74
  break;
75
+ // the Agent Signals switch size (C# 5c1288f7, drawnui-cross 6as): 46 x 22, the thumb inside its 2 pt margin
74
76
  default:
75
- this.SetContentSize(46, 28);
77
+ this.SetContentSize(46, 22);
76
78
  frame.CornerRadius = 20;
77
79
  thumb.Margin = new Thickness(2);
78
80
  break;
@@ -0,0 +1,52 @@
1
+ import type { SkiaControl } from "../core/SkiaControl";
2
+ import { type Color, Thickness } from "../core/Types";
3
+ /**
4
+ * Look and timing of the tooltips a canvas shows for controls with a `Tooltip` (drawnui-cross 6ar, C# TooltipStyle).
5
+ * Set app-wide with `Super.TooltipStyle`, or per canvas with `Canvas.TooltipStyle`. Read when a tooltip is built, so a
6
+ * change applies from the next tooltip shown.
7
+ */
8
+ export declare class TooltipStyle {
9
+ /** Background of the tooltip: dark, a step lighter than dark app surfaces. */
10
+ BackgroundColor: Color;
11
+ /** Color of the tooltip text. */
12
+ TextColor: Color;
13
+ /** Color of the 1 pt border, lifts the tooltip off dark surfaces. Undefined or transparent for none. */
14
+ BorderColor?: Color;
15
+ /** Color of the soft shadow under the tooltip. Undefined or transparent for none. */
16
+ ShadowColor?: Color;
17
+ /** Font family of the tooltip text, undefined for the default font. */
18
+ FontFamily?: string;
19
+ /** Font size of the tooltip text, in points. */
20
+ FontSize: number;
21
+ /** Corner radius of the tooltip, in points. */
22
+ CornerRadius: number;
23
+ /** Space around the text, in points. */
24
+ Padding: Thickness;
25
+ /** Longer text wraps at this width, in points. */
26
+ MaxWidth: number;
27
+ /** How long the mouse rests on a control before its tooltip shows, in milliseconds. */
28
+ ShowDelayMs: number;
29
+ /** A tooltip that closed less than this many milliseconds ago lets the next one show at once (moving along a toolbar). */
30
+ FollowWindowMs: number;
31
+ /**
32
+ * False (default): attached to its control, centered 6 pt above it (below it where there is no room). True: below and
33
+ * to the right of the pointer where it rested (above it where there is no room). Either way it stays put while the
34
+ * mouse moves over the control.
35
+ */
36
+ AtCursor: boolean;
37
+ /** Moves the tooltip right (negative: left) from where it would go, in points. */
38
+ OffsetX: number;
39
+ /** Moves the tooltip down (negative: up), in points; on the flipped side it moves the other way, keeping its distance. */
40
+ OffsetY: number;
41
+ /**
42
+ * Builds the tooltip content for a text instead of the default rounded label. The control is measured and drawn on its
43
+ * own, outside the tree: it takes no input and screen readers do not see it.
44
+ */
45
+ CreateTooltip?: (text: string) => SkiaControl;
46
+ constructor(init?: Partial<TooltipStyle>);
47
+ /** Room left around the default tooltip for its shadow, in points. */
48
+ static readonly ShadowRoom = 8;
49
+ private static Visible;
50
+ /** The default tooltip content: the text on a rounded background. */
51
+ CreateDefault(text: string): SkiaControl;
52
+ }
@@ -0,0 +1,88 @@
1
+ import { Aria } from "../core/Accessibility";
2
+ import { Super } from "../core/Super";
3
+ import { SkiaShadow, Thickness } from "../core/Types";
4
+ import { SkiaLabel } from "./SkiaLabel";
5
+ import { SkiaShape } from "./SkiaShape";
6
+ /**
7
+ * Look and timing of the tooltips a canvas shows for controls with a `Tooltip` (drawnui-cross 6ar, C# TooltipStyle).
8
+ * Set app-wide with `Super.TooltipStyle`, or per canvas with `Canvas.TooltipStyle`. Read when a tooltip is built, so a
9
+ * change applies from the next tooltip shown.
10
+ */
11
+ export class TooltipStyle {
12
+ /** Background of the tooltip: dark, a step lighter than dark app surfaces. */
13
+ BackgroundColor = "#2B2D31";
14
+ /** Color of the tooltip text. */
15
+ TextColor = "#F2F3F5";
16
+ /** Color of the 1 pt border, lifts the tooltip off dark surfaces. Undefined or transparent for none. */
17
+ BorderColor = "#24FFFFFF";
18
+ /** Color of the soft shadow under the tooltip. Undefined or transparent for none. */
19
+ ShadowColor = "#59000000";
20
+ /** Font family of the tooltip text, undefined for the default font. */
21
+ FontFamily;
22
+ /** Font size of the tooltip text, in points. */
23
+ FontSize = 13;
24
+ /** Corner radius of the tooltip, in points. */
25
+ CornerRadius = 6;
26
+ /** Space around the text, in points. */
27
+ Padding = new Thickness(12, 8);
28
+ /** Longer text wraps at this width, in points. */
29
+ MaxWidth = 320;
30
+ /** How long the mouse rests on a control before its tooltip shows, in milliseconds. */
31
+ ShowDelayMs = 600;
32
+ /** A tooltip that closed less than this many milliseconds ago lets the next one show at once (moving along a toolbar). */
33
+ FollowWindowMs = 500;
34
+ /**
35
+ * False (default): attached to its control, centered 6 pt above it (below it where there is no room). True: below and
36
+ * to the right of the pointer where it rested (above it where there is no room). Either way it stays put while the
37
+ * mouse moves over the control.
38
+ */
39
+ AtCursor = false;
40
+ /** Moves the tooltip right (negative: left) from where it would go, in points. */
41
+ OffsetX = 0;
42
+ /** Moves the tooltip down (negative: up), in points; on the flipped side it moves the other way, keeping its distance. */
43
+ OffsetY = 0;
44
+ /**
45
+ * Builds the tooltip content for a text instead of the default rounded label. The control is measured and drawn on its
46
+ * own, outside the tree: it takes no input and screen readers do not see it.
47
+ */
48
+ CreateTooltip;
49
+ constructor(init) { if (init)
50
+ Object.assign(this, init); }
51
+ /** Room left around the default tooltip for its shadow, in points. */
52
+ static ShadowRoom = 8;
53
+ static Visible(c) {
54
+ if (!c || c === "Transparent" || c === "transparent")
55
+ return false;
56
+ const p = Super.ParseColor(c);
57
+ return p[3] > 0;
58
+ }
59
+ /** The default tooltip content: the text on a rounded background. */
60
+ CreateDefault(text) {
61
+ const shadow = TooltipStyle.Visible(this.ShadowColor);
62
+ const border = TooltipStyle.Visible(this.BorderColor);
63
+ const shape = new SkiaShape();
64
+ shape.CornerRadius = this.CornerRadius;
65
+ shape.BackgroundColor = this.BackgroundColor;
66
+ if (border) {
67
+ shape.StrokeColor = this.BorderColor;
68
+ shape.StrokeWidth = 1;
69
+ }
70
+ shape.Padding = this.Padding;
71
+ shape.Margin = shadow ? new Thickness(TooltipStyle.ShadowRoom) : Thickness.Zero; // the shadow is drawn inside the measured size
72
+ shape.MaximumWidthRequest = this.MaxWidth;
73
+ shape.UseCache = "Image";
74
+ if (shadow)
75
+ shape.Shadows = [new SkiaShadow({ X: 0, Y: 2, Blur: 6, Opacity: 1, Color: this.ShadowColor })];
76
+ const label = new SkiaLabel();
77
+ label.Text = text;
78
+ label.TextColor = this.TextColor;
79
+ label.FontSize = this.FontSize;
80
+ if (this.FontFamily)
81
+ label.FontFamily = this.FontFamily;
82
+ shape.AddSubView(label);
83
+ shape.AccessibilityRole = Aria.RolePresentation;
84
+ label.AccessibilityRole = Aria.RolePresentation;
85
+ return shape;
86
+ }
87
+ }
88
+ Super.TooltipStyle = new TooltipStyle();
@@ -1,6 +1,8 @@
1
1
  import type { InputKey } from "./KeyboardManager";
2
2
  import type { SkiaControl } from "./SkiaControl";
3
3
  import { SKRect } from "./Types";
4
+ /** Controls with `AccessibilityModal` set, on every canvas (drawnui-cross 6av). Empty: no modal work at all. */
5
+ export declare const AccessibilityModals: Set<SkiaControl>;
4
6
  /** ARIA role constants (DrawnUi.Models.Aria) for `AccessibilityRole`. */
5
7
  export declare const Aria: {
6
8
  readonly RoleButton: "button";
@@ -148,6 +150,7 @@ export declare class SkiaAccessibilityManager {
148
150
  static TryFindGroup(control: SkiaControl): {
149
151
  Group: SkiaControl;
150
152
  Item: SkiaControl;
153
+ Holder: SkiaControl;
151
154
  } | undefined;
152
155
  /** Remembers where keyboard focus is inside its group, so the next Tab into the group lands there. */
153
156
  private NoteFocus;
@@ -166,6 +169,33 @@ export declare class SkiaAccessibilityManager {
166
169
  * content, and focused once drawn. True when the key belongs to the group.
167
170
  */
168
171
  MoveInGroup(focused: SkiaControl, key: InputKey): boolean;
172
+ private focusRequest?;
173
+ private popupFocusRoot?;
174
+ private focusAnyInside;
175
+ /** The keyboard goes to this control at the end of the next frame (a popup closed: back to what opened it). */
176
+ RequestKeyboardFocus(control: SkiaControl): void;
177
+ private popupScope?;
178
+ /**
179
+ * While set, Tab stays inside this control: only its nodes are Tab stops and Tab / Shift+Tab go round them: the top
180
+ * popup window that takes input (a menu, a dropdown; set by the canvas), else the active modal.
181
+ */
182
+ get KeyboardScope(): SkiaControl | undefined;
183
+ set KeyboardScope(v: SkiaControl | undefined);
184
+ /** The modal that accessibility is limited to: the topmost `AccessibilityModal` control that shows. Undefined when none. */
185
+ ActiveModal?: SkiaControl;
186
+ private readonly modalReturns;
187
+ /** A control behind the active modal (not in it, not in a popup window over it): no focus for navigation. */
188
+ IsOutsideModal(control: SkiaControl): boolean;
189
+ /** Frame end, only while some control is flagged modal or one was active: follows the top modal. */
190
+ private UpdateActiveModal;
191
+ /** The Tab stop after (or before) `from` in reading order; inside a KeyboardScope it goes round, never leaving. */
192
+ NextTabStop(from: SkiaControl | undefined, forward: boolean): SkiaControl | undefined;
193
+ /**
194
+ * A popup window just opened: at the end of the frame that draws it, the keyboard goes to its arrow-key group's current
195
+ * choice (a checked radio, menuitemradio, option or tab), else to its first interactive item, however it was opened.
196
+ */
197
+ FocusOpenedPopup(root: SkiaControl): void;
198
+ private ProcessFocusRequests;
169
199
  /** Frame end: focus the requested item once it is drawn, skipping items that cannot take input. */
170
200
  private ProcessGroupFocus;
171
201
  private FocusFromKeyboard;