Skip to content

Commit 2ba91f3

Browse files
emilkhacknus
authored andcommitted
Improve README.md
1 parent 649194c commit 2ba91f3

File tree

3 files changed

+59
-72
lines changed

3 files changed

+59
-72
lines changed

README.md

+49-63
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ egui aims to be the easiest-to-use Rust GUI library, and the simplest way to mak
2727

2828
egui can be used anywhere you can draw textured triangles, which means you can easily integrate it into your game engine of choice.
2929

30+
[`eframe`](https://github.com/emilk/egui/tree/master/crates/eframe) is the official egui framework, which supports writing apps for Web, Linux, Mac, Windows, and Android.
31+
32+
3033
## Example
3134

3235
``` rust
@@ -43,7 +46,9 @@ ui.label(format!("Hello '{name}', age {age}"));
4346
ui.image(egui::include_image!("ferris.png"));
4447
```
4548

46-
<img src="media/demo.gif">
49+
<img alt="Dark mode" src="media/demo.gif">
50+
&nbsp;&nbsp;
51+
<img alt="Light mode" src="media/demo_light_mode.png" height="278">
4752

4853
## Sections:
4954

@@ -73,7 +78,7 @@ If you have questions, use [GitHub Discussions](https://github.com/emilk/egui/di
7378

7479
## Demo
7580

76-
[Click to run egui web demo](https://www.egui.rs/#demo) (works in any browser with WASM and WebGL support). Uses [`eframe`](https://github.com/emilk/egui/tree/master/crates/eframe).
81+
[Click to run egui web demo](https://www.egui.rs/#demo) (works in any browser with Wasm and WebGL support). Uses [`eframe`](https://github.com/emilk/egui/tree/master/crates/eframe).
7782

7883
To test the demo app locally, run `cargo run --release -p egui_demo_app`.
7984

@@ -120,16 +125,17 @@ Still, egui can be used to create professional looking applications, like [the R
120125

121126
### Features
122127

123-
* Widgets: label, text button, hyperlink, checkbox, radio button, slider, draggable value, text editing, combo box, color picker, spinner
128+
* Widgets: label, text button, hyperlink, checkbox, radio button, slider, draggable value, text editing, color picker, spinner
124129
* Images
125130
* Layouts: horizontal, vertical, columns, automatic wrapping
126131
* Text editing: multiline, copy/paste, undo, emoji supports
127132
* Windows: move, resize, name, minimize and close. Automatically sized and positioned.
128-
* Regions: resizing, vertical scrolling, collapsing headers (sections)
133+
* Regions: resizing, vertical scrolling, collapsing headers (sections), panels
129134
* Rendering: Anti-aliased rendering of lines, circles, text and convex polygons.
130135
* Tooltips on hover
131136
* Accessibility via [AccessKit](https://accesskit.dev/)
132-
* More
137+
* Label text selection
138+
* And more!
133139

134140
<img src="media/widget_gallery_0.23.gif" width="50%">
135141

@@ -161,25 +167,6 @@ If you are not using Rust, egui is not for you. If you want a GUI that looks nat
161167

162168
But if you are writing something interactive in Rust that needs a simple GUI, egui may be for you.
163169

164-
### egui vs Dear ImGui
165-
166-
The obvious alternative to egui is [`imgui-rs`](https://github.com/Gekkio/imgui-rs), the Rust wrapper around the C++ library [Dear ImGui](https://github.com/ocornut/imgui). Dear ImGui is a great library (and the main inspiration for egui), with a lot more features and polish. However, egui provides some benefits for Rust users:
167-
168-
* egui is pure Rust
169-
* egui is easily compiled to WASM
170-
* egui lets you use native Rust string types (`imgui-rs` forces you to use annoying macros and wrappers for zero-terminated strings)
171-
* [Writing your own widgets in egui is simple](https://github.com/emilk/egui/blob/master/crates/egui_demo_lib/src/demo/toggle_switch.rs)
172-
173-
egui also tries to improve your experience in other small ways:
174-
175-
* Windows are automatically sized based on their contents
176-
* Windows are automatically positioned to not overlap with each other
177-
* Some subtle animations make egui come alive
178-
179-
So in summary:
180-
181-
* egui: pure Rust, new, exciting, work in progress
182-
* Dear ImGui: feature rich, well tested, cumbersome Rust integration
183170

184171
## Integrations
185172

@@ -189,49 +176,48 @@ egui itself doesn't know or care on what OS it is running or how to render thing
189176
An integration needs to do the following each frame:
190177

191178
* **Input**: Gather input (mouse, touches, keyboard, screen size, etc) and give it to egui
192-
* Run the application code
179+
* Call into the application GUI code
193180
* **Output**: Handle egui output (cursor changes, paste, texture allocations, …)
194181
* **Painting**: Render the triangle mesh egui produces (see [OpenGL example](https://github.com/emilk/egui/blob/master/crates/egui_glow/src/painter.rs))
195182

196183
### Official integrations
197184

198185
These are the official egui integrations:
199186

200-
* [`eframe`](https://github.com/emilk/egui/tree/master/crates/eframe) for compiling the same app to web/wasm and desktop/native. Uses `egui-winit` and `egui_glow` or `egui-wgpu`.
201-
* [`egui_glow`](https://github.com/emilk/egui/tree/master/crates/egui_glow) for rendering egui with [glow](https://github.com/grovesNL/glow) on native and web, and for making native apps.
202-
* [`egui-wgpu`](https://github.com/emilk/egui/tree/master/crates/egui-wgpu) for [wgpu](https://crates.io/crates/wgpu) (WebGPU API).
203-
* [`egui-winit`](https://github.com/emilk/egui/tree/master/crates/egui-winit) for integrating with [winit](https://github.com/rust-windowing/winit).
187+
* [`eframe`](https://github.com/emilk/egui/tree/master/crates/eframe) for compiling the same app to web/wasm and desktop/native. Uses `egui-winit` and `egui_glow` or `egui-wgpu`
188+
* [`egui_glow`](https://github.com/emilk/egui/tree/master/crates/egui_glow) for rendering egui with [glow](https://github.com/grovesNL/glow) on native and web, and for making native apps
189+
* [`egui-wgpu`](https://github.com/emilk/egui/tree/master/crates/egui-wgpu) for [wgpu](https://crates.io/crates/wgpu) (WebGPU API)
190+
* [`egui-winit`](https://github.com/emilk/egui/tree/master/crates/egui-winit) for integrating with [winit](https://github.com/rust-windowing/winit)
204191

205192
### 3rd party integrations
206193

207-
* [`amethyst_egui`](https://github.com/jgraef/amethyst_egui) for [the Amethyst game engine](https://amethyst.rs/).
208-
* [`egui-ash`](https://github.com/MatchaChoco010/egui-ash) for [`ash`](https://github.com/ash-rs/ash) (a very lightweight wrapper around Vulkan).
209-
* [`bevy_egui`](https://github.com/mvlabat/bevy_egui) for [the Bevy game engine](https://bevyengine.org/).
210-
* [`egui_glfw_gl`](https://github.com/cohaereo/egui_glfw_gl) for [GLFW](https://crates.io/crates/glfw).
211-
* [`egui_glium`](https://github.com/fayalalebrun/egui_glium) for compiling native apps with [Glium](https://github.com/glium/glium).
212-
* [`egui-glutin-gl`](https://github.com/h3r2tic/egui-glutin-gl/) for [glutin](https://crates.io/crates/glutin).
213-
* [`egui_sdl2_gl`](https://crates.io/crates/egui_sdl2_gl) for [SDL2](https://crates.io/crates/sdl2).
214-
* [`egui_sdl2_platform`](https://github.com/ComLarsic/egui_sdl2_platform) for [SDL2](https://crates.io/crates/sdl2).
215-
* [`egui_vulkano`](https://github.com/derivator/egui_vulkano) for [Vulkano](https://github.com/vulkano-rs/vulkano).
216-
* [`egui_winit_vulkano`](https://github.com/hakolao/egui_winit_vulkano) for [Vulkano](https://github.com/vulkano-rs/vulkano).
217-
* [`egui-macroquad`](https://github.com/optozorax/egui-macroquad) for [macroquad](https://github.com/not-fl3/macroquad).
218-
* [`egui-miniquad`](https://github.com/not-fl3/egui-miniquad) for [Miniquad](https://github.com/not-fl3/miniquad).
219-
* [`egui_speedy2d`](https://github.com/heretik31/egui_speedy2d) for [Speedy2d](https://github.com/QuantumBadger/Speedy2D).
220-
* [`egui-tetra`](https://crates.io/crates/egui-tetra) for [Tetra](https://crates.io/crates/tetra), a 2D game framework.
221-
* [`egui-winit-ash-integration`](https://github.com/MatchaChoco010/egui-winit-ash-integration) for [winit](https://github.com/rust-windowing/winit) and [ash](https://github.com/MaikKlein/ash).
222-
* [`fltk-egui`](https://crates.io/crates/fltk-egui) for [fltk-rs](https://github.com/fltk-rs/fltk-rs).
223-
* [`ggegui`](https://github.com/NemuiSen/ggegui) for the [ggez](https://ggez.rs/) game framework.
224-
* [`godot-egui`](https://github.com/setzer22/godot-egui) for [godot-rust](https://github.com/godot-rust/godot-rust).
225-
* [`nannou_egui`](https://github.com/nannou-org/nannou/tree/master/nannou_egui) for [nannou](https://nannou.cc).
226-
* [`notan_egui`](https://github.com/Nazariglez/notan/tree/main/crates/notan_egui) for [notan](https://github.com/Nazariglez/notan).
227-
* [`screen-13-egui`](https://github.com/attackgoat/screen-13/tree/master/contrib/screen-13-egui) for [Screen 13](https://github.com/attackgoat/screen-13).
228-
* [`egui_skia`](https://github.com/lucasmerlin/egui_skia) for [skia](https://github.com/rust-skia/rust-skia/tree/master/skia-safe).
229-
* [`smithay-egui`](https://github.com/Smithay/smithay-egui) for [smithay](https://github.com/Smithay/smithay/).
230-
* [`tauri-egui`](https://github.com/tauri-apps/tauri-egui) for [tauri](https://github.com/tauri-apps/tauri).
231-
232-
Missing an integration for the thing you're working on? Create one, it's easy!
194+
* [`amethyst_egui`](https://github.com/jgraef/amethyst_egui) for [the Amethyst game engine](https://amethyst.rs/)
195+
* [`egui-ash`](https://github.com/MatchaChoco010/egui-ash) for [`ash`](https://github.com/ash-rs/ash) (a very lightweight wrapper around Vulkan)
196+
* [`bevy_egui`](https://github.com/mvlabat/bevy_egui) for [the Bevy game engine](https://bevyengine.org/)
197+
* [`egui_glfw_gl`](https://github.com/cohaereo/egui_glfw_gl) for [GLFW](https://crates.io/crates/glfw)
198+
* [`egui_glium`](https://github.com/fayalalebrun/egui_glium) for compiling native apps with [Glium](https://github.com/glium/glium)
199+
* [`egui-glutin-gl`](https://github.com/h3r2tic/egui-glutin-gl/) for [glutin](https://crates.io/crates/glutin)
200+
* [`egui_sdl2_gl`](https://crates.io/crates/egui_sdl2_gl) for [SDL2](https://crates.io/crates/sdl2)
201+
* [`egui_sdl2_platform`](https://github.com/ComLarsic/egui_sdl2_platform) for [SDL2](https://crates.io/crates/sdl2)
202+
* [`egui_vulkano`](https://github.com/derivator/egui_vulkano) for [Vulkano](https://github.com/vulkano-rs/vulkano)
203+
* [`egui_winit_vulkano`](https://github.com/hakolao/egui_winit_vulkano) for [Vulkano](https://github.com/vulkano-rs/vulkano)
204+
* [`egui-macroquad`](https://github.com/optozorax/egui-macroquad) for [macroquad](https://github.com/not-fl3/macroquad)
205+
* [`egui-miniquad`](https://github.com/not-fl3/egui-miniquad) for [Miniquad](https://github.com/not-fl3/miniquad)
206+
* [`egui_speedy2d`](https://github.com/heretik31/egui_speedy2d) for [Speedy2d](https://github.com/QuantumBadger/Speedy2D)
207+
* [`egui-tetra`](https://crates.io/crates/egui-tetra) for [Tetra](https://crates.io/crates/tetra), a 2D game framework
208+
* [`egui-winit-ash-integration`](https://github.com/MatchaChoco010/egui-winit-ash-integration) for [winit](https://github.com/rust-windowing/winit) and [ash](https://github.com/MaikKlein/ash)
209+
* [`fltk-egui`](https://crates.io/crates/fltk-egui) for [fltk-rs](https://github.com/fltk-rs/fltk-rs)
210+
* [`ggegui`](https://github.com/NemuiSen/ggegui) for the [ggez](https://ggez.rs/) game framework
211+
* [`godot-egui`](https://github.com/setzer22/godot-egui) for [godot-rust](https://github.com/godot-rust/godot-rust)
212+
* [`nannou_egui`](https://github.com/nannou-org/nannou/tree/master/nannou_egui) for [nannou](https://nannou.cc)
213+
* [`notan_egui`](https://github.com/Nazariglez/notan/tree/main/crates/notan_egui) for [notan](https://github.com/Nazariglez/notan)
214+
* [`screen-13-egui`](https://github.com/attackgoat/screen-13/tree/master/contrib/screen-13-egui) for [Screen 13](https://github.com/attackgoat/screen-13)
215+
* [`egui_skia`](https://github.com/lucasmerlin/egui_skia) for [skia](https://github.com/rust-skia/rust-skia/tree/master/skia-safe)
216+
* [`smithay-egui`](https://github.com/Smithay/smithay-egui) for [smithay](https://github.com/Smithay/smithay/)
217+
* [`tauri-egui`](https://github.com/tauri-apps/tauri-egui) for [tauri](https://github.com/tauri-apps/tauri)
233218

234219
### Writing your own egui integration
220+
Missing an integration for the thing you're working on? Create one, it's easy!
235221
See <https://docs.rs/egui/latest/egui/#integrating-with-egui>.
236222

237223

@@ -292,12 +278,12 @@ Overall, ID handling is a rare inconvenience, and not a big disadvantage.
292278
Also see [GitHub Discussions](https://github.com/emilk/egui/discussions/categories/q-a).
293279

294280
### Can I use `egui` with non-latin characters?
295-
Yes! But you need to install your own font (`.ttf` or `.otf`) using `Context::set_fonts`.
281+
Yes! But you need to install your own font (`.ttf` or `.otf`) using [`Context::set_fonts`](https://docs.rs/egui/latest/egui/struct.Context.html#method.set_fonts).
296282

297283
### Can I customize the look of egui?
298284
Yes! You can customize the colors, spacing, fonts and sizes of everything using `Context::set_style`.
299285

300-
This is not yet as powerful as say CSS, [but this is going to improve soon](https://github.com/emilk/egui/issues/3284).
286+
This is not yet as powerful as say CSS, [but this is going to improve](https://github.com/emilk/egui/issues/3284).
301287

302288
Here is an example (from https://github.com/a-liashenko/TinyPomodoro):
303289

@@ -311,9 +297,9 @@ If you call `.await` in your GUI code, the UI will freeze, which is very bad UX.
311297
* [`eventuals::Eventual`](https://docs.rs/eventuals/latest/eventuals/struct.Eventual.html)
312298
* [`tokio::sync::watch::channel`](https://docs.rs/tokio/latest/tokio/sync/watch/fn.channel.html)
313299

314-
### How to do cross-platform file dialogs?
300+
### How to I create a file dialog?
315301

316-
The async version of [rfd](https://docs.rs/rfd/latest/rfd/) supports both native and WASM. See example app here https://github.com/woelper/egui_pick_file which also has a demo available via [gitub pages](https://woelper.github.io/egui_pick_file/).
302+
The async version of [rfd](https://docs.rs/rfd/latest/rfd/) supports both native and Wasm. See example app here https://github.com/woelper/egui_pick_file which also has a demo available via [gitub pages](https://woelper.github.io/egui_pick_file/).
317303

318304
### What about accessibility, such as screen readers?
319305
egui includes optional support for [AccessKit](https://accesskit.dev/), which currently implements the native accessibility APIs on Windows and macOS. This feature is enabled by default in eframe. For platforms that AccessKit doesn't yet support, including web, there is an experimental built-in screen reader; in [the web demo](https://www.egui.rs/#demo) you can enable it in the "Backend" tab.
@@ -328,12 +314,12 @@ That is the job of *the integration* or *backend*.
328314

329315
It is common to use `egui` from a game engine (using e.g. [`bevy_egui`](https://docs.rs/bevy_egui)),
330316
but you can also use `egui` stand-alone using `eframe`. `eframe` has integration for web and native, and handles input and rendering.
331-
The _frame_ in `eframe` stands both for the frame in which your egui app resides and also for "framework" (`frame` is a framework, `egui` is a library).
317+
The _frame_ in `eframe` stands both for the frame in which your egui app resides and also for "framework" (`eframe` is a framework, `egui` is a library).
332318

333319
### How do I render 3D stuff in an egui area?
334320
There are multiple ways to combine egui with 3D. The simplest way is to use a 3D library and have egui sit on top of the 3D view. See for instance [`bevy_egui`](https://github.com/mvlabat/bevy_egui) or [`three-d`](https://github.com/asny/three-d).
335321

336-
If you want to embed 3D into an egui view there are two options.
322+
If you want to embed 3D into an egui view there are two options:
337323

338324
#### `Shape::Callback`
339325
Example:
@@ -354,9 +340,9 @@ Examples:
354340

355341
All coordinates are in screen space coordinates, with (0, 0) in the top left corner
356342

357-
All coordinates are in "points" which may consist of many physical pixels.
343+
All coordinates are in logical "points" which may consist of many physical pixels.
358344

359-
All colors have premultiplied alpha.
345+
All colors have premultiplied alpha, unless otherwise stated.
360346

361347
egui uses the builder pattern for construction widgets. For instance: `ui.add(Label::new("Hello").text_color(RED));` I am not a big fan of the builder pattern (it is quite verbose both in implementation and in use) but until Rust has named, default arguments it is the best we can do. To alleviate some of the verbosity there are common-case helper functions, like `ui.label("Hello");`.
362348

crates/eframe/README.md

+10-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
![MIT](https://img.shields.io/badge/license-MIT-blue.svg)
66
![Apache](https://img.shields.io/badge/license-Apache-blue.svg)
77

8-
`eframe` is the official framework library for writing apps using [`egui`](https://github.com/emilk/egui). The app can be compiled both to run natively (cross platform) or be compiled to a web app (using WASM).
8+
`eframe` is the official framework library for writing apps using [`egui`](https://github.com/emilk/egui). The app can be compiled both to run natively (for Linux, Mac, Windows, and Android) or as a web app (using [Wasm](https://en.wikipedia.org/wiki/WebAssembly)).
99

1010
To get started, see the [examples](https://github.com/emilk/egui/tree/master/examples).
1111
To learn how to set up `eframe` for web and native, go to <https://github.com/emilk/eframe_template/> and follow the instructions there!
@@ -36,28 +36,29 @@ To get copy-paste working on web, you need to compile with `export RUSTFLAGS=--c
3636
You can also use `egui_glow` and [`winit`](https://github.com/rust-windowing/winit) to build your own app as demonstrated in <https://github.com/emilk/egui/blob/master/crates/egui_glow/examples/pure_glow.rs>.
3737

3838

39-
## Problems with running egui on the web
40-
`eframe` uses WebGL (via [`glow`](https://crates.io/crates/glow)) and WASM, and almost nothing else from the web tech stack. This has some benefits, but also produces some challenges and serious downsides.
39+
## Limitations when running egui on the web
40+
`eframe` uses WebGL (via [`glow`](https://crates.io/crates/glow)) and Wasm, and almost nothing else from the web tech stack. This has some benefits, but also produces some challenges and serious downsides.
4141

4242
* Rendering: Getting pixel-perfect rendering right on the web is very difficult.
4343
* Search: you cannot search an egui web page like you would a normal web page.
4444
* Bringing up an on-screen keyboard on mobile: there is no JS function to do this, so `eframe` fakes it by adding some invisible DOM elements. It doesn't always work.
4545
* Mobile text editing is not as good as for a normal web app.
46-
* Accessibility: There is an experimental screen reader for `eframe`, but it has to be enabled explicitly. There is no JS function to ask "Does the user want a screen reader?" (and there should probably not be such a function, due to user tracking/integrity concerns).
4746
* No integration with browser settings for colors and fonts.
47+
* Accessibility: There is an experimental screen reader for `eframe`, but it has to be enabled explicitly. There is no JS function to ask "Does the user want a screen reader?" (and there should probably not be such a function, due to user tracking/integrity concerns). `egui` supports [AccessKit](https://github.com/AccessKit/accesskit), but as of early 2024, AccessKit lacks a Web backend.
4848

4949
In many ways, `eframe` is trying to make the browser do something it wasn't designed to do (though there are many things browser vendors could do to improve how well libraries like egui work).
5050

5151
The suggested use for `eframe` are for web apps where performance and responsiveness are more important than accessibility and mobile text editing.
5252

5353

5454
## Companion crates
55-
Not all rust crates work when compiled to WASM, but here are some useful crates have been designed to work well both natively and as WASM:
55+
Not all rust crates work when compiled to Wasm, but here are some useful crates have been designed to work well both natively and as Wasm:
5656

57-
* Audio: [`cpal`](https://github.com/RustAudio/cpal).
58-
* HTTP client: [`ehttp`](https://github.com/emilk/ehttp) and [`reqwest`](https://github.com/seanmonstar/reqwest).
59-
* Time: [`chrono`](https://github.com/chronotope/chrono).
60-
* WebSockets: [`ewebsock`](https://github.com/rerun-io/ewebsock).
57+
* Audio: [`cpal`](https://github.com/RustAudio/cpal)
58+
* File dialogs: [rfd](https://docs.rs/rfd/latest/rfd/)
59+
* HTTP client: [`ehttp`](https://github.com/emilk/ehttp) and [`reqwest`](https://github.com/seanmonstar/reqwest)
60+
* Time: [`chrono`](https://github.com/chronotope/chrono)
61+
* WebSockets: [`ewebsock`](https://github.com/rerun-io/ewebsock)
6162

6263

6364
## Name

media/demo_light_mode.png

75 KB
Loading

0 commit comments

Comments
 (0)