Skip to content

Commit 39f4918

Browse files
committed
Rename pick_list::AccessoryContent to Handle
... and rename `Default` variant to `Arrow`.
1 parent fe5ab1e commit 39f4918

4 files changed

Lines changed: 34 additions & 39 deletions

File tree

native/src/widget/pick_list.rs

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,56 +20,56 @@ use std::borrow::Cow;
2020

2121
pub use iced_style::pick_list::{Appearance, StyleSheet};
2222

23-
/// The content to the right side of the [`PickList`].
23+
/// The handle to the right side of the [`PickList`].
2424
#[derive(Debug, Clone, PartialEq, Eq)]
25-
pub enum AccessoryContent<Renderer>
25+
pub enum Handle<Renderer>
2626
where
2727
Renderer: text::Renderer,
2828
{
29-
/// Default accessory content.
30-
Default {
29+
/// Displays an arrow icon (▼).
30+
///
31+
/// This is the default.
32+
Arrow {
3133
/// Font size of the content.
3234
size: Option<u16>,
3335
},
34-
/// Custom accessory content.
36+
/// A custom handle.
3537
Custom {
36-
/// Font which will be used in the accessory content.
38+
/// Font that will be used to display the `text`,
3739
font: Renderer::Font,
38-
/// Content which will be shown.
39-
content: String,
40+
/// Text that will be shown.
41+
text: String,
4042
/// Font size of the content.
4143
size: Option<u16>,
4244
},
43-
/// No accessory content will be shown.
45+
/// No handle will be shown.
4446
None,
4547
}
4648

47-
impl<Renderer> Default for AccessoryContent<Renderer>
49+
impl<Renderer> Default for Handle<Renderer>
4850
where
4951
Renderer: text::Renderer,
5052
{
5153
fn default() -> Self {
52-
Self::Default { size: None }
54+
Self::Arrow { size: None }
5355
}
5456
}
5557

56-
impl<Renderer> AccessoryContent<Renderer>
58+
impl<Renderer> Handle<Renderer>
5759
where
5860
Renderer: text::Renderer,
5961
{
6062
fn content(&self) -> Option<(Renderer::Font, String, Option<u16>)> {
6163
match self {
62-
AccessoryContent::Default { size } => Some((
64+
Self::Arrow { size } => Some((
6365
Renderer::ICON_FONT,
6466
Renderer::ARROW_DOWN_ICON.to_string(),
6567
*size,
6668
)),
67-
AccessoryContent::Custom {
68-
font,
69-
content,
70-
size,
71-
} => Some((font.clone(), content.clone(), *size)),
72-
AccessoryContent::None => None,
69+
Self::Custom { font, text, size } => {
70+
Some((font.clone(), text.clone(), *size))
71+
}
72+
Self::None => None,
7373
}
7474
}
7575
}
@@ -90,7 +90,7 @@ where
9090
padding: Padding,
9191
text_size: Option<u16>,
9292
font: Renderer::Font,
93-
accessory_content: AccessoryContent<Renderer>,
93+
handle: Handle<Renderer>,
9494
style: <Renderer::Theme as StyleSheet>::Style,
9595
}
9696

@@ -125,7 +125,7 @@ where
125125
padding: Self::DEFAULT_PADDING,
126126
text_size: None,
127127
font: Default::default(),
128-
accessory_content: Default::default(),
128+
handle: Default::default(),
129129
style: Default::default(),
130130
}
131131
}
@@ -160,12 +160,9 @@ where
160160
self
161161
}
162162

163-
/// Sets the [`AccessoryContent`] of the [`PickList`].
164-
pub fn accessory_content(
165-
mut self,
166-
accessory_content: AccessoryContent<Renderer>,
167-
) -> Self {
168-
self.accessory_content = accessory_content;
163+
/// Sets the [`Handle`] of the [`PickList`].
164+
pub fn handle(mut self, handle: Handle<Renderer>) -> Self {
165+
self.handle = handle;
169166
self
170167
}
171168

@@ -279,7 +276,7 @@ where
279276
&self.font,
280277
self.placeholder.as_deref(),
281278
self.selected.as_ref(),
282-
&self.accessory_content,
279+
&self.handle,
283280
&self.style,
284281
)
285282
}
@@ -581,7 +578,7 @@ pub fn draw<T, Renderer>(
581578
font: &Renderer::Font,
582579
placeholder: Option<&str>,
583580
selected: Option<&T>,
584-
accessory_content: &AccessoryContent<Renderer>,
581+
handle: &Handle<Renderer>,
585582
style: &<Renderer::Theme as StyleSheet>::Style,
586583
) where
587584
Renderer: text::Renderer,
@@ -608,14 +605,14 @@ pub fn draw<T, Renderer>(
608605
style.background,
609606
);
610607

611-
if let Some((font, content, size)) = accessory_content.content() {
608+
if let Some((font, text, size)) = handle.content() {
612609
let size = f32::from(size.unwrap_or_else(|| renderer.default_size()));
613610

614611
renderer.fill_text(Text {
615-
content: &content,
612+
content: &text,
616613
size,
617614
font,
618-
color: style.accessory_content_color,
615+
color: style.handle_color,
619616
bounds: Rectangle {
620617
x: bounds.x + bounds.width - f32::from(padding.horizontal()),
621618
y: bounds.center_y() - size / 2.0,

src/widget.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ pub mod pane_grid {
8080

8181
pub mod pick_list {
8282
//! Display a dropdown list of selectable values.
83-
pub use iced_native::widget::pick_list::{
84-
AccessoryContent, Appearance, StyleSheet,
85-
};
83+
pub use iced_native::widget::pick_list::{Appearance, Handle, StyleSheet};
8684

8785
/// A widget allowing the selection of a single value from a list of options.
8886
pub type PickList<'a, T, Message, Renderer = crate::Renderer> =

style/src/pick_list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ pub struct Appearance {
88
pub text_color: Color,
99
/// The placeholder [`Color`] of the pick list.
1010
pub placeholder_color: Color,
11-
/// The accessory content [`Color`] of the pick list.
12-
pub accessory_content_color: Color,
11+
/// The handle [`Color`] of the pick list.
12+
pub handle_color: Color,
1313
/// The [`Background`] of the pick list.
1414
pub background: Background,
1515
/// The border radius of the pick list.

style/src/theme.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ impl pick_list::StyleSheet for Theme {
534534
text_color: palette.background.weak.text,
535535
background: palette.background.weak.color.into(),
536536
placeholder_color: palette.background.strong.color,
537-
accessory_content_color: palette.background.weak.text,
537+
handle_color: palette.background.weak.text,
538538
border_radius: 2.0,
539539
border_width: 1.0,
540540
border_color: palette.background.strong.color,
@@ -553,7 +553,7 @@ impl pick_list::StyleSheet for Theme {
553553
text_color: palette.background.weak.text,
554554
background: palette.background.weak.color.into(),
555555
placeholder_color: palette.background.strong.color,
556-
accessory_content_color: palette.background.weak.text,
556+
handle_color: palette.background.weak.text,
557557
border_radius: 2.0,
558558
border_width: 1.0,
559559
border_color: palette.primary.strong.color,

0 commit comments

Comments
 (0)