mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-26 20:22:30 +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),
|
||||
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,
|
||||
data,
|
||||
})
|
||||
|
|
|
@ -13,8 +13,8 @@ pub use gpui::taffy::style::{
|
|||
use gpui::{
|
||||
fonts::{self, TextStyleRefinement},
|
||||
geometry::{
|
||||
rect::RectF, relative, AbsoluteLength, DefiniteLength, Edges, EdgesRefinement, Length,
|
||||
Point, PointRefinement, Size, SizeRefinement,
|
||||
rect::RectF, relative, vector::Vector2F, AbsoluteLength, DefiniteLength, Edges,
|
||||
EdgesRefinement, Length, Point, PointRefinement, Size, SizeRefinement,
|
||||
},
|
||||
scene, taffy, WindowContext,
|
||||
};
|
||||
|
@ -169,7 +169,7 @@ impl Style {
|
|||
cx.scene.push_quad(gpui::Quad {
|
||||
bounds,
|
||||
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(),
|
||||
});
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ impl Style {
|
|||
cx.scene.push_quad(gpui::Quad {
|
||||
bounds,
|
||||
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 {
|
||||
color: color.into(),
|
||||
top: border.top,
|
||||
|
@ -275,12 +275,14 @@ pub struct 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 {
|
||||
top_left: self.top_left.to_pixels(rem_size),
|
||||
top_right: self.top_right.to_pixels(rem_size),
|
||||
bottom_left: self.bottom_left.to_pixels(rem_size),
|
||||
bottom_right: self.bottom_right.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).min(max_radius),
|
||||
bottom_left: self.bottom_left.to_pixels(rem_size).min(max_radius),
|
||||
bottom_right: self.bottom_right.to_pixels(rem_size).min(max_radius),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,6 +147,7 @@ impl<V: 'static> CollabPanelElement<V> {
|
|||
img()
|
||||
.uri(avatar_uri)
|
||||
.size_3p5()
|
||||
.rounded_full()
|
||||
.fill(theme.middle.positive.default.foreground),
|
||||
)
|
||||
.child(label),
|
||||
|
|
Loading…
Reference in a new issue