Make tab close button square (#4052)

This PR makes the close button for tabs square.

`IconButton` now accepts a `shape`, and using `IconButtonShape::Square`
will ensure the `IconButton` is square with respect to its contained
icon.

#### Before

<img width="119" alt="Screenshot 2024-01-15 at 10 32 40 AM"
src="https://github.com/zed-industries/zed/assets/1486634/dc806b9b-411f-4cd9-8c10-676d2cbd298b">

#### After

<img width="116" alt="Screenshot 2024-01-15 at 10 32 24 AM"
src="https://github.com/zed-industries/zed/assets/1486634/8b4ef43c-14b6-449f-a235-5d7affd82c4e">

Release Notes:

- Changed the tab close button to be square.
This commit is contained in:
Marshall Bowers 2024-01-15 10:43:03 -05:00 committed by GitHub
parent 1da9c8b1e9
commit b136d21ebf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 13 deletions

View file

@ -300,6 +300,7 @@ pub struct ButtonLike {
pub(super) selected: bool,
pub(super) selected_style: Option<ButtonStyle>,
pub(super) width: Option<DefiniteLength>,
pub(super) height: Option<DefiniteLength>,
size: ButtonSize,
rounding: Option<ButtonLikeRounding>,
tooltip: Option<Box<dyn Fn(&mut WindowContext) -> AnyView>>,
@ -317,6 +318,7 @@ impl ButtonLike {
selected: false,
selected_style: None,
width: None,
height: None,
size: ButtonSize::Default,
rounding: Some(ButtonLikeRounding::All),
tooltip: None,
@ -325,6 +327,11 @@ impl ButtonLike {
}
}
pub(crate) fn height(mut self, height: DefiniteLength) -> Self {
self.height = Some(height);
self
}
pub(crate) fn rounding(mut self, rounding: impl Into<Option<ButtonLikeRounding>>) -> Self {
self.rounding = rounding.into();
self
@ -417,7 +424,7 @@ impl RenderOnce for ButtonLike {
.id(self.id.clone())
.group("")
.flex_none()
.h(self.size.height())
.h(self.height.unwrap_or(self.size.height().into()))
.when_some(self.width, |this, width| this.w(width).justify_center())
.when_some(self.rounding, |this, rounding| match rounding {
ButtonLikeRounding::All => this.rounded_md(),