From 1a353ad25d6e3600bf23bac304cfa23dbb96d1f6 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 24 May 2023 11:00:12 +0200 Subject: [PATCH] Show maximize/minimize icon for panes and terminal panel --- crates/terminal_view/src/terminal_panel.rs | 47 ++++++++++++++-------- crates/workspace/src/pane.rs | 16 +++++++- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index f265c53552..90334f9449 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -62,24 +62,37 @@ impl TerminalPanel { item.handle.act_as::(cx).is_some() }) }); - pane.set_render_tab_bar_buttons(cx, move |_, cx| { + pane.set_render_tab_bar_buttons(cx, move |pane, cx| { let this = weak_self.clone(); - Pane::render_tab_bar_button( - 0, - "icons/plus_12.svg", - cx, - move |_, cx| { - let this = this.clone(); - cx.window_context().defer(move |cx| { - if let Some(this) = this.upgrade(cx) { - this.update(cx, |this, cx| { - this.add_terminal(&Default::default(), cx); - }); - } - }) - }, - None, - ) + Flex::row() + .with_child(Pane::render_tab_bar_button( + 0, + "icons/plus_12.svg", + cx, + move |_, cx| { + let this = this.clone(); + cx.window_context().defer(move |cx| { + if let Some(this) = this.upgrade(cx) { + this.update(cx, |this, cx| { + this.add_terminal(&Default::default(), cx); + }); + } + }) + }, + None, + )) + .with_child(Pane::render_tab_bar_button( + 1, + if pane.is_zoomed() { + "icons/minimize_8.svg" + } else { + "icons/maximize_8.svg" + }, + cx, + move |pane, cx| pane.toggle_zoom(&Default::default(), cx), + None, + )) + .into_any() }); pane }); diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index a2b13eb0cc..4302c6b390 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -291,13 +291,24 @@ impl Pane { .handle_if_kind(TabBarContextMenuKind::New), )) .with_child(Self::render_tab_bar_button( - 2, + 1, "icons/split_12.svg", cx, |pane, cx| pane.deploy_split_menu(cx), pane.tab_bar_context_menu .handle_if_kind(TabBarContextMenuKind::Split), )) + .with_child(Pane::render_tab_bar_button( + 2, + if pane.is_zoomed() { + "icons/minimize_8.svg" + } else { + "icons/maximize_8.svg" + }, + cx, + move |pane, cx| pane.toggle_zoom(&Default::default(), cx), + None, + )) .into_any() }), } @@ -684,6 +695,9 @@ impl Pane { if self.zoomed { cx.emit(Event::ZoomOut); } else if !self.items.is_empty() { + if !self.has_focus { + cx.focus_self(); + } cx.emit(Event::ZoomIn); } }