emilk / emilk/egui

API discrepancy

Open
#7 2 comments 0 reactions 0 assignees View on GitHub
design
Dominant language
Rust
Stars
30.6k
Forks
2.1k
Avg merge
1d 12h
Merged PRs (30d)
67

Description

With `imgui-rs`, the API is pretty much the same for everything.
`WidgetType::new().param(args).build(&ui, || closure executed if widget is open for example for windows or buttons)`
(Actually, that's not entirely true, small widgets use ifs but their API is moving toward this version by version)

However while looking through `egui`'s source code, I've seen 4 ways the API is declared.
`menu` does everything in the constructor:
`menu::menu(ui, "Windows", |ui| { ... })`

`Button` uses ifs and `ui.add`:
`if ui.add(Button::new("Clear memory")).clicked { ... }`

`Windows` looks a bit like imgui:
`Window::new("Examples").show(ctx, |ui| { ... })`

`collapsing` comes directly from the ui object:
`ui.collapsing("About Egui", |ui| { ... })`

4 different ways of doing control flow for the same idea, which makes it a bit awkward to use.

_PS: I'm doing a lot of issues but it's because I'm seriously considering the crate for my project and there's a few quirks before I'm thinking of moving to it. I absolutely admire the amount of work you've put into it !_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.