Extract tab bar from workspace

This commit is contained in:
K Simmons 2022-07-26 10:41:02 -07:00
parent f963c0ed45
commit 2bd0819ac8
2 changed files with 18 additions and 22 deletions

View file

@ -75,12 +75,13 @@ pub struct TabBar {
pub pane_button: Interactive<IconButton>, pub pane_button: Interactive<IconButton>,
pub active_pane: TabStyles, pub active_pane: TabStyles,
pub inactive_pane: TabStyles, pub inactive_pane: TabStyles,
pub height: f32,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default)]
pub struct TabStyles { pub struct TabStyles {
active_tab: Tab, pub active_tab: Tab,
inactive_tab: Tab, pub inactive_tab: Tab,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default)]

View file

@ -873,18 +873,24 @@ impl Pane {
}; };
let is_pane_active = self.is_active; let is_pane_active = self.is_active;
let tab_styles = match is_pane_active {
true => theme.workspace.tab_bar.active_pane.clone(),
false => theme.workspace.tab_bar.inactive_pane.clone(),
};
let filler_style = tab_styles.inactive_tab.clone();
let mut row = Flex::row().scrollable::<Tabs, _>(1, autoscroll, cx); let mut row = Flex::row().scrollable::<Tabs, _>(1, autoscroll, cx);
for (ix, (item, detail)) in self.items.iter().zip(self.tab_details(cx)).enumerate() { for (ix, (item, detail)) in self.items.iter().zip(self.tab_details(cx)).enumerate() {
let detail = if detail == 0 { None } else { Some(detail) }; let detail = if detail == 0 { None } else { Some(detail) };
let is_tab_active = ix == self.active_item_index; let is_tab_active = ix == self.active_item_index;
row.add_child({ row.add_child({
let mut tab_style = match (is_pane_active, is_tab_active) { let mut tab_style = match is_tab_active {
(true, true) => theme.workspace.active_pane_active_tab.clone(), true => tab_styles.active_tab.clone(),
(true, false) => theme.workspace.active_pane_inactive_tab.clone(), false => tab_styles.inactive_tab.clone(),
(false, true) => theme.workspace.inactive_pane_active_tab.clone(),
(false, false) => theme.workspace.inactive_pane_inactive_tab.clone(),
}; };
let title = item.tab_content(detail, &tab_style, cx); let title = item.tab_content(detail, &tab_style, cx);
if ix == 0 { if ix == 0 {
@ -996,17 +1002,11 @@ impl Pane {
}) })
} }
let filler_style = if is_pane_active {
&theme.workspace.active_pane_inactive_tab
} else {
&theme.workspace.inactive_pane_inactive_tab
};
row.add_child( row.add_child(
Empty::new() Empty::new()
.contained() .contained()
.with_style(filler_style.container) .with_style(filler_style.container)
.with_border(theme.workspace.active_pane_active_tab.container.border) .with_border(filler_style.container.border)
.flex(0., true) .flex(0., true)
.named("filler"), .named("filler"),
); );
@ -1081,7 +1081,8 @@ impl View for Pane {
0, 0,
cx, cx,
|mouse_state, cx| { |mouse_state, cx| {
let theme = &cx.global::<Settings>().theme.workspace; let theme =
&cx.global::<Settings>().theme.workspace.tab_bar;
let style = let style =
theme.pane_button.style_for(mouse_state, false); theme.pane_button.style_for(mouse_state, false);
Svg::new("icons/split_12.svg") Svg::new("icons/split_12.svg")
@ -1111,13 +1112,7 @@ impl View for Pane {
tab_row tab_row
.constrained() .constrained()
.with_height( .with_height(cx.global::<Settings>().theme.workspace.tab_bar.height)
cx.global::<Settings>()
.theme
.workspace
.active_pane_active_tab
.height,
)
.boxed() .boxed()
}) })
.with_child(ChildView::new(&self.toolbar).boxed()) .with_child(ChildView::new(&self.toolbar).boxed())