diff --git a/crates/rundown-converter/src/gui/review.rs b/crates/rundown-converter/src/gui/review.rs index f64b98a..797ecef 100644 --- a/crates/rundown-converter/src/gui/review.rs +++ b/crates/rundown-converter/src/gui/review.rs @@ -2016,11 +2016,71 @@ impl App { } let table_width = ui.available_width() - ui.spacing().scroll.allocated_width(); let compact = table_width < 760.0; - let title_width = if compact { - (table_width - 300.0).max(180.0) - } else { - (table_width - 370.0).max(240.0) + // Reserve actual text widths rather than an approximate fixed allowance: + // row numbers, clocks and column spacing must not push controls off-screen. + let text_width = |text: &str| { + egui::WidgetText::from(text) + .into_galley( + ui, + Some(egui::TextWrapMode::Extend), + f32::INFINITY, + egui::TextStyle::Body, + ) + .size() + .x }; + let row_width = rows + .iter() + .map(|row| { + text_width(&format!( + "{} ✎", + if row.row == 0 { + "Gap".into() + } else { + row.row.to_string() + } + )) + }) + .fold(text_width("Row"), f32::max) + .ceil(); + let timing_widths = ["Start", "End", "Duration"].map(|heading| { + rows.iter() + .map(|row| { + text_width(match heading { + "Start" => &row.start, + "End" => &row.end, + _ => &row.duration, + }) + }) + .fold(text_width(heading), f32::max) + .ceil() + + 2.0 + }); + let compact_timing_width = rows + .iter() + .flat_map(|row| { + [ + format!("Start {}", row.start), + format!("End {}", row.end), + format!("Dur. {}", row.duration), + ] + }) + .map(|text| text_width(&text)) + .fold(105.0, f32::max) + .ceil(); + let controls_width = (text_width("Auto (Marker)") + 30.0).max(115.0); + let timing_width = if compact { + compact_timing_width + } else { + timing_widths.iter().sum() + }; + let title_width = (table_width + - row_width + - timing_width + - controls_width + - if compact { 30.0 } else { 50.0 } + - 4.0) + .max(80.0); let jump = self.jump_row; let mut jump_visible = !rows.iter().any(|r| Some(r.row) == jump); let mut jump_offset = None; @@ -2169,6 +2229,7 @@ impl App { .max(timing_height) .max(ui.spacing().interact_size.y + pending_height); let response = ui.vertical(|ui| { + ui.set_width(row_width); ui.set_min_height(row_height); ui.add( egui::Label::new(RichText::new(format!("{}{}", @@ -2206,7 +2267,7 @@ impl App { if compact { ui.push_id((row_index, row.row, row.gap_key.as_deref(), "compact_timing"), |ui| { ui.vertical(|ui| { - ui.set_width(105.0); + ui.set_width(compact_timing_width); ui.set_min_height(row_height); for (label, value, inferred) in [ ("Start", &row.start, row.inferred_start), @@ -2225,13 +2286,14 @@ impl App { }); }); } else { - for (role, value, inferred) in [ + for (timing_index, (role, value, inferred)) in [ ("start", &row.start, row.inferred_start), ("end", &row.end, row.inferred_end), ("duration", &row.duration, row.inferred_duration), - ] { + ].into_iter().enumerate() { ui.push_id((row_index, row.row, row.gap_key.as_deref(), role), |ui| { ui.vertical(|ui| { + ui.set_width(timing_widths[timing_index]); ui.set_min_height(row_height); ui.add( egui::Label::new(RichText::new(value).color( @@ -2303,7 +2365,7 @@ impl App { } }); let controls = ui.vertical(|ui| { - ui.set_width(105.0); + ui.set_width(controls_width); ui.set_min_height(row_height); if let Some(key) = &row.gap_key { Self::gap_resolution_control(ui, &mut profile, key); @@ -3514,6 +3576,38 @@ mod tests { assert!((positions[2] - positions[0]).abs() < 2.0); } + #[test] + fn preview_controls_fit_at_compact_and_wide_sizes() { + let mut app = sample(); + app.tables[0].rows.truncate(2); + let next = app.tables[0].rows[1].clone(); + app.tables[0].rows.push(next); + app.tables[0].rows[2][0].text = "09:30".into(); + app.tables[0].rows[1][2].text = + "A long presentation title that wraps across the remaining space".into(); + app.analysis = Some(pipeline::analyze( + &app.tables[0], + &Profile::default(), + &AtomicBool::new(false), + |_, _| {}, + )); + let ctx = egui::Context::default(); + configure_style(&ctx); + for width in [520.0, 760.0, 800.0, 960.0, 1260.0, 520.0] { + for _ in 0..4 { + render(&mut app, &ctx, [width, 900.0], vec![]); + } + let labels = render(&mut app, &ctx, [width, 900.0], vec![]); + for caption in ["Auto (Event)", "Keep gap"] { + let rect = labels.iter().find(|(text, _)| text == caption).unwrap().1; + assert!( + rect.right() < width - 30.0, + "Leave room for dropdown arrows and scrollbar at {width}: {rect:?}" + ); + } + } + } + #[test] fn multiline_titles_drop_blank_lines_and_align_with_timing() { let mut app = sample(); diff --git a/docs/rundown-converter.md b/docs/rundown-converter.md index 774c3d2..b8eaa05 100644 --- a/docs/rundown-converter.md +++ b/docs/rundown-converter.md @@ -113,7 +113,9 @@ visually distinct from labels and ordinary actions; the active tab uses the stro Scrollable panels and dialogs use always-visible, solid scrollbars. 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; + timing values stack so corrections remain accessible. The table reserves space + for timing text and row controls, then wraps titles into the remaining width. + Changes require recheck; the timing preview and diagnostics continue to show the previous analysis. - **Columns** shows a concise verified mapping summary, green detected roles, per-column role dropdowns, and sample values. **Suggested: …** shows useful