diff --git a/app/README.md b/app/README.md index a450638..84f126d 100644 --- a/app/README.md +++ b/app/README.md @@ -29,6 +29,7 @@ cargo run -- --snap recording-live-delete.png --scene recording-live-delete cargo run -- --snap recording-idle.png --scene recording-idle cargo run -- --snap audio.png --scene audio cargo run -- --snap review.png --scene review +cargo run -- --snap review-full.png --scene review-full # the picture alone, at rest cargo run -- --snap clips.png --scene clips cargo run -- --snap clip.png --scene clip cargo run -- --snap clips-many.png --scene clips-many --at 1 # 36 demo clips, to see the scrollbar @@ -99,7 +100,10 @@ reading (`history::tests`), highlight clipping (`highlight::tests`) and formatti mpv's, the three options in TODO.txt still apply; `Player` is confined to `screens/review.rs`. 6. Game review: done. The clip fills the window at 16:9, with play/pause, +/-10 s, and a scrubber that marks every event; highlights (play, export) and the timeline sit in a side - panel, one press away. ffmpeg exports each highlight. + panel, one press away. ffmpeg exports each highlight. The Full screen button beside the + volume, a double press on the picture, or F takes the whole display: the picture fills the + screen and the controls fade in over its bottom while the pointer is on them, gone 400 ms + after it leaves. Escape goes back. 7. Audio channels: the recorder writes one audio stream per source, and the review screen opens one player per stream (`export::extract_tracks` copies each into the audio cache). Toggles under the transport mute a channel for listening, and clip and highlight exports mix only diff --git a/app/src/app.rs b/app/src/app.rs index 1d934da..94b6430 100644 --- a/app/src/app.rs +++ b/app/src/app.rs @@ -124,6 +124,9 @@ pub struct App { pub sample: bool, /// The screens behind this one, oldest first: the back arrow returns through them. pub behind: Vec, + /// Whether the window is full screen at the app's asking. The review asks for it, and a + /// window that disagrees follows it in the next poll. + pub window_full: bool, pub settings_tab: SettingsTab, pub dark: bool, pub daemon: Daemon, @@ -202,6 +205,7 @@ impl App { let live = std::env::args().any(|arg| arg == "--live"); let mut app = Self { sample: headless && !live, + window_full: false, screen: Screen::History, behind: Vec::new(), settings_tab: SettingsTab::Quick, @@ -727,6 +731,9 @@ thread_local! { /// no picture. Reopening brings the same screen back, paused where it was. pub fn window_closed(app: &mut App, _tx: &mut Tx) { app.pause_playback(); + // The window comes back at its spec size, so a full screen review ends with it. + app.review.fullscreen = false; + app.window_full = false; } pub fn remember_window(handle: &rune::WindowHandle) { @@ -836,6 +843,17 @@ impl App { fn handle_poll(&mut self, t: f64, tx: &mut Tx) -> bool { let mut changed = false; + // Being full screen is a state of the window, not only of the review: the view drops + // the title bar and the status bar the moment the review asks for it, and the window + // follows in the same frame. Any way out of the review, or off the screen it was on, + // brings both back. + let full = self.screen == Screen::Review && self.review.fullscreen; + self.review.fullscreen = full; + if full != self.window_full { + self.window_full = full; + tx.toggle_full_screen(); + } + for event in self.daemon.drain() { changed = true; match (event.request, event.result) { @@ -1184,12 +1202,21 @@ pub fn on_key(app: &mut App, event: &KeyEvent, _tx: &mut Tx) -> bool { app.clips_menu_open = None; true } + // A full screen clip leaves the screen it fills before it leaves the screen. + (Key::Escape, _) if app.review.fullscreen => { + app.review.fullscreen = false; + true + } (Key::Escape, _) if !app.behind.is_empty() => { app.menu_open = None; app.clips_menu_open = None; app.back(); true } + (Key::Text(t), false) if app.screen == Screen::Review && t.eq_ignore_ascii_case("f") => { + app.review.fullscreen = !app.review.fullscreen; + true + } (Key::Text(t), true) if t.eq_ignore_ascii_case("r") => { app.refresh_games(); app.daemon.get_status(); @@ -1400,6 +1427,11 @@ pub fn view(app: &App, cx: &mut Cx) -> El { // Menus and dialogs cover the whole window, title bar and status bar included: the // history row menus, the add-application form and the delete confirmation. let mut overlays = Vec::new(); + // A full screen review is the picture alone: the title bar and the status bar would draw + // on it, and the window has no frame to hold them. + if app.screen == Screen::Review && app.review.fullscreen { + return rune_kit::root(screens::review::fullscreen(app, p), overlays); + } let content = match app.screen { Screen::Settings => screens::settings::view(app, p), Screen::History => screens::history::view(app, p, &mut overlays), diff --git a/app/src/main.rs b/app/src/main.rs index 7de9570..5845131 100644 --- a/app/src/main.rs +++ b/app/src/main.rs @@ -131,6 +131,10 @@ fn main() { app::demo_review(app); app.review.show_details = true; }), + ("review-full", |app| { + app::demo_review(app); + app.review.fullscreen = true; + }), ("clips-empty", |app| { app.jump(app::Screen::Clips); app.clips.clear(); diff --git a/app/src/screens/review.rs b/app/src/screens/review.rs index 29f6833..63e344b 100644 --- a/app/src/screens/review.rs +++ b/app/src/screens/review.rs @@ -47,6 +47,9 @@ pub struct Review { /// move under the pointer. pub frozen_window: Option<(f64, f64)>, pub show_details: bool, + /// The window fills the display and the picture fills the window, with the controls over + /// its bottom: entered from the transport, a double press on the picture, or F. + pub fullscreen: bool, pub highlights: Vec, /// The clip being chosen on the scrubber, once the Clip button is pressed. pub clip: Option, @@ -379,6 +382,7 @@ impl Default for Review { highlights: Vec::new(), clip: None, show_details: false, + fullscreen: false, export: None, export_note: None, error: None, @@ -501,6 +505,7 @@ pub fn leave(app: &mut App) { app.review.error = None; app.review.export_note = None; app.review.export = None; + app.review.fullscreen = false; } /// Called from `poll` while the review screen is up. /// Sound from a second player drifts from the pictures by a few milliseconds a minute. Past a @@ -709,6 +714,81 @@ pub fn view(app: &App, p: Paint) -> El { .child(body) } +/// The picture filling the window, with the controls over its bottom. The picture is the whole +/// screen, so the controls keep to their band: the pointer finds them there, and 200 ms after it +/// arrives they draw in, 400 ms after it leaves they are gone again. +pub fn fullscreen(app: &App, p: Paint) -> El { + let stage = el() + .key("fullscreen-stage") + .w_full() + .h_full() + .fill(rune::Color::BLACK) + .center(); + // A double press on the picture leaves the full screen, as it enters one. It sits on the + // picture, not the stage, so the controls over it keep their own presses. + let stage = match &app.review.player { + Some(player) => stage.child( + el().key("video") + .aspect_fit(16.0 / 9.0) + .video(player, SurfaceFit::Fill) + .on_double_press(|app: &mut App| app.review.fullscreen = false), + ), + None => stage.child( + text( + app.review + .error + .clone() + .unwrap_or_else(|| "Loading the clip…".into()), + ) + .key("stage-message") + .font(body(13.0)) + .color(p.muted()), + ), + }; + // A band on the bottom of the picture, not a sheet over all of it: the gradient reaches + // black under the transport and is already gone a hand's width above the scrubber, so the + // picture shows at its own brightness on every display. The band is the hover group, so the + // pointer has to come to the controls for them to show, and leaving them puts them away. + let band = col() + .key("fullscreen-controls") + .pin(Some(0.0), None, Some(0.0), Some(0.0)) + .hover_group() + .hover_motion( + rune::Spring::smooth(0.2, 0.0), + rune::Spring::smooth(0.4, 0.0), + ); + let mut controls = col() + .key("fullscreen-bar") + .w_full() + .gap(space::S2) + .px(space::S6) + .pt(space::S6) + .pb(space::S3) + .gradient(rune::Color::TRANSPARENT, rune::Color::BLACK.alpha(0.8)) + .group_opacity(0.0, 1.0); + if let Some(game) = app.reviewed() { + controls = controls.child(scrubber(app, p, game)); + } + controls = controls.child( + row() + .key("fullscreen-transport") + .w_full() + .center_y() + .gap(space::S2) + .child(playback(app, p)) + .child(volume(app, p)) + .child(el().grow(1.0)) + .child(ui::button( + p, + "exit-fullscreen", + "Exit full screen", + false, + |app: &mut App| app.review.fullscreen = false, + )), + ); + stage.child(band.child(controls)) +} + /// The clip itself: the largest 16:9 box that fits, on black, with a message when there is no /// file to play. fn video_stage(app: &App, p: Paint) -> El { @@ -720,7 +800,8 @@ fn video_stage(app: &App, p: Paint) -> El { .fill(rune::Color::BLACK) .radius(radius::LG) .clip_soft(radius::LG) - .center(); + .center() + .on_double_press(|app: &mut App| app.review.fullscreen = true); match &app.review.player { Some(player) => stage.child( @@ -782,6 +863,67 @@ fn transport(app: &App, p: Paint) -> El { .w_full() .center_y() .gap(space::S2) + .child(playback(app, p)) + .child(volume(app, p)) + .child(ui::button( + p, + "fullscreen", + "Full screen", + false, + |app: &mut App| app.review.fullscreen = true, + )) + .child(el().grow(1.0)); + if let Some(note) = &app.review.export_note { + bar = bar.child( + text(note.clone()) + .key("export-note") + .font(body(11.5)) + .color(p.muted()), + ); + } + let bar = bar + .child(ui::button( + p, + "clip", + "Clip", + app.review.clip.is_some(), + |app: &mut App| app.review.toggle_clip(), + )) + .child(ui::button( + p, + "toggle-details", + &if app.review.show_details { + "Hide details".to_string() + } else { + format!("Highlights · {count}") + }, + false, + |app: &mut App| { + app.review.show_details = !app.review.show_details; + }, + )); + + let mut column = col() + .key("transport-bar") + .w_full() + .gap(space::S2) + .child(bar); + if let Some(line) = channels(app, p) { + column = column.child(line); + } + if let Some(clip) = app.review.clip { + column = column.child(clip_row(app, p, clip)); + } + column +} + +/// Back ten seconds, play or pause, forward ten, and the clock: the bar and the full screen +/// picture show the same controls. +fn playback(app: &App, p: Paint) -> El { + row() + .key("playback") + .center_y() + .gap(space::S2) .child(ui::media_button( p, "rewind", @@ -828,52 +970,7 @@ fn transport(app: &App, p: Paint) -> El { .font(type_::MONO_CAPTION) .color(p.muted()), ) - .child(volume(app, p)) - .child(el().grow(1.0)); - if let Some(note) = &app.review.export_note { - bar = bar.child( - text(note.clone()) - .key("export-note") - .font(body(11.5)) - .color(p.muted()), - ); - } - let bar = bar - .child(ui::button( - p, - "clip", - "Clip", - app.review.clip.is_some(), - |app: &mut App| app.review.toggle_clip(), - )) - .child(ui::button( - p, - "toggle-details", - &if app.review.show_details { - "Hide details".to_string() - } else { - format!("Highlights · {count}") - }, - false, - |app: &mut App| { - app.review.show_details = !app.review.show_details; - }, - )); - - let mut column = col() - .key("transport-bar") - .w_full() - .gap(space::S2) - .child(bar); - if let Some(line) = channels(app, p) { - column = column.child(line); - } - if let Some(clip) = app.review.clip { - column = column.child(clip_row(app, p, clip)); - } - column } - /// One toggle per audio track, shown once the clip carries more than one. A track that is off /// is neither heard nor kept in an export. fn channels(app: &App, p: Paint) -> Option {