2022-11-10 01:10:28 +01:00
|
|
|
//! Change the appearance of a text input.
|
2020-01-01 18:26:49 +01:00
|
|
|
use iced_core::{Background, Color};
|
|
|
|
|
|
|
|
|
|
/// The appearance of a text input.
|
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2022-06-07 01:11:35 +02:00
|
|
|
pub struct Appearance {
|
2022-11-10 01:10:28 +01:00
|
|
|
/// The [`Background`] of the text input.
|
2020-01-01 18:26:49 +01:00
|
|
|
pub background: Background,
|
2022-11-10 01:10:28 +01:00
|
|
|
/// The border radius of the text input.
|
2020-11-23 00:31:50 +01:00
|
|
|
pub border_radius: f32,
|
2022-11-10 01:10:28 +01:00
|
|
|
/// The border width of the text input.
|
2020-11-23 00:31:50 +01:00
|
|
|
pub border_width: f32,
|
2022-11-10 01:10:28 +01:00
|
|
|
/// The border [`Color`] of the text input.
|
2020-01-01 18:26:49 +01:00
|
|
|
pub border_color: Color,
|
2023-02-16 14:32:59 +01:00
|
|
|
/// The icon [`Color`] of the text input.
|
|
|
|
|
pub icon_color: Color,
|
2020-01-01 18:26:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// A set of rules that dictate the style of a text input.
|
|
|
|
|
pub trait StyleSheet {
|
2022-11-10 01:10:28 +01:00
|
|
|
/// The supported style of the [`StyleSheet`].
|
2022-11-09 04:05:31 +01:00
|
|
|
type Style: Default;
|
2022-06-07 01:11:35 +02:00
|
|
|
|
2020-01-01 18:26:49 +01:00
|
|
|
/// Produces the style of an active text input.
|
2022-11-09 04:05:31 +01:00
|
|
|
fn active(&self, style: &Self::Style) -> Appearance;
|
2020-01-01 18:26:49 +01:00
|
|
|
|
|
|
|
|
/// Produces the style of a focused text input.
|
2022-11-09 04:05:31 +01:00
|
|
|
fn focused(&self, style: &Self::Style) -> Appearance;
|
2020-01-01 18:26:49 +01:00
|
|
|
|
2022-11-10 01:10:28 +01:00
|
|
|
/// Produces the [`Color`] of the placeholder of a text input.
|
2022-11-09 04:05:31 +01:00
|
|
|
fn placeholder_color(&self, style: &Self::Style) -> Color;
|
2020-01-06 18:44:45 +01:00
|
|
|
|
2022-11-10 01:10:28 +01:00
|
|
|
/// Produces the [`Color`] of the value of a text input.
|
2022-11-09 04:05:31 +01:00
|
|
|
fn value_color(&self, style: &Self::Style) -> Color;
|
2020-01-06 18:44:45 +01:00
|
|
|
|
2023-03-03 10:01:49 +03:00
|
|
|
/// Produces the [`Color`] of the value of a disabled text input.
|
|
|
|
|
fn disabled_color(&self, style: &Self::Style) -> Color;
|
|
|
|
|
|
2022-11-10 01:10:28 +01:00
|
|
|
/// Produces the [`Color`] of the selection of a text input.
|
2022-11-09 04:05:31 +01:00
|
|
|
fn selection_color(&self, style: &Self::Style) -> Color;
|
2020-02-22 21:33:45 +01:00
|
|
|
|
2020-01-01 18:26:49 +01:00
|
|
|
/// Produces the style of an hovered text input.
|
2022-11-09 04:05:31 +01:00
|
|
|
fn hovered(&self, style: &Self::Style) -> Appearance {
|
2022-06-07 01:11:35 +02:00
|
|
|
self.focused(style)
|
2020-01-01 18:26:49 +01:00
|
|
|
}
|
2023-03-03 10:01:49 +03:00
|
|
|
|
|
|
|
|
/// Produces the style of a disabled text input.
|
|
|
|
|
fn disabled(&self, style: &Self::Style) -> Appearance;
|
2020-01-01 18:26:49 +01:00
|
|
|
}
|