Fiddle with titlebar item spacing

Co-Authored-By: Max Brunsfeld <max@zed.dev>
This commit is contained in:
Julia 2023-02-22 14:13:29 -05:00
parent 812145f9ab
commit a07867d628
3 changed files with 36 additions and 26 deletions

View file

@ -71,12 +71,15 @@ impl View for CollabTitlebarItem {
}; };
let project = workspace.read(cx).project().read(cx); let project = workspace.read(cx).project().read(cx);
let mut worktree_root_names = String::new(); let mut project_title = String::new();
for (i, name) in project.worktree_root_names(cx).enumerate() { for (i, name) in project.worktree_root_names(cx).enumerate() {
if i > 0 { if i > 0 {
worktree_root_names.push_str(", "); project_title.push_str(", ");
} }
worktree_root_names.push_str(name); project_title.push_str(name);
}
if project_title.is_empty() {
project_title = "empty project".to_owned();
} }
let theme = cx.global::<Settings>().theme.clone(); let theme = cx.global::<Settings>().theme.clone();
@ -85,7 +88,9 @@ impl View for CollabTitlebarItem {
let mut left_container = Flex::row(); let mut left_container = Flex::row();
left_container.add_child( left_container.add_child(
Label::new(worktree_root_names, theme.workspace.titlebar.title.clone()) Label::new(project_title, theme.workspace.titlebar.title.clone())
.contained()
.with_margin_right(theme.workspace.titlebar.item_spacing)
.aligned() .aligned()
.left() .left()
.boxed(), .boxed(),
@ -118,6 +123,8 @@ impl View for CollabTitlebarItem {
theme.workspace.titlebar.title.clone(), theme.workspace.titlebar.title.clone(),
) )
.aligned() .aligned()
.contained()
.with_margin_left(theme.workspace.titlebar.item_spacing)
.boxed(), .boxed(),
); );
} else { } else {
@ -452,8 +459,7 @@ impl CollabTitlebarItem {
)) ))
.aligned() .aligned()
.contained() .contained()
.with_margin_left(theme.workspace.titlebar.avatar_margin) .with_margin_left(theme.workspace.titlebar.item_spacing)
.with_margin_right(theme.workspace.titlebar.avatar_margin)
.boxed(), .boxed(),
) )
} }
@ -501,8 +507,7 @@ impl CollabTitlebarItem {
)) ))
.aligned() .aligned()
.contained() .contained()
.with_margin_left(theme.workspace.titlebar.avatar_margin) .with_margin_left(theme.workspace.titlebar.item_spacing)
.with_margin_right(theme.workspace.titlebar.avatar_margin)
.boxed() .boxed()
} }
@ -557,7 +562,8 @@ impl CollabTitlebarItem {
.get(&participant.peer_id) .get(&participant.peer_id)
.map(|collaborator| collaborator.replica_id); .map(|collaborator| collaborator.replica_id);
let user = participant.user.clone(); let user = participant.user.clone();
Some(self.render_face_pile( Some(
Container::new(self.render_face_pile(
&user, &user,
replica_id, replica_id,
participant.peer_id, participant.peer_id,
@ -566,6 +572,9 @@ impl CollabTitlebarItem {
theme, theme,
cx, cx,
)) ))
.with_margin_left(theme.workspace.titlebar.face_pile_spacing)
.boxed(),
)
}) })
.collect() .collect()
} }
@ -597,6 +606,7 @@ impl CollabTitlebarItem {
Label::new("Sign in", style.text.clone()) Label::new("Sign in", style.text.clone())
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.with_margin_left(theme.workspace.titlebar.item_spacing)
.boxed() .boxed()
}) })
.on_click(MouseButton::Left, |_, cx| cx.dispatch_action(Authenticate)) .on_click(MouseButton::Left, |_, cx| cx.dispatch_action(Authenticate))
@ -725,8 +735,6 @@ impl CollabTitlebarItem {
.boxed(), .boxed(),
) )
})()) })())
.contained()
.with_margin_left(theme.workspace.titlebar.avatar_margin)
.boxed(); .boxed();
if let Some(location) = location { if let Some(location) = location {

View file

@ -74,7 +74,8 @@ pub struct Titlebar {
pub container: ContainerStyle, pub container: ContainerStyle,
pub height: f32, pub height: f32,
pub title: TextStyle, pub title: TextStyle,
pub avatar_margin: f32, pub item_spacing: f32,
pub face_pile_spacing: f32,
pub avatar_ribbon: AvatarRibbon, pub avatar_ribbon: AvatarRibbon,
pub follower_avatar_overlap: f32, pub follower_avatar_overlap: f32,
pub leader_selection: ContainerStyle, pub leader_selection: ContainerStyle,

View file

@ -12,7 +12,7 @@ import tabBar from "./tabBar";
export default function workspace(colorScheme: ColorScheme) { export default function workspace(colorScheme: ColorScheme) {
const layer = colorScheme.lowest; const layer = colorScheme.lowest;
const titlebarPadding = 6; const itemSpacing = 8;
const titlebarButton = { const titlebarButton = {
cornerRadius: 6, cornerRadius: 6,
padding: { padding: {
@ -83,13 +83,14 @@ export default function workspace(colorScheme: ColorScheme) {
}, },
statusBar: statusBar(colorScheme), statusBar: statusBar(colorScheme),
titlebar: { titlebar: {
avatarMargin: 8, itemSpacing,
facePileSpacing: 2,
height: 33, // 32px + 1px for overlaid border height: 33, // 32px + 1px for overlaid border
background: background(layer), background: background(layer),
border: border(layer, { bottom: true, overlay: true }), border: border(layer, { bottom: true, overlay: true }),
padding: { padding: {
left: 80, left: 80,
right: titlebarPadding, right: itemSpacing,
}, },
// Project // Project
@ -146,7 +147,7 @@ export default function workspace(colorScheme: ColorScheme) {
color: foreground(layer, "variant"), color: foreground(layer, "variant"),
width: 16, width: 16,
margin: { margin: {
left: titlebarPadding, left: itemSpacing,
}, },
padding: { padding: {
right: 4, right: 4,
@ -159,7 +160,7 @@ export default function workspace(colorScheme: ColorScheme) {
background: withOpacity(background(layer, "warning"), 0.3), background: withOpacity(background(layer, "warning"), 0.3),
border: border(layer, "warning"), border: border(layer, "warning"),
margin: { margin: {
left: titlebarPadding, left: itemSpacing,
}, },
padding: { padding: {
left: 8, left: 8,
@ -178,7 +179,7 @@ export default function workspace(colorScheme: ColorScheme) {
}, },
}, },
toggleContactsButton: { toggleContactsButton: {
margin: { left: 6 }, margin: { left: itemSpacing },
cornerRadius: 6, cornerRadius: 6,
color: foreground(layer, "variant"), color: foreground(layer, "variant"),
iconWidth: 8, iconWidth: 8,