summaryrefslogtreecommitdiffstats
path: root/widget/src/checkbox.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-04-19 02:00:45 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-05-02 01:02:32 +0200
commit4bd290afe7d81d9aaf7467b3ce91491f6600261a (patch)
tree906bfe10f6118c86429c3bb83a8ce742dccb170a /widget/src/checkbox.rs
parent33b5a900197e2798a393d6d9a0834039666eddbb (diff)
downloadiced-4bd290afe7d81d9aaf7467b3ce91491f6600261a.tar.gz
iced-4bd290afe7d81d9aaf7467b3ce91491f6600261a.tar.bz2
iced-4bd290afe7d81d9aaf7467b3ce91491f6600261a.zip
Introduce `text::Shaping` enum and replace magic boolean
Diffstat (limited to 'widget/src/checkbox.rs')
-rw-r--r--widget/src/checkbox.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/widget/src/checkbox.rs b/widget/src/checkbox.rs
index e28f76af..2a09b8fd 100644
--- a/widget/src/checkbox.rs
+++ b/widget/src/checkbox.rs
@@ -46,6 +46,7 @@ where
size: f32,
spacing: f32,
text_size: Option<f32>,
+ text_shaping: text::Shaping,
font: Option<Renderer::Font>,
icon: Icon<Renderer::Font>,
style: <Renderer::Theme as StyleSheet>::Style,
@@ -82,11 +83,13 @@ where
size: Self::DEFAULT_SIZE,
spacing: Self::DEFAULT_SPACING,
text_size: None,
+ text_shaping: text::Shaping::Basic,
font: None,
icon: Icon {
font: Renderer::ICON_FONT,
code_point: Renderer::CHECKMARK_ICON,
size: None,
+ shaping: text::Shaping::Basic,
},
style: Default::default(),
}
@@ -116,6 +119,12 @@ where
self
}
+ /// Sets the [`text::Shaping`] strategy of the [`Checkbox`].
+ pub fn text_shaping(mut self, shaping: text::Shaping) -> Self {
+ self.text_shaping = shaping;
+ self
+ }
+
/// Sets the [`Font`] of the text of the [`Checkbox`].
///
/// [`Font`]: crate::text::Renderer::Font
@@ -171,7 +180,8 @@ where
.size(
self.text_size
.unwrap_or_else(|| renderer.default_size()),
- ),
+ )
+ .shaping(self.text_shaping),
)
.layout(renderer, limits)
}
@@ -257,6 +267,7 @@ where
font,
code_point,
size,
+ shaping,
} = &self.icon;
let size = size.unwrap_or(bounds.height * 0.7);
@@ -273,7 +284,7 @@ where
color: custom_style.icon_color,
horizontal_alignment: alignment::Horizontal::Center,
vertical_alignment: alignment::Vertical::Center,
- advanced_shape: true,
+ shaping: *shaping,
});
}
}
@@ -293,7 +304,7 @@ where
},
alignment::Horizontal::Left,
alignment::Vertical::Center,
- false,
+ self.text_shaping,
);
}
}
@@ -322,4 +333,6 @@ pub struct Icon<Font> {
pub code_point: char,
/// Font size of the content.
pub size: Option<f32>,
+ /// The shaping strategy of the icon.
+ pub shaping: text::Shaping,
}