From 3a7ac9c0ff64181758c4bcce46db363da945c7e9 Mon Sep 17 00:00:00 2001 From: Julia Date: Tue, 14 Feb 2023 12:39:29 -0500 Subject: [PATCH] Focus pane when clicking on tab bar background --- crates/workspace/src/pane.rs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index cc1d8f0ad2..ccd2dd38e1 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -1420,23 +1420,40 @@ impl View for Pane { Stack::new() .with_child( MouseEventHandler::::new(0, cx, |_, cx| { + let active_item_index = self.active_item_index; + if let Some(active_item) = self.active_item() { Flex::column() .with_child({ + let theme = cx.global::().theme.clone(); + + let mut stack = Stack::new(); + + enum TabBarEventHandler {} + stack.add_child( + MouseEventHandler::::new(0, cx, |_, _| { + Flex::row() + .contained() + .with_style(theme.workspace.tab_bar.container) + .boxed() + }) + .on_click(MouseButton::Left, move |_, cx| { + cx.dispatch_action(ActivateItem(active_item_index)); + }) + .boxed(), + ); + let mut tab_row = Flex::row() .with_child(self.render_tabs(cx).flex(1., true).named("tabs")); - // Render pane buttons - let theme = cx.global::().theme.clone(); if self.is_active { tab_row.add_child(self.render_tab_bar_buttons(&theme, cx)) } - tab_row + stack.add_child(tab_row.boxed()); + stack .constrained() .with_height(theme.workspace.tab_bar.height) - .contained() - .with_style(theme.workspace.tab_bar.container) .flex(1., false) .named("tab bar") })