pub enum Sizing {
Fit,
Scale(f64),
}Expand description
Image sizing.
The default is Fit.
Variants§
Implementations§
Source§impl Sizing
impl Sizing
Sourcepub fn original() -> Self
pub fn original() -> Self
Keep the original size: Scale(1.).
Examples found in repository?
examples/scrollable.rs (line 15)
10fn main() {
11 let mut cursive = default();
12
13 cursive.add_layer(
14 Panel::new(
15 ImageView::default().with_image_file(FILE).with_sizing(Sizing::original()).scrollable().scroll_x(true),
16 )
17 .fixed_size((50, 20)),
18 );
19
20 cursive.add_global_callback('q', |cursive| cursive.quit());
21
22 cursive.run();
23}More examples
examples/positioning.rs (line 23)
15fn main() {
16 let mut cursive = default();
17
18 cursive.add_layer(Panel::new(ImageView::default().with_image_file(FILE).with_name(NAME).fixed_size((50, 20))));
19
20 cursive.add_global_callback('s', |cursive| {
21 _ = cursive.call_on_name(NAME, |image_view: &mut ImageView| {
22 image_view.set_sizing(match image_view.sizing() {
23 Sizing::Fit => Sizing::original(),
24 Sizing::Scale(_) => Sizing::Fit,
25 })
26 });
27 });
28
29 cursive.add_global_callback('h', |cursive| {
30 _ = cursive.call_on_name(NAME, |image_view: &mut ImageView| {
31 image_view.set_align(match image_view.align() {
32 Align { h: HAlign::Left, v } => Align { h: HAlign::Center, v },
33 Align { h: HAlign::Center, v } => Align { h: HAlign::Right, v },
34 Align { h: HAlign::Right, v } => Align { h: HAlign::Left, v },
35 })
36 });
37 });
38
39 cursive.add_global_callback('v', |cursive| {
40 _ = cursive.call_on_name(NAME, |image_view: &mut ImageView| {
41 image_view.set_align(match image_view.align() {
42 Align { h, v: VAlign::Top } => Align { h, v: VAlign::Center },
43 Align { h, v: VAlign::Center } => Align { h, v: VAlign::Bottom },
44 Align { h, v: VAlign::Bottom } => Align { h, v: VAlign::Top },
45 })
46 });
47 });
48
49 cursive.add_global_callback('q', |cursive| cursive.quit());
50
51 cursive.run();
52}Trait Implementations§
impl Copy for Sizing
impl StructuralPartialEq for Sizing
Auto Trait Implementations§
impl Freeze for Sizing
impl RefUnwindSafe for Sizing
impl Send for Sizing
impl Sync for Sizing
impl Unpin for Sizing
impl UnsafeUnpin for Sizing
impl UnwindSafe for Sizing
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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 moreSource§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>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().