forge
Explore
Log in

Don't you dare go Hollow

Fullscreen fills the screen with the player, not the app

Browse files at this commit

3b02ca610b82744c1b2ac52df10be2d8d8409fb7Ahmet Kaan GümüşParent: 6117d2424cc062
  • feat
    • fullscreen fills the screen with the player, not the app
Show full message
✨ feat(app): fullscreen fills the screen with the player, not the app

Merge of the player-fullscreen branch over the scrub-bar branch: the
picture region is one method both layouts call, and the preview scrub
bar rides in it — drawn last, so the PREVIEWING notice plate no longer
hides it the moment a preview starts.
crates/app/src/main.rsmodified+10 -0
@@ -30,6 +30,7 @@ pub(crate) use interact::*;
30 pub(crate) use layout::*;30 pub(crate) use layout::*;
31 pub(crate) use library_meta::*;31 pub(crate) use library_meta::*;
32 pub(crate) use menus::*;32 pub(crate) use menus::*;
33+pub(crate) use render::escape_leaves_player_fullscreen;
33 pub(crate) use notices::*;34 pub(crate) use notices::*;
34 pub(crate) use oracle::*;35 pub(crate) use oracle::*;
35 pub(crate) use subs::*;36 pub(crate) use subs::*;
@@ -93,6 +94,14 @@ struct Player {
93 /// ([`Player::open_preview`] pauses it so the two sounds never overlap):94 /// ([`Player::open_preview`] pauses it so the two sounds never overlap):
94 /// what [`Player::close_preview`] resumes, and only then.95 /// what [`Player::close_preview`] resumes, and only then.
95 preview_playing: bool,96 preview_playing: bool,
97+ /// The picture alone, filling the window -- what `Fullscreen` gives every
98+ /// consumer video player, and not what gpui's own `toggle_fullscreen`
99+ /// gives on its own (the OS window, chrome and all). Kept apart from
100+ /// `window.is_fullscreen()` because the two can fall out of step: a
101+ /// compositor keybind changes the window's without this flag hearing
102+ /// about it, so [`Player::act`] reconciles them rather than trusting
103+ /// either alone.
104+ player_fullscreen: bool,
96 /// Timeline seconds -> frame index, so the clock can be compared to what105 /// Timeline seconds -> frame index, so the clock can be compared to what
97 /// the decoder hands over.106 /// the decoder hands over.
98 fps: f64,107 fps: f64,
@@ -722,6 +731,7 @@ fn main() {
722 pending_settings: (None, None, None),731 pending_settings: (None, None, None),
723 preview_session: None,732 preview_session: None,
724 preview_playing: false,733 preview_playing: false,
734+ player_fullscreen: false,
725 // Full and unmuted, which is what the session it was just735 // Full and unmuted, which is what the session it was just
726 // handed is already set to: nothing to push at startup.736 // handed is already set to: nothing to push at startup.
727 volume: Volume::default(),737 volume: Volume::default(),
crates/app/src/player/actions.rsmodified+14 -4
@@ -98,10 +98,20 @@ impl Player {
98 // At the window's corner, since a stroke names no place -- and98 // At the window's corner, since a stroke names no place -- and
99 // [`menu_at`] keeps it on screen from there.99 // [`menu_at`] keeps it on screen from there.
100 ActionId::Theme => self.open_picker(Pick::Theme, Point::default(), cx),100 ActionId::Theme => self.open_picker(Pick::Theme, Point::default(), cx),
101- // The platform's own toggle (gpui::Window::toggle_fullscreen); the101+ // Not the window's own toggle alone -- every consumer video
102- // window reports its own new state back through `is_fullscreen`,102+ // player fullscreens the *picture*, chrome and all, not just the
103- // there is no local bool to keep in step with it.103+ // OS frame around it -- so this flips both: `player_fullscreen`
104- ActionId::Fullscreen => window.toggle_fullscreen(),104+ // is what [`crate::render`] reads to draw the picture only, and
105+ // the platform's own toggle is what actually grows the window to
106+ // the monitor. The two are asked to agree rather than one being
107+ // derived from the other, because a compositor keybind can move
108+ // `window.is_fullscreen()` without this action ever firing.
109+ ActionId::Fullscreen => {
110+ self.player_fullscreen = !self.player_fullscreen;
111+ if window.is_fullscreen() != self.player_fullscreen {
112+ window.toggle_fullscreen();
113+ }
114+ }
105 // Nothing to cancel while nothing is exporting; the export guard in115 // Nothing to cancel while nothing is exporting; the export guard in
106 // the key handler is what answers this one while there is.116 // the key handler is what answers this one while there is.
107 ActionId::CancelExport => {}117 ActionId::CancelExport => {}
crates/app/src/render.rsmodified+134 -83
@@ -3,6 +3,92 @@
3 3
4 use crate::*;4 use crate::*;
5 5
6+/// Whether a stroke leaves player fullscreen. Bare escape does, the same
7+/// stroke every card and menu in this window answers to -- and it is
8+/// answered *first*: the picture-only layout is the chrome itself missing,
9+/// not a card drawn over it, so it goes before a menu close or a preview
10+/// close gets a look at the same key. See the call site in [`Player::render`]
11+/// for the deliberate order this buys with a preview open underneath.
12+pub(crate) fn escape_leaves_player_fullscreen(key: &str, ctrl: bool, player_fullscreen: bool) -> bool {
13+ key == ESCAPE && !ctrl && player_fullscreen
14+}
15+
16+impl Player {
17+ /// The picture region alone: the image, the subtitle cue plate, the
18+ /// preview badge and the three transient bars over its bottom edge.
19+ /// Its own method so player fullscreen ([`Player::act`]) can stand it up
20+ /// as the window's only child without a second copy of what it draws.
21+ fn picture_area(
22+ &mut self,
23+ position: f64,
24+ window: &mut Window,
25+ cx: &mut Context<Self>,
26+ ) -> impl IntoElement {
27+ div()
28+ .flex_1()
29+ .min_h(px(0.))
30+ .overflow_hidden()
31+ // The bed the cue plate is placed against: it hangs off the
32+ // bottom of the picture region, which is the one box that is the
33+ // picture and nothing else.
34+ .relative()
35+ .flex()
36+ .justify_center()
37+ .items_center()
38+ .bg(rgb(BG_CANVAS()))
39+ .children(
40+ self.image
41+ .clone()
42+ .map(|i| {
43+ img(i)
44+ .size_full()
45+ .object_fit(gpui::ObjectFit::Contain)
46+ .into_any_element()
47+ })
48+ // With no file open the letterbox is the whole region,
49+ // and a black rectangle says only that something is
50+ // broken -- so it says what it wants instead. The window
51+ // is already the drop target.
52+ .or_else(|| {
53+ (self.active_session().is_none())
54+ .then(|| empty_hint().into_any_element())
55+ }),
56+ )
57+ // After the picture, so the plate is drawn over it rather than
58+ // under.
59+ .children(self.subtitle_overlay(position, window))
60+ .children(self.preview_badge(cx))
61+ // The three transient lines hang off the bottom of the picture
62+ // rather than taking a row of the column: a notice that arrives
63+ // must not push the transport, the toolbar and the timeline down
64+ // by its own height -- which is a control moving with state, on
65+ // every control below it at once.
66+ .child(
67+ div()
68+ .absolute()
69+ .bottom_0()
70+ .left_0()
71+ .right_0()
72+ .flex()
73+ .flex_col()
74+ .gap(px(2.))
75+ .children(self.import_bar(cx))
76+ .children(self.seek_bar())
77+ .children(self.notice_bar(cx))
78+ // How tall the lot came out, for the cue plate above to
79+ // step over ([`sub_bottom`]) -- the bars are over the
80+ // picture, and a message drawn across the line being
81+ // read loses both of them. Zero with no bar up, since
82+ // this box is then empty.
83+ .child(height_probe(self.notice_h.clone())),
84+ )
85+ // The preview's scrub bar, drawn LAST: the notice box above shares
86+ // its bottom edge, and a bar under the "PREVIEWING ..." plate was
87+ // invisible for exactly the moment it matters.
88+ .children(self.preview_scrub_bar(cx))
89+ }
90+}
91+
6 impl Render for Player {92 impl Render for Player {
7 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {93 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
8 // A file that has just been opened sits on its first frame with the94 // A file that has just been opened sits on its first frame with the
@@ -37,6 +123,16 @@ impl Render for Player {
37 window.set_window_title(&title);123 window.set_window_title(&title);
38 self.titled = title;124 self.titled = title;
39 }125 }
126+ // A compositor keybind (the window manager's own fullscreen, not
127+ // ours) can drop `window.is_fullscreen()` without ever going through
128+ // [`Player::act`] -- the picture-only layout below must not survive
129+ // that on its own, or the chrome never comes back. Only the *leaving*
130+ // direction is reconciled here: the platform going fullscreen behind
131+ // our back is not this editor asking for the picture-only layout, so
132+ // it is left alone rather than guessed at.
133+ if self.player_fullscreen && !window.is_fullscreen() {
134+ self.player_fullscreen = false;
135+ }
40 // No shadow flag: the session is the only truth about play state, and136 // No shadow flag: the session is the only truth about play state, and
41 // [`Player::transport`] is the one place it is read.137 // [`Player::transport`] is the one place it is read.
42 let state = self.transport();138 let state = self.transport();
@@ -477,6 +573,21 @@ impl Render for Player {
477 // the keys before anything under it does: ↑↓ walk it, enter573 // the keys before anything under it does: ↑↓ walk it, enter
478 // takes the row, and escape falls through to the close below --574 // takes the row, and escape falls through to the close below --
479 // the same three strokes every list in this editor answers.575 // the same three strokes every list in this editor answers.
576+ // The picture-only layout is the outermost thing on screen --
577+ // it is the chrome itself that is missing, not a card drawn
578+ // over it -- so its own escape is answered before any menu or
579+ // preview below gets a look at the stroke. Deliberate order:
580+ // with a preview open *and* the player fullscreen, the first
581+ // Escape only leaves fullscreen (the preview keeps playing,
582+ // now behind the chrome again), and it takes a second Escape
583+ // to stop the preview -- one stroke, one effect, same as
584+ // every other card in this chain.
585+ if escape_leaves_player_fullscreen(key, ctrl, this.player_fullscreen) {
586+ this.player_fullscreen = false;
587+ window.toggle_fullscreen();
588+ cx.notify();
589+ return;
590+ }
480 if let Some(mut picker) = this.picker {591 if let Some(mut picker) = this.picker {
481 let rows = this.choices(picker.of);592 let rows = this.choices(picker.of);
482 if !rows.is_empty() && matches!(key, "up" | "down" | "enter") {593 if !rows.is_empty() && matches!(key, "up" | "down" | "enter") {
@@ -598,7 +709,17 @@ impl Render for Player {
598 // it. Nothing here moves when the state changes -- the regions are709 // it. Nothing here moves when the state changes -- the regions are
599 // fixed and the panels keep their room whether or not anything is710 // fixed and the panels keep their room whether or not anything is
600 // open in them.711 // open in them.
601- .child(self.topbar(window, cx))712+ // Player fullscreen: the picture and nothing else -- what
713+ // `Fullscreen` gives every consumer video player. The four-region
714+ // layout is skipped rather than hidden under it (a hidden library
715+ // and inspector would still lay out and take the split's own
716+ // room), and the picture div itself is untouched either way --
717+ // [`Player::picture_area`] is the same call in both arms.
718+ .when(self.player_fullscreen, |d| {
719+ d.child(self.picture_area(position, window, cx))
720+ })
721+ .when(!self.player_fullscreen, |d| {
722+ d.child(self.topbar(window, cx))
602 .child(723 .child(
603 div()724 div()
604 .flex_1()725 .flex_1()
@@ -608,9 +729,9 @@ impl Render for Player {
608 self.split_px(Split::Library, window.viewport_size()),729 self.split_px(Split::Library, window.viewport_size()),
609 cx,730 cx,
610 ))731 ))
611- // The seams, one per pair of regions: what a hand drags to732+ // The seams, one per pair of regions: what a hand
612- // give a panel more room and its neighbour less733+ // drags to give a panel more room and its
613- // ([`divider`]).734+ // neighbour less ([`divider`]).
614 .child(divider(Split::Library, cx))735 .child(divider(Split::Library, cx))
615 .child(736 .child(
616 div()737 div()
@@ -618,93 +739,23 @@ impl Render for Player {
618 .min_w(px(0.))739 .min_w(px(0.))
619 .flex()740 .flex()
620 .flex_col()741 .flex_col()
621- .child(742+ .child(self.picture_area(position, window, cx))
622- div()
623- .flex_1()
624- .min_h(px(0.))
625- .overflow_hidden()
626- // The bed the cue plate is placed against:
627- // it hangs off the bottom of the picture
628- // region, which is the one box that is the
629- // picture and nothing else.
630- .relative()
631- .flex()
632- .justify_center()
633- .items_center()
634- .bg(rgb(BG_CANVAS()))
635- .children(
636- self.image
637- .clone()
638- .map(|i| {
639- img(i)
640- .size_full()
641- .object_fit(gpui::ObjectFit::Contain)
642- .into_any_element()
643- })
644- // With no file open the letterbox
645- // is the whole region, and a black
646- // rectangle says only that
647- // something is broken -- so it says
648- // what it wants instead. The window
649- // is already the drop target.
650- .or_else(|| {
651- (self.active_session().is_none())
652- .then(|| empty_hint().into_any_element())
653- }),
654- )
655- // After the picture, so the plate is drawn
656- // over it rather than under.
657- .children(self.subtitle_overlay(position, window))
658- .children(self.preview_badge(cx))
659- // The preview's own scrub bar, low over
660- // the picture the badge is drawn over the
661- // top of: drawn after both, so it sits
662- // above the subtitle plate and never
663- // under the badge's banner.
664- .children(self.preview_scrub_bar(cx))
665- // The three transient lines hang off the
666- // bottom of the picture rather than taking
667- // a row of the column: a notice that
668- // arrives must not push the transport, the
669- // toolbar and the timeline down by its own
670- // height -- which is a control moving with
671- // state, on every control below it at once.
672- .child(
673- div()
674- .absolute()
675- .bottom_0()
676- .left_0()
677- .right_0()
678- .flex()
679- .flex_col()
680- .gap(px(2.))
681- .children(self.import_bar(cx))
682- .children(self.seek_bar())
683- .children(self.notice_bar(cx))
684- // How tall the lot came out, for the
685- // cue plate above to step over
686- // ([`sub_bottom`]) -- the bars are
687- // over the picture, and a message
688- // drawn across the line being read
689- // loses both of them. Zero with no
690- // bar up, since this box is then
691- // empty.
692- .child(height_probe(self.notice_h.clone())),
693- ),
694- )
695 .child(self.transport_bar(state, window.viewport_size(), cx)),743 .child(self.transport_bar(state, window.viewport_size(), cx)),
696 )744 )
697 .child(divider(Split::Inspector, cx))745 .child(divider(Split::Inspector, cx))
698- // The settings cards live in here rather than over the746+ // The settings cards live in here rather than over
699- // timeline: adjusting a clip must not hide the clip.747+ // the timeline: adjusting a clip must not hide the
748+ // clip.
700 .child(self.inspector(window.viewport_size(), cx)),749 .child(self.inspector(window.viewport_size(), cx)),
701 )750 )
702- // Above the toolbar rather than under it: the toolbar is a fixed751+ // Above the toolbar rather than under it: the toolbar is
703- // strip belonging to the timeline, so the pair moves as one and the752+ // a fixed strip belonging to the timeline, so the pair
704- // edge the hand is pulling is the edge under the pointer.753+ // moves as one and the edge the hand is pulling is the
754+ // edge under the pointer.
705 .child(divider(Split::Timeline, cx))755 .child(divider(Split::Timeline, cx))
706 .child(self.toolbar(cx))756 .child(self.toolbar(cx))
707 .child(self.timeline(position, state, window.viewport_size(), cx))757 .child(self.timeline(position, state, window.viewport_size(), cx))
758+ })
708 // Over the region they were opened on, and under the modal cards:759 // Over the region they were opened on, and under the modal cards:
709 // they are only ever up while none of those is (`modal`).760 // they are only ever up while none of those is (`modal`).
710 .children(self.context_card(window.viewport_size(), cx))761 .children(self.context_card(window.viewport_size(), cx))
crates/app/src/tests/cards.rsmodified+11 -0
@@ -3,6 +3,17 @@
3 3
4 use super::*;4 use super::*;
5 5
6+#[test]
7+fn a_bare_escape_leaves_player_fullscreen_before_anything_under_it() {
8+ // Fires while the picture-only layout is up, on the same bare escape
9+ // every menu and preview close on -- and only that key: a chord, or an
10+ // escape while not fullscreen, means nothing to it.
11+ assert!(escape_leaves_player_fullscreen("escape", false, true));
12+ assert!(!escape_leaves_player_fullscreen("escape", false, false));
13+ assert!(!escape_leaves_player_fullscreen("escape", true, true));
14+ assert!(!escape_leaves_player_fullscreen("q", false, true));
15+}
16+
6 #[test]17 #[test]
7 fn only_a_chord_gets_out_of_an_export() {18 fn only_a_chord_gets_out_of_an_export() {
8 use keymap::ActionId;19 use keymap::ActionId;
crates/app/src/tests/mod.rsmodified+1 -0
@@ -25,6 +25,7 @@ use super::{
25 bitrate_detail, bitrate_refusal, can_add, cancels_export, clipboard_after_remove, color_snap, commit_mbps,25 bitrate_detail, bitrate_refusal, can_add, cancels_export, clipboard_after_remove, color_snap, commit_mbps,
26 containers,26 containers,
27 enable, envelope, eq_card_w, eq_freq, eq_freq_label, eq_spectrum, eq_x, eq_y,27 enable, envelope, eq_card_w, eq_freq, eq_freq_label, eq_spectrum, eq_x, eq_y,
28+ escape_leaves_player_fullscreen,
28 estimated_bytes, export_path, export_settings, format_key,29 estimated_bytes, export_path, export_settings, format_key,
29 format_line, format_refusal, fps_choices, fps_label, frac_along, frac_down, frame_at,30 format_line, format_refusal, fps_choices, fps_label, frac_along, frac_down, frame_at,
30 frame_rate_ladder, histogram,31 frame_rate_ladder, histogram,
crates/app/src/ui/toolbar.rsmodified+7 -3
@@ -49,9 +49,13 @@ impl Player {
49 /// write a file on the right. Export is the one accented button in the49 /// write a file on the right. Export is the one accented button in the
50 /// window -- the primary action of an editor, where every consumer editor50 /// window -- the primary action of an editor, where every consumer editor
51 /// puts it -- and it keeps its rect while it is a Cancel.51 /// puts it -- and it keeps its rect while it is a Cancel.
52- pub(crate) fn topbar(&self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {52+ pub(crate) fn topbar(&self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
53 let exporting = self.exporting().is_some();53 let exporting = self.exporting().is_some();
54- let fullscreen = window.is_fullscreen();54+ // This button's own row is part of the chrome player fullscreen
55+ // hides, so once it reads true the button is already off screen --
56+ // F11 or Escape is what a person actually leaves by, which is why the
57+ // hint below names both.
58+ let fullscreen = self.player_fullscreen;
55 div()59 div()
56 .flex_none()60 .flex_none()
57 .h(px(TOPBAR_H))61 .h(px(TOPBAR_H))
@@ -89,7 +93,7 @@ impl Player {
89 true => "Exit fullscreen",93 true => "Exit fullscreen",
90 false => "Fullscreen",94 false => "Fullscreen",
91 },95 },
92- "fills the screen with the window, or gives it back",96+ "fills the screen with the picture; F11 or Escape gives it back",
93 ActionId::Fullscreen,97 ActionId::Fullscreen,
94 cx.listener(|this, _: &ClickEvent, window, cx| {98 cx.listener(|this, _: &ClickEvent, window, cx| {
95 this.act(ActionId::Fullscreen, window, cx)99 this.act(ActionId::Fullscreen, window, cx)