use bevy_ecs::prelude::*;
use super::color::Color;
#[derive(Component)]
pub struct ButtonMarker;
#[derive(Component, Clone, Copy, Debug)]
pub struct ButtonColors {
pub base: Color,
pub hover: Color,
pub press: Color,
}
impl ButtonColors {
pub fn close() -> Self {
Self {
base: Color::srgba(0.0, 0.0, 0.0, 0.0),
hover: Color::srgb(0.62, 0.22, 0.22),
press: Color::srgb(0.45, 0.15, 0.15),
}
}
pub fn row() -> Self {
Self {
base: Color::srgba(0.0, 0.0, 0.0, 0.0),
hover: Color::srgb(0.24, 0.35, 0.55),
press: Color::srgb(0.18, 0.27, 0.44),
}
}
}
impl Default for ButtonColors {
fn default() -> Self {
Self {
base: Color::srgb(0.20, 0.22, 0.28),
hover: Color::srgb(0.30, 0.33, 0.42),
press: Color::srgb(0.14, 0.16, 0.21),
}
}
}
impl ButtonColors {
pub fn current(&self, hovered: bool, pressed: bool) -> Color {
if pressed {
self.press
} else if hovered {
self.hover
} else {
self.base
}
}
}
pub type ClickHandler = Box<dyn FnMut() + Send + Sync>;
#[derive(Component)]
pub struct OnClick(pub ClickHandler);