setzer22 / egui_node_graph

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

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

Closed kkngsm closed 1 year ago

kkngsm commented 1 year 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 1 year ago

The same goes for other sliders and toggle_value

Tsudico commented 1 year 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 1 year ago

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

setzer22 commented 1 year 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: