diff --git a/crates/gpui2/src/elements/img.rs b/crates/gpui2/src/elements/img.rs index cf22f2986992e2e61c3e112619633fb231a299db..1feb3cdf31eb9002bb8ba044ef6e26c1a578da9d 100644 --- a/crates/gpui2/src/elements/img.rs +++ b/crates/gpui2/src/elements/img.rs @@ -74,7 +74,7 @@ impl Element 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, }) diff --git a/crates/gpui2/src/style.rs b/crates/gpui2/src/style.rs index 5ec08123929ac3d376ac6deb5ecdf8c7f013de6a..0b1e9b3442559d3fbb8a6c84a4f5f514ab12e995 100644 --- a/crates/gpui2/src/style.rs +++ b/crates/gpui2/src/style.rs @@ -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), } } } diff --git a/crates/storybook/src/collab_panel.rs b/crates/storybook/src/collab_panel.rs index fe222a4ee5697d613ddbf6abf74be7db86fd50d4..9e510313816541a9aa2437c6a0c152eb947a7e98 100644 --- a/crates/storybook/src/collab_panel.rs +++ b/crates/storybook/src/collab_panel.rs @@ -147,6 +147,7 @@ impl CollabPanelElement { img() .uri(avatar_uri) .size_3p5() + .rounded_full() .fill(theme.middle.positive.default.foreground), ) .child(label),