use std::any::TypeId;
use crate::core::{Property, UpdateCtx};
use crate::peniko::Color;
use crate::theme;
#[derive(Default, Clone, Copy, Debug, PartialEq)]
pub struct TrackThickness(pub f64);
impl Property for TrackThickness {
fn static_default() -> &'static Self {
static DEFAULT: TrackThickness = TrackThickness(4.);
&DEFAULT
}
}
impl TrackThickness {
pub fn prop_changed(ctx: &mut UpdateCtx<'_>, property_type: TypeId) {
if property_type == TypeId::of::<Self>() {
ctx.request_layout();
}
}
}
#[derive(Default, Clone, Copy, Debug, PartialEq)]
pub struct ThumbRadius(pub f64);
impl Property for ThumbRadius {
fn static_default() -> &'static Self {
static DEFAULT: ThumbRadius = ThumbRadius(6.);
&DEFAULT
}
}
impl ThumbRadius {
pub fn prop_changed(ctx: &mut UpdateCtx<'_>, property_type: TypeId) {
if property_type == TypeId::of::<Self>() {
ctx.request_layout();
}
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct ThumbColor(pub Color);
impl Property for ThumbColor {
fn static_default() -> &'static Self {
static DEFAULT: ThumbColor = ThumbColor(theme::TEXT_COLOR);
&DEFAULT
}
}
impl Default for ThumbColor {
fn default() -> Self {
*Self::static_default()
}
}
impl ThumbColor {
pub fn prop_changed(ctx: &mut UpdateCtx<'_>, property_type: TypeId) {
if property_type == TypeId::of::<Self>() {
ctx.request_paint_only();
}
}
}