Struct UiApp

Source
pub struct UiApp<A> { /* private fields */ }
Expand description

Multi-window winit application (one runtime + one renderer per window).

Retained rendering flow:

  • reconcile runs once at startup per window,
  • each redraw: layout → paint → ailloli_ui_render_wgpu.

The application starts with no windows and uses [ControlFlow::Wait]. Each registered logical window retains its runtime, input, popup, text, and presentation intents across native suspend/resume cycles.

§Examples

let app = ailloli_ui_winit::UiApp::<()>::new();
assert!(app.window_snapshots().is_empty());
assert!(app.error().is_none());

Implementations§

Source§

impl<A: 'static> UiApp<A>

Declarative configuration, host wake wiring, diagnostics, and retained state access.

Source

pub fn new() -> Self

Creates an empty application using [ControlFlow::Wait].

Installs lazy native clipboard and validated system URL providers. No native event loop, window, renderer, or remote server is created yet.

§Examples
let app = ailloli_ui_winit::UiApp::<u32>::new();
assert!(app.error().is_none());
Source

pub fn with_control_flow(control_flow: ControlFlow) -> Self

Creates an empty application with an explicit winit control-flow policy.

The policy is copied into the event loop during presentation creation; host wait service may temporarily choose a deadline needed by resize, text, render-retry, or scheduled-repaint work.

§Examples
use winit::event_loop::ControlFlow;
let app = ailloli_ui_winit::UiApp::<()>::with_control_flow(ControlFlow::Poll);
assert!(app.window_snapshots().is_empty());
Source

pub fn capture_handle(self, handle: CaptureHandle) -> Self

Attaches a capture handle processed during redraw.

Repeated builder calls replace the previous handle. Clones held by the caller continue to share the newly attached queue state.

§Examples
use ailloli_ui_winit::{CaptureHandle, UiApp};
let captures = CaptureHandle::new();
let app = UiApp::<()>::new().capture_handle(captures.clone());
captures.request_window("main");
let _ = app;
Source

pub fn inject_presentation_fault( &mut self, logical_window_id: &LogicalWindowId, fault: PresentationTestFault, ) -> bool

Queues a deterministic presentation failure for the next safe event-loop boundary.

Returns true and appends the fault when the id is pending, attached, retained, or a live Wayland overlay; unknown ids return false without mutation. Faults for one id retain FIFO order.

§Examples
use ailloli_ui_core::LogicalWindowId;
use ailloli_ui_winit::{PresentationTestFault, UiApp};
let mut app = UiApp::<()>::new();
assert!(!app.inject_presentation_fault(
    &LogicalWindowId::new("missing"), PresentationTestFault::Lost));
Source

pub fn inject_event_envelope(&mut self, envelope: EventEnvelope) -> bool

Routes one provider-neutral event through a currently attached and generation-matching presentation.

Returns false for an unknown logical window or stale generation. A stale known envelope increments the saturating rejection counter. An accepted event ensures initial layout, routes input, and schedules redraw when routing or retained dirtiness requires it.

§Panics

Panics only if the internal window map loses the resolved entry between the immutable lookup and subsequent mutable lookup.

§Examples
fn inject(app: &mut ailloli_ui_winit::UiApp<()>,
    envelope: ailloli_ui_runtime::input::EventEnvelope) {
    let accepted: bool = app.inject_event_envelope(envelope);
    let _ = accepted;
}
Source

pub fn presentation_test_state( &self, logical_window_id: &LogicalWindowId, ) -> Option<PresentationTestState>

Returns deterministic presentation state/counters for native tests.

Returns None for unknown and still-pending windows. Live winit and Wayland presentations set attached; suspended retained windows do not. Missing counter history is reported as all zeros.

§Examples
use ailloli_ui_core::LogicalWindowId;
let app = ailloli_ui_winit::UiApp::<()>::new();
assert!(app.presentation_test_state(&LogicalWindowId::new("missing")).is_none());
Source

pub fn presentation_test_window_has_native_focus( &self, logical_window_id: &LogicalWindowId, ) -> Option<bool>

Reports whether the native host currently considers this test window focused.

Native input benchmarks use this readiness signal before injecting a focus-sensitive sequence. In particular, X11 can deliver its initial Focused(false)/Focused(true) pair after the first rendered frame. None means no attached winit window with that logical id; direct Wayland overlays deliberately do not report native focus here.

§Examples
use ailloli_ui_core::LogicalWindowId;
let app = ailloli_ui_winit::UiApp::<()>::new();
assert_eq!(app.presentation_test_window_has_native_focus(
    &LogicalWindowId::new("missing")), None);
Source

pub fn presentation_test_popup_mount_state( &self, logical_window_id: &LogicalWindowId, popup_id: PopupId, ) -> Option<(bool, bool)>

Reports whether a retained popup registration is mounted in the requested live presentation and whether that popup tree owns focus.

Returns None for non-live/unknown winit windows, otherwise Some((mounted, owns_focus)). Focus ownership implies the same popup id.

§Examples
fn inspect(app: &ailloli_ui_winit::UiApp<()>,
    id: &ailloli_ui_core::LogicalWindowId,
    popup: ailloli_ui_runtime::popup::PopupId) {
    let state: Option<(bool, bool)> = app.presentation_test_popup_mount_state(id, popup);
    let _ = state;
}
Source

pub fn presentation_test_element_bounds( &self, logical_window_id: &LogicalWindowId, key: &str, ) -> Option<Rect>

Returns the absolute layout bounds of one keyed view in a live native presentation. This is available only to the event-loop test driver.

Bounds use logical window coordinates. Unknown windows, missing or ambiguous keys, and elements without absolute paint bounds return None.

§Examples
use ailloli_ui_core::LogicalWindowId;
let app = ailloli_ui_winit::UiApp::<()>::new();
assert!(app.presentation_test_element_bounds(
    &LogicalWindowId::new("missing"), "button").is_none());
Source

pub fn presentation_test_focus_within_key( &self, logical_window_id: &LogicalWindowId, key: &str, ) -> Option<bool>

Reports whether a keyed view contains the current focus target in one live native presentation.

Some(false) means the window and unique key exist but focus is absent or outside that subtree. Unknown windows and unresolved keys return None.

§Examples
use ailloli_ui_core::LogicalWindowId;
let app = ailloli_ui_winit::UiApp::<()>::new();
assert!(app.presentation_test_focus_within_key(
    &LogicalWindowId::new("missing"), "editor").is_none());
Source

pub fn devtools_remote_addr(self, addr: SocketAddr) -> Self

Configures the loopback devtools address for subsequently created windows.

This builder stores the address but does not bind immediately. Each window attempts its own remote server when retained state is created.

§Examples
let address = "127.0.0.1:9229".parse().unwrap();
let app = ailloli_ui_winit::UiApp::<()>::new().devtools_remote_addr(address);
assert!(app.error().is_none());
Source

pub fn runtime(&self) -> RuntimeHandle<A>

Shared runtime handle (windows, focus, clipboard, chrome ops).

Clones share the same action queue and providers; this does not clone per-window retained trees or renderers.

§Examples
let app = ailloli_ui_winit::UiApp::<u32>::new();
let runtime: ailloli_ui_runtime::app::RuntimeHandle<u32> = app.runtime();
assert!(runtime.take_actions().is_empty());
Source

pub fn window(self, options: WindowOptions, root: impl IntoView<A>) -> Self

Registers a window to open on resumed (hidden until first frame is drawn).

The clear color defaults to transparent for transparent windows and #1a1a1f otherwise. Registration is append-only and performs no native work. The caller-provided visibility flag is overridden to hidden.

§Panics

Panics only if the fixed internal #1a1a1f color literal is changed to an invalid hexadecimal color.

§Examples
use ailloli_ui_widgets::text::Text;
use ailloli_ui_winit::{UiApp, WindowOptions};
let app = UiApp::<()>::new().window(WindowOptions::default(), Text::new("Hello"));
assert!(app.window_snapshots().is_empty());
Source

pub fn window_with_clear( self, options: WindowOptions, clear: Color, root: impl IntoView<A>, ) -> Self

Registers a hidden-until-first-frame window with an explicit clear color.

Unlike Self::window, transparency does not replace clear; the exact supplied color is retained. Native work remains deferred until resume.

§Examples
use ailloli_ui_core::Color;
use ailloli_ui_widgets::text::Text;
use ailloli_ui_winit::{UiApp, WindowOptions};
let app = UiApp::<()>::new().window_with_clear(
    WindowOptions::default(), Color::TRANSPARENT, Text::new("Overlay"));
assert!(app.error().is_none());
Source

pub fn request_redraw_all(&mut self)

Requests redraw for every live or retained presentation.

Live winit windows receive native redraw requests; retained windows queue a coalescible presentation intent. Direct Wayland overlays mark their redraw bit and best-effort wake the host. An empty application is a no-op.

§Examples
let mut app = ailloli_ui_winit::UiApp::<()>::new();
app.request_redraw_all();
assert!(app.error().is_none());
Source

pub fn request_window_redraw( &mut self, logical_window_id: &LogicalWindowId, ) -> bool

Requests a redraw for one stable logical window when it is attached.

Suspended retained windows queue the intent for replay after attachment. Returns false only when no live or retained presentation has the id.

§Examples
use ailloli_ui_core::LogicalWindowId;
let mut app = ailloli_ui_winit::UiApp::<()>::new();
assert!(!app.request_window_redraw(&LogicalWindowId::new("missing")));
Source

pub fn take_error(&mut self) -> Option<UiAppError>

Consumes the first fatal host error.

A second call returns None unless a later fatal error was recorded.

§Examples
let mut app = ailloli_ui_winit::UiApp::<()>::new();
assert!(app.take_error().is_none());
Source

pub fn error(&self) -> Option<&UiAppError>

Borrows the first fatal host error without consuming it.

§Examples
let app = ailloli_ui_winit::UiApp::<()>::new();
assert!(app.error().is_none());
Source

pub fn window_snapshots(&self) -> Vec<WindowSnapshot>

Returns the latest persisted/logical snapshot for every known window id.

Live attached state overrides an older retained snapshot with the same logical id. The returned HashMap values have unspecified order.

§Examples
let app = ailloli_ui_winit::UiApp::<()>::new();
let snapshots: Vec<ailloli_ui_app_storage::WindowSnapshot> = app.window_snapshots();
assert!(snapshots.is_empty());
Source

pub fn native_overlay_capabilities( &self, logical_window_id: &str, ) -> Option<NativeOverlayCapabilities>

Effective overlay capabilities for a live logical window.

Returns None for normal windows, unknown ids, retained/detached overlays, or native overlay setup that did not establish every invariant.

§Examples
let app = ailloli_ui_winit::UiApp::<()>::new();
assert!(app.native_overlay_capabilities("missing").is_none());

Trait Implementations§

Source§

impl<A: 'static> Default for UiApp<A>

Creates an empty wait-mode application with native clipboard and URL providers.

Source§

fn default() -> Self

Delegates to UiApp::new.

Auto Trait Implementations§

§

impl<A> Freeze for UiApp<A>

§

impl<A> !RefUnwindSafe for UiApp<A>

§

impl<A> !Send for UiApp<A>

§

impl<A> !Sync for UiApp<A>

§

impl<A> Unpin for UiApp<A>

§

impl<A> !UnwindSafe for UiApp<A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,