From e839dc5ee62d2b86c18c0666c47b5fbb9127d62f Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sat, 23 Dec 2023 21:53:08 +0200 Subject: [PATCH 1/2] Hide pane tab bar for 0 items, hide its end buttons for no focus --- crates/workspace2/src/pane.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/workspace2/src/pane.rs b/crates/workspace2/src/pane.rs index bcf36dfe18..ecbebcfa36 100644 --- a/crates/workspace2/src/pane.rs +++ b/crates/workspace2/src/pane.rs @@ -1684,9 +1684,11 @@ impl Pane { .tooltip(|cx| Tooltip::for_action("Go Forward", &GoForward, cx)), ), ) - .end_child({ - let render_tab_buttons = self.render_tab_bar_buttons.clone(); - render_tab_buttons(self, cx) + .when(self.has_focus(cx), |tab_bar| { + tab_bar.end_child({ + let render_tab_buttons = self.render_tab_bar_buttons.clone(); + render_tab_buttons(self, cx) + }) }) .children( self.items @@ -1937,7 +1939,9 @@ impl Render for Pane { }) }), ) - .child(self.render_tab_bar(cx)) + .when(self.active_item().is_some(), |pane| { + pane.child(self.render_tab_bar(cx)) + }) .child({ let has_worktrees = self.project.read(cx).worktrees().next().is_some(); // main content From a249375f991eaaef2a2ea9d84d66112bacc602ae Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sat, 23 Dec 2023 22:10:11 +0200 Subject: [PATCH 2/2] Do not show nav history buttons in terminal pane --- crates/terminal_view2/src/terminal_panel.rs | 1 + crates/workspace2/src/pane.rs | 56 ++++++++++++--------- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/crates/terminal_view2/src/terminal_panel.rs b/crates/terminal_view2/src/terminal_panel.rs index 044a9f3aa8..dd0c7d3999 100644 --- a/crates/terminal_view2/src/terminal_panel.rs +++ b/crates/terminal_view2/src/terminal_panel.rs @@ -74,6 +74,7 @@ impl TerminalPanel { ); pane.set_can_split(false, cx); pane.set_can_navigate(false, cx); + pane.display_nav_history_buttons(false); pane.set_render_tab_bar_buttons(cx, move |pane, cx| { h_stack() .gap_2() diff --git a/crates/workspace2/src/pane.rs b/crates/workspace2/src/pane.rs index ecbebcfa36..bdb95deb56 100644 --- a/crates/workspace2/src/pane.rs +++ b/crates/workspace2/src/pane.rs @@ -187,6 +187,7 @@ pub struct Pane { render_tab_bar_buttons: Rc) -> AnyElement>, _subscriptions: Vec, tab_bar_scroll_handle: ScrollHandle, + display_nav_history_buttons: bool, } pub struct ItemNavHistory { @@ -439,6 +440,7 @@ impl Pane { }) .into_any_element() }), + display_nav_history_buttons: true, _subscriptions: subscriptions, } } @@ -1660,30 +1662,32 @@ impl Pane { fn render_tab_bar(&mut self, cx: &mut ViewContext<'_, Pane>) -> impl IntoElement { TabBar::new("tab_bar") .track_scroll(self.tab_bar_scroll_handle.clone()) - .start_child( - h_stack() - .gap_2() - .child( - IconButton::new("navigate_backward", Icon::ArrowLeft) - .icon_size(IconSize::Small) - .on_click({ - let view = cx.view().clone(); - move |_, cx| view.update(cx, Self::navigate_backward) - }) - .disabled(!self.can_navigate_backward()) - .tooltip(|cx| Tooltip::for_action("Go Back", &GoBack, cx)), - ) - .child( - IconButton::new("navigate_forward", Icon::ArrowRight) - .icon_size(IconSize::Small) - .on_click({ - let view = cx.view().clone(); - move |_, cx| view.update(cx, Self::navigate_backward) - }) - .disabled(!self.can_navigate_forward()) - .tooltip(|cx| Tooltip::for_action("Go Forward", &GoForward, cx)), - ), - ) + .when(self.display_nav_history_buttons, |tab_bar| { + tab_bar.start_child( + h_stack() + .gap_2() + .child( + IconButton::new("navigate_backward", Icon::ArrowLeft) + .icon_size(IconSize::Small) + .on_click({ + let view = cx.view().clone(); + move |_, cx| view.update(cx, Self::navigate_backward) + }) + .disabled(!self.can_navigate_backward()) + .tooltip(|cx| Tooltip::for_action("Go Back", &GoBack, cx)), + ) + .child( + IconButton::new("navigate_forward", Icon::ArrowRight) + .icon_size(IconSize::Small) + .on_click({ + let view = cx.view().clone(); + move |_, cx| view.update(cx, Self::navigate_backward) + }) + .disabled(!self.can_navigate_forward()) + .tooltip(|cx| Tooltip::for_action("Go Forward", &GoForward, cx)), + ), + ) + }) .when(self.has_focus(cx), |tab_bar| { tab_bar.end_child({ let render_tab_buttons = self.render_tab_bar_buttons.clone(); @@ -1851,6 +1855,10 @@ impl Pane { }) .log_err(); } + + pub fn display_nav_history_buttons(&mut self, display: bool) { + self.display_nav_history_buttons = display; + } } impl FocusableView for Pane {