pub enum LoopMode {
RefreshSync,
Rate {
update_interval: Duration,
},
Wait,
NTimes {
number_of_updates: usize,
},
}Expand description
The mode in which the App is currently running the event loop and emitting Update events.
Variants§
RefreshSync
Synchronises Update events with requests for a new frame for the surface.
The result of using this loop mode is similar to using vsync in traditional applications. E.g. if you have one window running on a monitor with a 60hz refresh rate, your update will get called at a fairly consistent interval that is close to 60 times per second.
Rate
Specifies that the application is continuously looping at a consistent rate.
NOTE: This currently behaves the same as RefreshSync. Need to upate this to handled a
fix step properly in the future. See #456.
Wait
Waits for user input, window, device and wake-up events to occur before producing Update
events.
This is particularly useful for low-energy GUIs that only need to update when some sort of input has occurred. The benefit of using this mode is that you don’t waste CPU cycles looping or updating when you know nothing is changing in your model or view.
NTimes
Loops for the given number of updates and then finishes.
This is similar to the Wait loop mode, except that windowing, application and input
events will not cause the loop to update or view again after the initial
number_of_updates have already been applied.
This is useful for sketches where you only want to draw one frame, or if you know exactly how many updates you require for an animation, etc.
Implementations§
Source§impl LoopMode
impl LoopMode
pub const DEFAULT_RATE_FPS: f64 = 60f64
Sourcepub const UPDATES_PER_WAIT_EVENT: u32 = 3u32
pub const UPDATES_PER_WAIT_EVENT: u32 = 3u32
The minimum number of updates that will be emitted after an event is triggered in Wait mode.
Sourcepub fn refresh_sync() -> Self
pub fn refresh_sync() -> Self
A simplified constructor for the default RefreshSync loop mode.
Assumes a display refresh rate of ~60hz and in turn specifies a minimum_update_latency of
~8.33ms. The windows field is set to None.
Sourcepub fn loop_ntimes(number_of_updates: usize) -> Self
pub fn loop_ntimes(number_of_updates: usize) -> Self
Specify the Ntimes mode with one update
Waits long enough to ensure loop iteration never occurs faster than the given max_fps.
Trait Implementations§
impl StructuralPartialEq for LoopMode
Auto Trait Implementations§
impl Freeze for LoopMode
impl RefUnwindSafe for LoopMode
impl Send for LoopMode
impl Sync for LoopMode
impl Unpin for LoopMode
impl UnwindSafe for LoopMode
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
impl<T, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
Source§fn convert_into(self) -> U
fn convert_into(self) -> U
Source§fn convert_unclamped_into(self) -> U
fn convert_unclamped_into(self) -> U
Source§fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains the unclamped color. Read moreSource§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