Comments (1)
You are right in pointing this out, and I haven't quite converged on a final design here, but there is actually some method to the madness.
There are two fundamental categories in Egui:
-
Widgets: buttons, sliders, etc. You use a builder pattern to construct them, and then you add them to a ui, e.g.
ui.add(Label::new("Hello world"))
. -
Containers: things that wrap code that adds widgets. Examples are
ScrollArea
,Resize
,Frame
,CollapsingHeader
andWindow
(which is a wrapper around the four previous ones). Containers need to execute some custom code to add the contents. They follow the formContainer::new(...).builder(...).show(ui, |ui| {...})
Since you never run any custom closure for e.g. Label
, there makes no sense to unify Widgets and Containers. So that covers your Button
and Window
examples.
As for ui.collapsing
: this is part of a few shortcut functions. Others include ui.button("Click me")
, ui.label("Hello world")
, ui.checkbox(...)
and ui.radio(...)
. It is a bit inconsistent, but it is so much nicer to write if ui.button("OK").clicked
than ui.add(Button::new("OK")).clicked
. If Rust supported default, named arguments, this is the way I would design all widgets (instead of using the rather verbose builder pattern).
As for Menu
: that was something I threw together pretty quickly. It should probably be refactored into a Container.
from egui.
Related Issues (20)
- Smooth scrolling introduced latency
- Android WASM google keyboard backspace not working with suggestions
- web_demo: Table: Does not fill entire height
- Firefox panic with parking_lot (Parking not supported on this platform) HOT 5
- Scrollbars and other draggable elements get stuck mouse leaves browser window HOT 2
- [Web Rendering Bug]: Unexpected Height Event Setter Behavior on Mouse Move when Integrating Yew with Egui HOT 4
- After the #4337 update, the 'egui_demo_app' screen does not appear.
- eframe demo panic on startup
- Feature to get target refresh rate HOT 4
- Not detecting mouse release after alt-tab on windows
- egui_glow's winit feature should be enabled on wasm
- Context Menus demo crashes on negative width or height HOT 1
- Add ability to disable hover tooltip on TextWrapping HOT 2
- Chinese can be entered in the first position of text_editor, but not in other positions HOT 20
- egui_plot formatter, spacer etc. should not need to be 'static
- Update to `winit` 0.30 HOT 4
- Send non zero repaint delay due to animation.
- Dead keys seem to be broken on mac HOT 1
- Dragging windows allows cursor to become detached from original location
- Window position creeps between executions on scaled monitors
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from egui.