streamdeck_oxide/
theme.rs

1//! Theme definitions for Stream Deck buttons.
2//!
3//! This module provides types and functions for defining and customizing
4//! the appearance of Stream Deck buttons.
5
6use resvg::tiny_skia::Color;
7
8/// Defines the visual theme for Stream Deck buttons.
9///
10/// This struct contains color definitions for various button states
11/// and can be customized to match your application's visual style.
12#[derive(Clone, Copy)]
13pub struct Theme {
14    /// Background color for default buttons
15    pub(crate) background: Color,
16    /// Background color for active buttons
17    pub(crate) active_background: Color,
18    /// Background color for inactive buttons
19    pub(crate) inactive_background: Color,
20    /// Background color for pressed buttons
21    pub(crate) pressed_background: Color,
22    /// Background color for error buttons
23    pub(crate) error_background: Color,
24    /// Foreground (text/icon) color for default buttons
25    pub(crate) foreground_color: Color,
26    /// Foreground (text/icon) color for active buttons
27    pub(crate) active_foreground_color: Color,
28}
29
30impl Default for Theme {
31    fn default() -> Self {
32        Self {
33            background: Color::from_rgba8(20, 20, 25, 255),
34            active_background: Color::from_rgba8(235, 51, 148, 255),
35            inactive_background: Color::from_rgba8(41, 41, 51, 255),
36            pressed_background: Color::from_rgba8(51, 217, 230, 255),
37            error_background: Color::from_rgba8(255, 89, 0, 255),
38            foreground_color: Color::from_rgba8(242, 242, 255, 255),
39            active_foreground_color: Color::from_rgba8(255, 255, 255, 255),
40        }
41    }
42}
43
44impl Theme {
45    /// Create a new theme with custom colors.
46    pub fn new(
47        background: Color,
48        active_background: Color,
49        inactive_background: Color,
50        pressed_background: Color,
51        error_background: Color,
52        foreground_color: Color,
53        active_foreground_color: Color,
54    ) -> Self {
55        Self {
56            background,
57            active_background,
58            inactive_background,
59            pressed_background,
60            error_background,
61            foreground_color,
62            active_foreground_color,
63        }
64    }
65
66    /// Create a dark theme.
67    pub fn dark() -> Self {
68        Self::default()
69    }
70
71    /// Create a light theme.
72    pub fn light() -> Self {
73        Self {
74            background: Color::from_rgba8(240, 240, 245, 255),
75            active_background: Color::from_rgba8(0, 122, 255, 255),
76            inactive_background: Color::from_rgba8(200, 200, 210, 255),
77            pressed_background: Color::from_rgba8(0, 180, 180, 255),
78            error_background: Color::from_rgba8(255, 59, 48, 255),
79            foreground_color: Color::from_rgba8(30, 30, 30, 255),
80            active_foreground_color: Color::from_rgba8(255, 255, 255, 255),
81        }
82    }
83}