icons: add size option
This commit is contained in:
+22
-3
@@ -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<Transformation>,
|
||||
}
|
||||
|
||||
/// 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
|
||||
|
||||
Reference in New Issue
Block a user