Struct ResizeController

Source
pub struct ResizeController { /* private fields */ }
Expand description

Tracks pending window size and schedules resize before the next frame.

The default controller is ready, has no retry deadline, and has not observed a zero native extent. Resize requests coalesce: the most recent non-zero physical size replaces the previous pending size.

§Examples

use ailloli_ui_winit::resize::ResizeController;
let controller = ResizeController::default();
assert!(controller.pending().is_none());
assert!(!controller.zero_extent_unavailable());

Implementations§

Source§

impl ResizeController

Coalescing, retry, zero-extent, and acquisition-recovery state transitions.

Source

pub fn request(&mut self, size: PhysicalSize<u32>) -> bool

Retains a non-zero resize for the next redraw.

A zero physical extent makes the presentation dormant immediately: no retry deadline or pending redraw is retained until winit reports a later non-zero size.

Returns true when a non-zero request was queued and false when a zero component made the surface unavailable. Queuing a non-zero request does not clear the zero sentinel until the renderer successfully applies it.

§Examples
use ailloli_ui_winit::resize::ResizeController;
use winit::dpi::PhysicalSize;
let mut controller = ResizeController::default();
assert!(controller.request(PhysicalSize::new(640, 480)));
assert_eq!(controller.pending(), Some(PhysicalSize::new(640, 480)));
assert!(!controller.request(PhysicalSize::new(0, 480)));
assert!(controller.pending().is_none());
Source

pub fn request_window_size(&mut self, window: &Window) -> bool

Queues the window’s current physical client size.

This has the same zero-extent and coalescing semantics as Self::request.

§Examples
use ailloli_ui_winit::resize::ResizeController;
fn queue(controller: &mut ResizeController, window: &winit::window::Window) {
    let queued: bool = controller.request_window_size(window);
    let _ = queued;
}
Source

pub fn pending(&self) -> Option<PhysicalSize<u32>>

Returns the latest queued non-zero physical extent, if any.

§Examples
use ailloli_ui_winit::resize::ResizeController;
use winit::dpi::PhysicalSize;
let mut controller = ResizeController::default();
controller.request(PhysicalSize::new(320, 200));
assert_eq!(controller.pending(), Some(PhysicalSize::new(320, 200)));
Source

pub fn retry_at(&self) -> Option<Instant>

Returns the retry deadline after a renderer-deferred configure.

None means no timed retry is armed; it does not imply that no ordinary resize is pending.

§Examples
let controller = ailloli_ui_winit::resize::ResizeController::default();
assert!(controller.retry_at().is_none());
Source

pub fn zero_extent_unavailable(&self) -> bool

Reports whether a zero width or height currently prevents presentation.

The flag remains set after a later non-zero request and clears only once that request is successfully applied.

§Examples
use ailloli_ui_winit::resize::ResizeController;
use winit::dpi::PhysicalSize;
let mut controller = ResizeController::default();
controller.request(PhysicalSize::new(100, 0));
assert!(controller.zero_extent_unavailable());
Source

pub fn request_surface_recovery( &mut self, window: &Window, ) -> SurfaceRecoveryAction

Schedules the first, cheap recovery step for a Lost/Outdated surface. A repeated acquisition failure before a successful frame escalates to full presentation recreation instead of looping on configure forever. A zero extent preserves forced-reconfigure intent but cannot immediately escalate because no native surface can safely be rebuilt at that size.

§Examples
use ailloli_ui_winit::resize::{ResizeController, SurfaceRecoveryAction};
fn recover(controller: &mut ResizeController, window: &winit::window::Window) {
    let action: SurfaceRecoveryAction = controller.request_surface_recovery(window);
    let _ = action;
}
Source

pub fn mark_render_succeeded(&mut self)

Clears escalation state only after a frame was acquired and submitted.

§Examples
let mut controller = ailloli_ui_winit::resize::ResizeController::default();
controller.mark_render_succeeded();
assert!(!controller.zero_extent_unavailable());
Source

pub fn prepare_redraw( &mut self, window: &Window, renderer: &mut Renderer, ) -> Result<ResizeRedrawAction, RendererError>

Applies a pending resize if due; call before rendering each frame.

The window’s current physical size is authoritative, preventing a stale non-zero queued size from configuring a surface after minimization.

§Errors

Propagates renderer resize or forced-reconfiguration failures.

§Examples
use ailloli_ui_winit::resize::{ResizeController, ResizeRedrawAction};
fn prepare(
    controller: &mut ResizeController,
    window: &winit::window::Window,
    renderer: &mut ailloli_ui_render_wgpu::Renderer,
) {
    let action: ResizeRedrawAction = controller.prepare_redraw(window, renderer).unwrap();
    let _ = action;
}
Source

pub fn defer_for_surface(&mut self, window: &Window)

Forces a delayed surface reconfigure at the window’s current size.

A zero component cancels the deadline and leaves the controller dormant until another non-zero resize request arrives.

§Examples
use ailloli_ui_winit::resize::ResizeController;
fn defer(controller: &mut ResizeController, window: &winit::window::Window) {
    controller.defer_for_surface(window);
}
Source

pub fn take_due_redraw_request(&mut self) -> bool

Consumes a due retry deadline or reports an ordinary pending resize.

Returns false while a timed retry is still in the future. Once due, the deadline is cleared and exactly one true is returned; the pending size remains for Self::prepare_redraw.

§Examples
use ailloli_ui_winit::resize::ResizeController;
use winit::dpi::PhysicalSize;
let mut controller = ResizeController::default();
assert!(!controller.take_due_redraw_request());
controller.request(PhysicalSize::new(10, 10));
assert!(controller.take_due_redraw_request());

Trait Implementations§

Source§

impl Debug for ResizeController

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ResizeController

Source§

fn default() -> ResizeController

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,