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.
impl ResizeController
Coalescing, retry, zero-extent, and acquisition-recovery state transitions.
Sourcepub fn request(&mut self, size: PhysicalSize<u32>) -> bool
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());Sourcepub fn request_window_size(&mut self, window: &Window) -> bool
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;
}Sourcepub fn pending(&self) -> Option<PhysicalSize<u32>>
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)));Sourcepub fn retry_at(&self) -> Option<Instant>
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());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());Sourcepub fn request_surface_recovery(
&mut self,
window: &Window,
) -> SurfaceRecoveryAction
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;
}Sourcepub fn mark_render_succeeded(&mut self)
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());Sourcepub fn prepare_redraw(
&mut self,
window: &Window,
renderer: &mut Renderer,
) -> Result<ResizeRedrawAction, RendererError>
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;
}Sourcepub fn defer_for_surface(&mut self, window: &Window)
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);
}Sourcepub fn take_due_redraw_request(&mut self) -> bool
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
impl Debug for ResizeController
Source§impl Default for ResizeController
impl Default for ResizeController
Source§fn default() -> ResizeController
fn default() -> ResizeController
Auto Trait Implementations§
impl Freeze for ResizeController
impl RefUnwindSafe for ResizeController
impl Send for ResizeController
impl Sync for ResizeController
impl Unpin for ResizeController
impl UnwindSafe for ResizeController
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> DowncastSync for T
impl<T> DowncastSync for T
§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().