forge
Explore
Log in

Don't you dare go Hollow

The player goes fullscreen from the toolbar or F11

Browse files at this commit

1ac24b82f1b5ca1229d7b772500d491761fe0d61Ahmet Kaan GümüşParent: 31449fc
  • feat
    • the player goes fullscreen from the toolbar or F11
Show full message
✨ feat(app): the player goes fullscreen from the toolbar or F11

gpui Window::toggle_fullscreen wired as ActionId::Fullscreen (View category,
always enabled — window-level, touches no edit list). Player::act grows a
window parameter to reach the API; topbar gets a state-reflecting
Fullscreen / Exit fullscreen button beside Save/Export.
crates/app/src/keymap.rsmodified+15 -2
@@ -134,6 +134,9 @@ actions! {
134134 /// toolbar's Theme button. It was a build feature once, which made it a
135135 /// choice only whoever compiled the binary could make.
136136 Theme,
137+ /// The whole window, borderless over the screen: a player's own control,
138+ /// on the platform's own toggle ([`gpui::Window::toggle_fullscreen`]).
139+ Fullscreen,
137140 CancelExport,
138141 /// Opens the actions card -- the list every other action is on. A door of
139142 /// its own, because a card reachable only by a button in the panel is one a
@@ -197,6 +200,7 @@ impl ActionId {
197200 ActionId::ToggleProxies => "Proxies on / off for the picture",
198201 ActionId::ToggleAutoProxies => "Make proxies on import: on / off",
199202 ActionId::Theme => "Theme: the window's colours…",
203+ ActionId::Fullscreen => "Fullscreen on / off",
200204 ActionId::CancelExport => "Cancel export",
201205 ActionId::ShowActions => "All actions and their keys…",
202206 }
@@ -255,6 +259,7 @@ impl ActionId {
255259 ActionId::ToggleProxies => "toggle-proxies",
256260 ActionId::ToggleAutoProxies => "toggle-auto-proxies",
257261 ActionId::Theme => "theme",
262+ ActionId::Fullscreen => "fullscreen",
258263 ActionId::CancelExport => "cancel-export",
259264 ActionId::ShowActions => "show-actions",
260265 }
@@ -317,7 +322,10 @@ impl ActionId {
317322 | ActionId::ToggleAutoProxies
318323 // ...and what the whole window is painted in: it edits nothing at
319324 // all, it is what one is looking *with*.
320- | ActionId::Theme => Category::View,
325+ | ActionId::Theme
326+ // ...and whether that window fills the screen: a way of looking,
327+ // same as the zoom and the theme beside it.
328+ | ActionId::Fullscreen => Category::View,
321329 ActionId::Cut
322330 | ActionId::Regroup
323331 | ActionId::Detach
@@ -884,6 +892,10 @@ impl Keymap {
884892 // it is a preference set once, not a stroke wanted under a hand
885893 // that is editing.
886894 b(ActionId::Theme, "h", true),
895+ // Every other player's key for it, and free here: nothing in
896+ // this table answers to "f11" (gpui lowercases the keysym
897+ // name it gets from xkb, same as "f1" below).
898+ b(ActionId::Fullscreen, "f11", false),
887899 // A chord, and the only escape in this table: bare `esc` is the
888900 // stroke a hand throws at anything on screen, and throwing it
889901 // at a running export used to delete an hour of encoding. The
@@ -1158,7 +1170,8 @@ mod tests {
11581170 #[test]
11591171 fn every_default_stroke_reaches_its_action() {
11601172 let k = Keymap::defaults();
1161- assert_eq!(k.entries().len(), 53);
1173+ assert_eq!(k.entries().len(), 54);
1174+ assert_eq!(k.lookup("f11", false), Some(ActionId::Fullscreen));
11621175 assert_eq!(k.lookup("p", true), Some(ActionId::ToggleProxies));
11631176 assert_eq!(k.lookup("o", true), Some(ActionId::ToggleAutoProxies));
11641177 assert_eq!(k.lookup("f1", false), Some(ActionId::ShowActions));
crates/app/src/oracle.rsmodified+3 -1
@@ -98,7 +98,9 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable {
9898 // The window's own colours: there is always a window, and repainting it
9999 // touches no timeline -- so this one is live even while an export is
100100 // reading one, which is the only state that dims the list above.
101- if action == ActionId::Theme {
101+ // ...and whether that window fills the screen: also always there, also
102+ // touching no timeline, live through an export the same way.
103+ if action == ActionId::Theme || action == ActionId::Fullscreen {
102104 return Enable::Yes;
103105 }
104106 if action == ActionId::ShowActions {
crates/app/src/player/actions.rsmodified+5 -1
@@ -7,7 +7,7 @@ impl Player {
77 /// What an action does, wherever it was asked for -- a stroke, or the clip
88 /// menu item that names the same action. One table, so the two can never
99 /// come to mean different things.
10- pub(crate) fn act(&mut self, action: ActionId, cx: &mut Context<Self>) {
10+ pub(crate) fn act(&mut self, action: ActionId, window: &mut Window, cx: &mut Context<Self>) {
1111 // Two doors, one oracle. This used to be the asymmetry the whole
1212 // toolbar was built on: the buttons dimmed themselves off
1313 // [`enable`] while the keyboard walked straight past it, so with no
@@ -97,6 +97,10 @@ impl Player {
9797 // At the window's corner, since a stroke names no place -- and
9898 // [`menu_at`] keeps it on screen from there.
9999 ActionId::Theme => self.open_picker(Pick::Theme, Point::default(), cx),
100+ // The platform's own toggle (gpui::Window::toggle_fullscreen); the
101+ // window reports its own new state back through `is_fullscreen`,
102+ // there is no local bool to keep in step with it.
103+ ActionId::Fullscreen => window.toggle_fullscreen(),
100104 // Nothing to cancel while nothing is exporting; the export guard in
101105 // the key handler is what answers this one while there is.
102106 ActionId::CancelExport => {}
crates/app/src/render.rsmodified+3 -3
@@ -95,7 +95,7 @@ impl Render for Player {
9595
9696 div()
9797 .track_focus(&self.focus)
98- .on_key_down(cx.listener(|this, event: &KeyDownEvent, _, cx| {
98+ .on_key_down(cx.listener(|this, event: &KeyDownEvent, window, cx| {
9999 let key = event.keystroke.key.as_str();
100100 let ctrl = event.keystroke.modifiers.control;
101101 // `is_held` is the auto-repeat, and a value is the one thing
@@ -462,7 +462,7 @@ impl Render for Player {
462462 }
463463 }
464464 if let Some(action) = action {
465- this.act(action, cx);
465+ this.act(action, window, cx);
466466 }
467467 }))
468468 // The whole window is the drop target: gpui turns an external file
@@ -548,7 +548,7 @@ impl Render for Player {
548548 // it. Nothing here moves when the state changes -- the regions are
549549 // fixed and the panels keep their room whether or not anything is
550550 // open in them.
551- .child(self.topbar(cx))
551+ .child(self.topbar(window, cx))
552552 .child(
553553 div()
554554 .flex_1()
crates/app/src/tests/editing.rsmodified+7 -3
@@ -884,9 +884,13 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() {
884884 for action in ActionId::ALL {
885885 // Nothing may touch the edit list while an export is reading it --
886886 // and the palette does not: it repaints this window and writes one
887- // word to the user's own config file, which is why it is the one
888- // action besides the cancel that stays live here.
889- let allowed = action == ActionId::CancelExport || action == ActionId::Theme;
887+ // word to the user's own config file, which is why it is one of the
888+ // actions besides the cancel that stay live here. Fullscreen is the
889+ // same kind of thing: the platform's own window toggle, touching no
890+ // edit list either.
891+ let allowed = action == ActionId::CancelExport
892+ || action == ActionId::Theme
893+ || action == ActionId::Fullscreen;
890894 assert_eq!(
891895 whole(action, busy).yes(),
892896 allowed,
crates/app/src/ui/overlays.rsmodified+4 -4
@@ -304,14 +304,14 @@ impl Player {
304304 .when(!refusal.yes(), |d| d.opacity(0.4).cursor_not_allowed())
305305 .when(refusal.yes(), |d| {
306306 d.cursor_pointer().hover(|s| s.bg(rgb(BG_HOVER()))).on_click(
307- cx.listener(move |this, _: &ClickEvent, _, cx| {
307+ cx.listener(move |this, _: &ClickEvent, window, cx| {
308308 // The card goes first: several of
309309 // these open a card of their own,
310310 // and every edit moves the indices
311311 // the menus are holding.
312312 this.keys_open = false;
313313 this.rebinding = None;
314- this.act(action, cx);
314+ this.act(action, window, cx);
315315 cx.notify();
316316 }),
317317 )
@@ -578,7 +578,7 @@ impl Player {
578578 .when(enabled, |d| {
579579 d.cursor_pointer()
580580 .hover(|s| s.bg(rgb(BG_HOVER())))
581- .on_click(cx.listener(move |this, event: &ClickEvent, _, cx| {
581+ .on_click(cx.listener(move |this, event: &ClickEvent, window, cx| {
582582 // Closed first: the action moves the very
583583 // indices this menu is holding.
584584 this.context_menu = None;
@@ -594,7 +594,7 @@ impl Player {
594594 cx,
595595 );
596596 } else {
597- this.act(action, cx);
597+ this.act(action, window, cx);
598598 }
599599 }))
600600 })
crates/app/src/ui/toolbar.rsmodified+20 -1
@@ -49,8 +49,9 @@ impl Player {
4949 /// write a file on the right. Export is the one accented button in the
5050 /// window -- the primary action of an editor, where every consumer editor
5151 /// puts it -- and it keeps its rect while it is a Cancel.
52- pub(crate) fn topbar(&self, cx: &mut Context<Self>) -> impl IntoElement {
52+ pub(crate) fn topbar(&self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
5353 let exporting = self.exporting().is_some();
54+ let fullscreen = window.is_fullscreen();
5455 div()
5556 .flex_none()
5657 .h(px(TOPBAR_H))
@@ -76,6 +77,24 @@ impl Player {
7677 .truncate()
7778 .child(self.name.clone()),
7879 )
80+ // The window's own control, in the fixed rect the mute button uses
81+ // for the same reason (toolbar.rs:194-203): fullscreen swaps the
82+ // word and the colour, never the box.
83+ .child(self.action_control(
84+ "fullscreen",
85+ 0.,
86+ BG_RAISED(),
87+ None,
88+ match fullscreen {
89+ true => "Exit fullscreen",
90+ false => "Fullscreen",
91+ },
92+ "fills the screen with the window, or gives it back",
93+ ActionId::Fullscreen,
94+ cx.listener(|this, _: &ClickEvent, window, cx| {
95+ this.act(ActionId::Fullscreen, window, cx)
96+ }),
97+ ))
7998 .child(self.action_control(
8099 "save",
81100 0.,