propertiesView: Use image dimensions from decoder

This also shows the units for SVG dimensions if not pixels.

Issue #43

Part-of: <https://gitlab.gnome.org/Incubator/loupe/-/merge_requests/136>
This commit is contained in:
Sophie Herold 2023-03-10 19:08:26 +01:00 • committed by Marge Bot
parent 490a46d7c4
commit 42d558d22f
9 changed files with 101 additions and 265 deletions

View file

@ -126,6 +126,8 @@ mod imp {
/// Currently EXIF data
pub image_metadata: RefCell<LpImageMetadata>,
/// Image dimension details for SVGs
pub dimension_details: RefCell<decoder::ImageDimensionDetails>,
/// Current pointer position
pub pointer_position: Cell<Option<(f64, f64)>>,
@ -692,8 +694,9 @@ impl LpImage {
self.reset_rotation();
}
DecoderUpdate::Dimensions => {
DecoderUpdate::Dimensions(dimension_details) => {
log::debug!("Received dimensions: {:?}", self.original_dimensions());
self.imp().dimension_details.replace(dimension_details);
self.notify("image-size");
self.configure_best_fit();
self.request_tiles();
@ -1428,6 +1431,10 @@ impl LpImage {
self.imp().image_metadata.borrow().clone()
}
pub fn dimension_details(&self) -> decoder::ImageDimensionDetails {
self.imp().dimension_details.borrow().clone()
}
/// Drag and drop content provider
pub fn content_provider(&self) -> Option<gdk::ContentProvider> {
let file = self.file()?;