setzer22 / egui_node_graph

Build your node graph applications in Rust, using egui
MIT License
736 stars 138 forks source link

Buttons drawn on (after) the graph doesn't working. #65

Closed kkngsm closed 2 years ago

kkngsm commented 2 years ago

https://github.com/setzer22/egui_node_graph/blob/75308d0e72dd604339cd864173ca31f1bc7a3fc7/egui_node_graph_example/src/app.rs#L388-L399

If change it as follows, the switch doesn't work.

fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
    let graph_response = egui::CentralPanel::default()
        .show(ctx, |ui| {
            self.state
                .draw_graph_editor(ui, AllMyNodeTemplates, &mut self.user_state)
        })
        .inner;
    egui::TopBottomPanel::top("top").show(ctx, |ui| {
        egui::menu::bar(ui, |ui| {
            egui::widgets::global_dark_light_mode_switch(ui);
        });
    });
kkngsm commented 2 years ago

The same goes for other sliders and toggle_value

Tsudico commented 2 years ago

Is it possible that this is a limitation of egui? It appears they have reference to which order Panels must be defined in: https://github.com/emilk/egui/blob/af63101fdcbbba6e5b6b763598ba17eb76cff712/crates/egui/src/containers/panel.rs#L12 https://github.com/emilk/egui/blob/041f2e64bac778c9095fbf4316dc1f7c7bceb670/crates/egui_demo_lib/src/demo/window_with_panels.rs#L23

kkngsm commented 2 years ago

I see, it was an egui problem. Thank you very much.

setzer22 commented 2 years ago

As @Tsudico already pointed out, the immediate nature of egui means there are some compromises and the order in which you call certain functions influences rendering :smile: