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.
12pub struct Theme {
13    /// Background color for default buttons
14    pub(crate) background: Color,
15    /// Background color for active buttons
16    pub(crate) active_background: Color,
17    /// Background color for inactive buttons
18    pub(crate) inactive_background: Color,
19    /// Background color for pressed buttons
20    pub(crate) pressed_background: Color,
21    /// Background color for error buttons
22    pub(crate) error_background: Color,
23    /// Foreground (text/icon) color for default buttons
24    pub(crate) foreground_color: Color,
25    /// Foreground (text/icon) color for active buttons
26    pub(crate) active_foreground_color: Color,
27}
28
29impl Default for Theme {
30    fn default() -> Self {
31        Self {
32            background: Color::from_rgba8(20, 20, 25, 255),
33            active_background: Color::from_rgba8(235, 51, 148, 255),
34            inactive_background: Color::from_rgba8(41, 41, 51, 255),
35            pressed_background: Color::from_rgba8(51, 217, 230, 255),
36            error_background: Color::from_rgba8(255, 89, 0, 255),
37            foreground_color: Color::from_rgba8(242, 242, 255, 255),
38            active_foreground_color: Color::from_rgba8(255, 255, 255, 255),
39        }
40    }
41}
42
43impl Theme {
44    /// Create a new theme with custom colors.
45    pub fn new(
46        background: Color,
47        active_background: Color,
48        inactive_background: Color,
49        pressed_background: Color,
50        error_background: Color,
51        foreground_color: Color,
52        active_foreground_color: Color,
53    ) -> Self {
54        Self {
55            background,
56            active_background,
57            inactive_background,
58            pressed_background,
59            error_background,
60            foreground_color,
61            active_foreground_color,
62        }
63    }
64
65    /// Create a dark theme.
66    pub fn dark() -> Self {
67        Self::default()
68    }
69
70    /// Create a light theme.
71    pub fn light() -> Self {
72        Self {
73            background: Color::from_rgba8(240, 240, 245, 255),
74            active_background: Color::from_rgba8(0, 122, 255, 255),
75            inactive_background: Color::from_rgba8(200, 200, 210, 255),
76            pressed_background: Color::from_rgba8(0, 180, 180, 255),
77            error_background: Color::from_rgba8(255, 59, 48, 255),
78            foreground_color: Color::from_rgba8(30, 30, 30, 255),
79            active_foreground_color: Color::from_rgba8(255, 255, 255, 255),
80        }
81    }
82}