mirror of
https://github.com/eliasstepanik/egui_node_graph.git
synced 2026-01-10 21:38:27 +00:00
support light mode
This commit is contained in:
parent
c6c517644a
commit
303af6ac14
@ -319,10 +319,18 @@ where
|
||||
) -> Vec<NodeResponse<UserResponse>> {
|
||||
let margin = egui::vec2(15.0, 5.0);
|
||||
let mut responses = Vec::new();
|
||||
|
||||
let background_color = color_from_hex("#3f3f3f").unwrap();
|
||||
let titlebar_color = background_color.lighten(0.8);
|
||||
let text_color = color_from_hex("#fefefe").unwrap();
|
||||
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("#000000").unwrap();
|
||||
}
|
||||
|
||||
ui.visuals_mut().widgets.noninteractive.fg_stroke = Stroke::new(2.0, text_color);
|
||||
|
||||
@ -348,7 +356,7 @@ where
|
||||
ui.add(Label::new(
|
||||
RichText::new(&self.graph[self.node_id].label)
|
||||
.text_style(TextStyle::Button)
|
||||
.color(color_from_hex("#fefefe").unwrap()),
|
||||
.color(text_color),
|
||||
));
|
||||
});
|
||||
ui.add_space(margin.y);
|
||||
|
||||
@ -34,8 +34,16 @@ where
|
||||
ui: &mut Ui,
|
||||
all_kinds: impl NodeTemplateIter<Item = NodeTemplate>,
|
||||
) -> Option<NodeTemplate> {
|
||||
let background_color = color_from_hex("#3f3f3f").unwrap();
|
||||
let text_color = color_from_hex("#fefefe").unwrap();
|
||||
let background_color;
|
||||
let text_color;
|
||||
|
||||
if ui.visuals().dark_mode {
|
||||
background_color = color_from_hex("#3f3f3f").unwrap();
|
||||
text_color = color_from_hex("#fefefe").unwrap();
|
||||
} else {
|
||||
background_color = color_from_hex("#fefefe").unwrap();
|
||||
text_color = color_from_hex("#3f3f3f").unwrap();
|
||||
}
|
||||
|
||||
ui.visuals_mut().widgets.noninteractive.fg_stroke = Stroke::new(2.0, text_color);
|
||||
|
||||
|
||||
@ -349,6 +349,11 @@ impl eframe::App for NodeGraphExample {
|
||||
/// Called each time the UI needs repainting, which may be many times per second.
|
||||
/// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`.
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::TopBottomPanel::top("top").show(ctx, |ui| {
|
||||
egui::menu::bar(ui, |ui| {
|
||||
egui::widgets::global_dark_light_mode_switch(ui);
|
||||
});
|
||||
});
|
||||
let graph_response = egui::CentralPanel::default()
|
||||
.show(ctx, |ui| {
|
||||
self.state.draw_graph_editor(ui, AllMyNodeTemplates)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user