// Generated API outline. Implementation bodies omitted.
#nullable enable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using System.Threading;
using System;
using nfloat = System.Runtime.InteropServices.NFloat;
namespace Xui.ToolKit.UI.Design
{
using Xui.Core.Canvas;
///
/// A group of four semantically related colors derived from a single tonal palette,
/// together with the underlying OKLCH ramp that generated them. Shared by all consumers;
/// interaction colors are derived once on demand instead of copied into individual views.
///
public sealed class ColorGroup
{
/// Whether this group belongs to a dark appearance palette.
public bool IsDark { get; init; }
/// Background for a hovered filled control.
public Color HoverBackground { get; }
/// Background for a pressed filled control.
public Color PressedBackground { get; }
/// Pressed state layer for an outline or text control.
public Color PressedContainer { get; }
/// Hovered active toggle track.
public Color ToggleHoverBackground { get; }
/// Pressed background within a segmented selection.
public Color SelectedPressedBackground { get; }
///
/// Strong, saturated action color (ramp at tone 0.56 light / 0.75 dark).
/// Use as fill for filled buttons, active indicators, primary UI elements.
///
public Color Background { get; init; }
///
/// Black or white text/icon color on Background, selected by its actual luminance.
///
public Color Foreground { get; init; }
///
/// Light tinted fill from the same palette (ramp at tone 0.90 light / 0.30 dark).
/// Use for tonal buttons, chips, and highlighted list rows.
///
public Color Container { get; init; }
///
/// Text/icon color on top of Container (ramp at tone 0.10 light / 0.90 dark).
///
public Color OnContainer { get; init; }
///
/// The full tonal ramp for this palette entry (Lightness 0 to 1 at the group's hue).
/// Use for computing hover/press state colors.
///
public OklchRamp Ramp { get; init; }
///
/// The lightness value (0–1) used to produce from the ramp.
/// Enables relative hover/press offset computation.
///
public nfloat BackgroundLightness { get; init; }
///
/// Creates a from a tonal ramp and color scheme.
///
public static ColorGroup FromRamp(OklchRamp ramp, bool isDark);
}
///
/// Provides color roles derived from a seed palette, grouped into semantic
/// bundles and a set of neutral/structural colors.
///
public interface IColorSystem
{
///
/// The application canvas color group.
/// Background = window/screen fill, Foreground = body text,
/// Container = card/panel fill, OnContainer = card text.
///
ColorGroup Application { get; }
///
/// The surface (card/panel) color group, slightly elevated from Application.
/// Background = card fill, Foreground = card body text,
/// Container = alternate surface (e.g. alternating table row, hover bg),
/// OnContainer = secondary text on alternate surface.
///
ColorGroup Surface { get; }
///
/// Low-chroma interactive group matching the surface tone.
/// Used for quiet buttons, toolbars, and controls that should not compete
/// with Primary/Secondary/Tertiary.
///
ColorGroup Neutral { get; }
/// Neutral border/divider color (mid-tone).
Color Outline { get; }
/// Lighter neutral border/divider variant.
Color OutlineVariant { get; }
/// Brand / primary action group (from the Primary tonal ramp).
ColorGroup Primary { get; }
/// Supporting / secondary action group (from the Secondary tonal ramp).
ColorGroup Secondary { get; }
/// Tertiary highlight / accent group (from the Tertiary tonal ramp).
ColorGroup Tertiary { get; }
/// Warning / caution state group (yellow-orange tonal ramp).
ColorGroup Warning { get; }
/// Error / destructive state group (from the Error tonal ramp).
ColorGroup Error { get; }
/// Focus ring color (typically Tertiary.Background at full opacity).
Color FocusRing { get; }
///
/// Returns a full tonal ramp for any hue/chroma combination.
///
OklchRamp GetTonalRamp(nfloat hueDegrees, nfloat chroma);
/// True if the current effective color scheme is dark.
bool IsDark { get; }
}
///
/// Provides corner-radius tokens scaled by .
///
public interface IShapeSystem
{
/// Global multiplier for all corner radii (default 1.0).
nfloat RoundnessFactor { get; }
/// 0 pt — no rounding.
CornerRadius None { get; }
/// 2 pt base, scaled by RoundnessFactor.
CornerRadius ExtraSmall { get; }
/// 4 pt base, scaled by RoundnessFactor.
CornerRadius Small { get; }
/// 8 pt base, scaled by RoundnessFactor.
CornerRadius Medium { get; }
/// 12 pt base, scaled by RoundnessFactor.
CornerRadius Large { get; }
/// 16 pt base, scaled by RoundnessFactor.
CornerRadius ExtraLarge { get; }
/// 9999 pt — fully round (pill).
CornerRadius Full { get; }
}
///
/// OKLCH perceptual color space (Oklab-based Lightness, Chroma, Hue).
/// Interpolation in OKLCH produces vivid, perceptually uniform color transitions.
/// See: https://bottosson.github.io/posts/oklab/
///
public readonly struct Oklch
{
/// Perceptual lightness (0.0 = black, 1.0 = white).
public nfloat L { get; init; }
/// Colorfulness (0.0 = neutral gray; typical max ~0.37 for sRGB gamut).
public nfloat C { get; init; }
/// Hue angle in degrees (0–360).
public nfloat H { get; init; }
///
/// Creates a new OKLCH color value.
///
public Oklch(nfloat l, nfloat c, nfloat h);
///
/// Converts an sRGB to OKLCH.
///
public Oklch(Color color);
///
/// Converts this OKLCH value back to an sRGB .
///
public Color ToColor();
///
/// Returns the maximum chroma representable in sRGB for the given lightness and hue.
/// Uses bisection search: for a candidate chroma, convert OKLCH to sRGB and check
/// whether all channels are in [0, 1].
///
public static nfloat MaxSrgbChroma(nfloat lightness, nfloat hueDegrees);
///
/// Converts this OKLCH value to an sRGB .
///
public static implicit operator Color(Oklch oklch);
///
/// Converts an sRGB to OKLCH.
///
public static implicit operator Oklch(Color color);
}
///
/// A gamut-aware tonal ramp that maps t in [0, 1] to a color at lightness t.
/// At each lightness, chroma is clamped to the sRGB gamut boundary for the hue,
/// ensuring every output color is representable without clipping.
///
public readonly struct OklchRamp
{
/// Hue angle in degrees (0–360).
public nfloat Hue { get; init; }
/// Requested target chroma (clamped to sRGB gamut at each lightness).
public nfloat TargetChroma { get; init; }
///
/// Creates a gamut-aware tonal ramp for the given hue and target chroma.
///
/// Hue angle in degrees (0–360).
/// Desired chroma level (will be clamped to sRGB gamut at each lightness).
public OklchRamp(nfloat hueDegrees, nfloat targetChroma);
///
/// Evaluates the ramp at position t in [0, 1], returning an sRGB Color.
/// t maps to lightness; chroma is gamut-clamped.
///
public Color this[nfloat t] { get; }
}
///
/// An immutable snapshot of a single text style from the typography scale.
///
public readonly struct TextStyle()
{
/// Font family name.
public string FontFamily { get; init; }
/// Font size in points (pre-multiplied by accessibility scale).
public nfloat FontSize { get; init; }
/// Line height in points.
public nfloat LineHeight { get; init; }
/// Additional letter spacing in points.
public nfloat LetterSpacing { get; init; }
/// Font weight (100–900).
public FontWeight FontWeight { get; init; }
/// Font style (normal, italic, oblique).
public FontStyle FontStyle { get; init; }
}
}
namespace Xui.ToolKit.UI.Design
{
///
/// Color-scheme relationship used to derive secondary/tertiary hues from a primary hue.
///
public enum ColorHarmony
{
/// Secondary = H + 180°.
Complementary,
/// Secondary = H + 30°, Tertiary = H + 60°.
Analogous,
/// Secondary = H + 150°, Tertiary = H + 210°.
SplitComplementary,
/// Secondary = H + 120°, Tertiary = H + 240°.
Triadic,
/// Secondary = H + 90°, Tertiary = H + 180°, Quaternary = H + 270°.
Tetradic,
}
/// Token groups affected by a live design-system update.
[Flags]
public enum DesignSystemChange
{
/// No tokens changed.
None = 0,
/// Palette or appearance changed; redraw without layout.
Colors = 1,
/// Font family or metrics changed; measure and arrange again.
Typography = 2,
/// Spacing or control sizing changed; measure and arrange again.
Spacing = 4,
/// Corner radii changed; redraw without layout.
Shape = 8,
/// Animation preferences or timings changed.
Motion = 16,
/// Initial application or a complete refresh of every token group.
All = Colors | Typography | Spacing | Shape | Motion,
}
///
/// Root interface for the Xui Design System.
/// Resolved from the parent-chain service provider via GetService<IDesignSystem>().
///
public interface IDesignSystem
{
/// Color tokens and palette math.
IColorSystem Colors { get; }
/// Typography scale.
ITypographySystem Typography { get; }
/// Spacing tokens derived from the 4-pt grid.
ISpacingSystem Spacing { get; }
/// Shape / corner-radius tokens.
IShapeSystem Shape { get; }
/// Motion tokens (curves and springs).
IMotionSystem Motion { get; }
/// Raised with the affected token groups after an update; consumers invalidate only the required passes.
event Action? Changed;
}
///
/// Receives a design-token update after a view has resolved its .
/// Implementations read shared tokens from the retained provider and invalidate only affected passes.
///
public interface IDesignSystemChangeNotifications
{
/// Responds to the changed token groups without duplicating theme state on the view.
void OnDesignTokenChange(DesignSystemChange changes);
}
///
/// Provides motion tokens for animations.
///
public interface IMotionSystem
{
/// Whether springs or curves are preferred for interactive feedback.
MotionPreference Preference { get; }
/// True if the user has requested reduced motion (accessibility).
bool ReducedMotion { get; }
/// Elements entering the screen — (0.05, 0.7, 0.1, 1.0), 400 ms.
CurveToken EmphasizedDecelerate { get; }
/// Elements leaving the screen — (0.3, 0.0, 0.8, 0.15), 200 ms.
CurveToken EmphasizedAccelerate { get; }
/// General transitions — (0.2, 0.0, 0.0, 1.0), 300 ms.
CurveToken Standard { get; }
/// Settling transitions — (0.0, 0.0, 0.0, 1.0), 250 ms.
CurveToken StandardDecelerate { get; }
/// Quick dismissals — (0.3, 0.0, 1.0, 1.0), 200 ms.
CurveToken StandardAccelerate { get; }
/// Progress bars, continuous — (0.0, 0.0, 1.0, 1.0), any duration.
CurveToken Linear { get; }
/// Art / lifestyle apps, button press — stiffness 600, damping 0.5.
SpringToken SpringBouncy { get; }
/// Default interactive feedback — stiffness 300, damping 0.8.
SpringToken SpringResponsive { get; }
/// Business / utility apps, modals — stiffness 200, damping 1.0.
SpringToken SpringSmooth { get; }
}
///
/// Provides two parallel spacing scales:
/// - — for layout, content gaps, margins, card padding.
- — for interactive leaf elements (button padding, input fields, hit targets).
/// On desktop, Active aligns with Passive (tight). On touch, Active shifts up
/// so that buttons/inputs get generous padding while layout stays compact.
public interface ISpacingSystem
{
/// Layout/content spacing scale.
SpacingScale Passive { get; }
/// Interactive element spacing scale (shifted up for touch targets).
SpacingScale Active { get; }
/// 0 pt.
nfloat None { get; }
}
///
/// Provides the typography scale.
/// All FontSize values are pre-multiplied by the accessibility font scale.
///
public interface ITypographySystem
{
/// 57 pt — Hero, marketing, splash.
TextStyle Display { get; }
/// 24–32 pt — Page and section titles.
TextStyleGroup Headline { get; }
/// 14–22 pt — Card headers, toolbars, tabs.
TextStyleGroup Title { get; }
/// 12–16 pt — Reading and UI text.
TextStyleGroup Body { get; }
/// 11–14 pt — Buttons, badges, captions.
TextStyleGroup Label { get; }
/// The default font family used across the application.
string DefaultFontFamily { get; }
}
///
/// Whether the application prefers curve-based (Bezier) or spring-based (physics) animations.
///
public enum MotionPreference
{
/// Duration + cubic Bezier easing.
Curve,
/// Spring physics (stiffness + damping).
Spring,
}
///
/// Controls animation timing and whether animations are enabled.
///
public enum MotionPreset
{
/// No animations — all transitions snap instantly.
None,
/// Short/snappy animations (50% of normal duration).
Short,
/// Normal animation timing (default).
Normal,
/// Slow/deliberate animations (200% of normal duration). Useful for review/accessibility.
Long,
}
///
/// Controls the relationship between Application and Surface background colors.
///
public enum NeutralStyle
{
///
/// Both Application and Surface are desaturated neutral gray. No hue tint.
///
Monochrome,
///
/// Application gets a subtle Secondary hue tint, Surface stays neutral.
/// Suitable for apps with many panels/surfaces where the app background groups them.
///
SecondaryApp,
///
/// Surface gets a subtle Secondary hue tint, Application stays neutral.
/// Suitable when few panels appear and most widgets sit directly on the app background.
///
SecondarySurface,
///
/// Application gets a subtle Tertiary hue tint, Surface stays neutral.
///
TertiaryApp,
///
/// Surface gets a subtle Tertiary hue tint, Application stays neutral.
///
TertiarySurface,
}
///
/// Predefined shape profiles that control corner radius tokens across the design system.
///
public enum ShapePreset
{
/// All corners square (0 radius everywhere).
Square,
///
/// Classic desktop style: slight container radius (~7pt), square buttons and inputs.
/// Typical of macOS and Windows window chrome.
///
Desktop,
///
/// Modern dialog style: large outer radius, smaller inner radius, small button radius (3–5pt).
/// Similar to macOS alerts and Android Material dialogs.
///
Rounded,
///
/// Same as Rounded but with fully-round (pill) buttons.
///
RoundedPill,
///
/// Maximum roundness: large container radius, pill buttons. High visual softness.
///
Soft,
}
///
/// Predefined sizing profiles that control spacing tokens, minimum hit-test radius,
/// and overall density of the UI.
///
public enum SizingPreset
{
///
/// Compact desktop: small spacing, small hit targets (4pt), precise pointer assumed.
/// Suitable for dense desktop applications with mouse input.
///
Desktop,
///
/// Touch-enabled desktop: same compact layout as Desktop but with larger hit targets (22pt).
/// Good for laptop touchscreens and stylus-enabled desktops.
///
TouchEnabled,
///
/// Mobile: generous spacing, large hit targets (22pt), finger-friendly.
/// Suitable for phones and tablets.
///
Mobile,
}
///
/// A set of spacing values on a geometric scale (S through XXXL).
/// Used for both passive (layout/content) and active (interactive leaf) spacing.
///
public readonly struct SpacingScale
{
/// Small spacing.
public nfloat S { get; init; }
/// Medium spacing.
public nfloat M { get; init; }
/// Large spacing.
public nfloat L { get; init; }
/// Extra-large spacing.
public nfloat XL { get; init; }
/// 2× extra-large spacing.
public nfloat XXL { get; init; }
/// 3× extra-large spacing.
public nfloat XXXL { get; init; }
///
/// Minimum hit-test dimension for small interactive elements (icon buttons, tree toggles, etc.).
/// On Desktop this is small (e.g. 20pt), on touch it's finger-sized (e.g. 44pt).
/// Use as MinimumWidth/MinimumHeight on compact clickable views.
///
public nfloat MinHitTarget { get; init; }
}
///
/// Spring physics parameters for animation.
///
public readonly struct SpringToken
{
/// Spring stiffness (higher = faster oscillation).
public float Stiffness { get; init; }
/// Damping ratio (1.0 = critically damped, less than 1.0 = bouncy).
public float Damping { get; init; }
}
///
/// A group of three related text styles at small, medium, and large sizes.
///
public readonly struct TextStyleGroup
{
/// Small variant.
public TextStyle S { get; init; }
/// Medium variant.
public TextStyle M { get; init; }
/// Large variant.
public TextStyle L { get; init; }
}
}
namespace Xui.ToolKit.UI.Design
{
using Xui.Core.Animation;
///
/// An easing curve paired with a default duration for animation.
/// Wraps from Xui.Core.Animation.
///
public readonly struct CurveToken
{
/// The cubic Bezier easing curve.
public Easing.CubicBezier Curve { get; init; }
/// Default duration for this easing curve.
public TimeSpan DefaultDuration { get; init; }
}
}
namespace Xui.ToolKit.UI.Design
{
using Xui.Core.Canvas;
using Xui.Core.DI;
using Xui.Core.Math2D;
using Xui.Core.UI;
/// Provides a device-aware design system to a subtree of controls.
public sealed class DesignSystemView : View
{
/// Wraps content with the supplied theme, or the default Xui theme.
public DesignSystemView(View content, XuiDesignSystemOptions? options = null);
///
/// Returns the number of child views. Used by layout containers and traversal logic.
/// Leaf views should return 0.
///
public override int Count { get; }
///
/// Indexer to access child views by index.
/// Layout containers should implement this to expose their children.
///
public override View this[int index] { get; }
///
/// Resolves a service of the given type by walking up the parent chain.
/// Returns null if no ancestor provides the service.
///
public override object? GetService(Type type);
///
/// Called when this view becomes active — it will receive events, render, and animate.
/// Override this to start animations, subscribe to data sources, or acquire resources.
///
protected override void OnActivate();
///
/// Called when this view becomes dormant — it should stop animations, timers, and event subscriptions.
/// The view may remain in the tree (e.g., in a virtualizing panel's recycle pool).
///
protected override void OnDeactivate();
/// Override to compute the desired border-edge size.
protected override Size MeasureCore(Size available, IMeasureContext context);
/// Override to arrange children within this view's final frame.
protected override void ArrangeCore(Rect rect, IMeasureContext context);
}
}
namespace Xui.ToolKit.UI.Design
{
using Xui.Core.DI;
///
/// Concrete implementation of that derives a complete set of
/// design tokens from a small number of seed properties and the current .
///
public class XuiDesignSystem : IDesignSystem
{
///
/// Creates a new design system from the given options and device info.
///
public XuiDesignSystem(XuiDesignSystemOptions options, IDeviceInfo device);
/// Updates the retained palette in place and rebuilds only other changed token groups.
public void Update(XuiDesignSystemOptions options, IDeviceInfo device);
/// Color tokens and palette math.
public IColorSystem Colors { get; }
/// Typography scale.
public ITypographySystem Typography { get; }
/// Spacing tokens derived from the 4-pt grid.
public ISpacingSystem Spacing { get; }
/// Shape / corner-radius tokens.
public IShapeSystem Shape { get; }
/// Motion tokens (curves and springs).
public IMotionSystem Motion { get; }
/// Raised with the affected token groups after an update; consumers invalidate only the required passes.
public event Action? Changed;
///
/// Raises the event, causing widgets to re-query tokens.
///
public void NotifyChanged(DesignSystemChange changes = DesignSystemChange.All);
}
///
/// Value-type options for constructing or updating a without allocating a configuration object.
///
public readonly struct XuiDesignSystemOptions
{
/// Initializes the default design-system settings.
public XuiDesignSystemOptions();
/// Primary brand hue in degrees (0–360). Required.
public nfloat PrimaryHue { get; init; }
/// Optional secondary hue override. If null, derived from .
public nfloat? SecondaryHue { get; init; }
/// Optional tertiary/accent hue override. If null, derived from .
public nfloat? TertiaryHue { get; init; }
/// Optional neutral hue override. If null, derived as primary hue desaturated.
public nfloat? NeutralHue { get; init; }
/// Color harmony used to derive secondary/tertiary hues. Default: SplitComplementary.
public ColorHarmony Harmony { get; init; }
/// Target chroma for the primary palette (typical range 0.10–0.35). Default: 0.15.
public nfloat Chroma { get; init; }
/// Optional primary action lightness (0–1). Null uses the appearance's default action tone.
public nfloat? PrimaryLightness { get; init; }
/// Global corner-radius multiplier (0.0 = square, 1.0 = default, 2.0 = very round). Default: 1.0.
public nfloat RoundnessFactor { get; init; }
/// Shape preset controlling corner radius tokens. Default: Soft.
public ShapePreset Shape { get; init; }
/// Sizing preset controlling spacing and hit-test targets. Default: Mobile.
public SizingPreset Sizing { get; init; }
/// Controls the hue relationship between Application and Surface backgrounds. Default: Monochrome.
public NeutralStyle NeutralStyle { get; init; }
/// Preferred animation style. Default: Curve.
public MotionPreference MotionPreference { get; init; }
/// Animation timing preset. Default: Normal.
public MotionPreset Motion { get; init; }
/// Default font family for all text styles. Default: system-ui.
public string DefaultFontFamily { get; init; }
}
}