Complete Clean Architecture migration
Phase 1-7: Full migration from src/app/ to Clean Architecture
BREAKING CHANGES:
- Removed src/app/ (old TEA-style implementation)
- Removed src/constant.rs (constants now local to modules)
- Removed deprecated canvas_to_image_coords functions
NEW STRUCTURE:
- src/ui/ - UI Layer (COSMIC interface)
- src/application/ - Application Layer (DocumentManager, Commands)
- src/domain/ - Domain Layer (Document types, Operations)
- src/infrastructure/ - Infrastructure Layer (Loaders, Cache, System)
FEATURES:
- DocumentManager as Single Source of Truth
- Command Pattern for all operations
- Model caching for render data (performance)
- Sync mechanism between DocumentManager and UI Model
- Wallpaper support (COSMIC, KDE, GNOME, feh)
- Thumbnail cache with disk persistence
IMPROVEMENTS:
- Warnings: 62 → 43 (-31%)
- Deprecated warnings: 2 → 0 (-100%)
- Code removed: src/app/ (~2000 lines), constant.rs, deprecated functions
- Better Locality of Reference (constants local to modules)
- Clean separation of concerns
- No circular dependencies
DOCUMENTATION:
- Updated AGENTS.md (100% migration status)
- Updated README.md (architecture section)
- Updated Workflow.md
- Added Migration-Plan.md with full completion summary
TESTS:
- All 41 tests passing
- Build successful (0 errors, 43 warnings)
- Release build verified
Migration Status: ✅ 100% Complete
This commit is contained in:
parent
f8087a3c6a
commit
fc73e4b76b
87 changed files with 9461 additions and 3324 deletions
69
src/ui/views/canvas.rs
Normal file
69
src/ui/views/canvas.rs
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// src/app/view/canvas.rs
|
||||
//
|
||||
// Render the center canvas area with the current document.
|
||||
|
||||
use cosmic::iced::widget::image::FilterMethod;
|
||||
use cosmic::iced::{ContentFit, Length};
|
||||
use cosmic::iced_widget::stack;
|
||||
use cosmic::widget::{container, text};
|
||||
use cosmic::Element;
|
||||
|
||||
use crate::ui::components::crop::crop_overlay;
|
||||
use super::image_viewer::Viewer;
|
||||
use crate::ui::model::{ToolMode, ViewMode};
|
||||
use crate::ui::{AppMessage, AppModel};
|
||||
use crate::application::DocumentManager;
|
||||
use crate::config::AppConfig;
|
||||
use crate::fl;
|
||||
|
||||
/// Render the center canvas area with the current document.
|
||||
pub fn view<'a>(
|
||||
model: &'a AppModel,
|
||||
_manager: &'a DocumentManager,
|
||||
config: &'a AppConfig,
|
||||
) -> Element<'a, AppMessage> {
|
||||
if let Some(handle) = &model.current_image_handle {
|
||||
let content_fit = match model.view_mode {
|
||||
ViewMode::Fit => ContentFit::Contain,
|
||||
ViewMode::ActualSize | ViewMode::Custom => ContentFit::None,
|
||||
};
|
||||
|
||||
let img_viewer = Viewer::new(handle)
|
||||
.with_state(model.scale, model.pan_x, model.pan_y)
|
||||
.on_state_change(|scale, offset_x, offset_y, canvas_size, image_size| {
|
||||
AppMessage::ViewerStateChanged {
|
||||
scale,
|
||||
offset_x,
|
||||
offset_y,
|
||||
canvas_size,
|
||||
image_size,
|
||||
}
|
||||
})
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.content_fit(content_fit)
|
||||
.filter_method(FilterMethod::Nearest)
|
||||
.min_scale(config.min_scale)
|
||||
.max_scale(config.max_scale)
|
||||
.scale_step(config.scale_step - 1.0)
|
||||
.disable_pan(model.tool_mode == ToolMode::Crop);
|
||||
|
||||
if model.tool_mode == ToolMode::Crop {
|
||||
let overlay = crop_overlay(&model.crop_selection, config.crop_show_grid);
|
||||
|
||||
stack![img_viewer, overlay].into()
|
||||
} else {
|
||||
container(img_viewer)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.into()
|
||||
}
|
||||
} else {
|
||||
container(text(fl!("no-document")))
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.center(Length::Fill)
|
||||
.into()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue