dock: Show keybinding for ToggleZoom menu and button. (#861)

And binding `Shift-Esc` for example to toggle zoom panel, `Ctrl-W` for
close panel.


![image](https://github.com/user-attachments/assets/993dcbb3-ae39-467f-bf4c-d5faf5639b35)
This commit is contained in:
Jason Lee 2025-05-17 22:23:45 +08:00 committed by GitHub
parent 3c85ccbe2a
commit 1e2cc8315a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View file

@ -2,7 +2,7 @@ use anyhow::{Context as _, Result};
use gpui::*;
use gpui_component::{
button::{Button, ButtonVariants as _},
dock::{DockArea, DockAreaState, DockEvent, DockItem, DockPlacement},
dock::{ClosePanel, DockArea, DockAreaState, DockEvent, DockItem, DockPlacement, ToggleZoom},
popup_menu::PopupMenuExt,
IconName, Root, Sizable, Theme,
};
@ -41,6 +41,11 @@ pub fn init(cx: &mut App) {
gpui_component::init(cx);
story::init(cx);
cx.bind_keys(vec![
KeyBinding::new("shift-escape", ToggleZoom, None),
KeyBinding::new("ctrl-w", ClosePanel, None),
]);
cx.activate(true);
}

View file

@ -444,7 +444,7 @@ impl TabPanel {
.icon(icon)
.xsmall()
.ghost()
.tooltip(tooltip)
.tooltip_with_action(tooltip, &ToggleZoom, None)
.when(zoomed, |this| this.selected(true))
.on_click(cx.listener(|view, _, window, cx| {
view.on_action_toggle_zoom(&ToggleZoom, window, cx)
@ -799,6 +799,7 @@ impl TabPanel {
let is_render_in_tabs = self.panels.len() > 1 && self.inner_padding(cx);
v_flex()
.id("active-panel")
.group("")
.flex_1()
.when(is_render_in_tabs, |this| this.pt_2())