refactor: centralize file handling, fix zoom display and cleanup
File handling (document/file.rs): - move file operations from app/mod.rs to document/file.rs - add open_file_dialog() for native file picker - add collect_directory_siblings() for navigation context - add open_document_from_path() as main entry point Zoom/View (panels.rs, canvas.rs, model.rs): - fix zoom display using ViewMode enum - ViewMode::Fit shows Fit, ActualSize shows 100%, Custom shows percentage Model/Update cleanup: - adjust model.rs for new file handling - update.rs: use centralized file functions - document/mod.rs: re-exports for file module i18n: BB ctua.ftl with new/changed strings" A - update noctua.ftl with new/changed strings"
This commit is contained in:
parent
4de63d8549
commit
4c10a80b67
8 changed files with 212 additions and 259 deletions
|
|
@ -7,9 +7,9 @@ use cosmic::iced::{Alignment, Length};
|
|||
use cosmic::widget::{container, image, text, Column, Row};
|
||||
use cosmic::Element;
|
||||
|
||||
use crate::fl;
|
||||
use crate::app::model::ViewMode;
|
||||
use crate::app::{AppMessage, AppModel};
|
||||
use crate::fl;
|
||||
|
||||
/// Render the center canvas area with the current document.
|
||||
pub fn view(model: &AppModel) -> Element<'_, AppMessage> {
|
||||
|
|
@ -30,11 +30,11 @@ pub fn view(model: &AppModel) -> Element<'_, AppMessage> {
|
|||
.width(Length::Fixed(native_w as f32))
|
||||
.height(Length::Fixed(native_h as f32))
|
||||
}
|
||||
ViewMode::Custom(_) => {
|
||||
ViewMode::Custom(zoom) => {
|
||||
// Custom zoom factor applied to native size.
|
||||
let (native_w, native_h) = doc.dimensions();
|
||||
let scaled_w = (native_w as f32 * model.zoom).round();
|
||||
let scaled_h = (native_h as f32 * model.zoom).round();
|
||||
let scaled_w = (native_w as f32 * zoom).round();
|
||||
let scaled_h = (native_h as f32 * zoom).round();
|
||||
image::Image::new(handle)
|
||||
.width(Length::Fixed(scaled_w))
|
||||
.height(Length::Fixed(scaled_h))
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ use cosmic::iced::{Alignment, Length};
|
|||
use cosmic::widget::{self, Column, Container, Row, Text};
|
||||
|
||||
use crate::fl;
|
||||
use crate::app::model::ViewMode;
|
||||
use crate::app::{AppMessage, AppModel};
|
||||
|
||||
/// Top header bar (global actions, toggles).
|
||||
pub fn header(_model: &AppModel) -> Element<'_, AppMessage> {
|
||||
let content = Row::new().spacing(8).align_y(Alignment::Center);
|
||||
//.push(Text::new(fl!("noctua-app-name")).size(18));
|
||||
// In a real implementation, add more buttons/actions here.
|
||||
|
||||
Container::new(content)
|
||||
|
|
@ -30,7 +30,13 @@ pub fn footer(model: &AppModel) -> Element<'_, AppMessage> {
|
|||
.push(widget::button::standard("<").on_press(AppMessage::PrevDocument))
|
||||
.push(widget::button::standard(">").on_press(AppMessage::NextDocument));
|
||||
|
||||
let zoom_info = Text::new(format!("Zoom: {:.0}%", model.zoom * 100.0));
|
||||
let zoom_text = match model.view_mode {
|
||||
ViewMode::Fit => "Fit".to_string(),
|
||||
ViewMode::ActualSize => "100%".to_string(),
|
||||
ViewMode::Custom(zoom_factor) => format!("{:.0}%", zoom_factor * 100.0),
|
||||
};
|
||||
|
||||
let zoom_info = Text::new(format!("Zoom: {}", zoom_text));
|
||||
|
||||
let content = Row::new()
|
||||
.spacing(16)
|
||||
|
|
@ -52,10 +58,9 @@ pub fn left_panel(model: &AppModel) -> Option<Element<'_, AppMessage>> {
|
|||
|
||||
let tools = Column::new()
|
||||
.spacing(4)
|
||||
.push(Text::new("Tools"))
|
||||
.push(widget::button::standard("Crop").on_press(AppMessage::ToggleCropMode))
|
||||
.push(widget::button::standard("Scale").on_press(AppMessage::ToggleScaleMode));
|
||||
// Later: color pickers, marker tools, text tool, etc.
|
||||
.push(Text::new(fl!("tools")))
|
||||
.push(widget::button::standard(fl!("crop")).on_press(AppMessage::ToggleCropMode))
|
||||
.push(widget::button::standard(fl!("scale")).on_press(AppMessage::ToggleScaleMode));
|
||||
|
||||
let panel = Container::new(tools)
|
||||
.width(Length::Fixed(180.0))
|
||||
|
|
@ -78,7 +83,6 @@ pub fn right_panel(model: &AppModel) -> Option<Element<'_, AppMessage>> {
|
|||
"Current index: {:?}",
|
||||
model.current_index
|
||||
)));
|
||||
// Later: real EXIF / tags from model.metadata_cache
|
||||
|
||||
let panel = Container::new(meta)
|
||||
.width(Length::Fixed(220.0))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue