pub enum Sizing {
Shrink,
Fit,
Scale(f64),
}Expand description
Image sizing.
The default is Fit.
Variants§
Shrink
Shrinks the image if it’s too big.
Fit
Shrinks the image if it’s too big or expands it if it’s too small.
Scale(f64)
Scale.
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 24)
12fn main() {
13 let mut cursive = default();
14
15 cursive.add_layer(
16 Panel::new(
17 ImageView::default()
18 .with_image(
19 // Note that RGBA is supported, too, if you need transparency
20 Image::new_stream_from_jpeg_file(FILE, ImageFormat::RGB).expect("new_stream_from_jpeg_file"),
21 // If you prefer to keep the image data in memory:
22 // Image::new_owned_from_jpeg_file(FILE, ImageFormat::RGB, true).expect("new_owned_from_jpeg_file"),
23 )
24 .with_sizing(Sizing::original())
25 .scrollable()
26 .scroll_x(true),
27 )
28 .fixed_size((50, 20)),
29 );
30
31 cursive.add_global_callback('q', |cursive| cursive.quit());
32
33 cursive.run();
34}More examples
examples/pdf.rs (line 23)
10fn main() {
11 let mut cursive = default();
12
13 // The constructor returns a vector of images, one for each page in the PDF
14 // PDF pages can be either PNG or RGBA (PNG is usually more efficient)
15 // Note that we can apply scaling during rendering
16 let images = Image::new_owned_from_pdf_file(FILE, ImageFormat::PNG, 1.5, false).expect("new_owned_from_pdf_file");
17
18 cursive.set_user_data(Pages::new(images));
19
20 cursive.add_layer(
21 Dialog::around(
22 Panel::new(
23 ImageView::default().with_sizing(Sizing::original()).with_name(NAME).scrollable().scroll_x(true),
24 )
25 .fixed_size((50, 30)),
26 )
27 .button("Previous", |cursive| flip_page(cursive, -1))
28 .button("Next", |cursive| flip_page(cursive, 1)),
29 );
30
31 select_page(&mut cursive, 0);
32
33 cursive.add_global_callback('q', |cursive| cursive.quit());
34
35 cursive.run();
36}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