Struct ZoomModel
pub struct ZoomModel { /* private fields */ }Expand description
The scale of one app’s content: the levels it steps through, where
Ctrl+0 returns to, and the factor it shows now.
A window zooms its whole content (WindowZoom, the theme’s UI scale). A
widget or an app whose content has a size of its own — a photograph, a PDF
page, a board — keeps a ZoomModel instead: the levels and bounds are its
own (a picture fits a frame and magnifies to 8×; a page is 25 %–1600 %),
and the rules are this module’s, so Ctrl+=, Ctrl+- and Ctrl+0 mean
the same thing everywhere and every app states its level the same way.
use tilo_ui::content_zoom::{ZoomModel, ZoomStep};
let mut model = ZoomModel::stepping([1.0, 2.0, 4.0], 1.0);
assert_eq!(model.step(ZoomStep::In), 2.0);
assert_eq!(model.label("Fit to window"), "200%");
assert_eq!(model.step(ZoomStep::Reset), 1.0);
assert_eq!(model.label("Fit to window"), "Fit to window");Implementations§
§impl ZoomModel
impl ZoomModel
pub fn standard() -> ZoomModel
pub fn standard() -> ZoomModel
The toolkit’s levels (LEVELS): the window’s own content zoom, and
the default for content with no scale of its own.
pub fn stepping(levels: impl IntoIterator<Item = f32>, reset: f32) -> ZoomModel
pub fn stepping(levels: impl IntoIterator<Item = f32>, reset: f32) -> ZoomModel
levels as an app’s content steps through them, with reset where
Ctrl+0 goes. Levels are sorted, and a level that is not a finite
positive factor is dropped; a model with no usable level keeps the
toolkit’s.
pub fn default_factor(&self) -> f32
pub fn default_factor(&self) -> f32
The factor the content shows at its own size: what Ctrl+0 returns
to (100 % for a page, a picture fitted to its frame).
pub fn is_default(&self) -> bool
pub fn is_default(&self) -> bool
Whether the content shows at its own size.
pub fn step(&mut self, step: ZoomStep) -> f32
pub fn step(&mut self, step: ZoomStep) -> f32
Take step, between this model’s levels, and answer the factor the
content shows now.
pub fn set(&mut self, factor: f32) -> f32
pub fn set(&mut self, factor: f32) -> f32
Adopt factor as what the content shows (a wheel notch, a pinch, a
fit computed from the frame), left inside what the levels allow.
pub fn adopt(&mut self, factor: f32) -> f32
pub fn adopt(&mut self, factor: f32) -> f32
Adopt factor as what the content shows, without clamping: the value
came from the content itself (a wheel notch, a fit it computed), so the
model reports what is on screen even when that is outside its own
levels.
Trait Implementations§
impl StructuralPartialEq for ZoomModel
Auto Trait Implementations§
impl Freeze for ZoomModel
impl RefUnwindSafe for ZoomModel
impl Send for ZoomModel
impl Sync for ZoomModel
impl Unpin for ZoomModel
impl UnsafeUnpin for ZoomModel
impl UnwindSafe for ZoomModel
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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,
§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> 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>, which can then be
downcast into Box<dyn 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>, which 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> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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