use bladvak::eframe::egui;
use bladvak::utils::document::DocumentTrait;
use image::DynamicImage;
use std::path::{Path, PathBuf};
use crate::edit_mode::SelectionState;
#[derive(serde::Deserialize, serde::Serialize)]
pub(crate) struct Document {
#[serde(skip)]
pub(crate) img: DynamicImage,
#[serde(skip)]
pub(crate) saved_img: DynamicImage,
#[serde(skip)]
pub(crate) texture: Option<egui::TextureHandle>,
#[serde(skip)]
pub(crate) exif: Option<exif::Exif>,
pub(crate) filename: PathBuf,
pub(crate) selection: SelectionState,
pub(crate) scene_rect: egui::Rect,
}
impl std::fmt::Debug for Document {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Document")
.field("filename", &self.filename)
.field("selection", &self.selection)
.finish_non_exhaustive()
}
}
impl Default for Document {
fn default() -> Self {
Self {
img: DynamicImage::default(),
saved_img: DynamicImage::default(),
texture: None,
exif: None,
filename: PathBuf::new(),
selection: SelectionState::default(),
scene_rect: egui::Rect::NAN,
}
}
}
impl DocumentTrait for Document {
fn path(&self) -> &Path {
&self.filename
}
}