repl: Push button to clear outputs (#14873)

This commit is contained in:
Kyle Kelley 2024-07-20 11:32:03 -07:00 committed by GitHub
parent a1670551bf
commit 6dfb0a4a70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 139 additions and 42 deletions

View file

@ -76,8 +76,12 @@ impl IconSize {
}
}
/// Returns the length of a side of the square that contains this [`IconSize`], with padding.
pub(crate) fn square(&self, cx: &mut WindowContext) -> Pixels {
/// Returns the individual components of the square that contains this [`IconSize`].
///
/// The returned tuple contains:
/// 1. The length of one side of the square
/// 2. The padding of one side of the square
pub fn square_components(&self, cx: &mut WindowContext) -> (Pixels, Pixels) {
let icon_size = self.rems() * cx.rem_size();
let padding = match self {
IconSize::Indicator => Spacing::None.px(cx),
@ -86,6 +90,13 @@ impl IconSize {
IconSize::Medium => Spacing::XSmall.px(cx),
};
(icon_size, padding)
}
/// Returns the length of a side of the square that contains this [`IconSize`], with padding.
pub fn square(&self, cx: &mut WindowContext) -> Pixels {
let (icon_size, padding) = self.square_components(cx);
icon_size + padding * 2.
}
}