egui: an easy-to-use immediate mode GUI in pure Rust

Overview

🖌 egui: an easy-to-use GUI in pure Rust

github Latest version Documentation unsafe forbidden Build Status MIT Apache

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 library, 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:

Quick start

If you just want to write a GUI application in Rust (for the web or for native), go to https://github.com/emilk/eframe_template/ and follow the instructions there!

If you want to integrate egui into an existing engine, go to the Integrations section.

If you have questions, use Discussions. If you want to contribute to egui, please read the Contributing Guidelines

Demo

Click to run egui web demo (works in any browser with WASM and WebGL support). Uses egui_web.

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

The native backend is egui_glium (using glium) and should work out-of-the-box on Mac and Windows, but on Linux you need to first run:

sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev

On Fedora Rawhide you need to run:

dnf install clang clang-devel clang-tools-extra speech-dispatcher-devel libxkbcommon-devel pkg-config openssl-devel

NOTE: This is just for the demo app - egui itself is completely platform agnostic!

Example

ui.heading("My egui Application");
ui.horizontal(|ui| {
    ui.label("Your name: ");
    ui.text_edit_singleline(&mut name);
});
ui.add(egui::Slider::new(&mut age, 0..=120).text("age"));
if ui.button("Click each year").clicked() {
    age += 1;
}
ui.label(format!("Hello '{}', age {}", name, age));

Goals

  • The easiest to use GUI library
  • Responsive: target 60 Hz in debug build
  • Friendly: difficult to make mistakes, and shouldn't panic
  • Portable: the same code works on the web and as a native app
  • Easy to integrate into any environment
  • A simple 2D graphics API for custom painting (epaint).
  • No callbacks
  • Pure immediate mode
  • Extensible: easy to write your own widgets for egui
  • 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
  • Minimal dependencies: ab_glyph ahash atomic_refcell, nohash-hasher

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.

Non-goals

  • Become the most powerful GUI library
  • Native looking interface
  • Advanced and flexible layouts (that's fundamentally incompatible with immediate mode)

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.

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.

egui vs Dear ImGui

The obvious alternative to egui is imgui-rs, the Rust wrapper around the C++ library Dear 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:

  • egui is pure Rust
  • 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)
  • Writing your own widgets in egui is simple

egui also tries to improve your experience in other small ways:

  • Windows are automatically sized based on their contents
  • Windows are automatically positioned to not overlap with each other
  • Some subtle animations make egui come alive

So in summary:

  • egui: pure Rust, new, exciting, work in progress
  • Dear ImGui: feature rich, well tested, cumbersome Rust integration

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.

Features

  • Widgets: label, text button, hyperlink, checkbox, radio button, slider, draggable value, text editing, combo box, color picker
  • Layouts: horizontal, vertical, columns, automatic wrapping
  • Text editing: multiline, copy/paste, undo, emoji supports
  • Windows: move, resize, name, minimize and close. Automatically sized and positioned.
  • Regions: resizing, vertical scrolling, collapsing headers (sections)
  • Rendering: Anti-aliased rendering of lines, circles, text and convex polygons.
  • Tooltips on hover
  • More

Light Theme:

How it works

Loop:

  • Gather input (mouse, touches, keyboard, screen size, etc) and give it to egui
  • Run application code (Immediate Mode GUI)
  • Tell egui to tessellate the frame graphics to a triangle mesh
  • Render the triangle mesh with your favorite graphics API (see OpenGL example) or use eframe, the egui framework crate.

Integrations

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. 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, …).
  • Painting: Render the textured triangles that egui outputs.

Official

There are three official egui integrations made for apps:

If you making an app, consider using eframe, a framework which allows you to write code that works on both the web (egui_web) and native (using egui_glium).

3rd party

Missing an integration for the thing you're working on? Create one, it is easy!

Writing your own egui integration

You need to collect egui::RawInput, paint egui::ClippedMesh:es and handle egui::Output. The basic structure is this:

let mut egui_ctx = egui::CtxRef::default();

// Game loop:
loop {
    let raw_input: egui::RawInput = my_integration.gather_input();
    let (output, shapes) = egui_ctx.run(raw_input, |egui_ctx| {
        my_app.ui(egui_ctx); // add panels, windows and widgets to `egui_ctx` here
    });
    let clipped_meshes = egui_ctx.tessellate(shapes); // create triangles to paint
    my_integration.paint(clipped_meshes);
    my_integration.set_cursor_icon(output.cursor_icon);
    // Also see `egui::Output` for more
}

For a reference OpenGL backend, see the egui_glium painter, the egui_glow painter, or the egui_web WebGL painter.

Debugging your integration

Things look jagged

  • Turn off backface culling.

My text is blurry

  • 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.

My windows are too transparent or too dark

  • 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).
  • Use an sRGBA-aware texture if available (e.g. GL_SRGB8_ALPHA8).
    • Otherwise: remember to decode gamma in the fragment shader.
  • Decode the gamma of the incoming vertex colors in your vertex shader.
  • Turn on sRGBA/linear framebuffer if available (GL_FRAMEBUFFER_SRGB).
    • Otherwise: gamma-encode the colors before you write them again.

Why immediate mode

egui is an immediate mode GUI library, as opposed to a retained mode GUI library. The difference between retained mode and immediate mode is best illustrated with the example of a button: In a retained GUI you create a button, add it to some UI and install some on-click handler (callback). The button is retained in the UI, and to change the text on it you need to store some sort of reference to it. By contrast, in immediate mode you show the button and interact with it immediately, and you do so every frame (e.g. 60 times per second). This means there is no need for any on-click handler, nor to store any reference to it. In egui this looks like this: if ui.button("Save file").clicked() { save(file); }.

A more detailed description of immediate mode can be found in the egui docs.

There are advantages and disadvantages to both systems.

The short of it is this: immediate mode GUI libraries are easier to use, but less powerful.

Advantages of immediate mode

Usability

The main advantage of immediate mode is that the application code becomes vastly simpler:

  • You never need to have any on-click handlers and callbacks that disrupts your code flow.
  • You don't have to worry about a lingering callback calling something that is gone.
  • Your GUI code can easily live in a simple function (no need for an object just for the UI).
  • You don't have to worry about app state and GUI state being out-of-sync (i.e. the GUI showing something outdated), because the GUI isn't storing any state - it is showing the latest state immediately.

In other words, a whole lot of code, complexity and bugs are gone, and you can focus your time on something more interesting than writing GUI code.

Disadvantages of immediate mode

Layout

The main disadvantage of immediate mode is it makes layout more difficult. Say you want to show a small dialog window in the center of the screen. To position the window correctly the GUI library must first know the size of it. To know the size of the window the GUI library must first layout the contents of the window. In retained mode this is easy: the GUI library does the window layout, positions the window, then checks for interaction ("was the OK button clicked?").

In immediate mode you run into a paradox: to know the size of the window, we must do the layout, but the layout code also checks for interaction ("was the OK button clicked?") and so it needs to know the window position before showing the window contents. This means we must decide where to show the window before we know its size!

This is a fundamental shortcoming of immediate mode GUIs, and any attempt to resolve it comes with its own downsides.

One workaround is to store the size and use it the next frame. This produces a frame-delay for the correct layout, producing occasional flickering the first frame something shows up. egui does this for some things such as windows and grid layouts.

You can also call the layout code twice (once to get the size, once to do the interaction), but that is not only more expensive, it's also complex to implement, and in some cases twice is not enough. egui never does this.

For "atomic" widgets (e.g. a button) egui knows the size before showing it, so centering buttons, labels etc is possible in egui without any special workarounds.

CPU usage

Since an immediate mode GUI does a full layout each frame, the layout code needs to be quick. If you have a very complex GUI this can tax the CPU. In particular, having a very large UI in a scroll area (with very long scrollback) can be slow, as the content needs to be layed out each frame.

If you design the GUI with this in mind and refrain from huge scroll areas (or only lay out the part that is in view) then the performance hit is generally pretty small. For most cases you can expect egui to take up 1-2 ms per frame, but egui still has a lot of room for optimization (it's not something I've focused on yet). You can also set up egui to only repaint when there is interaction (e.g. mouse movement).

If your GUI is highly interactive, then immediate mode may actually be more performant compared to retained mode. Go to any web page and resize the browser window, and you'll notice that the browser is very slow to do the layout and eats a lot of CPU doing it. Resize a window in egui by contrast, and you'll get smooth 60 FPS at no extra CPU cost.

IDs

There are some GUI state that you want the GUI library to retain, even in an immediate mode library such as egui. This includes position and sizes of windows and how far the user has scrolled in some UI. In these cases you need to provide egui with a seed of a unique identifier (unique within the parent UI). For instance: by default egui uses the window titles as unique IDs to store window positions. If you want two windows with the same name (or one window with a dynamic name) you must provide some other ID source to egui (some unique integer or string).

egui also needs to track which widget is being interacted with (e.g. which slider is being dragged). egui uses unique id:s for this awell, but in this case the IDs are automatically generated, so there is no need for the user to worry about it. In particular, having two buttons with the same name is no problem (this is in contrast with Dear ImGui).

Overall, ID handling is a rare inconvenience, and not a big disadvantage.

FAQ

Also see GitHub Discussions.

Can I use egui with non-latin characters?

Yes! But you need to install your own font (.ttf or .otf) using Context::set_fonts.

Can I customize the look of egui?

Yes! You can customize the colors, spacing and sizes of everything. By default egui comes with a dark and a light theme.

What about accessibility, such as screen readers?

There is experimental support for a screen reader. In the web demo you can enable it in the "Backend" tab.

Read more at https://github.com/emilk/egui/issues/167.

What is the difference between egui and eframe?

egui is a 2D user interface library for laying out and interacting with buttons, sliders, etc. egui has no idea if it is running on the web or natively, and does not know how to collect input or show things on screen. That is the job of the integration or backend.

It is common to use egui from a game engine (using e.g. bevy_egui), but you can also use egui stand-alone using eframe. eframe has integration for web and native, and handles input and rendering. 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).

Why is egui_web using so much CPU in Firefox?

On Linux and Mac, Firefox will copy the WebGL render target from GPU, to CPU and then back again: https://bugzilla.mozilla.org/show_bug.cgi?id=1010527#c0

Why does my web app not fill the full width of the screen?

To alleviate the above mentioned performance issues the default max-width of an egui web app is 1024 points. You can change this by overriding the fn max_size_points of epi::App.

How do I render 3D stuff in an egui area?

egui can't do 3D graphics itself, but if you use a 3D library (e.g. glium using egui_glium, or miniquad using egui-miniquad) you can render your 3D content to a texture, then display it using ui.image(…). You first need to convert the native texture to an egui::TextureId, and how to do this depends on the integration you use (e.g. register_glium_texture).

There is an example for showing a native glium texture in an egui window at https://github.com/emilk/egui/blob/master/egui_glium/examples/native_texture.rs.

Other

Conventions and design choices

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

All coordinates are in "points" which may consist of many physical pixels.

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");.

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

The one and only Dear ImGui is a great Immediate Mode GUI for C++ which works with many backends. That library revolutionized how I think about GUI code and turned GUI programming from something I hated to do to something I now enjoy.

Name

The name of the library and the project is "egui" and pronounced as "e-gooey". Please don't write it as "EGUI".

The library was originally called "Emigui", but was renamed to "egui" in 2020.

Credits

egui author and maintainer: Emil Ernerfeldt (@emilk).

Notable contributions by:

egui is licensed under MIT OR Apache-2.0.

Default fonts:

Comments
  • Accessibility (A11y)

    Accessibility (A11y)

    Is your feature request related to a problem? Please describe. Not all GUI app users are sighted or can see well. This project does not indicate any effort to make apps accessible to the visually impaired.

    Describe the solution you'd like For this project to make a conscious and focused effort to support apps that can be used by the visually impaired.

    Describe alternatives you've considered None.

    Additional context I (and many others) will not use a GUI library in production unless it is designed with accessibility in mind.

    feature-request help wanted design accessibility 
    opened by nvzqz 60
  • File dialogs and drag-and-drop of files

    File dialogs and drag-and-drop of files

    Tracking issue for

    • [x] File browser dialog for native (rfd now works since https://github.com/emilk/egui/pull/631)
    • [ ] File browser dialog for egui_web ("Select a file to upload")
    • [x] Drag-and-drop files onto egui_web andegui_glium` (https://github.com/emilk/egui/pull/637)
    feature-request framework native-winit 
    opened by emilk 46
  • Dynamic sized strips, tables, and date picker

    Dynamic sized strips, tables, and date picker

    A (dynamic) grid and table layout widget which allows a mixed use of size constraints:

    • Absolute sizing
    • Relative sizing: relative to available size in dimension
    • Remainder: The remaining space is distributed evenly to all cells using Remainder Sizing
    • Relative/Remainder with minimum size

    Also contains a date picker button which is based on the dynamic grid.

    This is early in development and has definitely lots of bugs and rough edges.

    I didn't want to wait longer as I love the results so far and I wanted to show it and open it up for discussion!

    TODO

    I added many TODO comments in the code which I want as a minimum to get this released, like:

    • [ ] Positioning of date picker popup
    • [ ] Colors on date picker popup
    • [x] Internationalization/locale of date picker button/popup
    • [x] Padding in table/grid should be worked over/switched to a more egui like approach
    • [x] Is having two extra crates really needed? I developed it in extra grades but would not mind having it integrated into the main crate. I would prefer some integration into egui repository over maintaining external crates.

    Screenshots:

    opened by elwerene 39
  • Add egui_glow backend as alternative to egui_glium

    Add egui_glow backend as alternative to egui_glium

    I have opened this draft PR to move discussion about egui_glow from #93 to keep conversation focused. As of latest commit, this fork no longer builds. This is because of issues with lifetimes that I will need to fix.

    Feel free to give feedback, but keep in mind that a lot of things are still subject to change.

    TODOs:

    • [x] Get it working
    • [x] Use SRGB to match egui_glium
    • [x] Fix remaining lifetime issues
    • [x] Ensure there are no OpenGL resource leaks
    • [x] Detect OpenGL version for GLSL shaders
    • [x] Fix graphical glitch as shown in screenshot below (black rectangle in top left corner) image
    • [ ] Move egui_glow into its own directory, once reviewing is complete

    Closes #93.

    opened by AlexApps99 39
  • Context menu

    Context menu

    (updated 8.9.21)

    • ContextMenuSystem: Stored by the Context, stores menu state across frames

    • context_menu can be called on Response. It checks if a context menu should be shown and takes a builder closure for the context menu's contents:

    ui.horizontal(|ui| {
        ui.label("title:");
        ui.text_edit_singleline(title);
    })
    .response
    .context_menu(|ui| {
        if ui.button("Clear..").clicked() {
            *title = String::new();
            ui.close();
        }
    });
    
    • the Ui is extended to support creating and closing of menus via the menu and close methods. When menu is called from within a Ui for a menu, it creates a button with an expandable sub-menu, otherwise it creates an inline drop-down menu. Calling close clears the internal menu state.
    .response
    .context_menu(|ui| {
        if ui.button("Open...").clicked() {
            ui.close();
        }
        ui.menu("SubMenu", |ui| {
            ui.menu("SubMenu", |ui| {
                if ui.button("Open...").clicked() {
                    ui.close();
                }
                let _ = ui.button("Item");
            });
            if ui.button("Item").clicked() {
                ui.close();
            }
        });
    });
    

    Peek 2021-08-28 11-45

    To-Do:

    • [x] respect click context (i.e. clicked element)
    • [x] add more extensive examples to demo
    • [x] improve submenu navigation with more forgiving mouse movement paths
    • [x] unify with egui::menu
    • [x] fix hover failing at edge between context menus #577
    • [x] disable hover effect on other menu items when moving towards open submenu
    • [x] define useful Response for SubMenu::show: InnerResponse<Option<Response>>
    • [x] improve styling
    • [x] #547 or #578
    • [x] optimize menu item and submenu API (~MenuUi~)
    • [x] sometimes context menus applied to panels trigger when clicking on a window covering the panel

    Needs new PR:

    • is the shadow of the sub-menu on the parent menu fine?
    • widgets still show hover visuals when cursor moves over them while submenu is open #684
    • items don't adjust to width of larger items when they are added after them #606
    • #683

    Let me know if you have any suggestions or find any problems :)

    opened by mankinskin 32
  • egui 0.20.0 stopped working in WSLg

    egui 0.20.0 stopped working in WSLg

    Describe the bug

    When trying to migrate to egui 0.20 my application crashes on startup in my WSLg environment:

    ❯ ./target/debug/rs_ytdl 
    2022-12-09T15:51:36.763895Z ERROR egui_winit::clipboard: Cannot initialize smithay clipboard without a display handle!
    2022-12-09T15:51:37.240034Z ERROR arboard::platform::linux::x11: Worker thread errored with: Unknown error while interacting with the clipboard: Connection reset by peer (os error 104)    
    2022-12-09T15:51:37.240050Z ERROR arboard::platform::linux::x11: Could not hand the clipboard data over to the clipboard manager: Unknown error while interacting with the clipboard: The X11 server closed the connection    
    2022-12-09T15:51:37.240201Z ERROR arboard::platform::linux::x11: Failed to flush the clipboard window. Error: Broken pipe (os error 32)   
    

    When compiling with egui 0.19.0 this does not happen.

    Package part of my cargo.toml:

    [dependencies]
    egui = "0.20.0"
    eframe = "0.20.0"
    serde = { version = "1", features = ["derive"] }
    toml_edit = "0.15.0"
    subprocess = "0.2.9"
    serde_json = "1.0.89"
    ehttp = "0.2.0"
    sanitize-filename = "0.4.0"
    image = { version = "0.24", features = ["jpeg", "png"] }
    egui_extras = { version="0.20.0", features = ["image"] }
    reqwest = { version = "0.11.13", features = ["blocking"] }
    indexmap = "1.9.2"
    
    # native:
    [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
    tracing-subscriber = "0.3"
    
    # web:
    [target.'cfg(target_arch = "wasm32")'.dependencies]
    console_error_panic_hook = "0.1.6"
    tracing-wasm = "0.2"
    
    
    [profile.release]
    opt-level = 2 # fast and small wasm
    
    

    Expected behavior Application starts as in egui 0.19 without crashing.

    Desktop (please complete the following information):

    • OS: Windows WSLg (Fedora 36)
    • Version 11

    Additional context I've been using exactly the same setup as in egui 0.19.0 and all other GUI stuff works fine.

    Also in egui 0.19.0 clipboard works perfectly ok in the application, when I e.g. select something in a Text Edit I can copy it just fine.

    EDIT: I cross-checked on my M1Pro Macbook and there it works fine. So it really seems to be a breakage with WSLg

    bug 
    opened by markusdd 30
  • Replace Glium

    Replace Glium

    Glium is a convenient choice, but is a rather big dependency which compiles slowly, and uses build.rs. It is also no longer actively maintained.

    The ideal choice for compiling Egui natively would be something simple that compiles quickly. I'm not sure there is such an alternative though.

    One alternative worth investigating is pure glutin (which Glium depend on). It is a bit lower level compared to Glium, and requires use of unsafe, but it looks easy enough to use: https://gist.github.com/matthewjberger/9da00592b472b50ec1e6b3238719264b

    help wanted native-glium 
    opened by emilk 26
  • Can not run official example with error NoAvailablePixelFormat...

    Can not run official example with error NoAvailablePixelFormat...

    Describe the bug

    As my title say...

    To Reproduce Steps to reproduce the behavior:

    1. Clone the repo to local
    2. Into the repo dir and run command cargo run -p hello_world

    Expected behavior Run and show a gui.

    Screenshots image

    Desktop (please complete the following information):

    • OS: Ubuntu 22.04 with Gnome and Wayland.
    • Browser Both Firefox and Chrome.
    • Version Default version..

    Additional context

    No.

    bug native-glow 
    opened by rikonaka 22
  • Can't set an icon properly

    Can't set an icon properly

    fn main() -> Result<()> {
     
        let mut icon_bytes = Vec::new();
        let mut img_reader = BufReader::new(File::open("asset/test.jpg")?);
        img_reader.read_to_end(&mut icon_bytes)?;
    
        let options = eframe::NativeOptions {
            transparent: true,
            icon_data: Some(IconData{
                rgba: icon_bytes,
                width: 32,
                height: 32,
            }),
            ..Default::default()
        };
    
        eframe::run_native(Box::new(HelloWorldApp::new()?), options);
    }
    

    The is no change after add icon_data to options

    opened by TENX-S 21
  • failed to create glutin window surface

    failed to create glutin window surface

    Describe the bug when i run the egui example hello_world,but it run failed.

    $ cd examples
    $ cargo run -p hello_world
    warning: /home/xml/egui-0.20.1/crates/eframe/Cargo.toml: unused manifest key: target.cfg(not(target_arch = "wasm32")).dependencies.glutin.es
        Finished dev [unoptimized + debuginfo] target(s) in 0.35s
         Running `/home/xml/egui-0.20.1/target/debug/hello_world`
    2022-12-28T10:02:53.267553Z  INFO winit::platform_impl::platform::x11::window: Guessed window scale factor: 1.25    
    libEGL warning: DRI2: failed to authenticate
    thread 'main' panicked at 'failed to create glutin window surface: Error { raw_code: Some(12299), raw_os_message: None, kind: BadNativeWindow }', crates/eframe/src/native/run.rs:409:18
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    

    when i run it with RUST_BACKTRACE=1,i got that:

    $ RUST_BACKTRACE=1 cargo run -p hello_world
    warning: /home/xml/egui-0.20.1/crates/eframe/Cargo.toml: unused manifest key: target.cfg(not(target_arch = "wasm32")).dependencies.glutin.es
        Finished dev [unoptimized + debuginfo] target(s) in 0.12s
         Running `/home/xml/egui-0.20.1/target/debug/hello_world`
    2022-12-28T10:12:18.211554Z  INFO winit::platform_impl::platform::x11::window: Guessed window scale factor: 1.25    
    libEGL warning: DRI2: failed to authenticate
    thread 'main' panicked at 'failed to create glutin window surface: Error { raw_code: Some(12299), raw_os_message: None, kind: BadNativeWindow }', crates/eframe/src/native/run.rs:409:18
    stack backtrace:
       0: rust_begin_unwind
                 at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:584:5
       1: core::panicking::panic_fmt
                 at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/panicking.rs:142:14
       2: core::result::unwrap_failed
                 at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/result.rs:1785:5
       3: core::result::Result<T,E>::expect
                 at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/result.rs:1064:23
       4: new
                 at /data/home/xml/egui-0.20.1/crates/eframe/src/native/run.rs:407:30
       5: eframe::native::run::glow_integration::GlowWinitApp::create_glutin_windowed_context
                 at /data/home/xml/egui-0.20.1/crates/eframe/src/native/run.rs:505:26
       6: init_run_state
                 at /data/home/xml/egui-0.20.1/crates/eframe/src/native/run.rs:521:35
       7: <eframe::native::run::glow_integration::GlowWinitApp as eframe::native::run::WinitApp>::on_event
                 at /data/home/xml/egui-0.20.1/crates/eframe/src/native/run.rs:733:25
       8: {closure#0}<eframe::native::run::glow_integration::GlowWinitApp>
                 at /data/home/xml/egui-0.20.1/crates/eframe/src/native/run.rs:140:22
       9: winit::platform_impl::platform::sticky_exit_callback
                 at /home/xml/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/winit-0.27.5/src/platform_impl/linux/mod.rs:849:9
      10: single_iteration<eframe::native::run::UserEvent, eframe::native::run::run_and_return::{closure_env#0}<eframe::native::run::glow_integration::GlowWinitApp>>
                 at /home/xml/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/winit-0.27.5/src/platform_impl/linux/x11/mod.rs:339:17
      11: run_return<eframe::native::run::UserEvent, eframe::native::run::run_and_return::{closure_env#0}<eframe::native::run::glow_integration::GlowWinitApp>>
                 at /home/xml/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/winit-0.27.5/src/platform_impl/linux/x11/mod.rs:448:31
      12: winit::platform_impl::platform::EventLoop<T>::run_return
                 at /home/xml/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/winit-0.27.5/src/platform_impl/linux/mod.rs:748:56
      13: <winit::event_loop::EventLoop<T> as winit::platform::run_return::EventLoopExtRunReturn>::run_return
                 at /home/xml/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/winit-0.27.5/src/platform/run_return.rs:62:9
      14: run_and_return<eframe::native::run::glow_integration::GlowWinitApp>
                 at /data/home/xml/egui-0.20.1/crates/eframe/src/native/run.rs:107:5
      15: eframe::native::run::glow_integration::run_glow::{{closure}}
                 at /data/home/xml/egui-0.20.1/crates/eframe/src/native/run.rs:852:17
      16: eframe::native::run::with_event_loop::{{closure}}
                 at /data/home/xml/egui-0.20.1/crates/eframe/src/native/run.rs:96:9
      17: try_with<core::cell::RefCell<core::option::Option<winit::event_loop::EventLoop<eframe::native::run::UserEvent>>>, eframe::native::run::with_event_loop::{closure_env#0}<eframe::native::run::glow_integration::run_glow::{closure_env#0}>, ()>
                 at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/thread/local.rs:445:16
      18: std::thread::local::LocalKey<T>::with
                 at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/thread/local.rs:421:9
      19: eframe::native::run::with_event_loop
                 at /data/home/xml/egui-0.20.1/crates/eframe/src/native/run.rs:89:5
      20: eframe::native::run::glow_integration::run_glow
                 at /data/home/xml/egui-0.20.1/crates/eframe/src/native/run.rs:845:13
      21: run_native
                 at /data/home/xml/egui-0.20.1/crates/eframe/src/lib.rs:192:13
      22: main
                 at /data/home/xml/egui-0.20.1/examples/hello_world/src/main.rs:13:5
      23: core::ops::function::FnOnce::call_once
                 at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/ops/function.rs:248:5
    note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
    

    To Reproduce Steps to reproduce the behavior:

    1. get egui code
    2. cd examples
    3. cargo run -p hello_world

    Expected behavior

    Screenshots

    Desktop (please complete the following information):

    • OS: UOS V20(base on debian) with X11 Graphic system
    • Browser Chromium
    • Version

    detail info:

    $ cat /etc/os-release 
    PRETTY_NAME="UnionTech OS Desktop 20 Pro"
    NAME="uos"
    VERSION_ID="20"
    VERSION="20"
    ID=uos
    HOME_URL="https://www.chinauos.com/"
    BUG_REPORT_URL="http://bbs.chinauos.com"
    VERSION_CODENAME=eagle
    
    $ uname -a
    Linux xml-PC 4.19.0-amd64-desktop #5312 SMP Mon Nov 7 14:31:47 CST 2022 x86_64 GNU/Linux
    

    Smartphone (please complete the following information):

    • Device:
    • OS:
    • Browser
    • Version

    Additional context

    bug 
    opened by qiuzhiqian 20
  • Continue execution after closing native eframe window

    Continue execution after closing native eframe window

    Closes https://github.com/emilk/egui/issues/1223

    This adds NativeOptions::run_and_return with default value true.

    If true, execution will continue after the eframe window is closed. This is a new behavior introduced in this PR. If false, the app will close once the eframe window is closed. The is the old behavior.

    This is true by default, and the false option is only there so we can revert if we find any bugs.

    When true, winit::platform::run_return::EventLoopExtRunReturn::run_return is used. The winit docs warns of its usage, recommending EventLoop::run, but 🤷 When false, winit::event_loop::EventLoop::run is used.

    This is a really useful feature. You can now use eframe to quickly open up a window and show some data or options, and then continue your program after the eframe window is closed

    My previous attempt at this caused some problems, but my new attempt seems to be working much better, at least on my Mac.

    opened by emilk 18
  • Make window resize handle a public widget.

    Make window resize handle a public widget.

    Hi, I would like this widget to made a publicly accessible widget.

    2023-01-06_20-01

    I first posted this as a question using the bug template and came to know that this is a internal only thing through here - https://github.com/emilk/egui/issues/2548

    and @parasyte recommended me to post the issue as a feature request instead.

    feature-request 
    opened by apoorv569 0
  • Color Emoji support

    Color Emoji support

    Lack of full color emoji support makes egui a poor fit for a chat program

    I'm developing a nostr client in which, like chat or twitter, people use emojis often. I'm trying to decide whether to change GUIs or whether egui might step up to this challenge. Funding may be available.

    This issue is tightly related to font rendering, which there are other open issues for. Depending on the solution to those issues, this issue may also resolve. But I'm listing it explicitly because it might not. Many font rendering libraries do not handle the several font tables needed for color emoji support.

    Describe the solution you'd like

    I'd like color emoji support.

    I'd also like font hinting (the fonts look blurry to me, including in your screenshots so it's not an issue on my side), although it occurs to me that font hinting behaves differently depending on where the pixels line up and pre-rendering to a texture couldn't know where they will line up... but maybe I misunderstand. Nonetheless I didn't include it as I'm not sure it's possible in egui.

    I personally don't care if non-rust libraries are involved, but I understand that egui wishes to avoid that.

    cosmic-text uses swash IIRC for rasterization and rustybuzz for layout. Swash is probably the upstream solution for rasterization as far as I can tell (not all of cosmic-text is applicable). According to my tests, cosmic-text isn't alpha blending right (partial pixels of one character overwrite partial pixels of previous characters).

    Describe alternatives you've considered

    I tried seeing if I was bright enough to implement this myself but I got quite bogged down in parts I still don't understand.

    I've considered switching to iced gui or imgui.

    Additional context

    If color emojis are listed first as a FontFamily, layout breaks pretty badly.

    feature-request 
    opened by mikedilger 0
  • Add double-click and drag and triple-click and drag to select multiple words and to select multiple paragraphs

    Add double-click and drag and triple-click and drag to select multiple words and to select multiple paragraphs

    Is your feature request related to a problem? Please describe.

    It can be difficult to select large chunks of text at a time

    Describe the solution you'd like

    Double-click and drag and triple-click and drag are UX paradigms found on other platforms.

    Describe alternatives you've considered

    N/A

    Additional context

    Tested on TextEdit demo

    feature-request 
    opened by Poopooracoocoo 0
  • Add click, drag and release in menus

    Add click, drag and release in menus

    Is your feature request related to a problem? Please describe.

    With mice and touchpads, you usually find that menus support clicking and dragging to select an item in a menu.

    It'd be great to see this in the demo.

    image

    Additional context

    You can go through submenus of menus in a menu bar quickly using this. It's also in Android and Chrome for Android, many desktop apps and in many games. It's also seen across Windows (in WPF, win32, WinForms), macOS and GNOME and KDE. You sometimes also see this on comboboxes.

    cheers :)

    feature-request 
    opened by Poopooracoocoo 0
  • Instant crash. Something to do with my std::thread implementation

    Instant crash. Something to do with my std::thread implementation

    Describe the bug Application crashes instantly with no errors

    To Reproduce Open application

    Expected behaviour Application does not crash and runs fine

    I'm on win11

    This has something to do with my threading code as the app was just ok before I added threading to decouple my program's calculations and rendering.

    bug 
    opened by NotAF0e 5
Releases(0.20.1)
  • 0.20.0(Dec 8, 2022)

    egui changelog: https://github.com/emilk/egui/blob/master/CHANGELOG.md eframe changelog: https://github.com/emilk/egui/blob/master/crates/eframe/CHANGELOG.md

    Source code(tar.gz)
    Source code(zip)
  • 0.19.0(Aug 20, 2022)

    Highlights:

    • New wgpu backend for eframe
    • Context::request_repaint_after
    • eframe continues after closing native window

    egui changelog: https://github.com/emilk/egui/blob/master/CHANGELOG.md eframe changelog: https://github.com/emilk/egui/blob/master/crates/eframe/CHANGELOG.md

    Source code(tar.gz)
    Source code(zip)
  • 0.18.0(Apr 30, 2022)

  • 0.17.0(Feb 22, 2022)

    egui highlights:

    • Use any-sized font
    • Define custom text styles
    • Easy image loading using new crate egui_extras

    eframe highlights:

    • glow is now the default renderer on both native on web
    • follow OS light/dark mode preference

    Full changelog: https://github.com/emilk/egui/blob/master/CHANGELOG.md

    Source code(tar.gz)
    Source code(zip)
  • 0.16.0(Dec 29, 2021)

  • 0.15.0(Oct 24, 2021)

    Highlights:

    • Syntax highlighting
    • Horizontal scrolling
    • New monospace font
    • New crate egui_glow: a glow backend for eframe (opt-in)
    • New crate egui-web
    Source code(tar.gz)
    Source code(zip)
  • 0.14.1(Aug 28, 2021)

    Bugfix release of egui and egui_web. From the changelogs:

    egui 0.14.1

    Added ⭐

    • Add Ui::horizontal_top.

    Fixed 🐛

    • Fix set_width/set_min_width/set_height/set_min_height/expand_to_include_x/expand_to_include_y.
    • Make minimum grid column width propagate properly.
    • Make sure TextEdit contents expand to fill width if applicable.
    • ProgressBar: add a minimum width and fix for having it in an infinite layout.
    • Fix sometimes not being able to click inside a combo box or popup menu.

    egui_web 0.14.1

    Fixed 🐛

    • Fix alpha blending for WebGL2 and WebGL1 with sRGB support backends, now having identical results as egui_glium.
    • Fix use of egui on devices with both touch and mouse.
    Source code(tar.gz)
    Source code(zip)
  • 0.14.0(Aug 27, 2021)

  • 0.1.0(May 30, 2020)

Owner
Emil Ernerfeldt
Rust coder at Embark Studios. Previously worked with physics simulation, games, 3D scanning and cyber security. I am @ernerfeldt on Twitter
Emil Ernerfeldt
The bindings to the Nuklear 2D immediate GUI library.

nuklear-rust The bindings to the Nuklear 2D immediate GUI library. Currently beta. Drawing backends: gfx-pre-ll for GFX 3D drawing engine (examples: O

Serhii Plyhun 332 Dec 27, 2022
Egui node graph is a featureful, customizable library to create node graph applications using egui

Egui node graph is a featureful, customizable library to create node graph applications using egui. The library takes care of presenting a node graph to your users, and allows customizing many aspects of the interaction, creating the semantics you want for your specific application.

null 367 Jan 8, 2023
A presentation about egui, implemented in egui

egui presentation A presentation about egui, implemented in egui. You can view the presentation at https://emilk.github.io/egui_presentation/. TODO Li

Emil Ernerfeldt 9 Aug 24, 2023
An easy-to-use, 2D GUI library written entirely in Rust.

Conrod An easy-to-use, 2D GUI library written entirely in Rust. Guide What is Conrod? A Brief Summary Screenshots and Videos Feature Overview Availabl

PistonDevelopers 3.3k Jan 1, 2023
A simple GUI version of the pH calibration tool written in egui, based on the eframe template.

caliphui A simple GUI version of the pH calibration tool written in egui, based on the eframe template. Usage Native binaries are provided under relea

Peter Dunne 0 Dec 29, 2021
Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.

libui: a portable GUI library for C This README is being written. Status It has come to my attention that I have not been particularly clear about how

Pietro Gagliardi 10.4k Dec 31, 2022
Example showing how to use tokio and egui together.

Example using tokio with egui This example uses reqwest to send an HTTP request to httpbin. The parsed response contains an increment value (as provid

Jay Oster 10 Dec 25, 2022
An easy to use command line project manager for projects using the ReCT programming language

☢️ A powerful project manager for the ReCT programming language! ☢️ ReCTx makes your projects easier to manage by allowing you to configure everything

Remy 1 Nov 28, 2022
This project attempts to allow the creation of reusable egui-themes

egui stylist Note this project is considered to be experimental and -- while used in personal projects -- may have API breaking changes without warnin

Jacobsky 22 Dec 1, 2022
FLTK frontend for Egui WGPU backend.

Egui FLTK Frontend FLTK Frontend for Egui WGPU Backend On linux Debian/Ubuntu, make sure to install the latest main requirements: sudo apt-get update

Adia Robbie 5 Oct 25, 2022
D3D11 backend for egui library. Presumably for mods/cheats development

D3D11 backend for egui library. Presumably for mods/cheats development. Currently few features from egui are missing. WIP.

sy1ntexx 24 Jan 4, 2023
Egui bindings for macroquad

egui bindings for macroquad This is the easiest way to use egui. Just two functions! Web demo. Usage You need to call ui when you need to get informat

ilya sheprut 54 Dec 28, 2022
Egui bindings for miniquad

egui bindings for miniquad native On Linux you first must run apt install libx11-dev libxi-dev libgl1-mesa-dev (miniquad dependencies). cargo run --re

Fedor Logachev 48 Dec 28, 2022
Render egui with skia!

Skia backend for egui This is a drawing backend for egui that uses skia-safe. Usage Have a look at the metal or cpu examples to get started. Run the e

null 14 Dec 19, 2022
a day-planner/calendar app based on egui

Malakal Malakal is a day planner application. I crafted it because I was not able to find a comfortable calendar application for Linux. I myself have

null 5 Dec 21, 2022
A render-backend independant egui backend for sdl2

A Sdl2 + Egui Backend An egui backend for sdl2 unbound to any renderer-backend. You can include it like so: [dependencies] egui_sdl2_platform = "0.1.0

null 4 Dec 16, 2022
egui backend for D3D9.

egui-d3d9 egui backend for D3D9. Primarily intended for source games like CS:GO and GMod. It's not perfect by far, but it'll do. This is a rewrite of

unknowntrojan 6 Dec 25, 2022
A tool for creating egui Visuals (themes).

egui-visuals-utility A tool for creating egui Visuals (themes). The code is rather messy and might crash but it seems to work. To load the theme use s

null 7 Jan 13, 2023
egui port to Car Thing (and maybe an alternative Car Thing UI?)

tt This project contains a port of egui to the Spotify Car Thing although in the future I also plan for it to contain a custom Car Thing UI. Technical

Andy Bao 7 Dec 30, 2022