// Generated API outline. Implementation bodies omitted.
#nullable enable
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
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;
using static Xui.Core.Math2D.Constants;
namespace Xui.Core.Actual
{
///
/// Tactile presets. The platform chooses the closest available native effect;
/// strength and texture are not guaranteed to be identical across devices.
///
public enum HapticEffect
{
/// A small, crisp ruler or picker tick.
///
/// On iOS, uses UISelectionFeedbackGenerator.selectionChanged().
/// On Android, uses View.performHapticFeedback(SEGMENT_TICK) on API 34+,
/// falling back to CLOCK_TICK on earlier versions.
///
Tick,
/// A light physical impact.
///
/// On iOS, uses UIImpactFeedbackGenerator.impactOccurred() with the light style.
/// On Android, approximated with VibrationEffect.EFFECT_TICK on API 29+,
/// falling back to View.performHapticFeedback(CLOCK_TICK) on earlier versions.
///
LightImpact,
/// A medium physical impact.
///
/// On iOS, uses UIImpactFeedbackGenerator.impactOccurred() with the medium style.
/// On Android, approximated with VibrationEffect.EFFECT_CLICK on API 29+,
/// falling back to View.performHapticFeedback(LONG_PRESS) on earlier versions.
///
MediumImpact,
/// A heavy physical impact.
///
/// On iOS, uses UIImpactFeedbackGenerator.impactOccurred() with the heavy style.
/// On Android, approximated with VibrationEffect.EFFECT_HEAVY_CLICK on API 29+,
/// falling back to View.performHapticFeedback(LONG_PRESS) on earlier versions.
///
HeavyImpact,
/// A soft, rounded impact.
///
/// On iOS, uses UIImpactFeedbackGenerator.impactOccurred() with the soft style.
/// On Android API 31+, approximated with a composed PRIMITIVE_THUD at scale 0.5
/// when the device supports it. Otherwise uses VibrationEffect.EFFECT_CLICK on API 29+,
/// or View.performHapticFeedback(CLOCK_TICK) on earlier versions.
///
SoftImpact,
/// A firm, sharp impact.
///
/// On iOS, uses UIImpactFeedbackGenerator.impactOccurred() with the rigid style.
/// On Android API 31+, approximated with a composed PRIMITIVE_CLICK at scale 1.0
/// when the device supports it. Otherwise uses VibrationEffect.EFFECT_CLICK on API 29+,
/// or View.performHapticFeedback(LONG_PRESS) on earlier versions.
///
RigidImpact,
/// Positive completion feedback.
///
/// On iOS, uses UINotificationFeedbackGenerator.notificationOccurred(.success).
/// On Android, uses View.performHapticFeedback(CONFIRM) on API 30+.
/// Approximated with VibrationEffect.EFFECT_DOUBLE_CLICK on API 29,
/// or View.performHapticFeedback(LONG_PRESS) on earlier versions.
///
Success,
/// A cautionary notification.
///
/// On iOS, uses UINotificationFeedbackGenerator.notificationOccurred(.warning).
/// Android has no dedicated warning preset. Approximated with
/// VibrationEffect.EFFECT_DOUBLE_CLICK on API 29+, falling back to
/// View.performHapticFeedback(LONG_PRESS) on earlier versions.
///
Warning,
/// Failure or rejection feedback.
///
/// On iOS, uses UINotificationFeedbackGenerator.notificationOccurred(.error).
/// On Android, uses View.performHapticFeedback(REJECT) on API 30+.
/// Approximated with VibrationEffect.EFFECT_DOUBLE_CLICK on API 29,
/// or View.performHapticFeedback(LONG_PRESS) on earlier versions.
///
Error,
}
///
/// Represents a platform-specific dispatcher for marshaling callbacks onto the main UI thread.
/// Used by the Xui runtime to ensure thread-safe execution of UI logic.
///
/// Each platform must provide an implementation that posts callbacks to the appropriate runloop or UI thread.
///
public interface IDispatcher
{
///
/// Posts the specified callback to be executed on the dispatcher's thread (typically the UI thread).
/// Use this method when calling from a background thread and needing to safely transition
/// to the main thread for UI updates or layout work.
///
/// The action to execute on the dispatcher's thread.
void Post(Action callback);
}
///
/// Optional, window-scoped tactile feedback. Resolve through the view's service
/// provider and call on the UI thread. Desktop runtimes may leave this unregistered.
/// Requests respect native settings and hardware capabilities; playback is not guaranteed.
///
public interface IHapticFeedback
{
///
/// Prepares an effect without vibrating. This is an optional latency hint;
/// must work without it. Platforms may ignore the hint.
///
void Prepare(HapticEffect effect);
///
/// Plays a preset using the platform's closest available effect. Native platforms
/// may coalesce rapid requests; this does not queue delayed pulses.
///
void Play(HapticEffect effect);
}
///
/// Represents a platform-specific run loop responsible for driving the application's lifecycle.
/// Each platform must provide an implementation that enters the appropriate system event loop
/// and continues running until the application exits.
///
/// The Xui runtime uses this interface to abstract over platform differences in event dispatch and app execution.
///
public interface IRunLoop
{
///
/// Starts the main run loop for the application.
/// This method may block until the application terminates or exits naturally.
/// On platforms with built-in UI event loops (e.g., iOS, Android),
/// this method may return immediately after bootstrapping the application delegate.
///
/// The application’s exit code.
int Run();
///
/// Requests that the run loop exit gracefully.
/// On platforms with a definite exit (Win32, macOS) this posts a quit message to the main thread.
/// On platforms without a run loop (iOS, Browser) this is a no-op.
///
void Quit();
}
///
/// Provides a platform-specific implementation of the Xui runtime,
/// responsible for creating and connecting abstract application components to their actual counterparts.
///
/// This interface acts as a bridge between the platform-independent core and the underlying OS-specific APIs
/// (e.g., Win32, Cocoa, UIKit), enabling rendering, windowing, and event dispatch.
///
public interface IRuntime
{
///
/// Gets the main thread dispatcher for scheduling UI work.
/// Used to marshal execution onto the main thread for layout, input, and rendering.
///
IDispatcher MainDispatcher { get; }
///
/// Creates a platform-specific window that is bound to the given abstract window definition.
///
/// The abstract window definition provided by user code.
/// The window/application service chain reached after platform services.
/// A concrete window implementation for the current platform.
Actual.IWindow CreateWindow(Abstract.IWindow windowAbstract, IServiceProvider applicationServices);
///
/// Creates a platform-specific run loop associated with the given abstract application.
/// The returned run loop is responsible for managing the application's execution lifecycle.
///
/// The abstract application instance defined by user code.
/// A platform-specific run loop instance.
IRunLoop CreateRunloop(Abstract.Application applicationAbstract);
}
///
/// Optional window-scoped control of status-bar text and icons. Resolve through the
/// window or view service provider and use on the UI thread. Desktop runtimes may
/// leave this unregistered. This does not change the bar background or safe area.
///
public interface IStatusBar
{
/// Gets or sets the requested foreground appearance.
StatusBarAppearance Appearance { get; set; }
}
///
/// Optional, window-scoped vibration playback. Call on the UI thread. Each Play
/// replaces this service's previous playback; stop when the owning interaction ends.
/// Desktop runtimes need not register this service; emulators provide silent playback.
///
public interface IVibration
{
/// Whether the device can produce vibration.
bool IsSupported { get; }
/// Whether normalized frequency/texture control is available.
bool SupportsFrequency { get; }
///
/// Starts or updates continuous vibration until Stop. Strength and frequency
/// must be finite and in [0, 1]. Frequency describes texture, not physical Hz:
/// iOS maps it to sharpness; Android uses envelope sharpness when supported.
/// Android may replace the native effect when updating; otherwise frequency is ignored.
/// Zero strength silences playback. Native settings and interruptions still apply.
///
void Play(nfloat strength, nfloat frequency);
///
/// Plays linearly interpolated control points, optionally repeating until Stop.
/// At least two points are required, beginning at zero with strictly increasing
/// times, up to 30 seconds. Implementations copy or consume the span before returning.
/// Native devices may resample points or soften the pattern boundaries.
///
void Play(scoped ReadOnlySpan points, bool repeat = false);
/// Stops playback and cancels pending starts. Safe to call repeatedly.
void Stop();
}
/// Foreground appearance of the system status-bar text and icons.
public enum StatusBarAppearance
{
/// Follow platform appearance policy (normally the system light/dark theme), not canvas pixel sampling.
Auto = 0,
/// Light text and icons, suitable for a dark background.
Light = 1,
/// Dark text and icons, suitable for a light background.
Dark = 2,
}
/// Shared validation and interpolation for native vibration backends.
public static class VibrationPattern
{
/// The portable pattern duration limit, matching one iOS continuous event.
public static readonly TimeSpan MaximumDuration;
/// Validates a normalized strength/frequency pair.
public static void Validate(nfloat strength, nfloat frequency);
/// Validates the point count, times, duration and normalized values.
public static void Validate(scoped ReadOnlySpan points);
/// Samples a validated pattern, clamping outside its time range.
public static VibrationPoint Sample(scoped ReadOnlySpan points, TimeSpan time);
}
/// A vibration's normalized strength and frequency/texture at an absolute pattern time.
/// Time from the beginning of the pattern.
/// Strength in [0, 1].
/// Texture in [0, 1], from soft/low to crisp/high; not Hertz.
public readonly record struct VibrationPoint(TimeSpan Time, nfloat Strength, nfloat Frequency);
}
namespace Xui.Core.Actual
{
using Xui.Core.Canvas;
///
/// Platform image pipeline. Caches decoded GPU-resident images by URI and vends
/// handles to views via the service-resolution chain.
/// Implement this on each platform window to participate in image loading.
///
public interface IImagePipeline
{
///
/// Creates a new handle backed by this pipeline's catalog.
/// The handle is initially empty; populate it with
/// or .
///
IImage CreateImage();
}
///
/// Represents a platform-specific window implementation used by the Xui runtime.
/// Each platform (e.g., Windows, macOS, iOS) must provide an implementation of this interface
/// to manage window lifecycle, rendering, and input.
///
/// This interface is typically paired with an abstract window in the Xui framework,
/// and is not used directly by application developers.
///
public interface IWindow : IServiceProvider
{
///
/// Gets the abstract window immediately upstream of this actual window.
/// Together with , this forms the
/// bidirectional composed-window chain.
///
Abstract.IWindow? Abstract { get; }
///
/// The service provider reached after this actual window. Middleware uses this
/// exclusively for its forward service chain; it must never use its abstract
/// event receiver as a service fallback.
///
IServiceProvider NextServiceProvider { get; }
///
/// Gets or sets the window title, where supported by the platform (e.g., desktop).
///
string Title { get; set; }
///
/// Displays the window to the user. This may include making it visible, entering the main loop,
/// or attaching it to the application's view hierarchy, depending on the platform.
///
void Show();
///
/// Closes and destroys the platform window. Called when the abstract window is disposed
/// programmatically rather than through a user-initiated close gesture.
/// The default implementation is a no-op for platforms that do not support imperative close.
///
void Close();
///
/// Requests a redraw of the window surface.
/// The platform should trigger a paint or render callback as soon as possible.
///
void Invalidate();
///
/// Gets or sets whether the window currently requires keyboard input focus.
/// Platforms may use this to show or hide on-screen keyboards.
///
bool RequireKeyboard { get; set; }
///
/// Gets a lightweight text measure context for hit-testing text positions
/// during pointer events. Returns null on platforms that do not support it.
///
ITextMeasureContext? TextMeasureContext { get; }
}
}
namespace Xui.Core.Actual
{
using Xui.Core.UI;
/// Optional native range editing and selection service, resolved through the window.
public interface ITextInputSession
{
/// Connects the focused editor, or ends the session on blur. The service owns NativeSelection while connected.
void SetClient(ITextEditingClient? client);
/// Cancels native selection gestures when an ancestor takes pointer capture.
void CancelSelectionGesture();
}
}
namespace Xui.Core.Actual
{
using Xui.Core.Math2D;
///
/// Optional, window-scoped native precision-selection UI. Resolve through the view's
/// service provider; absence (or false) means no native loupe.
/// This presents rendered content only; the focused view owns text and selection.
///
public interface ITextMagnifier
{
/// Whether the running OS supports the native magnifier.
bool IsSupported { get; }
///
/// Begins or updates a precision-selection gesture. Both the touch position and
/// caret bounds are in logical window coordinates, after all view transforms.
/// Call on the UI thread, only from the focused selection owner.
///
void Show(Point position, Rect caret);
///
/// Ends the gesture and releases native state. Safe to call repeatedly.
/// Call on release, cancellation, loss of capture/focus, or removal of the owner.
///
void Hide();
}
}