From dabc98690cdc1f47793ce3dfa680fd074139b6f8 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Thu, 21 Dec 2023 15:48:37 -0500 Subject: [PATCH] Use small labels for title bar buttons (#3763) This PR adjusts the sizing of the labels in the buttons in the title bar to use the small label size. This should bring them more in line with how things looked in Zed1. Release Notes: - N/A --- crates/collab_ui2/src/collab_titlebar_item.rs | 2 ++ crates/ui2/src/components/button/button.rs | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/crates/collab_ui2/src/collab_titlebar_item.rs b/crates/collab_ui2/src/collab_titlebar_item.rs index 24e510ae8d..8e542e413e 100644 --- a/crates/collab_ui2/src/collab_titlebar_item.rs +++ b/crates/collab_ui2/src/collab_titlebar_item.rs @@ -334,6 +334,7 @@ impl CollabTitlebarItem { .trigger( Button::new("project_name_trigger", name) .style(ButtonStyle::Subtle) + .label_size(LabelSize::Small) .tooltip(move |cx| Tooltip::text("Recent Projects", cx)) .on_click(cx.listener(|this, _, cx| { this.toggle_project_menu(&ToggleProjectMenu, cx); @@ -368,6 +369,7 @@ impl CollabTitlebarItem { Button::new("project_branch_trigger", branch_name) .color(Color::Muted) .style(ButtonStyle::Subtle) + .label_size(LabelSize::Small) .tooltip(move |cx| { Tooltip::with_meta( "Recent Branches", diff --git a/crates/ui2/src/components/button/button.rs b/crates/ui2/src/components/button/button.rs index 014a2f5362..406cd1f420 100644 --- a/crates/ui2/src/components/button/button.rs +++ b/crates/ui2/src/components/button/button.rs @@ -12,6 +12,7 @@ pub struct Button { base: ButtonLike, label: SharedString, label_color: Option, + label_size: Option, selected_label: Option, icon: Option, icon_position: Option, @@ -26,6 +27,7 @@ impl Button { base: ButtonLike::new(id), label: label.into(), label_color: None, + label_size: None, selected_label: None, icon: None, icon_position: None, @@ -40,6 +42,11 @@ impl Button { self } + pub fn label_size(mut self, label_size: impl Into>) -> Self { + self.label_size = label_size.into(); + self + } + pub fn selected_label>(mut self, label: impl Into>) -> Self { self.selected_label = label.into().map(Into::into); self @@ -164,6 +171,7 @@ impl RenderOnce for Button { .child( Label::new(label) .color(label_color) + .size(self.label_size.unwrap_or_default()) .line_height_style(LineHeightStyle::UILabel), ) .when(!self.icon_position.is_some(), |this| {