diff --git a/egui_node_graph/src/editor_ui.rs b/egui_node_graph/src/editor_ui.rs index 4c42df3..8285211 100644 --- a/egui_node_graph/src/editor_ui.rs +++ b/egui_node_graph/src/editor_ui.rs @@ -324,15 +324,12 @@ where let mut responses = Vec::new(); let background_color; - let titlebar_color; let text_color; if ui.visuals().dark_mode { background_color = color_from_hex("#3f3f3f").unwrap(); - titlebar_color = background_color.lighten(0.8); text_color = color_from_hex("#fefefe").unwrap(); } else { background_color = color_from_hex("#ffffff").unwrap(); - titlebar_color = background_color.lighten(0.8); text_color = color_from_hex("#505050").unwrap(); } @@ -532,7 +529,10 @@ where let titlebar = Shape::Rect(RectShape { rect: titlebar_rect, rounding, - fill: titlebar_color, + fill: self.graph[self.node_id] + .user_data + .titlebar_color(ui, self.node_id, self.graph, user_state) + .unwrap_or_else(|| background_color.lighten(0.8)), stroke: Stroke::none(), }); diff --git a/egui_node_graph/src/traits.rs b/egui_node_graph/src/traits.rs index d054968..32acae1 100644 --- a/egui_node_graph/src/traits.rs +++ b/egui_node_graph/src/traits.rs @@ -48,6 +48,18 @@ where ) -> Vec> where Self::Response: UserResponseTrait; + + /// Set background color on titlebar + /// If the return value is None, the default color is set. + fn titlebar_color( + &self, + _ui: &egui::Ui, + _node_id: NodeId, + _graph: &Graph, + _user_state: &Self::UserState, + ) -> Option { + None + } } /// This trait can be implemented by any user type. The trait tells the library