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
2026-02-03 08:43:21 +01:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
2026-02-04 16:00:26 +01:00
|
|
|
// src/ui/views/canvas.rs
|
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
2026-02-03 08:43:21 +01:00
|
|
|
//
|
|
|
|
|
// Render the center canvas area with the current document.
|
|
|
|
|
|
|
|
|
|
use cosmic::iced::widget::image::FilterMethod;
|
|
|
|
|
use cosmic::iced::{ContentFit, Length};
|
|
|
|
|
use cosmic::widget::{container, text};
|
|
|
|
|
use cosmic::Element;
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
2026-02-04 16:00:26 +01:00
|
|
|
// TODO: Add crop dialog when ToolMode::Crop
|
|
|
|
|
// For now, just show the viewer
|
|
|
|
|
container(img_viewer)
|
|
|
|
|
.width(Length::Fill)
|
|
|
|
|
.height(Length::Fill)
|
|
|
|
|
.into()
|
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
2026-02-03 08:43:21 +01:00
|
|
|
} else {
|
|
|
|
|
container(text(fl!("no-document")))
|
|
|
|
|
.width(Length::Fill)
|
|
|
|
|
.height(Length::Fill)
|
|
|
|
|
.center(Length::Fill)
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
}
|