Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic example doesn't work in eframe template, widgets aren't recognized #7

Open
dRAT3 opened this issue Feb 19, 2023 · 9 comments
Open

Comments

@dRAT3
Copy link

dRAT3 commented Feb 19, 2023

Hi, I cloned the eframe starter and tried to add the widgets to it by copying the basic example into my update function

        let Self { label, value } = self;

        // Examples of how to create different panels and windows.
        // Pick whichever suits you.
        // Tip: a good default choice is to just keep the `CentralPanel`.
        // For inspiration and more examples, go to https://emilk.github.io/egui

        #[cfg(not(target_arch = "wasm32"))] // no File->Quit on web pages!
        egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
            // The top panel is often a good place for a menu bar:
            egui::menu::bar(ui, |ui| {
                ui.menu_button("File", |ui| {
                    if ui.button("Quit").clicked() {
                        _frame.close();
                    }
                });
            });
        });

        egui::CentralPanel::default().show(ctx, |ui| {
            // The central panel the region left after adding TopPanel's and SidePanel's

            ui.heading("eframe template");
            ui.hyperlink("https://github.com/emilk/eframe_template");
            ui.add(egui::github_link_file!(
                "https://github.com/emilk/eframe_template/blob/master/",
                "Source code."
            ));
            egui::warn_if_debug_build(ui);
        });
        egui::Window::new("My window")
            .default_pos(pos2(20.0, 100.0))
            .show(ctx, |ui| {
                ui.add(Port::new(0));
            });
        egui::Window::new("My window 2")
            .default_pos(pos2(200.0, 20.0))
            .show(ctx, |ui| {
                ui.add(Port::new(1));
                ui.add_space(10.0);
                ui.add(Port::new(2));
            });
        egui::Window::new("My window 3")
            .default_pos(pos2(200.0, 200.0))
            .show(ctx, |ui| {
                ui.add(Port::new(3));

                ui.add(Cable::new(0, Plug::to(0), Plug::to(1)));
                ui.add(Cable::new(1, Plug::to(0), Plug::to(3)));
                ui.add(Cable::new(2, Plug::to(2), Plug::unplugged()));
            });
    }
}

But then I get the error:

error[E0277]: expected a `FnOnce<(&mut egui::Ui,)>` closure, found `egui_cable::port::Port`
    --> src/app.rs:85:24
     |
85   |                 ui.add(Port::new(0));
     |                    --- ^^^^^^^^^^^^ expected an `FnOnce<(&mut egui::Ui,)>` closure, found `egui_cable::port::Port`
     |                    |
     |                    required by a bound introduced by this call
     |
     = help: the trait `for<'a> FnOnce<(&'a mut egui::Ui,)>` is not implemented for `egui_cable::port::Port`
     = help: the following other types implement trait `egui::Widget`:
               &eframe::epaint::PaintStats
               &mut eframe::epaint::TessellationOptions
               egui::Button
               egui::Checkbox<'a>
               egui::DragValue<'a>
               egui::Hyperlink
               egui::Image
               egui::ImageButton
             and 9 others
     = note: required for `egui_cable::port::Port` to implement `egui::Widget`
note: required by a bound in `egui::Ui::add`
    --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/egui-0.21.0/src/ui.rs:1055:40
     |
1055 |     pub fn add(&mut self, widget: impl Widget) -> Response {
     |                                        ^^^^^^ required by this bound in `egui::Ui::add`

I get the same error for all the egui_cable widgets.

Do you have any idea what I might've done wrong or if it is a bug?

@ryo33
Copy link
Owner

ryo33 commented Feb 19, 2023

@dRAT3 Thanks for reporting it! I've fixed it in 56c0e1b.
Can you update egui_cable to 0.3.1 and try it again?

@dRAT3
Copy link
Author

dRAT3 commented Feb 19, 2023

I am on version 0.4.0 from crates I'll try on 0.3.1

@ryo33
Copy link
Owner

ryo33 commented Feb 19, 2023

@dRAT3 Then, please ensure the version of egui depended by egui_cable is the same as the one you are using.

@ryo33
Copy link
Owner

ryo33 commented Feb 19, 2023

Oh I may had a mistake of the versioning

@ryo33
Copy link
Owner

ryo33 commented Feb 19, 2023

I’ll fix the wrong versioning and other things later. It should be done before about 3 hours later.

@dRAT3
Copy link
Author

dRAT3 commented Feb 19, 2023

To be shure I used
egui_cable = { git = "https://github.com/ryo33/egui_cable", branch = "main" }
and now I run into 43 errors inside the egui_cable package

Okay thanks I'll check back in a couple of hours

@ryo33
Copy link
Owner

ryo33 commented Feb 19, 2023

@dRAT3 Sorry for late. It takes longer than imagined to follow the latest egui's API. It should be finished in a day. For now, I'm going to sleep...zzz
For now, can you downgrade the egui to the former version, 0.20? It should work even now.

@ryo33
Copy link
Owner

ryo33 commented Feb 21, 2023

@dRAT3 I've released 0.5.0. Sorry for late. Can you try it?

@dRAT3
Copy link
Author

dRAT3 commented Feb 21, 2023

Yes for shure, no problem at all, thx matey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants