mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
fix(ui): the Photoshop-style status bar shows messages with no document open (#1567)
This commit is contained in:
1 parent
ec350d64ae
commit
b58d4c70fc
2 files changed
+29
-5
No files matched your search
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user