Introduce text::Shaping enum and replace magic boolean
This commit is contained in:
parent
33b5a90019
commit
4bd290afe7
25 changed files with 203 additions and 132 deletions
|
|
@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue