From 900fc34444c068ed8f91c8bd0090539ee0f6031d Mon Sep 17 00:00:00 2001 From: ellieplayswow <164806095+ellieplayswow@users.noreply.github.com> Date: Mon, 20 Jan 2025 10:08:36 +0000 Subject: [PATCH] feat(icon): add rotation property --- src/widget/icon/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/widget/icon/mod.rs b/src/widget/icon/mod.rs index eb91fc00..318b9fb1 100644 --- a/src/widget/icon/mod.rs +++ b/src/widget/icon/mod.rs @@ -16,6 +16,7 @@ use crate::Element; use derive_setters::Setters; use iced::widget::{Image, Svg}; use iced::{ContentFit, Length, Rectangle}; +use iced_core::Rotation; /// Create an [`Icon`] from a pre-existing [`Handle`] pub fn icon(handle: Handle) -> Icon { @@ -25,6 +26,7 @@ pub fn icon(handle: Handle) -> Icon { height: None, size: 16, class: crate::theme::Svg::default(), + rotation: None, width: None, } } @@ -47,6 +49,8 @@ pub struct Icon { width: Option, #[setters(strip_option)] height: Option, + #[setters(strip_option)] + rotation: Option, } impl Icon { @@ -80,6 +84,7 @@ impl Icon { self.height .unwrap_or_else(|| Length::Fixed(f32::from(self.size))), ) + .rotation(self.rotation.unwrap_or_else(Rotation::default)) .content_fit(self.content_fit) .into() }; @@ -95,6 +100,7 @@ impl Icon { self.height .unwrap_or_else(|| Length::Fixed(f32::from(self.size))), ) + .rotation(self.rotation.unwrap_or_else(Rotation::default)) .content_fit(self.content_fit) .symbolic(self.handle.symbolic) .into()