summaryrefslogtreecommitdiffstats
path: root/widget/src/pick_list.rs
diff options
context:
space:
mode:
Diffstat (limited to 'widget/src/pick_list.rs')
-rw-r--r--widget/src/pick_list.rs46
1 files changed, 36 insertions, 10 deletions
diff --git a/widget/src/pick_list.rs b/widget/src/pick_list.rs
index d44f4cae..c0cb2946 100644
--- a/widget/src/pick_list.rs
+++ b/widget/src/pick_list.rs
@@ -36,6 +36,7 @@ where
width: Length,
padding: Padding,
text_size: Option<f32>,
+ text_shaping: text::Shaping,
font: Option<Renderer::Font>,
handle: Handle<Renderer::Font>,
style: <Renderer::Theme as StyleSheet>::Style,
@@ -71,6 +72,7 @@ where
width: Length::Shrink,
padding: Self::DEFAULT_PADDING,
text_size: None,
+ text_shaping: text::Shaping::Basic,
font: None,
handle: Default::default(),
style: Default::default(),
@@ -101,6 +103,12 @@ where
self
}
+ /// Sets the [`text::Shaping`] strategy of the [`PickList`].
+ pub fn text_shaping(mut self, shaping: text::Shaping) -> Self {
+ self.text_shaping = shaping;
+ self
+ }
+
/// Sets the font of the [`PickList`].
pub fn font(mut self, font: impl Into<Renderer::Font>) -> Self {
self.font = Some(font.into());
@@ -164,6 +172,7 @@ where
self.width,
self.padding,
self.text_size,
+ self.text_shaping,
self.font,
self.placeholder.as_deref(),
&self.options,
@@ -221,6 +230,7 @@ where
cursor_position,
self.padding,
self.text_size,
+ self.text_shaping,
font,
self.placeholder.as_deref(),
self.selected.as_ref(),
@@ -243,6 +253,7 @@ where
state,
self.padding,
self.text_size,
+ self.text_shaping,
self.font.unwrap_or_else(|| renderer.default_font()),
&self.options,
self.style.clone(),
@@ -336,6 +347,8 @@ 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,
}
/// Computes the layout of a [`PickList`].
@@ -345,6 +358,7 @@ pub fn layout<Renderer, T>(
width: Length,
padding: Padding,
text_size: Option<f32>,
+ text_shaping: text::Shaping,
font: Option<Renderer::Font>,
placeholder: Option<&str>,
options: &[T],
@@ -366,7 +380,7 @@ where
text_size,
font.unwrap_or_else(|| renderer.default_font()),
Size::new(f32::INFINITY, f32::INFINITY),
- false,
+ text_shaping,
);
width.round()
@@ -516,6 +530,7 @@ pub fn overlay<'a, T, Message, Renderer>(
state: &'a mut State<T>,
padding: Padding,
text_size: Option<f32>,
+ text_shaping: text::Shaping,
font: Renderer::Font,
options: &'a [T],
style: <Renderer::Theme as StyleSheet>::Style,
@@ -543,6 +558,7 @@ where
.width(bounds.width)
.padding(padding)
.font(font)
+ .text_shaping(text_shaping)
.style(style);
if let Some(text_size) = text_size {
@@ -563,6 +579,7 @@ pub fn draw<'a, T, Renderer>(
cursor_position: Point,
padding: Padding,
text_size: Option<f32>,
+ text_shaping: text::Shaping,
font: Renderer::Font,
placeholder: Option<&str>,
selected: Option<&T>,
@@ -595,25 +612,34 @@ pub fn draw<'a, T, Renderer>(
);
let handle = match handle {
- Handle::Arrow { size } => {
- Some((Renderer::ICON_FONT, Renderer::ARROW_DOWN_ICON, *size))
- }
+ Handle::Arrow { size } => Some((
+ Renderer::ICON_FONT,
+ Renderer::ARROW_DOWN_ICON,
+ *size,
+ text::Shaping::Basic,
+ )),
Handle::Static(Icon {
font,
code_point,
size,
- }) => Some((*font, *code_point, *size)),
+ shaping,
+ }) => Some((*font, *code_point, *size, *shaping)),
Handle::Dynamic { open, closed } => {
if state().is_open {
- Some((open.font, open.code_point, open.size))
+ Some((open.font, open.code_point, open.size, open.shaping))
} else {
- Some((closed.font, closed.code_point, closed.size))
+ Some((
+ closed.font,
+ closed.code_point,
+ closed.size,
+ closed.shaping,
+ ))
}
}
Handle::None => None,
};
- if let Some((font, code_point, size)) = handle {
+ if let Some((font, code_point, size, shaping)) = handle {
let size = size.unwrap_or_else(|| renderer.default_size());
renderer.fill_text(Text {
@@ -629,7 +655,7 @@ pub fn draw<'a, T, Renderer>(
},
horizontal_alignment: alignment::Horizontal::Right,
vertical_alignment: alignment::Vertical::Center,
- advanced_shape: false,
+ shaping,
});
}
@@ -655,7 +681,7 @@ pub fn draw<'a, T, Renderer>(
},
horizontal_alignment: alignment::Horizontal::Left,
vertical_alignment: alignment::Vertical::Center,
- advanced_shape: false,
+ shaping: text_shaping,
});
}
}