mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
28 lines
636 B
Rust
28 lines
636 B
Rust
use gtk::{
|
|
ContentFit, Picture,
|
|
gdk::Paintable,
|
|
prelude::{IsA, WidgetExt},
|
|
};
|
|
|
|
pub struct Image {
|
|
pub picture: Picture,
|
|
}
|
|
|
|
impl Image {
|
|
// Defaults
|
|
|
|
pub const DEFAULT_MARGIN: i32 = 6;
|
|
pub const DEFAULT_CONTENT_FIT: ContentFit = ContentFit::ScaleDown;
|
|
|
|
// Constructors
|
|
|
|
pub fn new_from_paintable(paintable: &impl IsA<Paintable>) -> Self {
|
|
let picture = Picture::for_paintable(paintable);
|
|
|
|
picture.set_content_fit(Self::DEFAULT_CONTENT_FIT);
|
|
picture.set_margin_end(Self::DEFAULT_MARGIN);
|
|
picture.set_margin_start(Self::DEFAULT_MARGIN);
|
|
|
|
Self { picture }
|
|
}
|
|
}
|