iced-yoda/style/src/text_input.rs

50 lines
1.7 KiB
Rust
Raw Normal View History

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)]
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.
pub border_radius: f32,
2022-11-10 01:10:28 +01:00
/// The border width of the text input.
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,
/// 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`].
type Style: Default;
2020-01-01 18:26:49 +01:00
/// Produces the style of an active text input.
fn active(&self, style: &Self::Style) -> Appearance;
2020-01-01 18:26:49 +01:00
/// Produces the style of a focused text input.
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.
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.
fn value_color(&self, style: &Self::Style) -> Color;
2020-01-06 18:44:45 +01: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.
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.
fn hovered(&self, style: &Self::Style) -> Appearance {
self.focused(style)
2020-01-01 18:26:49 +01:00
}
/// Produces the style of a disabled text input.
fn disabled(&self, style: &Self::Style) -> Appearance;
2020-01-01 18:26:49 +01:00
}