diff --git a/crates/pptx-reporter/src/gui.rs b/crates/pptx-reporter/src/gui.rs index 59c47fb..52d3263 100644 --- a/crates/pptx-reporter/src/gui.rs +++ b/crates/pptx-reporter/src/gui.rs @@ -67,7 +67,16 @@ enum Update { Progress(Event), Finished(Result), } +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum Tab { + Setup, + Results, +} + struct App { + tab: Tab, + settings_open: bool, + formats_open: bool, preferences: Preferences, source: String, output: String, @@ -92,6 +101,9 @@ impl App { } fn from_preferences(preferences: Preferences) -> Self { Self { + tab: Tab::Setup, + settings_open: false, + formats_open: false, source: preferences.options.source.display().to_string(), output: preferences .options @@ -189,11 +201,12 @@ impl App { self.rx = None; match result { Ok(outcome) => { + self.tab = Tab::Results; self.status = Event::step( if outcome.paths.is_empty() { - "No embedded videos found." + "No videos found." } else { - "Reports ready" + "Files ready" }, 0, 0, @@ -229,6 +242,303 @@ impl eframe::App for App { } } impl App { + fn select_inputs(&mut self, mut paths: Vec) { + paths.sort_by(|a, b| crate::ordering::paths(a, b)); + if let Some(first) = paths.first() { + self.source = first.display().to_string(); + self.preferences.options.additional_sources = paths[1..].to_vec(); + self.tab = Tab::Setup; + self.error = None; + } + } + + fn setup(&mut self, ui: &mut egui::Ui) { + ui.add_enabled_ui(self.rx.is_none(), |ui| { + ui.horizontal_wrapped(|ui| { + ui.label(RichText::new("Inputs").strong()); + if ui.button("PPTX files…").clicked() + && let Some(files) = rfd::FileDialog::new().add_filter("PowerPoint", &["pptx"]).pick_files() { + self.select_inputs(files); + } + if ui.button("Folder…").clicked() + && let Some(folder) = rfd::FileDialog::new().pick_folder() { + self.select_inputs(vec![folder]); + } + if !self.preferences.recent.is_empty() { + let mut selected = None; + egui::ComboBox::from_id_salt("recent").selected_text("Recent…").width(90.0).show_ui(ui, |ui| { + for path in &self.preferences.recent { + if ui.selectable_label(false, path.display().to_string()).clicked() { selected = Some(path.clone()); } + } + }); + if let Some(path) = selected { self.select_inputs(vec![path]); } + } + }); + egui::Frame::group(ui.style()).inner_margin(10.0).show(ui, |ui| { + ui.set_min_width(ui.available_width()); + let height = (ui.ctx().screen_rect().height() * 0.20).clamp(60.0, 120.0); + egui::ScrollArea::vertical().id_salt("input_list").max_height(height).show(ui, |ui| { + if self.source.is_empty() { + ui.set_min_height(54.0); + ui.label(RichText::new("Drop PPTX files or a folder here").size(18.0)); + ui.weak("A folder can contain videos, presentations, or video subfolders."); + } else { + let first = PathBuf::from(&self.source); + let mut paths: Vec<_> = std::iter::once(&first).chain(&self.preferences.options.additional_sources).collect(); + paths.sort_by(|a, b| crate::ordering::paths(a, b)); + for path in paths { + ui.add(egui::Label::new(path.file_name().unwrap_or_default().to_string_lossy()).truncate()) + .on_hover_text(path.display().to_string()); + } + } + }); + }); + ui.horizontal_wrapped(|ui| { + let count = if self.source.is_empty() { 0 } else { 1 + self.preferences.options.additional_sources.len() }; + ui.weak(format!("{count} selected · Natural filename order")); + ui.collapsing("Enter a path", |ui| { + if ui.add(egui::TextEdit::singleline(&mut self.source).desired_width(260.0).hint_text("PPTX or folder path")).changed() { + self.preferences.options.additional_sources.clear(); + } + }); + }); + ui.separator(); + let options = &mut self.preferences.options; + let mut mode = if options.extract_only { 2 } else if options.timings_only { 1 } else { 0 }; + ui.horizontal(|ui| { + ui.label("Create"); + egui::ComboBox::from_id_salt("mode").selected_text(match mode { 1 => "Reports only", 2 => "Extract only", _ => "Extract + reports" }).show_ui(ui, |ui| { + ui.selectable_value(&mut mode, 0, "Extract + reports"); + ui.selectable_value(&mut mode, 1, "Reports only"); + ui.selectable_value(&mut mode, 2, "Extract only"); + }); + }); + options.extract_only = mode == 2; + options.timings_only = mode == 1; + ui.add_enabled_ui(!options.extract_only, |ui| { + ui.horizontal_wrapped(|ui| { + ui.label("Formats"); + for format in ["ontime", "pdf", "md"] { format_checkbox(ui, &mut options.formats, format); } + if ui.button("More formats…").clicked() { self.formats_open = true; } + }); + let selected = options.formats.iter().map(|f| format_label(f)).collect::>().join(", "); + ui.add(egui::Label::new(RichText::new(if selected.is_empty() { "Select at least one report format." } else { &selected }).weak()).truncate()).on_hover_text(&selected); + }); + ui.separator(); + ui.horizontal(|ui| { + ui.label("Save to"); + if ui.button("Change…").clicked() + && let Some(path) = rfd::FileDialog::new().pick_folder() { self.output = path.display().to_string(); } + if ui.button("Use default").clicked() { self.output.clear(); } + ui.add(egui::TextEdit::singleline(&mut self.output).desired_width(ui.available_width()).hint_text("Beside the first input")); + }); + if !self.source.is_empty() { + let output = Options { source: PathBuf::from(&self.source), output: (!self.output.trim().is_empty()).then(|| PathBuf::from(&self.output)), ..Default::default() }.output_dir(); + let path = output.display().to_string(); + ui.add(egui::Label::new(RichText::new(&path).weak()).truncate()).on_hover_text(path); + } + }); + } + + fn results(&mut self, ui: &mut egui::Ui, ctx: &egui::Context) { + if let Some(dir) = self.completed_output.clone() { + ui.horizontal(|ui| { + ui.label( + RichText::new("Your files are ready") + .size(20.0) + .color(Color32::from_rgb(133, 214, 170)) + .strong(), + ); + if ui.button("Open output folder").clicked() { + self.open(&dir); + } + }); + } else { + ui.label(if self.rx.is_some() { + "Processing your inputs…" + } else { + "Generated files will appear here." + }); + } + for path in self.paths.clone() { + ui.horizontal(|ui| { + if ui.button("Open").clicked() { + self.open(&path); + } + if ui.button("Copy path").clicked() { + ctx.copy_text(path.display().to_string()); + } + ui.add( + egui::Label::new( + RichText::new(path.file_name().unwrap_or_default().to_string_lossy()) + .strong(), + ) + .truncate(), + ) + .on_hover_text(path.display().to_string()); + }); + } + ui.collapsing("Activity & diagnostics", |ui| { + egui::ScrollArea::vertical() + .id_salt("diagnostics") + .max_height(180.0) + .stick_to_bottom(true) + .show(ui, |ui| { + for (line, warning) in &self.log { + ui.colored_label( + if *warning { + Color32::from_rgb(236, 185, 86) + } else { + Color32::from_rgb(160, 175, 195) + }, + line, + ); + } + }); + }); + } + + fn action_bar(&mut self, ui: &mut egui::Ui) { + ui.horizontal(|ui| { + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + if self.rx.is_some() { + let cancelling = self.cancel.load(Ordering::Relaxed); + if ui + .add_enabled( + !cancelling, + egui::Button::new(if cancelling { + "Cancelling…" + } else { + "Cancel" + }), + ) + .clicked() + { + self.cancel.store(true, Ordering::Relaxed); + } + ui.spinner(); + } else { + let options = &self.preferences.options; + let ready = !self.source.is_empty() + && (options.extract_only || !options.formats.is_empty()); + let action = if options.extract_only { + "Extract videos" + } else if options.timings_only { + "Generate reports" + } else { + "Extract & generate reports" + }; + if ui + .add_enabled( + ready, + egui::Button::new(RichText::new(action).color(Color32::WHITE)) + .min_size(egui::vec2(190.0, 34.0)) + .fill(Color32::from_rgb(87, 68, 181)), + ) + .clicked() + { + self.start(); + } + } + ui.with_layout(egui::Layout::left_to_right(egui::Align::Center), |ui| { + ui.add(egui::Label::new(&self.status.message).truncate()) + .on_hover_text(&self.status.message); + }); + }); + }); + if self.rx.is_some() { + let e = &self.status; + if e.total > 0 { + ui.add(egui::ProgressBar::new(e.done as f32 / e.total as f32).show_percentage()); + } + let eta = if e.done > 0 && e.done < e.total { + format!( + " · about {:.0}s remaining in this phase", + self.phase.elapsed().as_secs_f64() / e.done as f64 * (e.total - e.done) as f64 + ) + } else { + String::new() + }; + ui.weak(format!( + "{:.0}s elapsed{eta}", + self.started.elapsed().as_secs_f64() + )); + } + if let Some(error) = &self.error { + egui::ScrollArea::vertical() + .id_salt("error") + .max_height(54.0) + .show(ui, |ui| { + ui.colored_label(Color32::from_rgb(255, 150, 120), error); + }); + } + } + + fn dialogs(&mut self, ctx: &egui::Context) { + egui::Window::new("Settings") + .open(&mut self.settings_open) + .collapsible(false) + .resizable(true) + .default_width(420.0) + .show(ctx, |ui| { + ui.add_enabled_ui(self.rx.is_none(), |ui| { + ui.checkbox( + &mut self.preferences.options.overwrite, + "Replace existing extracted or copied videos", + ); + ui.label("Existing reports are regenerated. Source files are preserved."); + ui.separator(); + ui.horizontal(|ui| { + ui.label("FFprobe"); + if ui.button("Locate…").clicked() + && let Some(path) = rfd::FileDialog::new().pick_file() + { + self.ffprobe = path.display().to_string(); + } + }); + ui.add( + egui::TextEdit::singleline(&mut self.ffprobe) + .desired_width(f32::INFINITY) + .hint_text("Automatic: beside app, bin/, or PATH"), + ); + ui.weak("PDF generation is built in. FFprobe comes from FFmpeg."); + }); + }); + egui::Window::new("Report formats") + .open(&mut self.formats_open) + .collapsible(false) + .resizable(false) + .show(ctx, |ui| { + ui.add_enabled_ui( + self.rx.is_none() && !self.preferences.options.extract_only, + |ui| { + let formats = &mut self.preferences.options.formats; + ui.horizontal_wrapped(|ui| { + if ui.button("Reading & printing").clicked() { + *formats = ["html", "pdf", "pdf-dense"].map(String::from).to_vec(); + } + if ui.button("Defaults").clicked() { + *formats = Options::default().formats; + } + if ui.button("All").clicked() { + *formats = FORMATS.iter().map(|s| (*s).into()).collect(); + } + }); + egui::Grid::new("formats_grid") + .num_columns(2) + .show(ui, |ui| { + for (i, format) in FORMATS.iter().enumerate() { + format_checkbox(ui, formats, format); + if i % 2 == 1 { + ui.end_row(); + } + } + }); + }, + ); + }); + } + fn draw(&mut self, ctx: &egui::Context) { self.receive(); if self.rx.is_some() { @@ -248,174 +558,45 @@ impl App { ); } else { match accept_drop(drops) { - Ok(paths) => { - self.source = paths[0].display().to_string(); - self.preferences.options.additional_sources = paths[1..].to_vec(); - self.error = None; - } + Ok(paths) => self.select_inputs(paths), Err(e) => self.error = Some(e), } } } - egui::CentralPanel::default().show(ctx, |ui| { - egui::ScrollArea::vertical().show(ui, |ui| { - ui.add_space(12.0); - ui.label(RichText::new("PRESENTATION MEDIA").color(Color32::from_rgb(117,100,230)).strong()); - ui.heading(RichText::new("PPTX Reporter").size(32.0)); - ui.label("Turn embedded videos into clear timing reports."); - ui.add_space(18.0); - ui.add_enabled_ui(self.rx.is_none(), |ui| { - egui::Frame::group(ui.style()).inner_margin(20.0).show(ui, |ui| { - ui.set_min_width(ui.available_width()); - ui.label(RichText::new("1 Presentation").small().strong()); - let selected = !self.source.is_empty(); - let title = if selected { - std::path::Path::new(&self.source).file_name().unwrap_or_default().to_string_lossy().into_owned() - } else { "Drop PPTX files or a folder here".into() }; - ui.label(RichText::new(title).size(22.0).strong()); - ui.weak(if selected { "Drop another presentation to change your selection." } else { "Choose PPTX files, a video folder, or a folder of presentations." }); - if ui.button("Choose presentations…").clicked() - && let Some(files) = rfd::FileDialog::new().add_filter("PowerPoint",&["pptx"]).pick_files() - && let Some(file) = files.first() { - self.source = file.display().to_string(); - self.preferences.options.additional_sources = files[1..].to_vec(); - } - if ui.button("Choose folder…").clicked() - && let Some(folder) = rfd::FileDialog::new().pick_folder() { - self.source = folder.display().to_string(); - self.preferences.options.additional_sources.clear(); - } - if ui.add(egui::TextEdit::singleline(&mut self.source).desired_width(f32::INFINITY).hint_text("PPTX or folder path")).changed() { - self.preferences.options.additional_sources.clear(); - } - if !self.preferences.options.additional_sources.is_empty() { - ui.label(format!("{} selected inputs — combined in filename order", self.preferences.options.additional_sources.len() + 1)); - for path in &self.preferences.options.additional_sources { ui.weak(path.display().to_string()); } - } - if !self.preferences.recent.is_empty() { - egui::ComboBox::from_label("Recent presentations").selected_text("Choose…").show_ui(ui, |ui| { - for path in &self.preferences.recent { - if ui.selectable_label(false,path.display().to_string()).clicked() { self.source = path.display().to_string(); self.preferences.options.additional_sources.clear(); } - } - }); - } - }); - ui.add_space(12.0); - ui.label(RichText::new("2 Save location").strong()); - ui.horizontal(|ui| { - ui.label("Output folder"); - if ui.button("Choose…").clicked() - && let Some(path) = rfd::FileDialog::new().pick_folder() { - self.output = path.display().to_string(); - } - if ui.button("Use default").clicked() { self.output.clear(); } - }); - ui.add(egui::TextEdit::singleline(&mut self.output).desired_width(f32::INFINITY).hint_text("Default: _videos")); - if !self.source.is_empty() { - let preview = Options { - source: PathBuf::from(&self.source), - output: (!self.output.trim().is_empty()).then(|| PathBuf::from(&self.output)), - ..Default::default() - }.output_dir(); - ui.weak(format!("Save to: {}", preview.display())); + egui::TopBottomPanel::top("header").show(ctx, |ui| { + ui.horizontal(|ui| { + ui.label( + RichText::new("PPTX Reporter") + .size(24.0) + .strong() + .color(Color32::from_rgb(153, 137, 245)), + ); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + if ui.button("Settings").clicked() { + self.settings_open = true; } - ui.add_space(8.0); - ui.label(RichText::new("3 What to create").strong()); - let options = &mut self.preferences.options; - let mut mode = if options.extract_only { 2 } else if options.timings_only { 1 } else { 0 }; - ui.horizontal_wrapped(|ui| { - ui.selectable_value(&mut mode,0,"Extract + reports"); - ui.selectable_value(&mut mode,1,"Reports only"); - ui.selectable_value(&mut mode,2,"Extract only"); - }); - options.extract_only = mode == 2; options.timings_only = mode == 1; - ui.weak(match mode { - 1 => "Create reports without keeping extracted videos.", - 2 => "Save embedded videos without generating reports.", - _ => "Save embedded videos and generate timing reports.", - }); - ui.add_enabled_ui(!options.extract_only,|ui| { - ui.horizontal_wrapped(|ui| { - ui.label("Report formats"); - if ui.small_button("Reading & printing").on_hover_text("Web page, PDF and compact PDF").clicked() { - options.formats = ["html", "pdf", "pdf-dense"].map(String::from).to_vec(); - } - if ui.small_button("Defaults").on_hover_text("Markdown and Ontime").clicked() { - options.formats = Options::default().formats; - } - if ui.small_button("All").clicked() { options.formats = FORMATS.iter().map(|s| (*s).into()).collect(); } - }); - ui.horizontal_wrapped(|ui| { - for format in FORMATS { - let mut selected = options.formats.iter().any(|f| f == format); - if ui.checkbox(&mut selected,format_label(format)).changed() { - options.formats.retain(|f| f != format); - if selected { options.formats.push((*format).into()); } - } - } - }); - if options.formats.is_empty() { - ui.colored_label(Color32::from_rgb(236,185,86), "Select at least one report format."); - } - }); - ui.collapsing("Advanced",|ui| { - ui.checkbox(&mut options.overwrite,"Replace existing extracted videos"); - ui.label("Existing report files are regenerated. Videos are kept unless replacement is enabled."); - ui.horizontal(|ui| { - ui.label("FFprobe"); - if ui.button("Locate…").clicked() - && let Some(path) = rfd::FileDialog::new().pick_file() { - self.ffprobe = path.display().to_string(); - } - }); - ui.add(egui::TextEdit::singleline(&mut self.ffprobe).desired_width(f32::INFINITY).hint_text("Automatic: beside app, bin/, or PATH")); - ui.label("PDF generation is built in. FFprobe comes from FFmpeg; no PowerPoint installation is needed."); - }); - ui.add_space(10.0); - let ready = !self.source.is_empty() && (options.extract_only || !options.formats.is_empty()); - let action = match mode { - 1 => "Generate reports", - 2 => "Extract videos", - _ => "Extract & generate reports", - }; - ui.add_enabled_ui(ready, |ui| { - if ui.add_sized([240.0,40.0],egui::Button::new(RichText::new(action).color(Color32::WHITE)).fill(Color32::from_rgb(87,68,181))).clicked() { self.start(); } - }); - }); - ui.add_space(14.0); - if self.rx.is_some() { - ui.horizontal(|ui| { - ui.spinner(); ui.label(&self.status.message); - let cancelling = self.cancel.load(Ordering::Relaxed); - if ui.add_enabled(!cancelling, egui::Button::new(if cancelling { "Cancelling…" } else { "Cancel" })).clicked() { self.cancel.store(true,Ordering::Relaxed); } - }); - let e = &self.status; - if e.total > 0 { ui.add(egui::ProgressBar::new(e.done as f32/e.total as f32).show_percentage()); } - let eta = if e.done > 0 && e.done < e.total { - format!(" · about {:.0}s remaining in this phase",self.phase.elapsed().as_secs_f64()/e.done as f64*(e.total-e.done) as f64) - } else { String::new() }; - ui.label(format!("{:.0}s elapsed{eta}",self.started.elapsed().as_secs_f64())); - } else { ui.label(&self.status.message); } - if let Some(error) = &self.error { ui.colored_label(Color32::from_rgb(255,150,120),error); } - if let Some(dir) = self.completed_output.clone() { - ui.add_space(12.0); - ui.label(RichText::new("Your files are ready").size(20.0).color(Color32::from_rgb(133,214,170)).strong()); - if ui.button("Open output folder").clicked() { self.open(&dir); } - } - for path in self.paths.clone() { - ui.horizontal(|ui| { - ui.label(RichText::new(path.file_name().unwrap_or_default().to_string_lossy()).strong()); - if ui.button("Open").clicked() { self.open(&path); } - if ui.button("Copy path").clicked() { ctx.copy_text(path.display().to_string()); } - }); - } - ui.collapsing("Activity & diagnostics",|ui| { - egui::ScrollArea::vertical().max_height(180.0).stick_to_bottom(true).show(ui,|ui| { - for (line, warning) in &self.log { ui.colored_label(if *warning {Color32::from_rgb(236,185,86)} else {Color32::from_rgb(160,175,195)},line); } - }); }); }); + ui.horizontal(|ui| { + ui.selectable_value(&mut self.tab, Tab::Setup, "Setup"); + ui.selectable_value(&mut self.tab, Tab::Results, "Results"); + }); }); + egui::TopBottomPanel::bottom("actions").show(ctx, |ui| self.action_bar(ui)); + egui::CentralPanel::default().show(ctx, |ui| { + // Only the active pane scrolls; actions and navigation stay visible. + egui::ScrollArea::vertical() + .id_salt(match self.tab { + Tab::Setup => "setup", + Tab::Results => "results", + }) + .auto_shrink([false, false]) + .show(ui, |ui| match self.tab { + Tab::Setup => self.setup(ui), + Tab::Results => self.results(ui, ctx), + }); + }); + self.dialogs(ctx); if ctx.input(|i| !i.raw.hovered_files.is_empty()) { let painter = ctx.layer_painter(egui::LayerId::new( egui::Order::Foreground, @@ -425,21 +606,45 @@ impl App { painter.text( ctx.screen_rect().center(), egui::Align2::CENTER_CENTER, - "Drop your PPTX presentation", - egui::FontId::proportional(28.0), + "Drop PPTX files or folders", + egui::FontId::proportional(24.0), Color32::WHITE, ); } } } +fn format_checkbox(ui: &mut egui::Ui, formats: &mut Vec, format: &str) { + let mut selected = formats.iter().any(|f| f == format); + if ui.checkbox(&mut selected, format_label(format)).changed() { + formats.retain(|f| f != format); + if selected { + formats.push(format.into()); + } + } +} + +fn configure_style(ctx: &egui::Context) { + ctx.set_visuals(egui::Visuals::dark()); + let mut style = (*ctx.style()).clone(); + style.spacing.item_spacing = egui::vec2(10.0, 10.0); + style.visuals.override_text_color = Some(Color32::from_rgb(218, 224, 235)); + for role in [egui::TextStyle::Body, egui::TextStyle::Button] { + style + .text_styles + .insert(role, egui::FontId::proportional(14.0)); + } + style.visuals.selection.bg_fill = Color32::from_rgb(87, 68, 181); + ctx.set_style(style); +} + pub fn launch() -> anyhow::Result<()> { let icon = eframe::icon_data::from_png_bytes(include_bytes!("../assets/rust-report-icon.png"))?; let options = eframe::NativeOptions { viewport: egui::ViewportBuilder::default() .with_icon(icon) - .with_inner_size([860.0, 820.0]) - .with_min_inner_size([620.0, 500.0]) + .with_inner_size([760.0, 560.0]) + .with_min_inner_size([560.0, 420.0]) .with_drag_and_drop(true), ..Default::default() }; @@ -447,17 +652,7 @@ pub fn launch() -> anyhow::Result<()> { "PPTX Reporter", options, Box::new(|cc| { - cc.egui_ctx.set_visuals(egui::Visuals::dark()); - let mut style = (*cc.egui_ctx.style()).clone(); - style.spacing.item_spacing = egui::vec2(10.0, 10.0); - style.visuals.override_text_color = Some(Color32::from_rgb(218, 224, 235)); - for role in [egui::TextStyle::Body, egui::TextStyle::Button] { - style - .text_styles - .insert(role, egui::FontId::proportional(14.0)); - } - style.visuals.selection.bg_fill = Color32::from_rgb(87, 68, 181); - cc.egui_ctx.set_style(style); + configure_style(&cc.egui_ctx); Ok(Box::new(App::new())) }), ) @@ -525,9 +720,171 @@ mod tests { frame(&mut app, egui::RawInput::default()); assert_eq!(app.log.len(), 500); assert_eq!(app.paths.len(), 1); + assert_eq!(app.tab, Tab::Results); assert_eq!(app.completed_output, Some("reports".into())); let cancellation = app.cancel.clone(); drop(app); assert!(cancellation.load(Ordering::Relaxed)); } + fn layout_frame( + app: &mut App, + ctx: &egui::Context, + size: egui::Vec2, + events: Vec, + ) -> egui::FullOutput { + ctx.run( + egui::RawInput { + screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, size)), + events, + ..Default::default() + }, + |ctx| app.draw(ctx), + ) + } + + fn text_rect(output: &egui::FullOutput, text: &str) -> (egui::Rect, egui::Rect) { + output + .shapes + .iter() + .find_map(|clipped| { + if let egui::epaint::Shape::Text(shape) = &clipped.shape + && shape.galley.text() == text + { + return Some(( + shape.galley.rect.translate(shape.pos.to_vec2()), + clipped.clip_rect, + )); + } + None + }) + .unwrap_or_else(|| panic!("Missing text: {text}")) + } + + #[test] + fn compact_setup_and_actions_remain_visible_with_many_inputs() { + for size in [egui::vec2(760.0, 560.0), egui::vec2(560.0, 420.0)] { + let ctx = egui::Context::default(); + configure_style(&ctx); + let mut app = App::from_preferences(Preferences::default()); + app.select_inputs( + (1..=60) + .rev() + .map(|n| PathBuf::from(format!("/presentations/Presentation {n}.pptx"))) + .collect(), + ); + assert!(app.source.ends_with("Presentation 1.pptx")); + layout_frame(&mut app, &ctx, size, vec![]); + let output = layout_frame(&mut app, &ctx, size, vec![]); + for text in [ + "Setup", + "Results", + "Formats", + "Save to", + "Extract & generate reports", + ] { + let (rect, clip) = text_rect(&output, text); + assert!( + clip.contains_rect(rect), + "{text} clipped at {size:?}: {rect:?}, {clip:?}" + ); + assert!(egui::Rect::from_min_size(egui::Pos2::ZERO, size).contains_rect(rect)); + } + let (button, _) = text_rect(&output, "Extract & generate reports"); + assert!(button.top() > size.y - 55.0); + let (_tx, rx) = mpsc::channel(); + app.rx = Some(rx); + app.status = Event::step( + "Processing a very long filename that must not push Cancel off the edge of the window", + 1, + 3, + ); + layout_frame(&mut app, &ctx, size, vec![]); + let output = layout_frame(&mut app, &ctx, size, vec![]); + let (cancel, clip) = text_rect(&output, "Cancel"); + assert!(clip.contains_rect(cancel)); + assert!(cancel.right() <= size.x); + } + } + + #[test] + fn tabs_dialogs_and_cancel_work_in_compact_window() { + let ctx = egui::Context::default(); + configure_style(&ctx); + let mut app = App::from_preferences(Preferences::default()); + let size = egui::vec2(760.0, 560.0); + layout_frame(&mut app, &ctx, size, vec![]); + let mut output = layout_frame(&mut app, &ctx, size, vec![]); + for label in ["Results", "Setup", "Settings"] { + let pos = text_rect(&output, label).0.center(); + layout_frame( + &mut app, + &ctx, + size, + vec![ + egui::Event::PointerMoved(pos), + egui::Event::PointerButton { + pos, + button: egui::PointerButton::Primary, + pressed: true, + modifiers: egui::Modifiers::NONE, + }, + ], + ); + output = layout_frame( + &mut app, + &ctx, + size, + vec![egui::Event::PointerButton { + pos, + button: egui::PointerButton::Primary, + pressed: false, + modifiers: egui::Modifiers::NONE, + }], + ); + if label == "Results" { + assert_eq!(app.tab, Tab::Results); + } + if label == "Setup" { + assert_eq!(app.tab, Tab::Setup); + } + } + assert!(app.settings_open); + app.settings_open = false; + app.formats_open = true; + layout_frame(&mut app, &ctx, size, vec![]); + output = layout_frame(&mut app, &ctx, size, vec![]); + text_rect(&output, "Reading & printing"); + app.formats_open = false; + app.tab = Tab::Results; + let (_tx, rx) = mpsc::channel(); + app.rx = Some(rx); + output = layout_frame(&mut app, &ctx, size, vec![]); + let pos = text_rect(&output, "Cancel").0.center(); + layout_frame( + &mut app, + &ctx, + size, + vec![ + egui::Event::PointerMoved(pos), + egui::Event::PointerButton { + pos, + button: egui::PointerButton::Primary, + pressed: true, + modifiers: egui::Modifiers::NONE, + }, + ], + ); + layout_frame( + &mut app, + &ctx, + size, + vec![egui::Event::PointerButton { + pos, + button: egui::PointerButton::Primary, + pressed: false, + modifiers: egui::Modifiers::NONE, + }], + ); + assert!(app.cancel.load(Ordering::Relaxed)); + } } diff --git a/docs/images/reporter/01-start.png b/docs/images/reporter/01-start.png index 0ecaf3c..d80fb71 100644 Binary files a/docs/images/reporter/01-start.png and b/docs/images/reporter/01-start.png differ diff --git a/docs/images/reporter/02-options.png b/docs/images/reporter/02-options.png index a7d7242..e8c7ad7 100644 Binary files a/docs/images/reporter/02-options.png and b/docs/images/reporter/02-options.png differ diff --git a/docs/images/reporter/03-results.png b/docs/images/reporter/03-results.png index ed8b220..996b844 100644 Binary files a/docs/images/reporter/03-results.png and b/docs/images/reporter/03-results.png differ diff --git a/docs/rust-reporter.md b/docs/rust-reporter.md index b0db233..239bc8f 100644 --- a/docs/rust-reporter.md +++ b/docs/rust-reporter.md @@ -13,8 +13,13 @@ cargo run --locked --bin pptx-reporter -- presentation.pptx --extract-only Drop PPTX files or a folder into the window, choose multiple presentations, or use **Choose folder…**. Check the save location, choose extraction/report mode, select formats, then use the purple action button. -Reading & printing selects HTML, PDF and compact PDF; Defaults selects Markdown -and Ontime. Advanced contains video replacement and FFprobe location controls. +The **Setup** tab contains inputs, output location, mode, and common formats. +**More formats…** offers every format and presets: Reading & printing selects +HTML, PDF and compact PDF; Defaults selects Markdown and Ontime. **Settings** +contains video replacement and FFprobe location controls. The action/progress +bar stays visible at the bottom. Successful runs open **Results**, with file +actions and collapsible diagnostics. The default window is 760 × 560; long +input/result lists scroll within their panes. The app remembers options and the last eight presentations. Completed files can be opened directly or their paths copied. @@ -35,7 +40,7 @@ remains unchanged. See [report options and semantics](pptx-videos.md). PDF compilation and fonts are embedded; no Typst installation or package downloads are needed. FFprobe is discovered beside the app, in its `bin/` -subfolder, or on PATH. Override with `--ffprobe PATH` or Advanced in the GUI. +subfolder, or on PATH. Override with `--ffprobe PATH` or Settings in the GUI. On Windows, extract the whole portable ZIP and launch `pptx-reporter-gui.exe`. `pptx-reporter.exe` provides the CLI and opens the GUI when given no arguments. diff --git a/docs/user-guide.md b/docs/user-guide.md index 9d69349..cdd4f14 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -1,8 +1,8 @@ # PPTX Reporter user guide -The desktop app turns embedded PowerPoint videos into timing reports. The +The desktop app turns PowerPoint videos and video folders into timing reports. The Windows GUI has been confirmed working by the project owner. Screenshots below -show the same interface running on Linux with a sample presentation; window +show the compact interface running on Linux with a sample video folder; window borders, file dialogs and path separators differ on Windows. ## 1. Open a presentation @@ -11,15 +11,22 @@ On Windows, extract the **whole portable ZIP** and launch `pptx-reporter-gui.exe`. Keep `ffprobe.exe` beside it. No Python, PowerPoint or Typst installation is needed. -Drag one `.pptx` into the window, or click **Choose presentation…**. You can -also choose a previously used file from **Recent presentations**. +On **Setup**, drop PPTX files or a folder anywhere in the window, or use +**PPTX files…** / **Folder…**. **Recent…** reopens a previous input; **Enter a +path** lets you type a path. The input list uses natural filename order, so +`media2` comes before `media10`. Long lists scroll within their own area. + +The default window is 760 × 560. **Setup** and **Results** stay at the top; +the action button, progress and Cancel stay at the bottom. At smaller sizes or +with enlarged text, the active pane can scroll without hiding those controls. ![Start screen with the presentation picker and drop area](images/reporter/01-start.png) ## 2. Choose what to create -Check the selected filename and **Save to** path. Use **Choose…** under Output -folder for another destination, or **Use default** to reset it. +Check the selected inputs and **Save to** path. Use **Change…** for another +destination, type into the output field, or use **Use default** to reset it. +Hover a shortened filename or path to see its full value. | Mode | Result | | --- | --- | @@ -27,12 +34,13 @@ folder for another destination, or **Use default** to reset it. | Reports only | Generate reports without keeping newly extracted videos | | Extract only | Save videos without generating reports | -For easy reading, choose **Reading & printing**: it selects Web page, PDF and +Ontime, PDF and Markdown checkboxes are on Setup. **More formats…** opens +all formats and presets. For easy reading, choose **Reading & printing**: it selects Web page, PDF and Compact PDF. Add **Ontime** if you need a rundown import. **Defaults** selects Markdown and Ontime; **All** selects every format. Individual checkboxes let you adjust any selection. -The example below uses Reports only, with readable reports and Ontime selected. +The example below uses Reports only, with PDF, Markdown and Ontime selected. ![Selected presentation, save location and report formats](images/reporter/02-options.png) @@ -45,9 +53,12 @@ During processing, the app shows the current step and progress where measurable. Time estimates apply to that phase. **Cancel** stops between steps and interrupts FFprobe; an active PDF compilation finishes before stopping. -When **Your files are ready** appears, click **Open** beside a report or -**Open output folder**. **Copy path** copies a file's location, not its contents. -Scroll down if the result list extends below the window. +After successful completion, the app switches to **Results**. Click **Open** +beside a report or **Open output folder**. **Copy path** copies a file's location, +not its contents. Results scroll independently of the bottom action bar. +**Activity & diagnostics** contains warnings and detailed progress messages. +You can switch tabs during a run; input and format controls stay disabled until +it finishes. Errors remain visible in the bottom bar. ![Completed run with report files and Open actions](images/reporter/03-results.png) @@ -60,9 +71,10 @@ Showcase_videos/ ``` The `.typ` files are editable PDF sources; open `.pdf` for normal reading. -Existing reports are regenerated. Existing videos are reused unless **Advanced -→ Replace existing extracted videos** is enabled. The source PPTX is preserved. -A presentation with no embedded videos produces no new reports. +Existing reports are regenerated. Existing videos are reused unless **Settings +→ Replace existing extracted or copied videos** is enabled. The source PPTX is preserved. +A presentation with no embedded videos produces no new reports. **Settings** +also contains the FFprobe location override. ## 4. Read the timings @@ -84,7 +96,7 @@ for skipped events and choosing your show start time. ## If something needs attention - **FFprobe cannot be found:** keep the bundled executable beside the app, or - select it under **Advanced → FFprobe → Locate…**. + select it under **Settings → FFprobe → Locate…**. - **Generate is disabled:** choose a presentation and at least one report format, or select Extract only. - **A warning or failure appears:** expand **Activity & diagnostics** for details.