Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

Issue #345: activity stack polish

Andrey Vyrodov63d9b70356a7
diff --git a/crates/ui-egui/src/panels/activity.rs b/crates/ui-egui/src/panels/activity.rs
index 5a2e6095f..87a1163ff 100644
--- a/crates/ui-egui/src/panels/activity.rs
+++ b/crates/ui-egui/src/panels/activity.rs
@@ -115,7 +115,8 @@ fn row(ui: &mut egui::Ui, t: &Tokens, task: &TaskInfo, width: f32) -> bool {
let cross = task.cancellable && !task.cancelling;
let label_w = if cross { width - CROSS - 6.0 } else { width };
ui.allocate_ui_with_layout(vec2(label_w, 18.0), Layout::left_to_right(Align::Center), |ui| {
- ui.set_max_width(label_w);
+ // the whole width, so the cross lands at the right edge however short the name
+ ui.set_width(label_w);
ui.add(egui::Label::new(RichText::new(tr(&task.label)).font(t.font(12.5)).color(t.text)).truncate());
});
if cross {
diff --git a/crates/ui-egui/src/tests_activity.rs b/crates/ui-egui/src/tests_activity.rs
index 9cdcd8d46..39074161d 100644
--- a/crates/ui-egui/src/tests_activity.rs
+++ b/crates/ui-egui/src/tests_activity.rs
@@ -131,6 +131,16 @@ fn long_detail_stays_inside_the_stack() {
assert!(row.width() <= WIDTH + 1.0, "{row:?}");
}
+#[test]
+fn cross_sits_at_the_right_edge_of_its_row() {
+ let mut h = demo();
+ let g = h.app.session.activity.start("export", "Exporting", Cancel::Yes);
+ wait_visible(&mut h);
+ let row = rect(&h, &format!("activity:row:{}", g.id()));
+ let cross = rect(&h, &format!("activity:cancel:{}", g.id()));
+ assert!(cross.right() >= row.right() - 2.0, "the cross is at the right, not after the label: {cross:?} in {row:?}");
+}
+
#[test]
fn quit_with_a_running_task_asks_and_quit_anyway_cancels() {
let mut h = demo();
@@ -184,7 +194,6 @@ fn start_export(h: &mut Headless, n: usize) {
}
let r = h.request("ui.dialog.confirm", json!({}), T);
assert_eq!(r["ok"], true, "{r}");
- assert!(h.app.export.is_some(), "running in the background");
}
#[test]
@@ -192,6 +201,7 @@ fn export_shows_a_row_and_stops_on_activity_cancel() {
let mut h = demo();
h.app.services.write_shared = Some(slow_writer(200));
start_export(&mut h, 5);
+ assert!(h.app.export.is_some(), "running in the background");
let tasks = h.request("ui.inspect", json!({}), T)["result"]["activity"].clone();
assert_eq!(tasks[0]["kind"], "export", "{tasks}");
assert_eq!(tasks[0]["total"], 5, "{tasks}");