feat(icon): add rotation property
This commit is contained in:
parent
def11c6c96
commit
900fc34444
1 changed files with 6 additions and 0 deletions
|
|
@ -16,6 +16,7 @@ use crate::Element;
|
||||||
use derive_setters::Setters;
|
use derive_setters::Setters;
|
||||||
use iced::widget::{Image, Svg};
|
use iced::widget::{Image, Svg};
|
||||||
use iced::{ContentFit, Length, Rectangle};
|
use iced::{ContentFit, Length, Rectangle};
|
||||||
|
use iced_core::Rotation;
|
||||||
|
|
||||||
/// Create an [`Icon`] from a pre-existing [`Handle`]
|
/// Create an [`Icon`] from a pre-existing [`Handle`]
|
||||||
pub fn icon(handle: Handle) -> Icon {
|
pub fn icon(handle: Handle) -> Icon {
|
||||||
|
|
@ -25,6 +26,7 @@ pub fn icon(handle: Handle) -> Icon {
|
||||||
height: None,
|
height: None,
|
||||||
size: 16,
|
size: 16,
|
||||||
class: crate::theme::Svg::default(),
|
class: crate::theme::Svg::default(),
|
||||||
|
rotation: None,
|
||||||
width: None,
|
width: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -47,6 +49,8 @@ pub struct Icon {
|
||||||
width: Option<Length>,
|
width: Option<Length>,
|
||||||
#[setters(strip_option)]
|
#[setters(strip_option)]
|
||||||
height: Option<Length>,
|
height: Option<Length>,
|
||||||
|
#[setters(strip_option)]
|
||||||
|
rotation: Option<Rotation>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Icon {
|
impl Icon {
|
||||||
|
|
@ -80,6 +84,7 @@ impl Icon {
|
||||||
self.height
|
self.height
|
||||||
.unwrap_or_else(|| Length::Fixed(f32::from(self.size))),
|
.unwrap_or_else(|| Length::Fixed(f32::from(self.size))),
|
||||||
)
|
)
|
||||||
|
.rotation(self.rotation.unwrap_or_else(Rotation::default))
|
||||||
.content_fit(self.content_fit)
|
.content_fit(self.content_fit)
|
||||||
.into()
|
.into()
|
||||||
};
|
};
|
||||||
|
|
@ -95,6 +100,7 @@ impl Icon {
|
||||||
self.height
|
self.height
|
||||||
.unwrap_or_else(|| Length::Fixed(f32::from(self.size))),
|
.unwrap_or_else(|| Length::Fixed(f32::from(self.size))),
|
||||||
)
|
)
|
||||||
|
.rotation(self.rotation.unwrap_or_else(Rotation::default))
|
||||||
.content_fit(self.content_fit)
|
.content_fit(self.content_fit)
|
||||||
.symbolic(self.handle.symbolic)
|
.symbolic(self.handle.symbolic)
|
||||||
.into()
|
.into()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue