mirror of https://github.com/emilk/egui.git
Emil Ernerfeldt
4 years ago
9 changed files with 204 additions and 19 deletions
@ -0,0 +1,50 @@ |
|||
# Arcitecture |
|||
This document describes how the crates that make up egui are all connected. |
|||
|
|||
Also see `CONTRIBUTING.md` for what to do before opening a PR. |
|||
|
|||
|
|||
## Crate overview |
|||
The crates in this repository are: `egui, emath, epaint, egui, epi, egui_web, egui_glium, egui_demo_lib, egui_demo_app`. |
|||
|
|||
### `egui`: The main GUI library. |
|||
Example code: `if ui.button("Click me").clicked() { … }` |
|||
This is the crate where the bulk of the code is at. `egui` depends only on `emath` and `epaint`. |
|||
|
|||
### `emath`: minimal 2D math library |
|||
Examples: `Vec2, Pos2, Rect, lerp, remap` |
|||
|
|||
### `epaint` |
|||
2d shapes and text that can be turned into textured triangles. |
|||
|
|||
Example: `Shape::Circle { center, radius, fill, stroke }` |
|||
|
|||
Depends on `emath`, [`rusttype`](https://crates.io/crates/rusttype), [`atomic_refcell`](https://crates.io/crates/atomic_refcell), [`ahash`](https://crates.io/crates/ahash). |
|||
|
|||
### `epi` |
|||
Depends only on `egui`. |
|||
Adds a thin application level wrapper around `egui` for hosting an `egui` app inside of `eframe`. |
|||
|
|||
### `egui_web` |
|||
Puts an egui app inside the web browser by compiling to WASM and binding to the web browser with [`js-sys`](https://crates.io/crates/js-sys) and [`wasm-bindgen`](https://crates.io/crates/wasm-bindgen). Paints the triangles that egui outputs using WebGL. |
|||
|
|||
### `egui_glium` |
|||
Puts an egui app inside a native window on your laptop. Paints the triangles that egui outputs using [glium](https://github.com/glium/glium). |
|||
|
|||
### `eframe` |
|||
A wrapper around `egui_web` + `egui_glium`, so you can compile the same app for either web or native. |
|||
|
|||
The demo that you can see at <https://emilk.github.io/egui/index.html> is using `eframe` to host the `egui`. The demo code is found in: |
|||
|
|||
### `egui_demo_lib` |
|||
Depends on `egui` + `epi`. |
|||
This contains a bunch of uses of `egui` and looks like the ui code you would write for an `egui` app. |
|||
|
|||
|
|||
### `egui_demo_app` |
|||
Thin wrapper around `egui_demo_lib` so we can compile it to a web site or a native app executable. |
|||
Depends on `egui_demo_lib` + `eframe`. |
|||
|
|||
### Other integrations |
|||
|
|||
There are also many great integrations for game engines such as `bevy` and `miniquad` which you can find at <https://github.com/emilk/egui#integrations>. |
@ -1,26 +1,62 @@ |
|||
# Contributing guidelines |
|||
|
|||
You are welcome to contribute to egui via discussions, issues, pull requests and by publishing egui integrations. |
|||
## Introduction |
|||
|
|||
`egui` has been an on-and-off weekend project of mine since late 2018. I am grateful to any help I can get, but bare in mind that sometimes I can be slow to respond because I am busy with other things! |
|||
|
|||
/ Emil |
|||
|
|||
|
|||
## Discussion |
|||
|
|||
You can ask questions, share screenshots and more at GitHub Discussions: https://github.com/emilk/egui/discussions |
|||
You can ask questions, share screenshots and more at [GitHub Discussions](https://github.com/emilk/egui/discussions). |
|||
|
|||
There is also an `egui` channel on the Embark discord at <https://discord.gg/vY8ZGS292W> (NOTE: I work at [Embark](https://www.embark-studios.com/), but `egui` is my hobby project). |
|||
|
|||
There is also an egui channel on the Embark discord at <https://discord.gg/vY8ZGS292W> (NOTE: I work at [Embark](https://www.embark-studios.com/), but egui is my hobby project). |
|||
|
|||
## Filing an issue |
|||
|
|||
Issues are for bug reports and feature requests. Issues are not for asking questions (use [Discussions](https://github.com/emilk/egui/discussions) for that). |
|||
[Issues](https://github.com/emilk/egui/issues) are for bug reports and feature requests. Issues are not for asking questions (use [Discussions](https://github.com/emilk/egui/discussions) for that). |
|||
|
|||
Always make sure there is not already a similar issue to the one you are creating. |
|||
|
|||
If you are filing a bug, please provide a way to reproduce it. |
|||
|
|||
|
|||
## Making a PR |
|||
|
|||
Always file an issue (or find an existing one) and get feedback before you start working on a non-trivial pull request! |
|||
First file an issue (or find an existing one) and announce that you plan to work on something. That way we will avoid having several people doing double work. Please ask for feedback before you start working on something non-trivial! |
|||
|
|||
Browse through [`ARCHITECTURE.md`](https://github.com/emilk/egui/blob/master/ARCHITECTURE.md) to get a sense of how all pieces connects. |
|||
|
|||
When you have something that works, open a draft PR. You may get some helpful feedback early! |
|||
When you feel the PR is ready to go, do a self-review of the code, and then open it for review. |
|||
|
|||
|
|||
## Creating an integration for egui |
|||
|
|||
If you make an integration for egui for some engine or renderer, please share it with the world! |
|||
I will add a link to it from the egui README.md so others can easily find it. |
|||
If you make an integration for `egui` for some engine or renderer, please share it with the world! |
|||
I will add a link to it from the `egui` README.md so others can easily find it. |
|||
|
|||
Read the section on integrations at <https://github.com/emilk/egui#integrations>. |
|||
|
|||
|
|||
## Code Conventions |
|||
Conventions unless otherwise specified: |
|||
|
|||
* angles are in radians |
|||
* `Vec2::X` is right and `Vec2::Y` is down. |
|||
* `Pos2::ZERO` is left top. |
|||
|
|||
While using an immediate mode gui is simple, implementing one is a lot more tricky. There are many subtle corner-case you need to think through. The `egui` source code is a bit messy, partially because it is still evolving. |
|||
|
|||
* read some code before writing your own |
|||
* follow the `egui` code style |
|||
* write idiomatic rust |
|||
* avoid `unsafe` |
|||
* avoid code that can cause panics |
|||
* use good names for everything |
|||
* add docstrings to types, `struct` fields and all `pub fn`. |
|||
* add some example code (doc-tests) |
|||
* before making a function longer, consider adding a helper function |
|||
* break the above rules when it makes sense |
|||
|
@ -1,6 +1,12 @@ |
|||
#!/bin/bash |
|||
set -eu |
|||
|
|||
cd docs |
|||
# Starts a local web-server that servs the contents of the `doc/` folder, |
|||
# i.e. the web-version of `egui_demo_app`. |
|||
|
|||
cargo install basic-http-server |
|||
|
|||
echo "open http://localhost:8888" |
|||
python3 -m http.server 8888 --bind 127.0.0.1 |
|||
|
|||
(cd docs && basic-http-server --addr 127.0.0.1:8888 .) |
|||
# (cd docs && python3 -m http.server 8888 --bind 127.0.0.1) |
|||
|
Loading…
Reference in new issue