2026-01-07 20:42:28 +01:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
2026-01-07 20:22:49 +01:00
|
|
|
// src/app/view/canvas.rs
|
|
|
|
|
//
|
Implement comprehensive metadata extraction for raster images with
EXIF support and display in the right panel.
New features:
- Extract basic metadata (filename, format, resolution, file size, color type)
- Parse EXIF data (camera, date, exposure, aperture, ISO, focal length, GPS)
- Display metadata in collapsible right panel (toggle with 'i' key)
- Auto-refresh metadata on document navigation
Changes by file:
Cargo.toml, Cargo.lock:
- Add kamadak-exif dependency for EXIF parsing
i18n/en/noctua.ftl:
- Add translation strings for all metadata labels
src/app/document/meta.rs:
- New module for metadata types (BasicMeta, ExifMeta, DocumentMeta)
- Extraction logic with EXIF parsing via kamadak-exif
- Helper methods for formatted display (resolution, file size, camera, GPS)
src/app/document/mod.rs:
- Re-export meta module
src/app/document/{raster,vector,portable}.rs:
- Add extract_metadata() method stubs (full impl for raster)
src/app/document/file.rs:
- Reset metadata on document change
src/app/message.rs:
- Add ToggleRightPanel and RefreshMetadata messages
src/app/model.rs:
- Add metadata: Option<DocumentMeta> field
- Add show_right_panel: bool field
src/app/update.rs:
- Handle panel toggle and metadata refresh
- Auto-refresh metadata on navigation when panel visible
src/app/view/panels.rs:
- Implement right_panel() with metadata display
- Conditional sections for basic info and EXIF data
src/app/view/canvas.rs:
- Integrate right panel into layout"
2026-01-10 11:46:07 +01:00
|
|
|
/// Renders the center canvas area with the current document.
|
|
|
|
|
//
|
2026-01-07 20:22:49 +01:00
|
|
|
use cosmic::iced::{Alignment, Length};
|
|
|
|
|
use cosmic::widget::{container, image, text, Column, Row};
|
|
|
|
|
use cosmic::Element;
|
|
|
|
|
|
|
|
|
|
use crate::app::model::ViewMode;
|
|
|
|
|
use crate::app::{AppMessage, AppModel};
|
2026-01-08 12:18:13 +01:00
|
|
|
use crate::fl;
|
2026-01-07 20:22:49 +01:00
|
|
|
|
|
|
|
|
/// Render the center canvas area with the current document.
|
|
|
|
|
pub fn view(model: &AppModel) -> Element<'_, AppMessage> {
|
|
|
|
|
if let Some(doc) = &model.document {
|
|
|
|
|
let handle = doc.handle();
|
|
|
|
|
|
|
|
|
|
let img_widget = match &model.view_mode {
|
|
|
|
|
ViewMode::Fit => {
|
|
|
|
|
// Fit mode: image scales to fill container while preserving aspect ratio.
|
|
|
|
|
image::Image::new(handle)
|
|
|
|
|
.width(Length::Fill)
|
|
|
|
|
.height(Length::Fill)
|
|
|
|
|
}
|
|
|
|
|
ViewMode::ActualSize => {
|
|
|
|
|
// 1:1 pixel size.
|
|
|
|
|
let (native_w, native_h) = doc.dimensions();
|
|
|
|
|
image::Image::new(handle)
|
|
|
|
|
.width(Length::Fixed(native_w as f32))
|
|
|
|
|
.height(Length::Fixed(native_h as f32))
|
|
|
|
|
}
|
2026-01-08 12:18:13 +01:00
|
|
|
ViewMode::Custom(zoom) => {
|
2026-01-07 20:22:49 +01:00
|
|
|
// Custom zoom factor applied to native size.
|
|
|
|
|
let (native_w, native_h) = doc.dimensions();
|
2026-01-08 12:18:13 +01:00
|
|
|
let scaled_w = (native_w as f32 * zoom).round();
|
|
|
|
|
let scaled_h = (native_h as f32 * zoom).round();
|
2026-01-07 20:22:49 +01:00
|
|
|
image::Image::new(handle)
|
|
|
|
|
.width(Length::Fixed(scaled_w))
|
|
|
|
|
.height(Length::Fixed(scaled_h))
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Center the image both horizontally and vertically.
|
|
|
|
|
Column::new()
|
|
|
|
|
.width(Length::Fill)
|
|
|
|
|
.height(Length::Fill)
|
|
|
|
|
.align_x(Alignment::Center)
|
|
|
|
|
.push(
|
|
|
|
|
Row::new()
|
|
|
|
|
.push(img_widget)
|
|
|
|
|
.width(Length::Fill)
|
|
|
|
|
.height(Length::Fill)
|
|
|
|
|
.align_y(Alignment::Center),
|
|
|
|
|
)
|
|
|
|
|
.into()
|
|
|
|
|
} else {
|
|
|
|
|
container(text(fl!("no_document_loaded")))
|
|
|
|
|
.center_x(Length::Fill)
|
|
|
|
|
.center_y(Length::Fill)
|
|
|
|
|
.width(Length::Fill)
|
|
|
|
|
.height(Length::Fill)
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
}
|