mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-27 12:54:42 +00:00
Max out corner radii to half the smaller dimension of the parent box
This commit is contained in:
parent
99ad60460a
commit
a8d5d93757
3 changed files with 13 additions and 10 deletions
|
@ -74,7 +74,7 @@ impl<V: 'static> Element<V> for Img {
|
||||||
bottom: style.border_widths.bottom.to_pixels(rem_size),
|
bottom: style.border_widths.bottom.to_pixels(rem_size),
|
||||||
left: style.border_widths.left.to_pixels(rem_size),
|
left: style.border_widths.left.to_pixels(rem_size),
|
||||||
},
|
},
|
||||||
corner_radii: style.corner_radii.to_gpui(rem_size),
|
corner_radii: style.corner_radii.to_gpui(layout.bounds.size(), rem_size),
|
||||||
grayscale: false,
|
grayscale: false,
|
||||||
data,
|
data,
|
||||||
})
|
})
|
||||||
|
|
|
@ -13,8 +13,8 @@ pub use gpui::taffy::style::{
|
||||||
use gpui::{
|
use gpui::{
|
||||||
fonts::{self, TextStyleRefinement},
|
fonts::{self, TextStyleRefinement},
|
||||||
geometry::{
|
geometry::{
|
||||||
rect::RectF, relative, AbsoluteLength, DefiniteLength, Edges, EdgesRefinement, Length,
|
rect::RectF, relative, vector::Vector2F, AbsoluteLength, DefiniteLength, Edges,
|
||||||
Point, PointRefinement, Size, SizeRefinement,
|
EdgesRefinement, Length, Point, PointRefinement, Size, SizeRefinement,
|
||||||
},
|
},
|
||||||
scene, taffy, WindowContext,
|
scene, taffy, WindowContext,
|
||||||
};
|
};
|
||||||
|
@ -169,7 +169,7 @@ impl Style {
|
||||||
cx.scene.push_quad(gpui::Quad {
|
cx.scene.push_quad(gpui::Quad {
|
||||||
bounds,
|
bounds,
|
||||||
background: Some(color.into()),
|
background: Some(color.into()),
|
||||||
corner_radii: self.corner_radii.to_gpui(rem_size),
|
corner_radii: self.corner_radii.to_gpui(bounds.size(), rem_size),
|
||||||
border: Default::default(),
|
border: Default::default(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ impl Style {
|
||||||
cx.scene.push_quad(gpui::Quad {
|
cx.scene.push_quad(gpui::Quad {
|
||||||
bounds,
|
bounds,
|
||||||
background: None,
|
background: None,
|
||||||
corner_radii: self.corner_radii.to_gpui(rem_size),
|
corner_radii: self.corner_radii.to_gpui(bounds.size(), rem_size),
|
||||||
border: scene::Border {
|
border: scene::Border {
|
||||||
color: color.into(),
|
color: color.into(),
|
||||||
top: border.top,
|
top: border.top,
|
||||||
|
@ -275,12 +275,14 @@ pub struct CornerRadii {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CornerRadii {
|
impl CornerRadii {
|
||||||
pub fn to_gpui(&self, rem_size: f32) -> gpui::scene::CornerRadii {
|
pub fn to_gpui(&self, box_size: Vector2F, rem_size: f32) -> gpui::scene::CornerRadii {
|
||||||
|
let max_radius = box_size.x().min(box_size.y()) / 2.;
|
||||||
|
|
||||||
gpui::scene::CornerRadii {
|
gpui::scene::CornerRadii {
|
||||||
top_left: self.top_left.to_pixels(rem_size),
|
top_left: self.top_left.to_pixels(rem_size).min(max_radius),
|
||||||
top_right: self.top_right.to_pixels(rem_size),
|
top_right: self.top_right.to_pixels(rem_size).min(max_radius),
|
||||||
bottom_left: self.bottom_left.to_pixels(rem_size),
|
bottom_left: self.bottom_left.to_pixels(rem_size).min(max_radius),
|
||||||
bottom_right: self.bottom_right.to_pixels(rem_size),
|
bottom_right: self.bottom_right.to_pixels(rem_size).min(max_radius),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,6 +147,7 @@ impl<V: 'static> CollabPanelElement<V> {
|
||||||
img()
|
img()
|
||||||
.uri(avatar_uri)
|
.uri(avatar_uri)
|
||||||
.size_3p5()
|
.size_3p5()
|
||||||
|
.rounded_full()
|
||||||
.fill(theme.middle.positive.default.foreground),
|
.fill(theme.middle.positive.default.foreground),
|
||||||
)
|
)
|
||||||
.child(label),
|
.child(label),
|
||||||
|
|
Loading…
Reference in a new issue