Skip to main content

ferrum_flow/
theme.rs

1//! Canvas-wide visual tokens. Plugins can replace or tweak values in
2//! [`crate::plugin::InitPluginContext::theme`] / [`crate::plugin::PluginContext::theme`].
3//!
4//! Colors are `u32` in **GPUI `rgb` / `rgba` layout**: `0x00RRGGBB` for opaque colors
5//! (first byte unused by [`gpui::rgb`]), and `0xRRGGBBAA` for [`gpui::rgba`] fills.
6
7/// Default canvas chrome: node cards, grid, edges, selection marquee.
8#[derive(Debug, Clone, PartialEq)]
9pub struct FlowTheme {
10    /// Default node card background ([`gpui::rgb`]).
11    pub node_card_background: u32,
12    /// Default node card border when not selected.
13    pub node_card_border: u32,
14    /// Default node card border when selected.
15    pub node_card_border_selected: u32,
16
17    /// Unknown node type card background.
18    pub undefined_node_background: u32,
19    /// Unknown node type card border.
20    pub undefined_node_border: u32,
21
22    /// Primary label on default node cards.
23    pub node_caption_text: u32,
24    /// Label on undefined-type node cards.
25    pub undefined_node_caption_text: u32,
26
27    /// Default circular port fill ([`NodeRenderer::port_render`](crate::NodeRenderer::port_render)).
28    pub default_port_fill: u32,
29
30    /// Main surface color behind the dot grid.
31    pub background: u32,
32    /// Dot color for the background grid.
33    pub background_grid_dot: u32,
34
35    /// Edge curve when not selected.
36    pub edge_stroke: u32,
37    /// Edge curve when selected.
38    pub edge_stroke_selected: u32,
39
40    /// Marquee / move-preview rectangle outline ([`gpui::rgb`]).
41    pub selection_rect_border: u32,
42    /// Marquee / move-preview fill ([`gpui::rgba`], e.g. `0x78A0FF4c`).
43    pub selection_rect_fill_rgba: u32,
44
45    /// Temporary line while dragging a link from a port.
46    pub port_preview_line: u32,
47    /// Endpoint disc while dragging a link from a port (muted so it does not overpower the canvas).
48    pub port_preview_dot: u32,
49
50    /// Minimap inner panel fill ([`crate::MinimapPlugin`]).
51    pub minimap_background: u32,
52    /// Minimap inner panel outline.
53    pub minimap_border: u32,
54    /// Minimap graph edges (straight segments between node centers).
55    pub minimap_edge: u32,
56    /// Minimap node rectangle fill.
57    pub minimap_node_fill: u32,
58    /// Minimap node rectangle outline.
59    pub minimap_node_stroke: u32,
60    /// Minimap viewport / visible-area frame.
61    pub minimap_viewport_stroke: u32,
62
63    /// Zoom bar button fill ([`crate::ZoomControlsPlugin`]).
64    pub zoom_controls_background: u32,
65    /// Zoom bar button border.
66    pub zoom_controls_border: u32,
67    /// Zoom bar glyph color.
68    pub zoom_controls_text: u32,
69
70    /// Context menu panel fill ([`crate::ContextMenuPlugin`]).
71    pub context_menu_background: u32,
72    /// Context menu panel outline.
73    pub context_menu_border: u32,
74    /// Context menu row label.
75    pub context_menu_text: u32,
76    /// Context menu shortcut hint (muted).
77    pub context_menu_shortcut_text: u32,
78    /// Context menu separator rule between rows.
79    pub context_menu_separator: u32,
80}
81
82impl Default for FlowTheme {
83    fn default() -> Self {
84        Self {
85            node_card_background: 0x00FFFFFF,
86            node_card_border: 0x001A192B,
87            node_card_border_selected: 0x00FF7800,
88            undefined_node_background: 0x00F5F5F5,
89            undefined_node_border: 0x00FF9800,
90            node_caption_text: 0x001A192B,
91            undefined_node_caption_text: 0x005F6368,
92            default_port_fill: 0x001A192B,
93            background: 0x00f8f9fb,
94            background_grid_dot: 0x009F9FA7,
95            edge_stroke: 0x00b1b1b8,
96            edge_stroke_selected: 0x00FF7800,
97            selection_rect_border: 0x0078A0FF,
98            selection_rect_fill_rgba: 0x78A0FF4c,
99            port_preview_line: 0x00b1b1b8,
100            port_preview_dot: 0x007189a3,
101            minimap_background: 0x00f8f9fb,
102            minimap_border: 0x00b1b1b8,
103            minimap_edge: 0x00b1b1b8,
104            minimap_node_fill: 0x00FFFFFF,
105            minimap_node_stroke: 0x001a192b,
106            minimap_viewport_stroke: 0x0078a0ff,
107            zoom_controls_background: 0x00fcfcfc,
108            zoom_controls_border: 0x00c8c8d0,
109            zoom_controls_text: 0x001a192b,
110            context_menu_background: 0x00fcfcfc,
111            context_menu_border: 0x00c8c8d0,
112            context_menu_text: 0x001a192b,
113            context_menu_shortcut_text: 0x007a7a88,
114            context_menu_separator: 0x00e0e0e8,
115        }
116    }
117}
118
119impl FlowTheme {
120    /// Same as [`Default::default`]; kept for explicit call sites.
121    pub fn light() -> Self {
122        Self::default()
123    }
124}