Fix review row alignment and blank title lines

This commit is contained in:
Dandaedre 2026-11-03 15:44:59 +01:00
parent 6481333a48
commit 7c6a028210
2 changed files with 66 additions and 18 deletions

View File

@ -977,10 +977,25 @@ impl App {
} else {
ui.visuals().text_color()
};
let response = ui.add(
// Size every cell to the actual content, then lay it out from the top.
// Keep blank spreadsheet lines out of the preview, preserving the source.
let title = row.title.lines().map(str::trim).filter(|line| !line.is_empty()).collect::<Vec<_>>().join("\n");
let title_height = egui::WidgetText::from(title.as_str())
.into_galley(ui, Some(egui::TextWrapMode::Wrap), title_width, egui::TextStyle::Body)
.size().y;
let timing_height = ui.text_style_height(&egui::TextStyle::Body)
* if compact { 3.0 } else { 1.0 }
+ if compact { 2.0 * ui.spacing().item_spacing.y } else { 0.0 };
let issue_height = if row.issues.is_empty() { 0.0 }
else { ui.spacing().interact_size.y + ui.spacing().item_spacing.y };
let row_height = (title_height + issue_height).max(timing_height).max(ui.spacing().interact_size.y);
let response = ui.vertical(|ui| {
ui.set_min_height(row_height);
ui.add(
egui::Label::new(RichText::new(if row.row == 0 { "Gap".into() } else { row.row.to_string() }).color(color))
.sense(egui::Sense::click()),
);
)
}).inner;
if response.double_clicked() && row.row > 0 {
details = Some(row.row);
}
@ -996,6 +1011,7 @@ impl App {
if compact {
ui.vertical(|ui| {
ui.set_width(105.0);
ui.set_min_height(row_height);
for (label, value) in [
("Start", &row.start),
("End", &row.end),
@ -1006,23 +1022,15 @@ impl App {
});
} else {
for value in [&row.start, &row.end, &row.duration] {
ui.colored_label(color, value);
ui.vertical(|ui| {
ui.set_min_height(row_height);
ui.add(egui::Label::new(RichText::new(value).color(color)).extend());
});
}
}
// Grid cells are centered vertically. Give the title stack enough
// height for the neighboring controls/timing so its text starts
// at the row top, whether or not it has an issue button.
let title_min_height = if compact {
3.0 * ui.text_style_height(&egui::TextStyle::Body)
+ 2.0 * ui.spacing().item_spacing.y
} else if row.gap {
ui.spacing().interact_size.y
} else {
2.0 * ui.spacing().interact_size.y + ui.spacing().item_spacing.y
};
ui.vertical(|ui| {
ui.set_width(title_width);
ui.set_min_height(title_min_height);
ui.set_min_height(row_height);
let status = if ignored {
"Ignored"
} else if row.source_only {
@ -1055,7 +1063,7 @@ impl App {
}
if ui
.add(
egui::Label::new(RichText::new(&row.title).color(color))
egui::Label::new(RichText::new(&title).color(color))
.wrap()
.sense(egui::Sense::click()),
)
@ -1086,7 +1094,7 @@ impl App {
});
let controls = ui.vertical(|ui| {
ui.set_width(105.0);
ui.set_min_height(title_min_height);
ui.set_min_height(row_height);
if let Some(key) = &row.gap_key {
let mut action = profile.gap_resolutions.get(key).cloned().unwrap_or_else(|| "keep".into());
egui::ComboBox::from_id_salt(("gap_resolution", key))
@ -1745,6 +1753,45 @@ mod tests {
assert!((positions[2] - positions[0]).abs() < 2.0);
}
#[test]
fn multiline_titles_drop_blank_lines_and_align_with_timing() {
let mut app = sample();
let original = "\n Opening \n\n Welcome everyone \n";
app.tables[0].rows[1][2].text = original.into();
app.analysis = Some(pipeline::analyze(
&app.tables[0],
&Profile::default(),
&AtomicBool::new(false),
|_, _| {},
));
let ctx = egui::Context::default();
configure_style(&ctx);
for size in [[860.0, 620.0], [560.0, 400.0]] {
for _ in 0..3 {
render(&mut app, &ctx, size, vec![]);
}
let labels = render(&mut app, &ctx, size, vec![]);
let title = labels
.iter()
.find(|(s, _)| s == "Opening\nWelcome everyone")
.unwrap()
.1;
let start = labels
.iter()
.find(|(s, _)| {
s == if size[0] > 760.0 {
"09:00:00"
} else {
"Start 09:00:00"
}
})
.unwrap()
.1;
assert!((title.top() - start.top()).abs() <= 1.0);
}
assert_eq!(app.tables[0].rows[1][2].text, original);
}
#[test]
fn titles_align_with_or_without_issue_buttons() {
for size in [[860.0, 620.0], [560.0, 400.0]] {

View File

@ -90,7 +90,8 @@ Review has two views:
formulas). Pending edits are distinguished from the last analyzed timing.
**Issues** opens the issue navigator, including sheet-level and gap errors.
The table fills the remaining space; its title column expands with the window.
On narrow windows,
Preview cells align at the top; blank title lines are omitted without changing
original values in the inspector or exports. On narrow windows,
timing values stack so corrections remain accessible. Changes require recheck;
the timing preview and diagnostics continue to show the previous analysis.
- **Columns** shows a concise verified mapping summary, green detected roles,