Fix initial document display and set Fit mode as default
- Cache rendered image handle on startup to fix 'No document loaded' issue - Set ViewMode::Fit as default for initial load and navigation - Disable tooltips in header (too ugly) - Temporarily disable main menu button (needs proper implementation)
This commit is contained in:
parent
9624eec699
commit
a8344f77a1
3 changed files with 44 additions and 25 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
// COSMIC application wiring and main app struct.
|
// COSMIC application wiring and main app struct.
|
||||||
|
|
||||||
use super::message::AppMessage;
|
use super::message::AppMessage;
|
||||||
use super::model::AppModel;
|
use super::model::{AppModel, ViewMode};
|
||||||
use super::update;
|
use super::update;
|
||||||
use crate::ui::views;
|
use crate::ui::views;
|
||||||
|
|
||||||
|
|
@ -73,8 +73,6 @@ impl cosmic::Application for NoctuaApp {
|
||||||
Err(_) => (AppConfig::default(), None),
|
Err(_) => (AppConfig::default(), None),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut model = AppModel::new(config.clone());
|
|
||||||
|
|
||||||
let Flags::Args(args) = flags;
|
let Flags::Args(args) = flags;
|
||||||
|
|
||||||
// Determine initial path: CLI argument takes priority.
|
// Determine initial path: CLI argument takes priority.
|
||||||
|
|
@ -90,10 +88,31 @@ impl cosmic::Application for NoctuaApp {
|
||||||
// Initialize document manager
|
// Initialize document manager
|
||||||
let mut document_manager = DocumentManager::new();
|
let mut document_manager = DocumentManager::new();
|
||||||
|
|
||||||
|
// Initialize model
|
||||||
|
let mut model = AppModel::new(config.clone());
|
||||||
|
|
||||||
// Load initial document if provided
|
// Load initial document if provided
|
||||||
if let Some(path) = initial_path {
|
if let Some(path) = initial_path {
|
||||||
if let Err(e) = document_manager.open_document(&path) {
|
if let Err(e) = document_manager.open_document(&path) {
|
||||||
log::error!("Failed to open initial path {}: {}", path.display(), e);
|
log::error!("Failed to open initial path {}: {}", path.display(), e);
|
||||||
|
} else {
|
||||||
|
// Set initial view mode to Fit
|
||||||
|
model.viewport.fit_mode = ViewMode::Fit;
|
||||||
|
model.viewport.scale = 1.0;
|
||||||
|
model.reset_pan();
|
||||||
|
|
||||||
|
// Cache initial render so image is displayed immediately
|
||||||
|
if let Some(doc) = document_manager.current_document_mut() {
|
||||||
|
use crate::domain::document::core::document::Renderable;
|
||||||
|
match doc.render(model.viewport.scale as f64) {
|
||||||
|
Ok(output) => {
|
||||||
|
model.viewport.cached_image_handle = Some(output.handle);
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
log::error!("Failed to render initial document: {}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ pub fn update(app: &mut NoctuaApp, msg: &AppMessage) -> UpdateResult {
|
||||||
{
|
{
|
||||||
// Reset zoom when navigating to new document
|
// Reset zoom when navigating to new document
|
||||||
app.model.viewport.scale = 1.0;
|
app.model.viewport.scale = 1.0;
|
||||||
app.model.viewport.fit_mode = ViewMode::ActualSize;
|
app.model.viewport.fit_mode = ViewMode::Fit;
|
||||||
app.model.reset_pan();
|
app.model.reset_pan();
|
||||||
cache_render(&mut app.model, &mut app.document_manager);
|
cache_render(&mut app.model, &mut app.document_manager);
|
||||||
}
|
}
|
||||||
|
|
@ -61,7 +61,7 @@ pub fn update(app: &mut NoctuaApp, msg: &AppMessage) -> UpdateResult {
|
||||||
{
|
{
|
||||||
// Reset zoom when navigating to new document
|
// Reset zoom when navigating to new document
|
||||||
app.model.viewport.scale = 1.0;
|
app.model.viewport.scale = 1.0;
|
||||||
app.model.viewport.fit_mode = ViewMode::ActualSize;
|
app.model.viewport.fit_mode = ViewMode::Fit;
|
||||||
app.model.reset_pan();
|
app.model.reset_pan();
|
||||||
cache_render(&mut app.model, &mut app.document_manager);
|
cache_render(&mut app.model, &mut app.document_manager);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,23 +25,23 @@ pub fn start<'a>(
|
||||||
.spacing(4)
|
.spacing(4)
|
||||||
.push(
|
.push(
|
||||||
button::icon(icon::from_name("view-sidebar-start-symbolic"))
|
button::icon(icon::from_name("view-sidebar-start-symbolic"))
|
||||||
.on_press(AppMessage::ToggleNavBar)
|
.on_press(AppMessage::ToggleNavBar),
|
||||||
.tooltip(fl!("tooltip-nav-toggle")),
|
//.tooltip(fl!("tooltip-nav-toggle")),
|
||||||
)
|
|
||||||
.push(
|
|
||||||
button::icon(icon::from_name("open-menu-symbolic"))
|
|
||||||
.on_press(AppMessage::ToggleMainMenu)
|
|
||||||
.tooltip(fl!("menu-main")),
|
|
||||||
)
|
)
|
||||||
|
// .push(
|
||||||
|
// button::icon(icon::from_name("open-menu-symbolic"))
|
||||||
|
// .on_press(AppMessage::ToggleMainMenu),
|
||||||
|
// //.tooltip(fl!("menu-main")),
|
||||||
|
// )
|
||||||
.push(
|
.push(
|
||||||
button::icon(icon::from_name("go-previous-symbolic"))
|
button::icon(icon::from_name("go-previous-symbolic"))
|
||||||
.on_press_maybe(has_doc.then_some(AppMessage::PrevDocument))
|
.on_press_maybe(has_doc.then_some(AppMessage::PrevDocument)),
|
||||||
.tooltip(fl!("tooltip-nav-previous")),
|
//.tooltip(fl!("tooltip-nav-previous")),
|
||||||
)
|
)
|
||||||
.push(
|
.push(
|
||||||
button::icon(icon::from_name("go-next-symbolic"))
|
button::icon(icon::from_name("go-next-symbolic"))
|
||||||
.on_press_maybe(has_doc.then_some(AppMessage::NextDocument))
|
.on_press_maybe(has_doc.then_some(AppMessage::NextDocument)),
|
||||||
.tooltip(fl!("tooltip-nav-next")),
|
//.tooltip(fl!("tooltip-nav-next")),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Center section: Transformations
|
// Center section: Transformations
|
||||||
|
|
@ -49,24 +49,24 @@ pub fn start<'a>(
|
||||||
.spacing(4)
|
.spacing(4)
|
||||||
.push(
|
.push(
|
||||||
button::icon(icon::from_name("object-rotate-left-symbolic"))
|
button::icon(icon::from_name("object-rotate-left-symbolic"))
|
||||||
.on_press_maybe(has_doc.then_some(AppMessage::RotateCCW))
|
.on_press_maybe(has_doc.then_some(AppMessage::RotateCCW)),
|
||||||
.tooltip(fl!("tooltip-rotate-ccw")),
|
//.tooltip(fl!("tooltip-rotate-ccw")),
|
||||||
)
|
)
|
||||||
.push(
|
.push(
|
||||||
button::icon(icon::from_name("object-rotate-right-symbolic"))
|
button::icon(icon::from_name("object-rotate-right-symbolic"))
|
||||||
.on_press_maybe(has_doc.then_some(AppMessage::RotateCW))
|
.on_press_maybe(has_doc.then_some(AppMessage::RotateCW)),
|
||||||
.tooltip(fl!("tooltip-rotate-cw")),
|
//.tooltip(fl!("tooltip-rotate-cw")),
|
||||||
)
|
)
|
||||||
.push(horizontal_space().width(Length::Fixed(12.0)))
|
.push(horizontal_space().width(Length::Fixed(12.0)))
|
||||||
.push(
|
.push(
|
||||||
button::icon(icon::from_name("object-flip-horizontal-symbolic"))
|
button::icon(icon::from_name("object-flip-horizontal-symbolic"))
|
||||||
.on_press_maybe(has_doc.then_some(AppMessage::FlipHorizontal))
|
.on_press_maybe(has_doc.then_some(AppMessage::FlipHorizontal)),
|
||||||
.tooltip(fl!("tooltip-flip-horizontal")),
|
//.tooltip(fl!("tooltip-flip-horizontal")),
|
||||||
)
|
)
|
||||||
.push(
|
.push(
|
||||||
button::icon(icon::from_name("object-flip-vertical-symbolic"))
|
button::icon(icon::from_name("object-flip-vertical-symbolic"))
|
||||||
.on_press_maybe(has_doc.then_some(AppMessage::FlipVertical))
|
.on_press_maybe(has_doc.then_some(AppMessage::FlipVertical)),
|
||||||
.tooltip(fl!("tooltip-flip-vertical")),
|
//.tooltip(fl!("tooltip-flip-vertical")),
|
||||||
);
|
);
|
||||||
|
|
||||||
vec![
|
vec![
|
||||||
|
|
@ -85,7 +85,7 @@ pub fn end<'a>(
|
||||||
// Info panel toggle
|
// Info panel toggle
|
||||||
button::icon(icon::from_name("dialog-information-symbolic"))
|
button::icon(icon::from_name("dialog-information-symbolic"))
|
||||||
.on_press(AppMessage::ToggleContextPage(ContextPage::Properties))
|
.on_press(AppMessage::ToggleContextPage(ContextPage::Properties))
|
||||||
.tooltip(fl!("tooltip-info-panel"))
|
//.tooltip(fl!("tooltip-info-panel"))
|
||||||
.into(),
|
.into(),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue