diff --git a/crates/rundown-converter/src/gui/review.rs b/crates/rundown-converter/src/gui/review.rs index 6696d35..ff644f6 100644 --- a/crates/rundown-converter/src/gui/review.rs +++ b/crates/rundown-converter/src/gui/review.rs @@ -526,6 +526,31 @@ fn column_settings_changed(current: &Profile, analyzed: &Profile) -> bool { || current.duration_unit != analyzed.duration_unit } +fn schedule_settings_changed(current: &Profile, analyzed: &Profile) -> bool { + current.untimed_as_notes != analyzed.untimed_as_notes + || current.ignore_warnings != analyzed.ignore_warnings + || current.row_kinds != analyzed.row_kinds + || current.titles != analyzed.titles + || current.starts != analyzed.starts + || current.ends != analyzed.ends + || current.durations != analyzed.durations + || current.gap_resolutions != analyzed.gap_resolutions +} + +fn preview_row_settings_changed(row: &PreviewRow, current: &Profile, analyzed: &Profile) -> bool { + let row_changed = row.row > 0 + && (current.row_kinds.get(&row.row) != analyzed.row_kinds.get(&row.row) + || current.titles.get(&row.row) != analyzed.titles.get(&row.row) + || current.starts.get(&row.row) != analyzed.starts.get(&row.row) + || current.ends.get(&row.row) != analyzed.ends.get(&row.row) + || current.durations.get(&row.row) != analyzed.durations.get(&row.row)); + let gap_changed = row + .gap_key + .as_ref() + .is_some_and(|key| current.gap_resolutions.get(key) != analyzed.gap_resolutions.get(key)); + row_changed || gap_changed +} + fn show_row( row: &PreviewRow, filter: RowFilter, @@ -947,6 +972,11 @@ impl App { .into_iter() .find(|r| r.row == row) }); + let row_pending = preview.as_ref().is_some_and(|preview| { + self.analyzed_profile + .as_ref() + .is_some_and(|analyzed| preview_row_settings_changed(preview, &profile, analyzed)) + }); let mut open = self.row_details; let mut close = false; egui::Window::new(format!("Row {row} · {}", self.sheet)) @@ -962,8 +992,13 @@ impl App { ui.strong("Row type:"); ui.label(profile.row_kinds.get(&row).map(String::as_str).unwrap_or(&preview.kind)); }); - if self.dirty { - ui.colored_label(PREVIEW_AMBER, "Pending changes · timing and diagnostics are from the last analysis"); + if row_pending { + ui.colored_label( + PREVIEW_PENDING, + "Pending apply · this correction is not reflected in the timing or issues yet", + ); + } else if self.dirty { + ui.colored_label(PREVIEW_AMBER, "Other changes are pending · timing and diagnostics are from the last analysis"); } egui::Frame::group(ui.style()).show(ui, |ui| { ui.horizontal_wrapped(|ui| { @@ -1099,6 +1134,7 @@ impl App { if before != serde_json::to_string(&profile).unwrap() { self.profile = serde_json::to_string_pretty(&profile).unwrap(); self.decisions_changed(); + ctx.request_repaint(); } } @@ -1116,6 +1152,10 @@ impl App { }; let mut profile: Profile = serde_json::from_str(&self.profile).unwrap_or_default(); let before = serde_json::to_string(&profile).unwrap(); + let gap_pending = self + .analyzed_profile + .as_ref() + .is_some_and(|analyzed| preview_row_settings_changed(&preview, &profile, analyzed)); let mut open = self.row_details; let mut close = false; egui::Window::new(format!("Gap · {}", self.sheet)) @@ -1127,10 +1167,15 @@ impl App { .show(ctx, |ui| { ui.heading(&preview.title); ui.label("Inferred schedule interval · no source row or timer"); - if self.dirty { + if gap_pending { + ui.colored_label( + PREVIEW_PENDING, + "Pending apply · this gap resolution is not reflected in the schedule yet", + ); + } else if self.dirty { ui.colored_label( PREVIEW_AMBER, - "Pending changes · timing and diagnostics are from the last analysis", + "Other changes are pending · timing and diagnostics are from the last analysis", ); } egui::Frame::group(ui.style()).show(ui, |ui| { @@ -1195,6 +1240,7 @@ impl App { if before != serde_json::to_string(&profile).unwrap() { self.profile = serde_json::to_string_pretty(&profile).unwrap(); self.decisions_changed(); + ctx.request_repaint(); } } @@ -1545,6 +1591,24 @@ impl App { } return; } + let schedule_pending = serde_json::from_str::(&self.profile) + .ok() + .is_some_and(|profile| { + self.analyzed_profile + .as_ref() + .is_some_and(|analyzed| schedule_settings_changed(&profile, analyzed)) + }); + if schedule_pending { + egui::Frame::new() + .fill(Color32::from_rgb(53, 43, 88)) + .stroke(egui::Stroke::new(2.0_f32, PREVIEW_PENDING)) + .corner_radius(5.0) + .inner_margin(8.0) + .show(ui, |ui| { + ui.colored_label(PREVIEW_PENDING, "Pending schedule changes"); + ui.label("Apply & recheck to update timing, issues and export."); + }); + } let ignorable = self .analysis .as_ref() @@ -1650,9 +1714,17 @@ impl App { } })) .collect(); + let pending_rows: Vec<_> = std::iter::once(false) + .chain( + rows.iter() + .map(|row| preview_row_settings_changed(row, &profile, &analyzed_profile)), + ) + .collect(); let backgrounds: Vec<_> = std::iter::once(None) .chain(rows.iter().map(|row| { - if row.automatically_ignored + if preview_row_settings_changed(row, &profile, &analyzed_profile) { + Some(Color32::from_rgb(43, 36, 70)) + } else if row.automatically_ignored || ignored_row(row.row, table, &analyzed_profile, a.mapping.as_ref()) { Some(Color32::from_rgb(34, 35, 39)) @@ -1702,7 +1774,8 @@ impl App { ui.strong("Title & issues"); ui.strong("Row type"); ui.end_row(); - for row in &rows { + for (row_index, row) in rows.iter().enumerate() { + let pending = pending_rows[row_index + 1]; let row_top = ui.cursor().min; let ignored = row.automatically_ignored || ignored_row( @@ -1763,19 +1836,35 @@ impl App { + if compact { 2.0 * ui.spacing().item_spacing.y } else { 0.0 }; let issue_height = if row.issues.is_empty() || inline_issue { 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 pending_height = if pending { + ui.text_style_height(&egui::TextStyle::Small) + + ui.spacing().item_spacing.y + } else { + 0.0 + }; + let row_height = (title_height + issue_height) + .max(timing_height) + .max(ui.spacing().interact_size.y + pending_height); let response = ui.vertical(|ui| { ui.set_min_height(row_height); - ui.add( + let response = ui.add( egui::Label::new(RichText::new(format!("{}{}", if row.row == 0 { "Gap".into() } else { row.row.to_string() }, - if modified { " ✎" } else { "" } + if modified || pending { " ✎" } else { "" } )).color(color)) .sense(egui::Sense::click()), - ) + ); + if pending { + ui.colored_label(PREVIEW_PENDING, "Pending apply"); + } + response }).inner; - let response = if modified { - response.on_hover_text("Modified by a saved or pending row resolution") + let response = if pending { + response.on_hover_text( + "This row has unapplied changes. Apply & recheck to update the schedule.", + ) + } else if modified { + response.on_hover_text("Modified by a saved row resolution") } else { response }; @@ -1970,6 +2059,7 @@ impl App { if before != serde_json::to_string(&profile).unwrap() { self.profile = serde_json::to_string_pretty(&profile).unwrap(); self.decisions_changed(); + ui.ctx().request_repaint(); } } } @@ -2191,6 +2281,12 @@ mod tests { ); let labels = render(&mut app, &ctx, [860.0, 900.0], vec![]); assert!(labels.iter().any(|(text, _)| text == "Gap ✎")); + assert!( + labels + .iter() + .any(|(text, _)| text == "Pending schedule changes") + ); + assert!(labels.iter().any(|(text, _)| text == "Pending apply")); let a = pipeline::analyze(&app.tables[0], &profile, &AtomicBool::new(false), |_, _| {}); assert!(a.rundown.as_ref().unwrap().gaps.is_empty()); let rows = preview_rows(&a, Some(&app.tables[0])); @@ -2842,6 +2938,15 @@ mod tests { assert!(app.dirty); let labels = render(&mut app, &ctx, size, vec![]); assert!(labels.iter().any(|(text, _)| text == "2 ✎")); + assert!( + labels + .iter() + .any(|(text, _)| text == "Pending schedule changes") + ); + assert!(labels.iter().any(|(text, _)| text == "Pending apply")); + assert!(labels.iter().any(|(text, _)| { + text == "Pending apply · this correction is not reflected in the timing or issues yet" + })); let corrections = labels .iter() .find(|(s, _)| s == "Timing corrections")