Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

fix(ui): the Photoshop-style status bar shows messages with no document open (#1567) (#1698)

MarekSpodBiedry549baa778fb2
diff --git a/crates/ui-egui/src/chrome_ui.rs b/crates/ui-egui/src/chrome_ui.rs
index dd3bbf86b..e36083bf8 100644
--- a/crates/ui-egui/src/chrome_ui.rs
+++ b/crates/ui-egui/src/chrome_ui.rs
@@ -124,6 +124,8 @@ pub fn status_bar_pro(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let t = Tokens::get(ui.ctx());
let (Some(st), Some(i)) = (app.session.active(), app.session.active_index()) else {
ui.label(RichText::new(tl!("No document")).color(t.text_dim));
+ // A command run with no document open still reports here (#1567: File › Automate › Batch).
+ status_message(app, ui, &t);
return;
};
let text = status_info_text(&st.doc, &app.ui.chrome.status_info, tl!(app.ui.tool.label()), &profile_name(&st.doc));
@@ -150,12 +152,18 @@ pub fn status_bar_pro(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
}
});
- if !app.ui.status.is_empty() {
- let (r, _) = ui.allocate_exact_size(vec2(17.0, 16.0), Sense::hover());
- ui.painter().line_segment([r.center_top(), r.center_bottom()], Stroke::new(1.0, t.separator));
- let is_err = app.ui.status_error || app.ui.status.starts_with("Couldn");
- ui.label(RichText::new(&app.ui.status).color(if is_err { t.warning } else { t.text_faint }));
+ status_message(app, ui, &t);
+}
+
+/// The latest status message after a separator, in the warning colour when it is an error.
+fn status_message(app: &PhotocraftApp, ui: &mut egui::Ui, t: &Tokens) {
+ if app.ui.status.is_empty() {
+ return;
}
+ let (r, _) = ui.allocate_exact_size(vec2(17.0, 16.0), Sense::hover());
+ ui.painter().line_segment([r.center_top(), r.center_bottom()], Stroke::new(1.0, t.separator));
+ let is_err = app.ui.status_error || app.ui.status.starts_with("Couldn");
+ ui.label(RichText::new(&app.ui.status).color(if is_err { t.warning } else { t.text_faint }));
}
/// Home button at the very start of Photoshop 2026's options bar: toggles the Home (start)
@@ -317,6 +325,21 @@ mod tests {
assert_eq!(marquee_end("fixedRatio", w, h, false, [0.0, 0.0], [50.0, 20.0]), [50.0, 50.0]);
}
+ #[test]
+ fn status_message_shows_with_no_document_open() {
+ // #1567: File › Automate › Batch with no recorded action and no document answered nothing.
+ use egui_kittest::{Harness, kittest::Queryable};
+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
+ app.session.actions.list.clear();
+ let e = crate::menus::invoke(&mut app, &egui::Context::default(), "file.automate.batch", json!({})).unwrap_err();
+ app.ui.status = e.clone();
+ app.ui.status_error = true;
+ let mut h = Harness::builder().with_size(vec2(900.0, 40.0)).build_ui_state(|ui, app| status_bar_pro(app, ui), app);
+ h.run_steps(2);
+ assert!(h.query_by_label("No document").is_some());
+ assert!(h.query_by_label(&e).is_some(), "status bar shows {e:?}");
+ }
+
#[test]
fn every_status_key_has_text() {
let d = doc();
diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs
index 01fad74b1..7bce021e2 100644
--- a/crates/ui-egui/src/menus.rs
+++ b/crates/ui-egui/src/menus.rs
@@ -898,6 +898,7 @@ pub fn menu_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) -> f32 {
let id = alt_click(id, ctx.input(|i| i.modifiers.alt));
if let Err(e) = invoke(app, &ctx, &id, json!({})) {
app.ui.status = e;
+ app.ui.status_error = true;
}
}
right