Introduce placeholder_color to pick_list::Style
This commit is contained in:
parent
26b2a824a9
commit
1b36068847
3 changed files with 7 additions and 1 deletions
|
|
@ -171,6 +171,7 @@ impl pick_list::StyleSheet for PickList {
|
||||||
},
|
},
|
||||||
border_radius: 2.0,
|
border_radius: 2.0,
|
||||||
icon_size: 0.5,
|
icon_size: 0.5,
|
||||||
|
..pick_list::Style::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ where
|
||||||
style: &Box<dyn StyleSheet>,
|
style: &Box<dyn StyleSheet>,
|
||||||
) -> Self::Output {
|
) -> Self::Output {
|
||||||
let is_mouse_over = bounds.contains(cursor_position);
|
let is_mouse_over = bounds.contains(cursor_position);
|
||||||
|
let is_selected = selected.is_some();
|
||||||
|
|
||||||
let style = if is_mouse_over {
|
let style = if is_mouse_over {
|
||||||
style.hovered()
|
style.hovered()
|
||||||
|
|
@ -74,7 +75,9 @@ where
|
||||||
content: label,
|
content: label,
|
||||||
size: f32::from(text_size),
|
size: f32::from(text_size),
|
||||||
font,
|
font,
|
||||||
color: style.text_color,
|
color: is_selected
|
||||||
|
.then(|| style.text_color)
|
||||||
|
.unwrap_or(style.placeholder_color),
|
||||||
bounds: Rectangle {
|
bounds: Rectangle {
|
||||||
x: bounds.x + f32::from(padding.left),
|
x: bounds.x + f32::from(padding.left),
|
||||||
y: bounds.center_y(),
|
y: bounds.center_y(),
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ use iced_core::{Background, Color};
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct Style {
|
pub struct Style {
|
||||||
pub text_color: Color,
|
pub text_color: Color,
|
||||||
|
pub placeholder_color: Color,
|
||||||
pub background: Background,
|
pub background: Background,
|
||||||
pub border_radius: f32,
|
pub border_radius: f32,
|
||||||
pub border_width: f32,
|
pub border_width: f32,
|
||||||
|
|
@ -16,6 +17,7 @@ impl std::default::Default for Style {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
text_color: Color::BLACK,
|
text_color: Color::BLACK,
|
||||||
|
placeholder_color: [0.4, 0.4, 0.4].into(),
|
||||||
background: Background::Color([0.87, 0.87, 0.87].into()),
|
background: Background::Color([0.87, 0.87, 0.87].into()),
|
||||||
border_radius: 0.0,
|
border_radius: 0.0,
|
||||||
border_width: 1.0,
|
border_width: 1.0,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue