diff --git a/crates/rundown-converter/src/gui/review.rs b/crates/rundown-converter/src/gui/review.rs index ea5b683..d368af2 100644 --- a/crates/rundown-converter/src/gui/review.rs +++ b/crates/rundown-converter/src/gui/review.rs @@ -468,7 +468,8 @@ impl App { let Some(cells) = table.rows.get(row.saturating_sub(1)) else { return; }; - let profile: Profile = serde_json::from_str(&self.profile).unwrap_or_default(); + let mut profile: Profile = serde_json::from_str(&self.profile).unwrap_or_default(); + let before = serde_json::to_string(&profile).unwrap(); let evidence = detect::inspect(table, &profile).1; let header = profile .header_row @@ -511,8 +512,25 @@ impl App { }); if preview.gap { ui.small("Gap interval · duration is elapsed time; allocation follows the selected gap resolution."); } }); - if let Some(duration) = profile.durations.get(&row) { - ui.label(format!("Duration correction: {duration}")); + ui.heading("Edit row"); + ui.horizontal_wrapped(|ui| { + ui.label("Row type"); + let detected = match preview.kind.as_str() { + "event" => Some("Event"), "marker" => Some("Marker"), + kind if kind.starts_with("Note") => Some("Note"), + kind if kind.starts_with("Gap") => Some("Gap"), _ => None, + }; + Self::row_kind_control(ui, &mut profile, row, if self.dirty { None } else { detected }); + }); + if !preview.gap { + ui.label("Duration correction"); + let mut duration = profile.durations.get(&row).cloned().unwrap_or_default(); + if ui.add(egui::TextEdit::singleline(&mut duration) + .id_salt(("editor_duration", row)).hint_text("e.g. 2 min").desired_width(180.0)).changed() { + if duration.trim().is_empty() { profile.durations.remove(&row); } + else { profile.durations.insert(row, duration); } + } + ui.small("Leave empty to use the source duration. Close this window and apply & recheck after editing."); } if let Some(a) = &self.analysis { if !preview.issues.is_empty() { ui.heading("Needs attention"); } @@ -532,7 +550,7 @@ impl App { } ui.separator(); ui.heading("Original cells"); - ui.small("Source values are unchanged. Make corrections in the review table, then apply & recheck."); + ui.small("Source values are unchanged. Corrections are saved in the resolution profile."); let value_width = (ui.available_width() - 150.0).max(120.0); egui::Grid::new("inspector_cells").striped(true).spacing(egui::vec2(16.0, 12.0)).show(ui, |ui| { ui.strong("Column / header"); @@ -559,6 +577,10 @@ impl App { }); }); self.row_details = open; + if before != serde_json::to_string(&profile).unwrap() { + self.profile = serde_json::to_string_pretty(&profile).unwrap(); + self.decisions_changed(); + } } fn columns_view(&mut self, ui: &mut egui::Ui) { @@ -672,6 +694,9 @@ impl App { ui.selectable_value(&mut self.row_filter, RowFilter::Attention, "Needs attention"); let count = self.analysis.as_ref().map_or(0, |a| a.diagnostics.len()); ui.toggle_value(&mut self.show_issue_details, format!("Issues ({count})")); + if ui.add_enabled(self.selected_row.is_some(), egui::Button::new("Edit row…")).clicked() { + self.row_details = true; + } }); if self.show_issue_details { self.issue_navigator(ui); @@ -758,9 +783,10 @@ impl App { } } ui.strong("Title & issues"); - ui.strong("Row type / duration"); + ui.strong("Row type"); ui.end_row(); for row in &rows { + let row_top = ui.cursor().min; let ignored = ignored_row(row.row, table, &profile); let error = row .issues @@ -850,7 +876,7 @@ impl App { } if row.row > 0 { explanation.push_str( - "\n\nDouble-click the title or row number to view original cells.", + "\n\nDouble-click anywhere on this row to edit it and view original cells.", ); } if ui @@ -890,8 +916,9 @@ impl App { } } }); - ui.vertical(|ui| { + let controls = ui.vertical(|ui| { ui.set_width(105.0); + ui.set_min_height(title_min_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)) @@ -926,26 +953,25 @@ impl App { }; Self::row_kind_control(ui, &mut profile, row.row, detected) }); - let mut duration = - profile.durations.get(&row.row).cloned().unwrap_or_default(); - if ui - .add( - egui::TextEdit::singleline(&mut duration) - .id_salt(("schedule_duration", row.row)) - .desired_width(95.0) - .hint_text("e.g. 2 min"), - ) - .on_hover_text("Duration correction; blank uses the source value") - .changed() - { - if duration.trim().is_empty() { - profile.durations.remove(&row.row); - } else { - profile.durations.insert(row.row, duration); - } - } }); ui.end_row(); + let row_rect = egui::Rect::from_min_max(row_top, + egui::pos2(controls.response.rect.right(), ui.cursor().top() - ui.spacing().item_spacing.y * 0.5)); + // Observe the entire row without placing an input-catching widget over + // dropdowns or buttons. Layer-aware hit testing excludes open windows. + if row.row > 0 && ui.rect_contains_pointer(row_rect) { + if ui.input(|i| i.pointer.primary_clicked()) { + self.selected_row = Some(row.row); + } + if !ui.rect_contains_pointer(controls.response.rect) + && ui.input(|i| i.pointer.button_double_clicked(egui::PointerButton::Primary)) { + details = Some(row.row); + } + } + if row.row > 0 && self.selected_row == Some(row.row) { + ui.painter().rect_stroke(row_rect, 2.0, + egui::Stroke::new(1.0_f32, ui.visuals().selection.bg_fill), egui::StrokeKind::Inside); + } } }); @@ -1190,6 +1216,60 @@ mod tests { assert_eq!(app.selected_row, Some(3)); } + #[test] + fn whole_row_selection_and_editor_duration_changes() { + let mut app = sample(); + app.selected_row = None; + let ctx = egui::Context::default(); + configure_style(&ctx); + let size = [860.0, 900.0]; + render(&mut app, &ctx, size, vec![]); + let labels = render(&mut app, &ctx, size, vec![]); + assert!(!labels.iter().any(|(s, _)| s == "e.g. 2 min")); + let title = labels.iter().find(|(s, _)| s == "Opening").unwrap().1; + let blank = egui::pos2(title.right() + 80.0, title.center().y); + click_size(&mut app, &ctx, blank, size); + assert_eq!(app.selected_row, Some(2)); + assert!(!app.row_details); + click_size(&mut app, &ctx, blank, size); + assert!(app.row_details); + render(&mut app, &ctx, size, vec![]); + let labels = render(&mut app, &ctx, size, vec![]); + let duration = labels + .iter() + .find(|(s, _)| s == "e.g. 2 min") + .unwrap() + .1 + .center(); + click_size(&mut app, &ctx, duration, size); + render( + &mut app, + &ctx, + size, + vec![egui::Event::Text("2 min".into())], + ); + let profile: Profile = serde_json::from_str(&app.profile).unwrap(); + assert_eq!(profile.durations[&2], "2 min"); + assert!(app.dirty); + app.row_details = false; + render( + &mut app, + &ctx, + size, + vec![egui::Event::PointerMoved(egui::pos2(0.0, 0.0))], + ); + let labels = render(&mut app, &ctx, size, vec![]); + let edit = labels + .iter() + .find(|(s, _)| s == "Edit row…") + .unwrap() + .1 + .center(); + click_size(&mut app, &ctx, edit, size); + assert!(app.row_details); + assert_eq!(app.selected_row, Some(2)); + } + #[test] fn titles_align_with_or_without_issue_buttons() { for size in [[860.0, 620.0], [560.0, 400.0]] { diff --git a/docs/rundown-converter.md b/docs/rundown-converter.md index 0d8a296..af9a42e 100644 --- a/docs/rundown-converter.md +++ b/docs/rundown-converter.md @@ -36,8 +36,9 @@ In the desktop app, choose or drop one file, read its sheets, select a sheet and click **Analyze rundown**. Review has two views: - **Schedule & corrections** combines the schedule preview and row editing in one - table. Start/end/duration, titles, colored issues, row type and - duration corrections are visible together. **All rows** includes ignored rows; + table. Start/end/duration, titles, colored issues and row types are visible + together. Click anywhere on a source row to select it; its outline shows selection. + **Edit row…** opens the selected row editor, including duration correction. **All rows** includes ignored rows; **Included rows** hides ignored rows and rows containing only ignored columns, while keeping notes, markers and breaks; **Needs attention** shows rows with diagnostics from the last analysis and gaps for context. Ignored rows can be restored using All rows. @@ -56,8 +57,9 @@ click **Analyze rundown**. Review has two views: remove the stale choice in Setup or reset decisions and recheck. Unknown values show `?`. Hover over a title or issue button for row status and full diagnostic explanations. - Double-click a row number/title, or click its **Unresolved** / **Error** button, - to open the row inspector. It shows timing, row type, full diagnostics, timing + Double-click anywhere on a source row, or click its **Unresolved** / **Error** button, + to open the same editor (inline dropdowns keep their normal interaction). + It shows timing, editable row type and duration, full diagnostics, timing decisions and a formatted table of original cells (including empty values and formulas). Pending edits are distinguished from the last analyzed timing. **Issues** opens the issue navigator, including sheet-level and gap errors.