From edc6a6f2b5170460062d3e8e347ebb901956e7fc Mon Sep 17 00:00:00 2001 From: Ren Amamiya Date: Thu, 12 Nov 2026 15:35:25 +0700 Subject: [PATCH] icons: add size option --- crates/icons/src/lib.rs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/crates/icons/src/lib.rs b/crates/icons/src/lib.rs index 9a2639c..8e088e1 100644 --- a/crates/icons/src/lib.rs +++ b/crates/icons/src/lib.rs @@ -13,6 +13,10 @@ mod freedesktop; #[cfg_attr(not(target_os = "windows"), allow(dead_code))] mod segoe; +const SMALL_ICON_SIZE: Pixels = px(14.0); +const DEFAULT_ICON_SIZE: Pixels = px(16.0); +const LARGE_ICON_SIZE: Pixels = px(20.0); + /// The semantic glyphs UI components need. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum IconRole { @@ -234,9 +238,6 @@ pub struct Icon { transformation: Option, } -/// The default icon size; this crate sits beside the theme crate without depending on it. -const DEFAULT_ICON_SIZE: Pixels = px(16.0); - /// Creates an icon for the role at the default size. pub fn icon(role: IconRole) -> Icon { Icon { @@ -266,6 +267,24 @@ impl Icon { self } + /// The small size. + pub fn small(mut self) -> Self { + self.size = SMALL_ICON_SIZE; + self + } + + /// The default medium size. + pub fn medium(mut self) -> Self { + self.size = DEFAULT_ICON_SIZE; + self + } + + /// The large size. + pub fn large(mut self) -> Self { + self.size = LARGE_ICON_SIZE; + self + } + pub fn color(mut self, color: Hsla) -> Self { self.color = Some(color); self