diff options
author | 2023-04-19 02:00:45 +0200 | |
---|---|---|
committer | 2023-05-02 01:02:32 +0200 | |
commit | 4bd290afe7d81d9aaf7467b3ce91491f6600261a (patch) | |
tree | 906bfe10f6118c86429c3bb83a8ce742dccb170a /widget/src/radio.rs | |
parent | 33b5a900197e2798a393d6d9a0834039666eddbb (diff) | |
download | iced-4bd290afe7d81d9aaf7467b3ce91491f6600261a.tar.gz iced-4bd290afe7d81d9aaf7467b3ce91491f6600261a.tar.bz2 iced-4bd290afe7d81d9aaf7467b3ce91491f6600261a.zip |
Introduce `text::Shaping` enum and replace magic boolean
Diffstat (limited to 'widget/src/radio.rs')
-rw-r--r-- | widget/src/radio.rs | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/widget/src/radio.rs b/widget/src/radio.rs index b685c1a1..f62f4703 100644 --- a/widget/src/radio.rs +++ b/widget/src/radio.rs @@ -81,6 +81,7 @@ where size: f32, spacing: f32, text_size: Option<f32>, + text_shaping: text::Shaping, font: Option<Renderer::Font>, style: <Renderer::Theme as StyleSheet>::Style, } @@ -123,6 +124,7 @@ where size: Self::DEFAULT_SIZE, spacing: Self::DEFAULT_SPACING, //15 text_size: None, + text_shaping: text::Shaping::Basic, font: None, style: Default::default(), } @@ -152,6 +154,12 @@ where self } + /// Sets the [`text::Shaping`] strategy of the [`Radio`] button. + pub fn text_shaping(mut self, shaping: text::Shaping) -> Self { + self.text_shaping = shaping; + self + } + /// Sets the text font of the [`Radio`] button. pub fn font(mut self, font: impl Into<Renderer::Font>) -> Self { self.font = Some(font.into()); @@ -192,9 +200,15 @@ where .spacing(self.spacing) .align_items(Alignment::Center) .push(Row::new().width(self.size).height(self.size)) - .push(Text::new(&self.label).width(self.width).size( - self.text_size.unwrap_or_else(|| renderer.default_size()), - )) + .push( + Text::new(&self.label) + .width(self.width) + .size( + self.text_size + .unwrap_or_else(|| renderer.default_size()), + ) + .shaping(self.text_shaping), + ) .layout(renderer, limits) } @@ -309,7 +323,7 @@ where }, alignment::Horizontal::Left, alignment::Vertical::Center, - false, + self.text_shaping, ); } } |