Add close actions to rundown editors

This commit is contained in:
Dandaedre 2026-11-03 16:34:01 +01:00
parent 4747e5165d
commit 2567907223
1 changed files with 34 additions and 4 deletions

View File

@ -849,6 +849,7 @@ impl App {
.find(|r| r.row == row)
});
let mut open = self.row_details;
let mut close = false;
egui::Window::new(format!("Row {row} · {}", self.sheet))
.id(egui::Id::new("row_details"))
.open(&mut open)
@ -874,7 +875,14 @@ impl App {
});
if preview.gap { ui.small("Gap interval · duration is elapsed time; allocation follows the selected gap resolution."); }
});
ui.heading("Edit row");
ui.horizontal(|ui| {
ui.heading("Edit row");
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
if ui.button("Close").clicked() {
close = true;
}
});
});
ui.horizontal_wrapped(|ui| {
ui.label("Row type");
let detected = match preview.kind.as_str() {
@ -929,7 +937,7 @@ impl App {
false,
);
});
ui.small("Leave a field empty to use or calculate it from the source values. Close this window and apply & recheck after editing.");
ui.small("Leave a field empty to use or calculate it from the source values. Apply & recheck after closing the editor.");
}
if let Some(a) = &self.analysis {
if !preview.issues.is_empty() { ui.heading("Needs attention"); }
@ -987,6 +995,9 @@ impl App {
}
});
});
if close {
open = false;
}
self.row_details = open;
if before != serde_json::to_string(&profile).unwrap() {
self.profile = serde_json::to_string_pretty(&profile).unwrap();
@ -1009,6 +1020,7 @@ impl App {
let mut profile: Profile = serde_json::from_str(&self.profile).unwrap_or_default();
let before = serde_json::to_string(&profile).unwrap();
let mut open = self.row_details;
let mut close = false;
egui::Window::new(format!("Gap · {}", self.sheet))
.id(egui::Id::new("gap_details"))
.open(&mut open)
@ -1039,7 +1051,14 @@ impl App {
}
});
});
ui.heading("Gap resolution");
ui.horizontal(|ui| {
ui.heading("Gap resolution");
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
if ui.button("Close").clicked() {
close = true;
}
});
});
ui.push_id("gap_inspector", |ui| {
Self::gap_resolution_control(ui, &mut profile, key);
});
@ -1074,6 +1093,9 @@ impl App {
ui.add(egui::Label::new(&preview.decisions).wrap());
}
});
if close {
open = false;
}
self.row_details = open;
if before != serde_json::to_string(&profile).unwrap() {
self.profile = serde_json::to_string_pretty(&profile).unwrap();
@ -2452,7 +2474,15 @@ mod tests {
assert_eq!(profile.ends[&2], "09:00");
assert_eq!(profile.durations[&2], "2 min");
assert!(app.dirty);
app.row_details = false;
let labels = render(&mut app, &ctx, size, vec![]);
let close = labels
.iter()
.find(|(s, _)| s == "Close")
.unwrap()
.1
.center();
click_size(&mut app, &ctx, close, size);
assert!(!app.row_details);
render(
&mut app,
&ctx,