Rename Egui to egui

Also update iamges in README.md
This commit is contained in:
Emil Ernerfeldt 2021-01-17 14:48:59 +01:00
parent 9dba63fa3f
commit 31b7eda51e
55 changed files with 173 additions and 172 deletions

View file

@ -1,6 +1,6 @@
# Egui Changelog # egui changelog
All notable changes to the Egui crate will be documented in this file. All notable changes to the egui crate will be documented in this file.
NOTE: `epi`, `eframe`, `egui_web` and `egui_glium` has their own changelogs! NOTE: `epi`, `eframe`, `egui_web` and `egui_glium` has their own changelogs!
@ -63,7 +63,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
* `ui.vertical_centered` and `ui.vertical_centered_justified`. * `ui.vertical_centered` and `ui.vertical_centered_justified`.
* `ui.allocate_painter` helper. * `ui.allocate_painter` helper.
* Mouse-over explanation to duplicate ID warning. * Mouse-over explanation to duplicate ID warning.
* You can now easily constrain Egui to a portion of the screen using `RawInput::screen_rect`. * You can now easily constrain egui to a portion of the screen using `RawInput::screen_rect`.
* You can now control the minimum and maixumum number of decimals to show in a `Slider` or `DragValue`. * You can now control the minimum and maixumum number of decimals to show in a `Slider` or `DragValue`.
* Add `egui::math::Rot2`: rotation helper. * Add `egui::math::Rot2`: rotation helper.
* `Response` now contains the `Id` of the widget it pertains to. * `Response` now contains the `Id` of the widget it pertains to.
@ -145,7 +145,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
* Pressing enter in a single-line `TextEdit` will now surrender keyboard focus for it. * Pressing enter in a single-line `TextEdit` will now surrender keyboard focus for it.
* You must now be explicit when creating a `TextEdit` if you want it to be singeline or multiline. * You must now be explicit when creating a `TextEdit` if you want it to be singeline or multiline.
* Improved automatic `Id` generation, making `Id` clashes less likely. * Improved automatic `Id` generation, making `Id` clashes less likely.
* Egui now requires modifier key state from the integration * egui now requires modifier key state from the integration
* Added, renamed and removed some keys in the `Key` enum. * Added, renamed and removed some keys in the `Key` enum.
* Fixed incorrect text wrapping width on radio buttons * Fixed incorrect text wrapping width on radio buttons
@ -159,10 +159,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added ⭐ ### Added ⭐
* Panels: you can now create panels using `SidePanel`, `TopPanel` and `CentralPanel`. * Panels: you can now create panels using `SidePanel`, `TopPanel` and `CentralPanel`.
* You can now override the default Egui fonts. * You can now override the default egui fonts.
* Add ability to override text color with `visuals.override_text_color`. * Add ability to override text color with `visuals.override_text_color`.
* The demo now includes a simple drag-and-drop example. * The demo now includes a simple drag-and-drop example.
* The demo app now has a slider to scale all of Egui. * The demo app now has a slider to scale all of egui.
### Changed 🔧 ### Changed 🔧

View file

@ -1,12 +1,12 @@
# Contributing guidelines # Contributing guidelines
You are welcome to contribute to Egui via discussions, issues, pull requests and by publishing Egui integrations. You are welcome to contribute to egui via discussions, issues, pull requests and by publishing egui integrations.
## Discussion ## 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 ## Filing an issue
@ -20,7 +20,7 @@ If you are filing a bug, please provide a way to reproduce it.
Always file an issue (or find an existing one) and get feedback before you start working on a non-trivial pull request! Always file an issue (or find an existing one) and get feedback before you start working on a non-trivial pull request!
## Creating an integration for Egui ## Creating an integration for egui
If you make an integration for Egui for some engine or renderer, please share it with the world! 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. I will add a link to it from the egui README.md so others can easily find it.

View file

@ -1,4 +1,4 @@
# 🖌 Egui: an easy-to-use GUI in pure Rust # 🖌 egui: an easy-to-use GUI in pure Rust
[![Latest version](https://img.shields.io/crates/v/egui.svg)](https://crates.io/crates/egui) [![Latest version](https://img.shields.io/crates/v/egui.svg)](https://crates.io/crates/egui)
[![Documentation](https://docs.rs/egui/badge.svg)](https://docs.rs/egui) [![Documentation](https://docs.rs/egui/badge.svg)](https://docs.rs/egui)
@ -8,18 +8,19 @@
![MIT](https://img.shields.io/badge/license-MIT-blue.svg) ![MIT](https://img.shields.io/badge/license-MIT-blue.svg)
![Apache](https://img.shields.io/badge/license-Apache-blue.svg) ![Apache](https://img.shields.io/badge/license-Apache-blue.svg)
Egui is a simple, fast, and highly portable immediate mode GUI library for Rust. Egui runs on the web, natively, and in your favorite game engine (or will soon).
Egui aims to be the easiest-to-use Rust GUI libary, and the simplest way to make a web app in Rust. egui is a simple, fast, and highly portable immediate mode GUI library for Rust. egui runs on the web, natively, and in your favorite game engine (or will soon).
Egui can be used anywhere you can draw textured triangles, which means you can easily integrate it into your game engine of choice. egui aims to be the easiest-to-use Rust GUI libary, and the simplest way to make a web app in Rust.
egui can be used anywhere you can draw textured triangles, which means you can easily integrate it into your game engine of choice.
Sections: Sections:
* [Quick start](#quick-start) * [Quick start](#quick-start)
* [Demo](#demo) * [Demo](#demo)
* [Goals](#goals) * [Goals](#goals)
* [Who is Egui for?](#who-is-egui-for) * [Who is egui for?](#who-is-egui-for)
* [State / features](#state) * [State / features](#state)
* [How it works](#how-it-works) * [How it works](#how-it-works)
* [Integrations](#integrations) * [Integrations](#integrations)
@ -29,20 +30,20 @@ Sections:
If you just want to write a GUI application in Rust (for the web or for native), go to <https://github.com/emilk/egui_template/> and follow the instructions there! If you just want to write a GUI application in Rust (for the web or for native), go to <https://github.com/emilk/egui_template/> and follow the instructions there!
If you want to integrate Egui into an existing engine, go to the [Integrations](#integrations) section. If you want to integrate egui into an existing engine, go to the [Integrations](#integrations) section.
If you have questions, use [Discussions](https://github.com/emilk/egui/discussions). If you want to contribute to Egui, please read the [Contributing Guidelines](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md) If you have questions, use [Discussions](https://github.com/emilk/egui/discussions). If you want to contribute to egui, please read the [Contributing Guidelines](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
## Demo ## Demo
[Click to run Egui web demo](https://emilk.github.io/egui/index.html). [Click to run egui web demo](https://emilk.github.io/egui/index.html).
[Hobogo](https://emilk.github.io/hobogo/index.html): A small game I made using Egui. Source: <https://github.com/emilk/hobogo> [Hobogo](https://emilk.github.io/hobogo/index.html): A small game I made using egui. Source: <https://github.com/emilk/hobogo>
### Example ### Example
``` rust ``` rust
ui.heading("My Egui Application"); ui.heading("My egui Application");
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.label("Your name: "); ui.label("Your name: ");
ui.text_edit_singleline(&mut name); ui.text_edit_singleline(&mut name);
@ -54,7 +55,7 @@ if ui.button("Click each year").clicked {
ui.label(format!("Hello '{}', age {}", name, age)); ui.label(format!("Hello '{}', age {}", name, age));
``` ```
<img src="media/demo-2021-01-02.png" width="60%"> <img src="media/demo-2021-01-17.gif">
## Goals ## Goals
@ -66,15 +67,15 @@ ui.label(format!("Hello '{}', age {}", name, age));
* A simple 2D graphics API for custom painting * A simple 2D graphics API for custom painting
* No callbacks * No callbacks
* Pure immediate mode * Pure immediate mode
* Extensible: [easy to write your own widgets for Egui](https://github.com/emilk/egui/blob/master/egui_demo_lib/src/apps/demo/toggle_switch.rs) * Extensible: [easy to write your own widgets for egui](https://github.com/emilk/egui/blob/master/egui_demo_lib/src/apps/demo/toggle_switch.rs)
* Modular: You should be able to use small parts of Egui and combine them in new ways * Modular: You should be able to use small parts of egui and combine them in new ways
* Safe: there is no `unsafe` code in Egui * Safe: there is no `unsafe` code in egui
* Minimal dependencies * Minimal dependencies
* [`rusttype`](https://crates.io/crates/rusttype), [`atomic_refcell`](https://crates.io/crates/atomic_refcell) and [`ahash`](https://crates.io/crates/ahash). * [`rusttype`](https://crates.io/crates/rusttype), [`atomic_refcell`](https://crates.io/crates/atomic_refcell) and [`ahash`](https://crates.io/crates/ahash).
Egui is *not* a framework. Egui is a library you call into, not an environment you program for. egui is *not* a framework. egui is a library you call into, not an environment you program for.
**NOTE**: Egui does not claim to have reached all these goals yet! Egui is still work in progress. **NOTE**: egui does not claim to have reached all these goals yet! egui is still work in progress.
### Non-goals ### Non-goals
@ -82,37 +83,37 @@ Egui is *not* a framework. Egui is a library you call into, not an environment y
* Native looking interface * Native looking interface
* Advanced and flexible layouts (that's fundamentally incompatible with immediate mode) * Advanced and flexible layouts (that's fundamentally incompatible with immediate mode)
## Who is Egui for? ## Who is egui for?
Egui aims to be the best choice when you want a simple way to create a GUI, or you want to add a GUI to a game engine. egui aims to be the best choice when you want a simple way to create a GUI, or you want to add a GUI to a game engine.
If you are not using Rust, Egui is not for you. If you want a GUI that looks native, Egui is not for you. If you want something that doesn't break when you upgrade it, Egui isn't for you (yet). If you are not using Rust, egui is not for you. If you want a GUI that looks native, egui is not for you. If you want something that doesn't break when you upgrade it, egui isn't for you (yet).
But if you are writing something interactive in Rust that needs a simple GUI, Egui may be for you. But if you are writing something interactive in Rust that needs a simple GUI, egui may be for you.
### Egui vs Dear ImGui ### egui vs Dear ImGui
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, which a lot more features and polish compared to Egui. However, Egui provides some benefits for Rust users: 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, which a lot more features and polish compared to egui. However, egui provides some benefits for Rust users:
* Egui is pure Rust * egui is pure Rust
* Egui is easily compiled to WASM * egui is easily compiled to WASM
* Egui lets you use native Rust String types (`imgui-rs` forces you to use annoying macros and wrappers for zero-terminated strings) * egui lets you use native Rust String types (`imgui-rs` forces you to use annoying macros and wrappers for zero-terminated strings)
* [Writing your own widgets in Egui is simple](https://github.com/emilk/egui/blob/master/egui_demo_lib/src/apps/demo/toggle_switch.rs) * [Writing your own widgets in egui is simple](https://github.com/emilk/egui/blob/master/egui_demo_lib/src/apps/demo/toggle_switch.rs)
Egui also tries to improve your experience in other small ways: egui also tries to improve your experience in other small ways:
* Windows are automatically sized based on their contents * Windows are automatically sized based on their contents
* Windows are automatically positioned to not overlap with each other * Windows are automatically positioned to not overlap with each other
* Some subtle animations make Egui come alive * Some subtle animations make egui come alive
So in summary: So in summary:
* Egui: pure Rust, new, exciting, work in progress * egui: pure Rust, new, exciting, work in progress
* Dear ImGui: feature rich, well tested, cumbersome Rust integration * Dear ImGui: feature rich, well tested, cumbersome Rust integration
## State ## State
Egui is in active development. It works well for what it does, but it lacks many features and the interfaces are still in flux. New releases will have breaking changes. egui is in active development. It works well for what it does, but it lacks many features and the interfaces are still in flux. New releases will have breaking changes.
### Features ### Features
@ -125,31 +126,31 @@ Egui is in active development. It works well for what it does, but it lacks many
* Tooltips on hover * Tooltips on hover
* More * More
<img src="media/widget_gallery.png" width="60%"> <img src="media/widget_gallery.gif" width="50%">
## How it works ## How it works
Loop: Loop:
* Gather input (mouse, touches, keyboard, screen size, etc) and give it to Egui * Gather input (mouse, touches, keyboard, screen size, etc) and give it to egui
* Run application code (Immediate Mode GUI) * Run application code (Immediate Mode GUI)
* Tell Egui to tessellate the frame graphics to a triangle mesh * Tell egui to tessellate the frame graphics to a triangle mesh
* Render the triangle mesh with your favorite graphics API (see [OpenGL example](https://github.com/emilk/egui/blob/master/egui_glium/src/painter.rs)) * Render the triangle mesh with your favorite graphics API (see [OpenGL example](https://github.com/emilk/egui/blob/master/egui_glium/src/painter.rs))
## Integrations ## Integrations
Egui is build to be easy to integrate into any existing game engine or platform you are working on. egui is build to be easy to integrate into any existing game engine or platform you are working on.
Egui itself doesn't know or care on what OS it is running or how to render things to the screen - that is the job of the Egui integration. egui itself doesn't know or care on what OS it is running or how to render things to the screen - that is the job of the egui integration.
The integration needs to do two things: The integration needs to do two things:
* **IO**: Supply Egui with input (mouse position, keyboard presses, ...) and handle Egui output (cursor changes, copy-paste integration, ...). * **IO**: Supply egui with input (mouse position, keyboard presses, ...) and handle egui output (cursor changes, copy-paste integration, ...).
* **Painting**: Render the textured triangles that Egui outputs. * **Painting**: Render the textured triangles that egui outputs.
### Official ### Official
I maintain two official Egui integrations: I maintain two official egui integrations:
* [egui_web](https://crates.io/crates/egui_web) for making a web app. Compiles to WASM, renders with WebGL. [Click to run the Egui demo](https://emilk.github.io/egui/index.html). * [egui_web](https://crates.io/crates/egui_web) for making a web app. Compiles to WASM, renders with WebGL. [Click to run the egui demo](https://emilk.github.io/egui/index.html).
* [egui_glium](https://crates.io/crates/egui_glium) for compiling native apps with [Glium](https://github.com/glium/glium). * [egui_glium](https://crates.io/crates/egui_glium) for compiling native apps with [Glium](https://github.com/glium/glium).
The same code can be compiled to a native app or a web app. The same code can be compiled to a native app or a web app.
@ -161,9 +162,9 @@ The same code can be compiled to a native app or a web app.
* Alternative: [egui_winit_wgpu](https://github.com/Gonkalbell/egui_winit_wgpu) (not available to crates.io) * Alternative: [egui_winit_wgpu](https://github.com/Gonkalbell/egui_winit_wgpu) (not available to crates.io)
* [egui_sdl2_gl](https://crates.io/crates/egui_sdl2_gl) for [SDL2](https://crates.io/crates/sdl2) * [egui_sdl2_gl](https://crates.io/crates/egui_sdl2_gl) for [SDL2](https://crates.io/crates/sdl2)
* [emigui-miniquad](https://github.com/not-fl3/emigui-miniquad): backend for [Miniquad](https://github.com/not-fl3/miniquad). [Web demo](https://not-fl3.github.io/miniquad-samples/emigui.html) and [demo source](https://github.com/not-fl3/good-web-game/blob/master/examples/emigui.rs). * [emigui-miniquad](https://github.com/not-fl3/emigui-miniquad): backend for [Miniquad](https://github.com/not-fl3/miniquad). [Web demo](https://not-fl3.github.io/miniquad-samples/emigui.html) and [demo source](https://github.com/not-fl3/good-web-game/blob/master/examples/emigui.rs).
* [egui_winit_platform](https://github.com/hasenbanck/egui_winit_platform) provides bindings between [winit](https://crates.io/crates/winit) and Egui. It only provides the first half of an Egui integration (IO). Painting can be done with e.g. [egui_wgpu_backend](https://crates.io/crates/egui_wgpu_backend). * [egui_winit_platform](https://github.com/hasenbanck/egui_winit_platform) provides bindings between [winit](https://crates.io/crates/winit) and egui. It only provides the first half of an egui integration (IO). Painting can be done with e.g. [egui_wgpu_backend](https://crates.io/crates/egui_wgpu_backend).
### Writing your own Egui integration ### Writing your own egui integration
You need to collect [`egui::RawInput`](https://docs.rs/egui/latest/egui/struct.RawInput.html), paint [`egui::PaintJobs`](https://docs.rs/egui/latest/egui/paint/tessellator/type.PaintJobs.html) and handle [`egui::Output`](https://docs.rs/egui/latest/egui/struct.Output.html). The basic structure is this: You need to collect [`egui::RawInput`](https://docs.rs/egui/latest/egui/struct.RawInput.html), paint [`egui::PaintJobs`](https://docs.rs/egui/latest/egui/paint/tessellator/type.PaintJobs.html) and handle [`egui::Output`](https://docs.rs/egui/latest/egui/struct.Output.html). The basic structure is this:
@ -193,12 +194,12 @@ For a reference OpenGL backend, see [the `egui_glium` painter](https://github.co
#### My text is blurry #### My text is blurry
* Make sure you set the proper `pixels_per_point` in the input to Egui. * Make sure you set the proper `pixels_per_point` in the input to egui.
* Make sure the texture sampler is not off by half a pixel. Try nearest-neighbor sampler to check. * Make sure the texture sampler is not off by half a pixel. Try nearest-neighbor sampler to check.
#### My windows are too transparent or too dark #### My windows are too transparent or too dark
* Egui uses premultiplied alpha, so make sure your blending function is `(ONE, ONE_MINUS_SRC_ALPHA)`. * egui uses premultiplied alpha, so make sure your blending function is `(ONE, ONE_MINUS_SRC_ALPHA)`.
* Make sure your texture sampler is clamped (`GL_CLAMP_TO_EDGE`). * Make sure your texture sampler is clamped (`GL_CLAMP_TO_EDGE`).
* Use an sRGBA-aware texture if available (e.g. `GL_SRGB8_ALPHA8`). * Use an sRGBA-aware texture if available (e.g. `GL_SRGB8_ALPHA8`).
* Otherwise: remember to decode gamma in the fragment shader. * Otherwise: remember to decode gamma in the fragment shader.
@ -216,9 +217,9 @@ All coordinates are in locial "points" which may consist of many physical pixels
All colors have premultiplied alpha. All colors have premultiplied alpha.
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");`. 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");`.
Instead of using matching `begin/end` style function calls (which can be error prone) Egui prefers to use `FnOnce` closures passed to a wrapping function. Lambdas are a bit ugly though, so I'd like to find a nicer solution to this. Instead of using matching `begin/end` style function calls (which can be error prone) egui prefers to use `FnOnce` closures passed to a wrapping function. Lambdas are a bit ugly though, so I'd like to find a nicer solution to this.
### Inspiration ### Inspiration
@ -226,15 +227,15 @@ The one and only [Dear ImGui](https://github.com/ocornut/imgui) is a great Immed
### Name ### Name
The name of the library and the project is "Egui" and pronounced as "e-gooey". The name of the library and the project is "egui" and pronounced as "e-gooey".
The library was originally called "Emigui", but was renamed to Egui in 2020. The library was originally called "Emigui", but was renamed to "egui" in 2020.
### Credits / Licenses ### Credits / Licenses
Egui author: Emil Ernerfeldt egui author: Emil Ernerfeldt
Egui is under MIT OR Apache-2.0 license. egui is under MIT OR Apache-2.0 license.
Fonts: Fonts:

View file

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<head> <head>
<title>Egui An experimental immediate mode GUI written in Rust</title> <title>egui An experimental immediate mode GUI written in Rust</title>
<style> <style>
html { html {
/* Remove touch delay: */ /* Remove touch delay: */
@ -76,4 +76,4 @@
</html> </html>
<!-- Powered by Egui: https://github.com/emilk/egui/ --> <!-- Powered by egui: https://github.com/emilk/egui/ -->

View file

@ -2,7 +2,7 @@
name = "eframe" name = "eframe"
version = "0.7.0" version = "0.7.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
description = "Egui Framework - write GUI apps that compiles to web and/or natively" description = "egui framework - write GUI apps that compiles to web and/or natively"
edition = "2018" edition = "2018"
homepage = "https://github.com/emilk/egui" homepage = "https://github.com/emilk/egui"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"

View file

@ -1,6 +1,6 @@
# Egui Framework # egui framework
This aims to be the entry-level crate if you want to write an Egui App. This aims to be the entry-level crate if you want to write an egui app.
`eframe` calls into your code (it is a framework) and supports web apps (via [`egui_web`](https://crates.io/crates/egui_web)) and native apps (via [`egui_glium`](https://crates.io/crates/egui_glium)). `eframe` calls into your code (it is a framework) and supports web apps (via [`egui_web`](https://crates.io/crates/egui_web)) and native apps (via [`egui_glium`](https://crates.io/crates/egui_glium)).

View file

@ -16,14 +16,14 @@ impl Default for MyApp {
impl epi::App for MyApp { impl epi::App for MyApp {
fn name(&self) -> &str { fn name(&self) -> &str {
"My Egui App" "My egui App"
} }
fn update(&mut self, ctx: &egui::CtxRef, frame: &mut epi::Frame<'_>) { fn update(&mut self, ctx: &egui::CtxRef, frame: &mut epi::Frame<'_>) {
let Self { name, age } = self; let Self { name, age } = self;
egui::CentralPanel::default().show(ctx, |ui| { egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("My Egui Application"); ui.heading("My egui Application");
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.label("Your name: "); ui.label("Your name: ");
ui.text_edit_singleline(name); ui.text_edit_singleline(name);

View file

@ -1,7 +1,7 @@
//! eframe - the Egui Framework crate //! eframe - the egui framework crate
//! //!
//! If you are planning to write an app for web or native, //! If you are planning to write an app for web or native,
//! and are happy with just using Egui for all visuals, //! and are happy with just using egui for all visuals,
//! Then `eframe` is for you! //! Then `eframe` is for you!
//! //!
//! To get started, look at <https://github.com/emilk/egui_template>. //! To get started, look at <https://github.com/emilk/egui_template>.

View file

@ -1,2 +1,2 @@
# GUI implementation # GUI implementation
This is the core library crate Egui. It is fully platform independent without any backend. You give the Egui library input each frame (mouse pos etc), and it outputs a triangle mesh for you to paint. This is the core library crate egui. It is fully platform independent without any backend. You give the egui library input each frame (mouse pos etc), and it outputs a triangle mesh for you to paint.

View file

@ -82,7 +82,7 @@ impl FrameState {
} }
/// How much space is still available after panels has been added. /// How much space is still available after panels has been added.
/// This is the "background" area, what Egui doesn't cover with panels (but may cover with windows). /// This is the "background" area, what egui doesn't cover with panels (but may cover with windows).
/// This is also the area to which windows are constrained. /// This is also the area to which windows are constrained.
pub fn available_rect(&self) -> Rect { pub fn available_rect(&self) -> Rect {
debug_assert!( debug_assert!(
@ -375,7 +375,7 @@ impl CtxRef {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/// This is the first thing you need when working with Egui. Create using [`CtxRef`]. /// This is the first thing you need when working with egui. Create using [`CtxRef`].
/// ///
/// Contains the [`InputState`], [`Memory`], [`Output`], and more. /// Contains the [`InputState`], [`Memory`], [`Output`], and more.
// TODO: too many mutexes. Maybe put it all behind one Mutex instead. // TODO: too many mutexes. Maybe put it all behind one Mutex instead.
@ -425,7 +425,7 @@ impl Context {
} }
/// How much space is still available after panels has been added. /// How much space is still available after panels has been added.
/// This is the "background" area, what Egui doesn't cover with panels (but may cover with windows). /// This is the "background" area, what egui doesn't cover with panels (but may cover with windows).
/// This is also the area to which windows are constrained. /// This is also the area to which windows are constrained.
pub fn available_rect(&self) -> Rect { pub fn available_rect(&self) -> Rect {
self.frame_state.lock().available_rect() self.frame_state.lock().available_rect()
@ -469,7 +469,7 @@ impl Context {
.expect("No fonts available until first call to CtxRef::begin_frame()") .expect("No fonts available until first call to CtxRef::begin_frame()")
} }
/// The Egui texture, containing font characters etc. /// The egui texture, containing font characters etc.
/// Not valid until first call to [`CtxRef::begin_frame()`]. /// Not valid until first call to [`CtxRef::begin_frame()`].
/// That's because since we don't know the proper `pixels_per_point` until then. /// That's because since we don't know the proper `pixels_per_point` until then.
pub fn texture(&self) -> Arc<paint::Texture> { pub fn texture(&self) -> Arc<paint::Texture> {
@ -641,14 +641,14 @@ impl Context {
} }
/// How much space is used by panels and windows. /// How much space is used by panels and windows.
/// You can shrink your Egui area to this size and still fit all Egui components. /// You can shrink your egui area to this size and still fit all egui components.
pub fn used_size(&self) -> Vec2 { pub fn used_size(&self) -> Vec2 {
self.used_rect().max - Pos2::new(0.0, 0.0) self.used_rect().max - Pos2::new(0.0, 0.0)
} }
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
/// Is the mouse over any Egui area? /// Is the mouse over any egui area?
pub fn is_mouse_over_area(&self) -> bool { pub fn is_mouse_over_area(&self) -> bool {
if let Some(mouse_pos) = self.input.mouse.pos { if let Some(mouse_pos) = self.input.mouse.pos {
if let Some(layer) = self.layer_id_at(mouse_pos) { if let Some(layer) = self.layer_id_at(mouse_pos) {
@ -665,22 +665,22 @@ impl Context {
} }
} }
/// True if Egui is currently interested in the mouse. /// True if egui is currently interested in the mouse.
/// Could be the mouse is hovering over a [`Window`] or the user is dragging a widget. /// Could be the mouse is hovering over a [`Window`] or the user is dragging a widget.
/// If `false`, the mouse is outside of any Egui area and so /// If `false`, the mouse is outside of any egui area and so
/// you may be interested in what it is doing (e.g. controlling your game). /// you may be interested in what it is doing (e.g. controlling your game).
/// Returns `false` if a drag started outside of Egui and then moved over an Egui area. /// Returns `false` if a drag started outside of egui and then moved over an egui area.
pub fn wants_mouse_input(&self) -> bool { pub fn wants_mouse_input(&self) -> bool {
self.is_using_mouse() || (self.is_mouse_over_area() && !self.input().mouse.down) self.is_using_mouse() || (self.is_mouse_over_area() && !self.input().mouse.down)
} }
/// Is Egui currently using the mouse position (e.g. dragging a slider). /// Is egui currently using the mouse position (e.g. dragging a slider).
/// NOTE: this will return `false` if the mouse is just hovering over an Egui area. /// NOTE: this will return `false` if the mouse is just hovering over an egui area.
pub fn is_using_mouse(&self) -> bool { pub fn is_using_mouse(&self) -> bool {
self.memory().interaction.is_using_mouse() self.memory().interaction.is_using_mouse()
} }
/// If `true`, Egui is currently listening on text input (e.g. typing text in a [`TextEdit`]). /// If `true`, egui is currently listening on text input (e.g. typing text in a [`TextEdit`]).
pub fn wants_keyboard_input(&self) -> bool { pub fn wants_keyboard_input(&self) -> bool {
self.memory().interaction.kb_focus_id.is_some() self.memory().interaction.kb_focus_id.is_some()
} }
@ -767,14 +767,14 @@ impl Context {
use crate::containers::*; use crate::containers::*;
ui.label(format!("Is using mouse: {}", self.is_using_mouse())) ui.label(format!("Is using mouse: {}", self.is_using_mouse()))
.on_hover_text("Is Egui currently using the mouse actively (e.g. dragging a slider)?"); .on_hover_text("Is egui currently using the mouse actively (e.g. dragging a slider)?");
ui.label(format!("Wants mouse input: {}", self.wants_mouse_input())) ui.label(format!("Wants mouse input: {}", self.wants_mouse_input()))
.on_hover_text("Is Egui currently interested in the location of the mouse (either because it is in use, or because it is hovering over a window)."); .on_hover_text("Is egui currently interested in the location of the mouse (either because it is in use, or because it is hovering over a window).");
ui.label(format!( ui.label(format!(
"Wants keyboard input: {}", "Wants keyboard input: {}",
self.wants_keyboard_input() self.wants_keyboard_input()
)) ))
.on_hover_text("Is Egui currently listening for text input"); .on_hover_text("Is egui currently listening for text input");
ui.advance_cursor(16.0); ui.advance_cursor(16.0);
CollapsingHeader::new("📥 Input") CollapsingHeader::new("📥 Input")
@ -791,7 +791,7 @@ impl Context {
pub fn memory_ui(&self, ui: &mut crate::Ui) { pub fn memory_ui(&self, ui: &mut crate::Ui) {
if ui if ui
.button("Reset all") .button("Reset all")
.on_hover_text("Reset all Egui state") .on_hover_text("Reset all egui state")
.clicked .clicked
{ {
*self.memory() = Default::default(); *self.memory() = Default::default();

View file

@ -1,8 +1,8 @@
//! The input needed by Egui. //! The input needed by egui.
use crate::math::*; use crate::math::*;
/// What the integrations provides to Egui at the start of each frame. /// What the integrations provides to egui at the start of each frame.
/// ///
/// Set the values that make sense, leave the rest at their `Default::default()`. /// Set the values that make sense, leave the rest at their `Default::default()`.
/// ///
@ -10,7 +10,7 @@ use crate::math::*;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct RawInput { pub struct RawInput {
/// Is the button currently down? /// Is the button currently down?
/// NOTE: Egui currently only supports the primary mouse button. /// NOTE: egui currently only supports the primary mouse button.
pub mouse_down: bool, pub mouse_down: bool,
/// Current position of the mouse in points. /// Current position of the mouse in points.
@ -22,12 +22,12 @@ pub struct RawInput {
#[deprecated = "Use screen_rect instead: `Some(Rect::from_pos_size(Default::default(), vec2(window_width, window_height)))`"] #[deprecated = "Use screen_rect instead: `Some(Rect::from_pos_size(Default::default(), vec2(window_width, window_height)))`"]
pub screen_size: Vec2, pub screen_size: Vec2,
/// Position and size of the area that Egui should use. /// Position and size of the area that egui should use.
/// Usually you would set this to /// Usually you would set this to
/// ///
/// `Some(Rect::from_pos_size(Default::default(), vec2(window_width, window_height)))`. /// `Some(Rect::from_pos_size(Default::default(), vec2(window_width, window_height)))`.
/// ///
/// but you could also constrain Egui to some smaller portion of your window if you like. /// but you could also constrain egui to some smaller portion of your window if you like.
/// ///
/// `None` will be treated as "same as last frame", with the default being a very big area. /// `None` will be treated as "same as last frame", with the default being a very big area.
pub screen_rect: Option<Rect>, pub screen_rect: Option<Rect>,
@ -37,7 +37,7 @@ pub struct RawInput {
pub pixels_per_point: Option<f32>, pub pixels_per_point: Option<f32>,
/// Monotonically increasing time, in seconds. Relative to whatever. Used for animations. /// Monotonically increasing time, in seconds. Relative to whatever. Used for animations.
/// If `None` is provided, Egui will assume a time delta of `predicted_dt` (default 1/60 seconds). /// If `None` is provided, egui will assume a time delta of `predicted_dt` (default 1/60 seconds).
pub time: Option<f64>, pub time: Option<f64>,
/// Should be set to the expected time between frames when painting at vsync speeds. /// Should be set to the expected time between frames when painting at vsync speeds.
@ -91,7 +91,7 @@ impl RawInput {
/// An input event generated by the integration. /// An input event generated by the integration.
/// ///
/// This only covers events that Egui cares about. /// This only covers events that egui cares about.
#[derive(Clone, Debug, Eq, PartialEq)] #[derive(Clone, Debug, Eq, PartialEq)]
pub enum Event { pub enum Event {
/// The integration detected a "copy" event (e.g. Cmd+C). /// The integration detected a "copy" event (e.g. Cmd+C).
@ -109,7 +109,7 @@ pub enum Event {
}, },
} }
/// State of the modifier keys. These must be fed to Egui. /// State of the modifier keys. These must be fed to egui.
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct Modifiers { pub struct Modifiers {
/// Either of the alt keys are down (option ⌥ on Mac). /// Either of the alt keys are down (option ⌥ on Mac).
@ -123,14 +123,14 @@ pub struct Modifiers {
pub mac_cmd: bool, pub mac_cmd: bool,
/// On Windows and Linux, set this to the same value as `ctrl`. /// On Windows and Linux, set this to the same value as `ctrl`.
/// On Mac, this should be set whenever one of the ⌘ Command keys are down (same as `mac_cmd`). /// On Mac, this should be set whenever one of the ⌘ Command keys are down (same as `mac_cmd`).
/// This is so that Egui can, for instance, select all text by checking for `command + A` /// This is so that egui can, for instance, select all text by checking for `command + A`
/// and it will work on both Mac and Windows. /// and it will work on both Mac and Windows.
pub command: bool, pub command: bool,
} }
/// Keyboard keys. /// Keyboard keys.
/// ///
/// Includes all keys Egui is interested in (such as `Home` and `End`) /// Includes all keys egui is interested in (such as `Home` and `End`)
/// plus a few that are useful for detecting keyboard shortcuts. /// plus a few that are useful for detecting keyboard shortcuts.
/// ///
/// Many keys are omitted because they are not always physical keys (depending on keyboard language), e.g. `;` and `§`, /// Many keys are omitted because they are not always physical keys (depending on keyboard language), e.g. `;` and `§`,

View file

@ -1,6 +1,6 @@
//! All the data egui returns to the backend at the end of each frame. //! All the data egui returns to the backend at the end of each frame.
/// What Egui emits each frame. /// What egui emits each frame.
/// The backend should use this. /// The backend should use this.
#[derive(Clone, Default)] #[derive(Clone, Default)]
pub struct Output { pub struct Output {
@ -13,18 +13,18 @@ pub struct Output {
/// Response to [`crate::Event::Copy`] or [`crate::Event::Cut`]. Ignore if empty. /// Response to [`crate::Event::Copy`] or [`crate::Event::Cut`]. Ignore if empty.
pub copied_text: String, pub copied_text: String,
/// If `true`, Egui is requesting immediate repaint (i.e. on the next frame). /// If `true`, egui is requesting immediate repaint (i.e. on the next frame).
/// ///
/// This happens for instance when there is an animation, or if a user has called `Context::request_repaint()`. /// This happens for instance when there is an animation, or if a user has called `Context::request_repaint()`.
/// ///
/// As an Egui user: don't set this value directly. /// As an egui user: don't set this value directly.
/// Call `Context::request_repaint()` instead and it will do so for you. /// Call `Context::request_repaint()` instead and it will do so for you.
pub needs_repaint: bool, pub needs_repaint: bool,
} }
/// A mouse cursor icon. /// A mouse cursor icon.
/// ///
/// Egui emits a [`CursorIcon`] in [`Output`] each frame as a request to the integration. /// egui emits a [`CursorIcon`] in [`Output`] each frame as a request to the integration.
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub enum CursorIcon { pub enum CursorIcon {
Default, Default,

View file

@ -2,7 +2,7 @@
use std::hash::Hash; use std::hash::Hash;
/// Egui tracks widgets frame-to-frame using `Id`s. /// egui tracks widgets frame-to-frame using `Id`s.
/// ///
/// For instance, if you start dragging a slider one frame, egui stores /// For instance, if you start dragging a slider one frame, egui stores
/// the sliders `Id` as the current active id so that next frame when /// the sliders `Id` as the current active id so that next frame when

View file

@ -10,7 +10,7 @@ const MAX_CLICK_DIST: f32 = 6.0; // TODO: move to settings
/// The new mouse press must come within this many seconds from previous mouse release /// The new mouse press must come within this many seconds from previous mouse release
const MAX_CLICK_DELAY: f64 = 0.3; // TODO: move to settings const MAX_CLICK_DELAY: f64 = 0.3; // TODO: move to settings
/// Input state that Egui updates each frame. /// Input state that egui updates each frame.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct InputState { pub struct InputState {
/// The raw input we got this frame /// The raw input we got this frame
@ -21,7 +21,7 @@ pub struct InputState {
/// How many pixels the user scrolled /// How many pixels the user scrolled
pub scroll_delta: Vec2, pub scroll_delta: Vec2,
/// Position and size of the Egui area. /// Position and size of the egui area.
pub screen_rect: Rect, pub screen_rect: Rect,
/// Also known as device pixel ratio, > 1 for HDPI screens. /// Also known as device pixel ratio, > 1 for HDPI screens.

View file

@ -77,7 +77,7 @@ impl Widget for &epaint::stats::PaintStats {
fn ui(self, ui: &mut Ui) -> Response { fn ui(self, ui: &mut Ui) -> Response {
ui.vertical(|ui| { ui.vertical(|ui| {
ui.label( ui.label(
"Egui generates intermediate level shapes like circles and text. \ "egui generates intermediate level shapes like circles and text. \
These are later tessellated into triangles.", These are later tessellated into triangles.",
); );
ui.advance_cursor(10.0); ui.advance_cursor(10.0);

View file

@ -1,9 +1,9 @@
//! Egui core library //! egui core library
//! //!
//! To quickly get started with Egui, you can take a look at [`egui_template`](https://github.com/emilk/egui_template) //! To quickly get started with egui, you can take a look at [`egui_template`](https://github.com/emilk/egui_template)
//! which uses [`eframe`](https://docs.rs/eframe). //! which uses [`eframe`](https://docs.rs/eframe).
//! //!
//! To create a GUI using Egui you first need a [`CtxRef`] (by convention referred to by `ctx`). //! To create a GUI using egui you first need a [`CtxRef`] (by convention referred to by `ctx`).
//! Use one of [`SidePanel`], [`TopPanel`], [`CentralPanel`], [`Window`] or [`Area`] to //! Use one of [`SidePanel`], [`TopPanel`], [`CentralPanel`], [`Window`] or [`Area`] to
//! get access to an [`Ui`] where you can put widgets. For example: //! get access to an [`Ui`] where you can put widgets. For example:
//! //!
@ -16,7 +16,7 @@
//! ``` //! ```
//! //!
//! //!
//! To write your own integration for Egui you need to do this: //! To write your own integration for egui you need to do this:
//! //!
//! ``` ignore //! ``` ignore
//! let mut egui_ctx = egui::CtxRef::default(); //! let mut egui_ctx = egui::CtxRef::default();
@ -150,7 +150,7 @@ pub fn warn_if_debug_build(ui: &mut crate::Ui) {
.small() .small()
.text_color(crate::Color32::RED), .text_color(crate::Color32::RED),
) )
.on_hover_text("Egui was compiled with debug assertions enabled."); .on_hover_text("egui was compiled with debug assertions enabled.");
} }
} }

View file

@ -11,7 +11,7 @@ use crate::{
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/// The data that Egui persists between frames. /// The data that egui persists between frames.
/// ///
/// This includes window positions and sizes, /// This includes window positions and sizes,
/// how far the user has scrolled in a `ScrollArea` etc. /// how far the user has scrolled in a `ScrollArea` etc.

View file

@ -1,4 +1,4 @@
//! Egui theme (spacing, colors, etc). //! egui theme (spacing, colors, etc).
#![allow(clippy::if_same_then_else)] #![allow(clippy::if_same_then_else)]

View file

@ -1,4 +1,4 @@
//! Miscellaneous tools used by the rest of Egui. //! Miscellaneous tools used by the rest of egui.
pub(crate) mod cache; pub(crate) mod cache;
mod history; mod history;

View file

@ -2,7 +2,7 @@
name = "egui_demo_lib" name = "egui_demo_lib"
version = "0.7.0" version = "0.7.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
description = "Example library for Egui" description = "Example library for egui"
edition = "2018" edition = "2018"
homepage = "https://github.com/emilk/egui" homepage = "https://github.com/emilk/egui"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"

View file

@ -1,8 +1,8 @@
# Egui Demo Library # egui demo library
This crate contains example code for Egui. this crate contains example code for egui.
It is in a separate crate for two reasons: it is in a separate crate for two reasons:
* To ensure it only uses the public `egui` API. * to ensure it only uses the public `egui` api.
* To remove the amount of code in `egui` proper. * to remove the amount of code in `egui` proper.

View file

@ -57,7 +57,7 @@ impl ColorTest {
ui: &mut Ui, ui: &mut Ui,
mut tex_allocator: &mut Option<&mut dyn epi::TextureAllocator>, mut tex_allocator: &mut Option<&mut dyn epi::TextureAllocator>,
) { ) {
ui.label("This is made to test that the Egui painter backend is set up correctly, so that all colors are interpolated and blended in linear space with premultiplied alpha."); ui.label("This is made to test that the egui painter backend is set up correctly, so that all colors are interpolated and blended in linear space with premultiplied alpha.");
ui.label("If everything is set up correctly, all groups of gradients will look uniform"); ui.label("If everything is set up correctly, all groups of gradients will look uniform");
ui.checkbox(&mut self.vertex_gradients, "Vertex gradients"); ui.checkbox(&mut self.vertex_gradients, "Vertex gradients");

View file

@ -1,4 +1,4 @@
/// Demonstrates how to make an app using Egui. /// Demonstrates how to make an app using egui.
/// ///
/// Implements `epi::App` so it can be used with /// Implements `epi::App` so it can be used with
/// [`egui_glium`](https://crates.io/crates/egui_glium) and [`egui_web`](https://crates.io/crates/egui_web). /// [`egui_glium`](https://crates.io/crates/egui_glium) and [`egui_web`](https://crates.io/crates/egui_web).
@ -11,7 +11,7 @@ pub struct DemoApp {
impl epi::App for DemoApp { impl epi::App for DemoApp {
fn name(&self) -> &str { fn name(&self) -> &str {
"Egui Demo" "Demos"
} }
#[cfg(feature = "persistence")] #[cfg(feature = "persistence")]

View file

@ -132,7 +132,7 @@ impl ColorWidgets {
fn ui(&mut self, ui: &mut Ui) { fn ui(&mut self, ui: &mut Ui) {
egui::reset_button(ui, self); egui::reset_button(ui, self);
ui.label("Egui lets you edit colors stored as either sRGBA or linear RGBA and with or without premultiplied alpha"); ui.label("egui lets you edit colors stored as either sRGBA or linear RGBA and with or without premultiplied alpha");
let Self { let Self {
srgba_unmul, srgba_unmul,

View file

@ -64,17 +64,17 @@ impl DemoWindows {
/// `sidebar_ui` can be used to optionally show some things in the sidebar /// `sidebar_ui` can be used to optionally show some things in the sidebar
pub fn ui(&mut self, ctx: &CtxRef) { pub fn ui(&mut self, ctx: &CtxRef) {
egui::SidePanel::left("side_panel", 200.0).show(ctx, |ui| { egui::SidePanel::left("side_panel", 200.0).show(ctx, |ui| {
ui.heading("Egui Demo"); ui.heading("egui demos");
ui.separator(); ui.separator();
ScrollArea::auto_sized().show(ui, |ui| { ScrollArea::auto_sized().show(ui, |ui| {
ui.label("Egui is an immediate mode GUI library written in Rust."); ui.label("egui is an immediate mode GUI library written in Rust.");
ui.add( ui.add(
egui::Hyperlink::new("https://github.com/emilk/egui").text("Egui home page"), egui::Hyperlink::new("https://github.com/emilk/egui").text("egui home page"),
); );
ui.label("Egui can be run on the web, or natively on 🐧"); ui.label("egui can be run on the web, or natively on 🐧");
ui.separator(); ui.separator();
@ -237,7 +237,7 @@ impl OpenWindows {
memory, memory,
resize, resize,
} = self; } = self;
ui.label("Egui:"); ui.label("egui:");
ui.checkbox(settings, "🔧 Settings"); ui.checkbox(settings, "🔧 Settings");
ui.checkbox(inspection, "🔍 Inspection"); ui.checkbox(inspection, "🔍 Inspection");
ui.checkbox(memory, "📝 Memory"); ui.checkbox(memory, "📝 Memory");
@ -259,7 +259,7 @@ fn show_menu_bar(ui: &mut Ui) {
ui.ctx().memory().reset_areas(); ui.ctx().memory().reset_areas();
} }
if ui if ui
.button("Clear Egui memory") .button("Clear egui memory")
.on_hover_text("Forget scroll, collapsing headers etc") .on_hover_text("Forget scroll, collapsing headers etc")
.clicked .clicked
{ {

View file

@ -107,7 +107,7 @@ impl super::Demo for DragAndDropDemo {
impl super::View for DragAndDropDemo { impl super::View for DragAndDropDemo {
fn ui(&mut self, ui: &mut Ui) { fn ui(&mut self, ui: &mut Ui) {
ui.label("This is a proof-of-concept of drag-and-drop in Egui"); ui.label("This is a proof-of-concept of drag-and-drop in egui");
ui.label("Drag items between columns."); ui.label("Drag items between columns.");
let mut source_col_row = None; let mut source_col_row = None;

View file

@ -58,7 +58,7 @@ impl super::View for FontBook {
use super::font_contents_ubuntu::UBUNTU_FONT_CHARACTERS; use super::font_contents_ubuntu::UBUNTU_FONT_CHARACTERS;
ui.label(format!( ui.label(format!(
"Egui supports {} standard characters and {} emojis.\nClick on a character to copy it.", "egui supports {} standard characters and {} emojis.\nClick on a character to copy it.",
UBUNTU_FONT_CHARACTERS.len(), UBUNTU_FONT_CHARACTERS.len(),
FULL_EMOJI_LIST.len(), FULL_EMOJI_LIST.len(),
)); ));

View file

@ -1529,7 +1529,7 @@ pub const NOTO_EMOJI_LIST: &[(u32, char, &str)] = &[
(0xFE837, '󾠷', "digit zero in square"), (0xFE837, '󾠷', "digit zero in square"),
]; ];
/// All emojis supported by Egui. /// All emojis supported by egui.
/// The union of `emoji-icon-font.ttf` and `NotoEmoji-Regular.ttf`. /// The union of `emoji-icon-font.ttf` and `NotoEmoji-Regular.ttf`.
#[rustfmt::skip] #[rustfmt::skip]
pub const FULL_EMOJI_LIST: &[(u32, char, &str)] = &[ pub const FULL_EMOJI_LIST: &[(u32, char, &str)] = &[

View file

@ -1,4 +1,4 @@
//! Demo-code for showing how Egui is used. //! Demo-code for showing how egui is used.
//! //!
//! The demo-code is also used in benchmarks and tests. //! The demo-code is also used in benchmarks and tests.

View file

@ -32,8 +32,8 @@ pub fn toggle(ui: &mut egui::Ui, on: &mut bool) -> egui::Response {
} }
// 4. Paint! // 4. Paint!
// First let's ask for a simple animation from Egui. // First let's ask for a simple animation from egui.
// Egui keeps track of changes in the boolean associated with the id and // egui keeps track of changes in the boolean associated with the id and
// returns an animated value in the 0-1 range for how much "on" we are. // returns an animated value in the 0-1 range for how much "on" we are.
let how_on = ui.ctx().animate_bool(response.id, *on); let how_on = ui.ctx().animate_bool(response.id, *on);
// We will follow the current style by asking // We will follow the current style by asking

View file

@ -62,7 +62,7 @@ impl super::View for WidgetGallery {
ui.end_row(); ui.end_row();
ui.label("Hyperlink:"); ui.label("Hyperlink:");
ui.add(egui::Hyperlink::new("https://github.com/emilk/egui").text("Egui home page")); ui.add(egui::Hyperlink::new("https://github.com/emilk/egui").text("egui home page"));
ui.end_row(); ui.end_row();
ui.label("Text Input:"); ui.label("Text Input:");

View file

@ -43,7 +43,7 @@ impl FrameHistory {
1e3 * self.mean_frame_time() 1e3 * self.mean_frame_time()
)) ))
.on_hover_text( .on_hover_text(
"Includes Egui layout and tessellation time.\n\ "Includes egui layout and tessellation time.\n\
Does not include GPU usage, nor overhead for sending data to GPU.", Does not include GPU usage, nor overhead for sending data to GPU.",
); );
egui::warn_if_debug_build(ui); egui::warn_if_debug_build(ui);
@ -59,7 +59,7 @@ impl FrameHistory {
use egui::*; use egui::*;
let graph_top_cpu_usage = 0.010; let graph_top_cpu_usage = 0.010;
ui.label("Egui CPU usage history"); ui.label("egui CPU usage history");
let history = &self.frame_times; let history = &self.frame_times;

View file

@ -1,4 +1,4 @@
//! Demo-code for showing how Egui is used. //! Demo-code for showing how egui is used.
//! //!
//! The demo-code is also used in benchmarks and tests. //! The demo-code is also used in benchmarks and tests.

View file

@ -35,7 +35,7 @@ pub struct WrapApp {
impl epi::App for WrapApp { impl epi::App for WrapApp {
fn name(&self) -> &str { fn name(&self) -> &str {
"Egui Demo Apps" "egui demo apps"
} }
#[cfg(feature = "persistence")] #[cfg(feature = "persistence")]
@ -135,7 +135,7 @@ fn clock_button(ui: &mut egui::Ui, seconds_since_midnight: f64) -> egui::Respons
enum RunMode { enum RunMode {
/// This is the default for the demo. /// This is the default for the demo.
/// ///
/// If this is selected, Egui is only updated if are input events /// If this is selected, egui is only updated if are input events
/// (like mouse movements) or there are some animations in the GUI. /// (like mouse movements) or there are some animations in the GUI.
/// ///
/// Reactive mode saves CPU. /// Reactive mode saves CPU.
@ -151,13 +151,13 @@ enum RunMode {
/// This will call `egui::Context::request_repaint()` at the end of each frame /// This will call `egui::Context::request_repaint()` at the end of each frame
/// to request the backend to repaint as soon as possible. /// to request the backend to repaint as soon as possible.
/// ///
/// On most platforms this will mean that Egui will run at the display refresh rate of e.g. 60 Hz. /// On most platforms this will mean that egui will run at the display refresh rate of e.g. 60 Hz.
/// ///
/// For this demo it is not any reason to do so except to /// For this demo it is not any reason to do so except to
/// demonstrate how quickly Egui runs. /// demonstrate how quickly egui runs.
/// ///
/// For games or other interactive apps, this is probably what you want to do. /// For games or other interactive apps, this is probably what you want to do.
/// It will guarantee that Egui is always up-to-date. /// It will guarantee that egui is always up-to-date.
Continuous, Continuous,
} }
@ -221,7 +221,7 @@ impl BackendPanel {
ui.separator(); ui.separator();
if frame.is_web() { if frame.is_web() {
ui.label("Egui is an immediate mode GUI written in Rust, compiled to WebAssembly, rendered with WebGL."); ui.label("egui is an immediate mode GUI written in Rust, compiled to WebAssembly, rendered with WebGL.");
ui.label( ui.label(
"Everything you see is rendered as textured triangles. There is no DOM. There are no HTML elements. \ "Everything you see is rendered as textured triangles. There is no DOM. There are no HTML elements. \
This is not JavaScript. This is Rust, running at 60 FPS. This is the web page, reinvented with game tech."); This is not JavaScript. This is Rust, running at 60 FPS. This is the web page, reinvented with game tech.");

View file

@ -9,7 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed 🐛 ### Fixed 🐛
* Fix a bug where key releases weren't sent to Egui * Fix a bug where key releases weren't sent to egui
* Fix `set_window_size` for non-native `pixels_per_point`. * Fix `set_window_size` for non-native `pixels_per_point`.

View file

@ -2,7 +2,7 @@
name = "egui_glium" name = "egui_glium"
version = "0.7.0" version = "0.7.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
description = "Bindings for using Egui natively using the glium library" description = "Bindings for using egui natively using the glium library"
edition = "2018" edition = "2018"
homepage = "https://github.com/emilk/egui" homepage = "https://github.com/emilk/egui"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"

View file

@ -5,4 +5,4 @@
# egui_glium # egui_glium
This crates provides bindings between [Egui](https://crates.io/crates/egui) and [glium](https://crates.io/crates/glium) which allows you to write GUI code using Egui and compile it and run it natively, cross platform. This crates provides bindings between [egui](https://crates.io/crates/egui) and [glium](https://crates.io/crates/glium) which allows you to write GUI code using egui and compile it and run it natively, cross platform.

View file

@ -284,7 +284,7 @@ pub fn run(mut app: Box<dyn epi::App>) -> ! {
glutin::event::Event::WindowEvent { event, .. } => { glutin::event::Event::WindowEvent { event, .. } => {
input_to_egui(event, clipboard.as_mut(), &mut input_state, control_flow); input_to_egui(event, clipboard.as_mut(), &mut input_state, control_flow);
display.gl_window().window().request_redraw(); // TODO: ask Egui if the events warrants a repaint instead display.gl_window().window().request_redraw(); // TODO: ask egui if the events warrants a repaint instead
} }
glutin::event::Event::LoopDestroyed => { glutin::event::Event::LoopDestroyed => {
app.on_exit(); app.on_exit();

View file

@ -43,7 +43,7 @@ const VERTEX_SHADER_SOURCE: &str = r#"
1.0 - 2.0 * a_pos.y / u_screen_size.y, 1.0 - 2.0 * a_pos.y / u_screen_size.y,
0.0, 0.0,
1.0); 1.0);
// Egui encodes vertex colors in gamma spaces, so we must decode the colors here: // egui encodes vertex colors in gamma spaces, so we must decode the colors here:
v_rgba = linear_from_srgba(a_srgba); v_rgba = linear_from_srgba(a_srgba);
v_tc = a_tc; v_tc = a_tc;
} }
@ -199,7 +199,7 @@ impl Painter {
let height_in_points = height_in_pixels as f32 / pixels_per_point; let height_in_points = height_in_pixels as f32 / pixels_per_point;
if let Some(texture) = self.get_texture(triangles.texture_id) { if let Some(texture) = self.get_texture(triangles.texture_id) {
// The texture coordinates for text are so that both nearest and linear should work with the Egui font texture. // The texture coordinates for text are so that both nearest and linear should work with the egui font texture.
// For user textures linear sampling is more likely to be the right choice. // For user textures linear sampling is more likely to be the right choice.
let filter = MagnifySamplerFilter::Linear; let filter = MagnifySamplerFilter::Linear;
@ -208,7 +208,7 @@ impl Painter {
u_sampler: texture.sampled().magnify_filter(filter).wrap_function(SamplerWrapFunction::Clamp), u_sampler: texture.sampled().magnify_filter(filter).wrap_function(SamplerWrapFunction::Clamp),
}; };
// Egui outputs colors with premultiplied alpha: // egui outputs colors with premultiplied alpha:
let color_blend_func = glium::BlendingFunction::Addition { let color_blend_func = glium::BlendingFunction::Addition {
source: glium::LinearBlendingFactor::One, source: glium::LinearBlendingFactor::One,
destination: glium::LinearBlendingFactor::OneMinusSourceAlpha, destination: glium::LinearBlendingFactor::OneMinusSourceAlpha,
@ -227,7 +227,7 @@ impl Painter {
..Default::default() ..Default::default()
}; };
// Egui outputs triangles in both winding orders: // egui outputs triangles in both winding orders:
let backface_culling = glium::BackfaceCullingMode::CullingDisabled; let backface_culling = glium::BackfaceCullingMode::CullingDisabled;
// Transform clip rect to physical pixels: // Transform clip rect to physical pixels:
@ -273,7 +273,7 @@ impl Painter {
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// user textures: this is an experimental feature. // user textures: this is an experimental feature.
// No need to implement this in your Egui integration! // No need to implement this in your egui integration!
pub fn alloc_user_texture(&mut self) -> egui::TextureId { pub fn alloc_user_texture(&mut self) -> egui::TextureId {
for (i, tex) in self.user_textures.iter_mut().enumerate() { for (i, tex) in self.user_textures.iter_mut().enumerate() {

View file

@ -2,7 +2,7 @@
name = "egui_web" name = "egui_web"
version = "0.7.0" version = "0.7.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
description = "Bindings for compiling Egui code to WASM for a web page" description = "Bindings for compiling egui code to WASM for a web page"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2018" edition = "2018"
homepage = "https://github.com/emilk/egui" homepage = "https://github.com/emilk/egui"

View file

@ -5,6 +5,6 @@
# egui_web # egui_web
This crates allows you to compile GUI code written with [Egui](https://crates.io/crates/egui) to [WASM](https://en.wikipedia.org/wiki/WebAssembly) to run on a web page. This crates allows you to compile GUI code written with [egui](https://crates.io/crates/egui) to [WASM](https://en.wikipedia.org/wiki/WebAssembly) to run on a web page.
Check out [egui_template](https://github.com/emilk/egui_template) for an example of how to set it up. Check out [egui_template](https://github.com/emilk/egui_template) for an example of how to set it up.

View file

@ -456,7 +456,7 @@ fn install_document_events(runner_ref: &AppRunnerRef) -> Result<(), JsValue> {
let prevent_default = if matches!(event.key().as_str(), "Tab") { let prevent_default = if matches!(event.key().as_str(), "Tab") {
// Always prevent moving cursor to url bar. // Always prevent moving cursor to url bar.
// Egui wants to use tab to move to the next text field. // egui wants to use tab to move to the next text field.
true true
} else if egui_wants_keyboard { } else if egui_wants_keyboard {
matches!( matches!(

View file

@ -39,7 +39,7 @@ const VERTEX_SHADER_SOURCE: &str = r#"
1.0 - 2.0 * a_pos.y / u_screen_size.y, 1.0 - 2.0 * a_pos.y / u_screen_size.y,
0.0, 0.0,
1.0); 1.0);
// Egui encodes vertex colors in gamma spaces, so we must decode the colors here: // egui encodes vertex colors in gamma spaces, so we must decode the colors here:
v_rgba = linear_from_srgba(a_srgba); v_rgba = linear_from_srgba(a_srgba);
v_tc = a_tc; v_tc = a_tc;
} }
@ -484,7 +484,7 @@ impl crate::Painter for WebGlPainter {
let gl = &self.gl; let gl = &self.gl;
gl.enable(Gl::SCISSOR_TEST); gl.enable(Gl::SCISSOR_TEST);
gl.disable(Gl::CULL_FACE); // Egui is not strict about winding order. gl.disable(Gl::CULL_FACE); // egui is not strict about winding order.
gl.enable(Gl::BLEND); gl.enable(Gl::BLEND);
gl.blend_func(Gl::ONE, Gl::ONE_MINUS_SRC_ALPHA); // premultiplied alpha gl.blend_func(Gl::ONE, Gl::ONE_MINUS_SRC_ALPHA); // premultiplied alpha
gl.use_program(Some(&self.program)); gl.use_program(Some(&self.program));

View file

@ -41,7 +41,7 @@ const VERTEX_SHADER_SOURCE: &str = r#"
1.0 - 2.0 * a_pos.y / u_screen_size.y, 1.0 - 2.0 * a_pos.y / u_screen_size.y,
0.0, 0.0,
1.0); 1.0);
// Egui encodes vertex colors in gamma spaces, so we must decode the colors here: // egui encodes vertex colors in gamma spaces, so we must decode the colors here:
v_rgba = linear_from_srgba(a_srgba); v_rgba = linear_from_srgba(a_srgba);
v_tc = a_tc; v_tc = a_tc;
} }
@ -473,7 +473,7 @@ impl crate::Painter for WebGl2Painter {
let gl = &self.gl; let gl = &self.gl;
gl.enable(Gl::SCISSOR_TEST); gl.enable(Gl::SCISSOR_TEST);
gl.disable(Gl::CULL_FACE); // Egui is not strict about winding order. gl.disable(Gl::CULL_FACE); // egui is not strict about winding order.
gl.enable(Gl::BLEND); gl.enable(Gl::BLEND);
gl.blend_func(Gl::ONE, Gl::ONE_MINUS_SRC_ALPHA); // premultiplied alpha gl.blend_func(Gl::ONE, Gl::ONE_MINUS_SRC_ALPHA); // premultiplied alpha
gl.use_program(Some(&self.program)); gl.use_program(Some(&self.program));

View file

@ -1,4 +1,4 @@
# emath - Egui Math Library # emath - egui math library
A bare-bones 2D math library with types and functions useful for GUI building. A bare-bones 2D math library with types and functions useful for GUI building.

View file

@ -5,7 +5,7 @@ use crate::*;
/// A vector has a direction and length. /// A vector has a direction and length.
/// A [`Vec2`] is often used to represent a size. /// A [`Vec2`] is often used to represent a size.
/// ///
/// Egui represents positions using [`Pos2`]. /// emath represents positions using [`Pos2`].
/// ///
/// Normally the units are points (logical pixels). /// Normally the units are points (logical pixels).
#[derive(Clone, Copy, Default)] #[derive(Clone, Copy, Default)]
@ -68,7 +68,7 @@ impl Vec2 {
} }
/// Rotates the vector by 90°, i.e positive X to positive Y /// Rotates the vector by 90°, i.e positive X to positive Y
/// (clockwise in Egui coordinates). /// (clockwise in egui coordinates).
#[inline(always)] #[inline(always)]
pub fn rot90(self) -> Self { pub fn rot90(self) -> Self {
vec2(self.y, -self.x) vec2(self.y, -self.x)

View file

@ -1,4 +1,4 @@
# epaint - Egui Paint Library # epaint - egui paint library
A bare-bones 2D graphics library for turning simple 2D shapes and text into textured triangles. A bare-bones 2D graphics library for turning simple 2D shapes and text into textured triangles.

View file

@ -71,7 +71,7 @@ pub use ahash;
pub use emath; pub use emath;
/// The UV coordinate of a white region of the texture mesh. /// The UV coordinate of a white region of the texture mesh.
/// The default Egui texture has the top-left corner pixel fully white. /// The default egui texture has the top-left corner pixel fully white.
/// You need need use a clamping texture sampler for this to work /// You need need use a clamping texture sampler for this to work
/// (so it doesn't do bilinear blending with bottom right corner). /// (so it doesn't do bilinear blending with bottom right corner).
pub const WHITE_UV: emath::Pos2 = emath::pos2(0.0, 0.0); pub const WHITE_UV: emath::Pos2 = emath::pos2(0.0, 0.0);
@ -79,12 +79,12 @@ pub const WHITE_UV: emath::Pos2 = emath::pos2(0.0, 0.0);
/// What texture to use in a [`Triangles`] mesh. /// What texture to use in a [`Triangles`] mesh.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum TextureId { pub enum TextureId {
/// The Egui font texture. /// The egui font texture.
/// If you don't want to use a texture, pick this and the [`WHITE_UV`] for uv-coord. /// If you don't want to use a texture, pick this and the [`WHITE_UV`] for uv-coord.
Egui, Egui,
/// Your own texture, defined in any which way you want. /// Your own texture, defined in any which way you want.
/// Egui won't care. The backend renderer will presumably use this to look up what texture to use. /// egui won't care. The backend renderer will presumably use this to look up what texture to use.
User(u64), User(u64),
} }

View file

@ -25,7 +25,7 @@ pub struct Vertex {
pub struct Triangles { pub struct Triangles {
/// Draw as triangles (i.e. the length is always multiple of three). /// Draw as triangles (i.e. the length is always multiple of three).
/// ///
/// Egui is NOT consistent with what winding order it uses, so turn off backface culling. /// egui is NOT consistent with what winding order it uses, so turn off backface culling.
pub indices: Vec<u32>, pub indices: Vec<u32>,
/// The vertex data indexed by `indices`. /// The vertex data indexed by `indices`.

View file

@ -2,7 +2,7 @@
name = "epi" name = "epi"
version = "0.7.0" version = "0.7.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
description = "Backend-agnostic interface for writing apps using Egui" description = "Backend-agnostic interface for writing apps using egui"
edition = "2018" edition = "2018"
homepage = "https://github.com/emilk/egui" homepage = "https://github.com/emilk/egui"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"

View file

@ -1,5 +1,5 @@
# Egui app Programming Interface # egui app programming interface
Backend-agnostic interface for writing apps using [`egui`](https://crates.io/crates/egui) (a platform agnostic GUI library). Backend-agnostic interface for writing apps using [`egui`](https://crates.io/crates/egui) (a platform agnostic GUI library).
This crate provides a common interface for programming an app using Egui, which can then be easily plugged into [`egui_frame`](https://crates.io/crates/egui_frame) (which in a wrapper over [`egui_web`](https://crates.io/crates/egui_web) or [`egui_glium`](https://crates.io/crates/egui_glium)). This crate provides a common interface for programming an app using egui, which can then be easily plugged into [`egui_frame`](https://crates.io/crates/egui_frame) (which in a wrapper over [`egui_web`](https://crates.io/crates/egui_web) or [`egui_glium`](https://crates.io/crates/egui_glium)).

View file

@ -2,7 +2,7 @@
//! //!
//! `epi` provides interfaces for window management, serialization and http requests. //! `epi` provides interfaces for window management, serialization and http requests.
//! An app written for `epi` can then be plugged into [`eframe`](https://docs.rs/eframe), //! An app written for `epi` can then be plugged into [`eframe`](https://docs.rs/eframe),
//! the Egui framework crate. //! the egui framework crate.
//! //!
//! Start by looking at the [`App`] trait, and implement [`App::update`]. //! Start by looking at the [`App`] trait, and implement [`App::update`].

BIN
media/demo-2021-01-17.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

BIN
media/widget_gallery.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB