diff --git a/crates/assistant2/src/assistant_panel.rs b/crates/assistant2/src/assistant_panel.rs index 17a020fb9c9ed9a3a667a9126d358a06095c564e..b0b1378dbd2e3c3f91e8ed5603f49cad1635c778 100644 --- a/crates/assistant2/src/assistant_panel.rs +++ b/crates/assistant2/src/assistant_panel.rs @@ -55,7 +55,7 @@ use std::{ use theme::ThemeSettings; use ui::{ h_stack, prelude::*, v_stack, Button, ButtonLike, Icon, IconButton, IconElement, Label, TabBar, - Tooltip, + Tooltip, TAB_HEIGHT_IN_REMS, }; use util::{paths::CONVERSATIONS_DIR, post_inc, ResultExt, TryFutureExt}; use uuid::Uuid; @@ -1129,45 +1129,36 @@ impl Render for AssistantPanel { .border() .border_color(gpui::red()) } else { - let title = self - .active_editor() - .map(|editor| Label::new(editor.read(cx).title(cx))); - - // let mut header = h_stack() - // .p_1() - // .border_b() - // .border_color(cx.theme().colors().border_variant) - // .bg(cx.theme().colors().toolbar_background) - // .child(div().flex_1()); - let header = TabBar::new("assistant_header") .start_child( - h_stack() - .gap_1() - .child(Self::render_hamburger_button(cx)) - .children(title), + h_stack().gap_1().child(Self::render_hamburger_button(cx)), // .children(title), ) + .children(self.active_editor().map(|editor| { + h_stack() + .h(rems(TAB_HEIGHT_IN_REMS)) + .flex_1() + .px_2() + .child(Label::new(editor.read(cx).title(cx)).into_element()) + })) .end_child(if self.focus_handle.contains_focused(cx) { h_stack() - .gap_1() - .children(self.render_editor_tools(cx)) - .child(Self::render_plus_button(cx)) - .child(self.render_zoom_button(cx)) + .gap_2() + .child(h_stack().gap_1().children(self.render_editor_tools(cx))) + .child( + ui::Divider::vertical() + .inset() + .color(ui::DividerColor::Border), + ) + .child( + h_stack() + .gap_1() + .child(Self::render_plus_button(cx)) + .child(self.render_zoom_button(cx)), + ) } else { div() }); - // if self.focus_handle.contains_focused(cx) { - // header = header.child( - // div() - // .flex() - // .gap_1() - // .children(self.render_editor_tools(cx)) - // .child(Self::render_plus_button(cx)) - // .child(self.render_zoom_button(cx)), - // ); - // } - v_stack() .size_full() .on_action(cx.listener(|this, _: &workspace::NewFile, cx| { diff --git a/crates/ui2/src/components/divider.rs b/crates/ui2/src/components/divider.rs index cb48ce00ae24f031807d8522510aa18bc586d638..20744d6c48e94ea80312acd9bf3ef63b7a30496f 100644 --- a/crates/ui2/src/components/divider.rs +++ b/crates/ui2/src/components/divider.rs @@ -1,4 +1,4 @@ -use gpui::{Div, IntoElement}; +use gpui::{Div, Hsla, IntoElement}; use crate::prelude::*; @@ -7,9 +7,26 @@ enum DividerDirection { Vertical, } +#[derive(Default)] +pub enum DividerColor { + Border, + #[default] + BorderVariant, +} + +impl DividerColor { + pub fn hsla(self, cx: &WindowContext) -> Hsla { + match self { + DividerColor::Border => cx.theme().colors().border, + DividerColor::BorderVariant => cx.theme().colors().border_variant, + } + } +} + #[derive(IntoElement)] pub struct Divider { direction: DividerDirection, + color: DividerColor, inset: bool, } @@ -26,7 +43,7 @@ impl RenderOnce for Divider { this.w_px().h_full().when(self.inset, |this| this.my_1p5()) } }) - .bg(cx.theme().colors().border_variant) + .bg(self.color.hsla(cx)) } } @@ -34,6 +51,7 @@ impl Divider { pub fn horizontal() -> Self { Self { direction: DividerDirection::Horizontal, + color: DividerColor::default(), inset: false, } } @@ -41,6 +59,7 @@ impl Divider { pub fn vertical() -> Self { Self { direction: DividerDirection::Vertical, + color: DividerColor::default(), inset: false, } } @@ -49,4 +68,9 @@ impl Divider { self.inset = true; self } + + pub fn color(mut self, color: DividerColor) -> Self { + self.color = color; + self + } } diff --git a/crates/ui2/src/components/tab.rs b/crates/ui2/src/components/tab.rs index 8114a322e300cac465981438bf8ad02d84ca029e..7f20a923299d27caca8f30a7b5b234d8525f98eb 100644 --- a/crates/ui2/src/components/tab.rs +++ b/crates/ui2/src/components/tab.rs @@ -3,6 +3,8 @@ use gpui::{AnyElement, IntoElement, Stateful}; use smallvec::SmallVec; use std::cmp::Ordering; +pub const TAB_HEIGHT_IN_REMS: f32 = 30. / 16.; + /// The position of a [`Tab`] within a list of tabs. #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum TabPosition { @@ -94,8 +96,6 @@ impl RenderOnce for Tab { type Rendered = Stateful