Skip to content

Commit

Permalink
feat(icon): add rotation property
Browse files Browse the repository at this point in the history
  • Loading branch information
ellieplayswow authored Jan 20, 2025
1 parent def11c6 commit 900fc34
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/widget/icon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -25,6 +26,7 @@ pub fn icon(handle: Handle) -> Icon {
height: None,
size: 16,
class: crate::theme::Svg::default(),
rotation: None,
width: None,
}
}
Expand All @@ -47,6 +49,8 @@ pub struct Icon {
width: Option<Length>,
#[setters(strip_option)]
height: Option<Length>,
#[setters(strip_option)]
rotation: Option<Rotation>,
}

impl Icon {
Expand Down Expand Up @@ -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()
};
Expand All @@ -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()
Expand Down

0 comments on commit 900fc34

Please sign in to comment.