use iced_native::{image, Color, Rectangle};
use crate::style::{default_colors, text_marks, tick_marks};
#[derive(Debug, Clone)]
pub enum Appearance {
Texture(TextureAppearance),
Classic(ClassicAppearance),
Rect(RectAppearance),
RectBipolar(RectBipolarAppearance),
}
#[derive(Debug, Clone)]
pub struct ClassicRail {
pub rail_colors: (Color, Color),
pub rail_widths: (f32, f32),
pub rail_padding: f32,
}
#[derive(Debug, Clone)]
pub struct TextureAppearance {
pub rail: ClassicRail,
pub image_handle: image::Handle,
pub handle_height: u16,
pub image_bounds: Rectangle,
}
#[derive(Debug, Clone)]
pub struct ClassicAppearance {
pub rail: ClassicRail,
pub handle: ClassicHandle,
}
impl Default for ClassicAppearance {
fn default() -> Self {
ClassicAppearance {
rail: ClassicRail {
rail_colors: default_colors::SLIDER_RAIL,
rail_widths: (1.0, 1.0),
rail_padding: 12.0,
},
handle: ClassicHandle::default(),
}
}
}
#[derive(Debug, Clone)]
pub struct ClassicHandle {
pub color: Color,
pub height: u16,
pub notch_width: f32,
pub notch_color: Color,
pub border_radius: f32,
pub border_width: f32,
pub border_color: Color,
}
impl Default for ClassicHandle {
fn default() -> Self {
ClassicHandle {
color: default_colors::LIGHT_BACK,
height: 34,
notch_width: 4.0,
notch_color: default_colors::BORDER,
border_radius: 2.0,
border_color: default_colors::BORDER,
border_width: 1.0,
}
}
}
#[derive(Debug, Clone, Copy)]
pub struct RectAppearance {
pub back_color: Color,
pub back_border_width: f32,
pub back_border_radius: f32,
pub back_border_color: Color,
pub filled_color: Color,
pub handle_color: Color,
pub handle_height: u16,
pub handle_filled_gap: f32,
}
#[derive(Debug, Clone, Copy)]
pub struct RectBipolarAppearance {
pub back_color: Color,
pub back_border_width: f32,
pub back_border_radius: f32,
pub back_border_color: Color,
pub top_filled_color: Color,
pub bottom_filled_color: Color,
pub handle_top_color: Color,
pub handle_bottom_color: Color,
pub handle_center_color: Color,
pub handle_height: u16,
pub handle_filled_gap: f32,
}
#[derive(Debug, Clone)]
pub enum ModRangePlacement {
Center {
width: f32,
offset: f32,
},
CenterFilled {
edge_padding: f32,
},
Left {
width: f32,
offset: f32,
},
Right {
width: f32,
offset: f32,
},
}
#[derive(Debug, Clone)]
pub struct ModRangeAppearance {
pub placement: ModRangePlacement,
pub back_border_width: f32,
pub back_border_radius: f32,
pub back_border_color: Color,
pub back_color: Option<Color>,
pub filled_color: Color,
pub filled_inverse_color: Color,
}
#[derive(Debug, Clone)]
pub struct TickMarksAppearance {
pub style: tick_marks::Appearance,
pub placement: tick_marks::Placement,
}
#[derive(Debug, Clone)]
pub struct TextMarksAppearance {
pub style: text_marks::Appearance,
pub placement: text_marks::Placement,
}
pub trait StyleSheet {
type Style: Default;
fn active(&self, style: &Self::Style) -> Appearance;
fn hovered(&self, style: &Self::Style) -> Appearance;
fn dragging(&self, style: &Self::Style) -> Appearance;
fn tick_marks_appearance(
&self,
_style: &Self::Style,
) -> Option<TickMarksAppearance> {
None
}
fn mod_range_appearance(
&self,
_style: &Self::Style,
) -> Option<ModRangeAppearance> {
None
}
fn mod_range_appearance_2(
&self,
_style: &Self::Style,
) -> Option<ModRangeAppearance> {
None
}
fn text_marks_appearance(
&self,
_style: &Self::Style,
) -> Option<TextMarksAppearance> {
None
}
}