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.
impl<A: 'static> UiApp<A>
Declarative configuration, host wake wiring, diagnostics, and retained state access.
Sourcepub fn new() -> Self
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());Sourcepub fn with_control_flow(control_flow: ControlFlow) -> Self
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());Sourcepub fn capture_handle(self, handle: CaptureHandle) -> Self
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;Sourcepub fn inject_presentation_fault(
&mut self,
logical_window_id: &LogicalWindowId,
fault: PresentationTestFault,
) -> bool
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));Sourcepub fn inject_event_envelope(&mut self, envelope: EventEnvelope) -> bool
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;
}Sourcepub fn presentation_test_state(
&self,
logical_window_id: &LogicalWindowId,
) -> Option<PresentationTestState>
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());Sourcepub fn presentation_test_window_has_native_focus(
&self,
logical_window_id: &LogicalWindowId,
) -> Option<bool>
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);Sourcepub fn presentation_test_popup_mount_state(
&self,
logical_window_id: &LogicalWindowId,
popup_id: PopupId,
) -> Option<(bool, bool)>
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;
}Sourcepub fn presentation_test_element_bounds(
&self,
logical_window_id: &LogicalWindowId,
key: &str,
) -> Option<Rect>
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());Sourcepub fn presentation_test_focus_within_key(
&self,
logical_window_id: &LogicalWindowId,
key: &str,
) -> Option<bool>
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());Sourcepub fn devtools_remote_addr(self, addr: SocketAddr) -> Self
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());Sourcepub fn runtime(&self) -> RuntimeHandle<A>
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());Sourcepub fn window(self, options: WindowOptions, root: impl IntoView<A>) -> Self
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());Sourcepub fn window_with_clear(
self,
options: WindowOptions,
clear: Color,
root: impl IntoView<A>,
) -> Self
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());Sourcepub fn request_redraw_all(&mut self)
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());Sourcepub fn request_window_redraw(
&mut self,
logical_window_id: &LogicalWindowId,
) -> bool
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")));Sourcepub fn take_error(&mut self) -> Option<UiAppError>
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());Sourcepub fn error(&self) -> Option<&UiAppError>
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());Sourcepub fn window_snapshots(&self) -> Vec<WindowSnapshot>
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());Sourcepub fn native_overlay_capabilities(
&self,
logical_window_id: &str,
) -> Option<NativeOverlayCapabilities>
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().