[][src]Crate egui

egui core library

To quickly get started with egui, you can take a look at egui_template which uses eframe.

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 get access to an Ui where you can put widgets. For example:

egui::CentralPanel::default().show(&ctx, |ui| {
    ui.label("Hello");
});

To write your own integration for egui you need to do this:

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

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

Re-exports

pub use emath as math;
pub use epaint as paint;
pub use epaint::emath;
pub use containers::*;
pub use layers::LayerId;
pub use layers::Order;
pub use style::Style;
pub use widgets::*;

Modules

color

Color conversions and types.

containers

Containers are pieces of the UI which wraps other pieces of UI. Examples: Window, ScrollArea, Resize, etc.

layers

Handles paint layers, i.e. how things are sometimes painted behind or in front of other things.

menu

Menu bar functionality (very basic so far).

mutex

Helper module that wraps some Mutex types with different implementations.

style

egui theme (spacing, colors, etc).

util

Miscellaneous tools used by the rest of egui.

widgets

Widgets are pieces of GUI such as Label, Button, Slider etc.

Macros

github_link_file

Create a Hyperlink to the current file! on github.

github_link_file_line

Create a Hyperlink to the current file! (and line) on Github

Structs

Align2

Two-dimension alignment, e.g. Align2::LEFT_TOP.

Color32

This format is used for space-efficient color representation (32 bits).

Context

This is the first thing you need when working with egui. Create using CtxRef.

CtxRef

A wrapper around Arc<Context>. This is how you will normally create and access a Context.

FontDefinitions

Describes the font data and the sizes to use.

Grid

A simple grid layout.

Id

egui tracks widgets frame-to-frame using Ids.

InputState

Input state that egui updates each frame.

Layout

The layout of a Ui, e.g. "vertical & centered".

Memory

The data that egui persists between frames.

Modifiers

State of the modifier keys. These must be fed to egui.

Output

What egui emits each frame. The backend should use this.

Painter

Helper to paint shapes and text to a specific region on a specific layer.

Pos2

A position on screen.

RawInput

What the integrations provides to egui at the start of each frame.

Rect

A rectangular region of space.

Response

The result of adding a widget to a Ui.

Rgba

0-1 linear space RGBA color with premultiplied alpha.

Sense

What sort of interaction is a widget sensitive to?

Stroke

Describes the width and color of a line.

Texture

An 8-bit texture containing font data.

Ui

This is what you use to place widgets.

Vec2

A vector has a direction and length. A Vec2 is often used to represent a size.

Enums

Align

left/center/right or top/center/bottom alignment for e.g. anchors and layouts.

CursorIcon

A mouse cursor icon.

Direction

Layout direction, one of LeftToRight, RightToLeft, TopDown, BottomUp.

Event

An input event generated by the integration.

FontFamily

Which style of font: Monospace or Proportional.

Key

Keyboard keys.

Shape

A paint primitive such as a circle or a piece of text. Coordinates are all screen space points (not physical pixels).

TextStyle

One of a few categories of styles of text, e.g. body, button or heading.

TextureId

What texture to use in a Triangles mesh.

Traits

NumExt

Extends f32, Vec2 etc with at_least and at_most as aliases for max and min.

Functions

clamp

Returns range.start() if x <= range.start(), returns range.end() if x >= range.end() and returns x elsewhen.

lerp

Linear interpolation.

pos2

pos2(x,y) == Pos2::new(x, y)

remap

Linearly remap a value from one range to another, so that when x == from.start() returns to.start() and when x == from.end() returns to.end().

remap_clamp

Like remap, but also clamps the value so that the returned value is always in the to range.

vec2

vec2(x,y) == Vec2::new(x, y)

warn_if_debug_build

Helper function that adds a label when compiling with debug assertions enabled.

Type Definitions

PaintJobs

Grouped by clip rectangles, in points (logical pixels).