mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-09 10:56:20 +00:00
Hide pane tab bar buttons in certain contexts (#3807)
* entirely remove history navigation buttons in the terminal pane that allows terminal elements only * hide the entire tab bar if no active item is in pane (as in zed1) * hide +/split/zoom buttons when the pane is not in focus (as in zed1) Release Notes: - N/A
This commit is contained in:
commit
1f603afbc1
2 changed files with 41 additions and 28 deletions
|
@ -74,6 +74,7 @@ impl TerminalPanel {
|
||||||
);
|
);
|
||||||
pane.set_can_split(false, cx);
|
pane.set_can_split(false, cx);
|
||||||
pane.set_can_navigate(false, cx);
|
pane.set_can_navigate(false, cx);
|
||||||
|
pane.display_nav_history_buttons(false);
|
||||||
pane.set_render_tab_bar_buttons(cx, move |pane, cx| {
|
pane.set_render_tab_bar_buttons(cx, move |pane, cx| {
|
||||||
h_stack()
|
h_stack()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
|
|
|
@ -187,6 +187,7 @@ pub struct Pane {
|
||||||
render_tab_bar_buttons: Rc<dyn Fn(&mut Pane, &mut ViewContext<Pane>) -> AnyElement>,
|
render_tab_bar_buttons: Rc<dyn Fn(&mut Pane, &mut ViewContext<Pane>) -> AnyElement>,
|
||||||
_subscriptions: Vec<Subscription>,
|
_subscriptions: Vec<Subscription>,
|
||||||
tab_bar_scroll_handle: ScrollHandle,
|
tab_bar_scroll_handle: ScrollHandle,
|
||||||
|
display_nav_history_buttons: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ItemNavHistory {
|
pub struct ItemNavHistory {
|
||||||
|
@ -439,6 +440,7 @@ impl Pane {
|
||||||
})
|
})
|
||||||
.into_any_element()
|
.into_any_element()
|
||||||
}),
|
}),
|
||||||
|
display_nav_history_buttons: true,
|
||||||
_subscriptions: subscriptions,
|
_subscriptions: subscriptions,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1660,33 +1662,37 @@ impl Pane {
|
||||||
fn render_tab_bar(&mut self, cx: &mut ViewContext<'_, Pane>) -> impl IntoElement {
|
fn render_tab_bar(&mut self, cx: &mut ViewContext<'_, Pane>) -> impl IntoElement {
|
||||||
TabBar::new("tab_bar")
|
TabBar::new("tab_bar")
|
||||||
.track_scroll(self.tab_bar_scroll_handle.clone())
|
.track_scroll(self.tab_bar_scroll_handle.clone())
|
||||||
.start_child(
|
.when(self.display_nav_history_buttons, |tab_bar| {
|
||||||
h_stack()
|
tab_bar.start_child(
|
||||||
.gap_2()
|
h_stack()
|
||||||
.child(
|
.gap_2()
|
||||||
IconButton::new("navigate_backward", Icon::ArrowLeft)
|
.child(
|
||||||
.icon_size(IconSize::Small)
|
IconButton::new("navigate_backward", Icon::ArrowLeft)
|
||||||
.on_click({
|
.icon_size(IconSize::Small)
|
||||||
let view = cx.view().clone();
|
.on_click({
|
||||||
move |_, cx| view.update(cx, Self::navigate_backward)
|
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)),
|
.disabled(!self.can_navigate_backward())
|
||||||
)
|
.tooltip(|cx| Tooltip::for_action("Go Back", &GoBack, cx)),
|
||||||
.child(
|
)
|
||||||
IconButton::new("navigate_forward", Icon::ArrowRight)
|
.child(
|
||||||
.icon_size(IconSize::Small)
|
IconButton::new("navigate_forward", Icon::ArrowRight)
|
||||||
.on_click({
|
.icon_size(IconSize::Small)
|
||||||
let view = cx.view().clone();
|
.on_click({
|
||||||
move |_, cx| view.update(cx, Self::navigate_backward)
|
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)),
|
.disabled(!self.can_navigate_forward())
|
||||||
),
|
.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(
|
.children(
|
||||||
self.items
|
self.items
|
||||||
|
@ -1849,6 +1855,10 @@ impl Pane {
|
||||||
})
|
})
|
||||||
.log_err();
|
.log_err();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn display_nav_history_buttons(&mut self, display: bool) {
|
||||||
|
self.display_nav_history_buttons = display;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FocusableView for Pane {
|
impl FocusableView for Pane {
|
||||||
|
@ -1937,7 +1947,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({
|
.child({
|
||||||
let has_worktrees = self.project.read(cx).worktrees().next().is_some();
|
let has_worktrees = self.project.read(cx).worktrees().next().is_some();
|
||||||
// main content
|
// main content
|
||||||
|
|
Loading…
Reference in a new issue