Skip to main content

EguiUiBuilder

Struct EguiUiBuilder 

Source
pub struct EguiUiBuilder<'a> { /* private fields */ }
Expand description

Wraps &mut egui::Ui to implement the abstract [UiBuilder] trait.

Implementations§

Source§

impl<'a> EguiUiBuilder<'a>

Source

pub fn new( ui: &'a mut Ui, viewport_textures: &'a HashMap<ViewportTextureHandle, TextureId>, ) -> Self

Creates a new builder wrapping the given egui UI region.

Trait Implementations§

Source§

impl UiBuilder for EguiUiBuilder<'_>

Source§

fn heading(&mut self, text: &str)

Large heading text.
Source§

fn label(&mut self, text: &str)

Normal label text.
Source§

fn colored_label(&mut self, color: [f32; 4], text: &str)

Colored label.
Source§

fn small_label(&mut self, text: &str)

Small / secondary label.
Source§

fn monospace(&mut self, text: &str)

Monospaced text (for code / log output).
Source§

fn button(&mut self, text: &str) -> bool

Push-button. Returns true the frame it is clicked.
Source§

fn small_button(&mut self, text: &str) -> bool

Small push-button (less padding).
Source§

fn selectable_label(&mut self, active: bool, text: &str) -> bool

Selectable label — highlights when active is true. Returns true when clicked.
Source§

fn selectable_label_double_clicked(&mut self, active: bool, text: &str) -> bool

Selectable label that returns true when double-clicked.
Source§

fn checkbox(&mut self, checked: &mut bool, text: &str) -> bool

Boolean checkbox. Returns true when toggled.
Source§

fn drag_value_f32(&mut self, label: &str, value: &mut f32, speed: f32) -> bool

Draggable f32 value. Returns true when changed.
Source§

fn slider_f32( &mut self, label: &str, value: &mut f32, min: f32, max: f32, ) -> bool

Slider for f32. Returns true when changed.
Source§

fn text_edit_singleline(&mut self, text: &mut String) -> bool

Single-line text input. Returns true when changed.
Source§

fn vec3_editor(&mut self, label: &str, value: &mut [f32; 3], speed: f32) -> bool

Editable Vec3 as three drag-values (X / Y / Z). Returns true when any component changed.
Source§

fn color_edit(&mut self, label: &str, color: &mut [f32; 4]) -> bool

RGBA color picker. Returns true when changed.
Source§

fn combo_box( &mut self, id_salt: &str, label: &str, current: &mut usize, options: &[&str], ) -> bool

Drop-down combo box picking among string options. current is the index of the currently selected item. Returns true when the selection changed. Dropdown over options, writing the picked index into current. Read more
Source§

fn horizontal(&mut self, f: &mut dyn FnMut(&mut dyn UiBuilder))

Horizontal layout — children placed left-to-right.
Source§

fn vertical(&mut self, f: &mut dyn FnMut(&mut dyn UiBuilder))

Vertical layout (default, but useful inside a horizontal).
Source§

fn collapsing( &mut self, header: &str, default_open: bool, f: &mut dyn FnMut(&mut dyn UiBuilder), )

Collapsible section with a header.
Source§

fn indent(&mut self, id: &str, f: &mut dyn FnMut(&mut dyn UiBuilder))

Indented block.
Source§

fn scroll_area(&mut self, id: &str, f: &mut dyn FnMut(&mut dyn UiBuilder))

Scrollable area.
Source§

fn viewport_image( &mut self, handle: ViewportTextureHandle, size: [f32; 2], ) -> Option<[f32; 2]>

Display a viewport texture at the given size. Read more
Source§

fn separator(&mut self)

Horizontal separator line.
Source§

fn spacing(&mut self, points: f32)

Blank vertical spacing (in logical points).
Source§

fn is_last_item_double_clicked(&self) -> bool

Returns true if the last widget was double-clicked.
Source§

fn is_last_item_hovered(&self) -> bool

Returns true if the last widget is currently hovered by the pointer.
Source§

fn is_last_item_enter_pressed(&self) -> bool

Returns true if Enter was pressed while the last widget had focus.
Source§

fn is_last_item_escape_pressed(&self) -> bool

Returns true if Escape was pressed while the last widget had focus.
Source§

fn context_menu_last(&mut self, f: &mut dyn FnMut(&mut dyn UiBuilder))

Shows a right-click context menu on the last widget. The closure is called to build menu content when the menu is open.
Source§

fn context_menu_panel(&mut self, f: &mut dyn FnMut(&mut dyn UiBuilder))

Shows a right-click context menu when the user right-clicks anywhere on the current panel background (not on a specific widget). Read more
Source§

fn close_menu(&mut self)

Close the currently open context menu (if any). Read more
Source§

fn menu_button(&mut self, label: &str, f: &mut dyn FnMut(&mut dyn UiBuilder))

Shows a sub-menu button inside a context menu. Unlike collapsing, this creates a proper egui sub-menu that doesn’t steal focus from the parent context menu.
Source§

fn paint_line( &mut self, from: [f32; 2], to: [f32; 2], color: [f32; 4], thickness: f32, )

Paints a line in window-space coordinates.
Source§

fn paint_rect_filled( &mut self, min: [f32; 2], size: [f32; 2], color: [f32; 4], rounding: f32, )

Paints a filled rectangle in window-space coordinates.
Source§

fn paint_text(&mut self, pos: [f32; 2], color: [f32; 4], text: &str)

Paints text at a window-space position.
Source§

fn available_width(&self) -> f32

Available width in the current layout region.
Source§

fn available_height(&self) -> f32

Available height in the current layout region.
Source§

fn panel_rect(&self) -> [f32; 4]

Returns the current paint region in screen-space coordinates as [min_x, min_y, width, height]. Read more
Source§

fn screen_rect(&self) -> [f32; 4]

Returns the full screen size (top-left = (0, 0)) as [min_x, min_y, width, height]. Read more
Source§

fn paint_rect_stroke( &mut self, min: [f32; 2], size: [f32; 2], color: [f32; 4], rounding: f32, thickness: f32, )

Paints a stroked (outlined) rectangle in window-space.
Source§

fn paint_circle_filled( &mut self, center: [f32; 2], radius: f32, color: [f32; 4], )

Paints a filled circle.
Source§

fn paint_circle_stroke( &mut self, center: [f32; 2], radius: f32, color: [f32; 4], thickness: f32, )

Paints a circle outline.
Source§

fn paint_text_styled( &mut self, pos: [f32; 2], text: &str, size: f32, color: [f32; 4], family: FontFamilyHint, align: TextAlign, )

Paints text with explicit size, font family and alignment.
Source§

fn paint_path_filled(&mut self, points: &[[f32; 2]], color: [f32; 4])

Paints a closed polygon path (for diamonds, triangles, custom shapes). points is a list of [x, y] window-space coordinates.
Source§

fn interact_rect(&mut self, id_salt: &str, rect: [f32; 4]) -> Interaction

Allocates a clickable region at the given absolute window-space rect and reports interaction this frame. The id_salt disambiguates overlapping or repeatedly-painted hot regions.
Source§

fn key_pressed(&self, key: KeyCode) -> bool

Whether key was pressed this frame and no text field is consuming keyboard input. Read more
Source§

fn keyboard_captured(&self) -> bool

Whether any widget currently holds keyboard focus — typically a text field being typed into. Read more
Source§

fn raw_key_pressed(&self, key: KeyCode) -> bool

Whether key was pressed this frame, regardless of focus. Read more
Source§

fn focus_last_item(&mut self)

Asks the backend to give the last widget keyboard focus. Read more
Source§

fn push_clip_rect(&mut self, rect: [f32; 4])

Restricts painting to rect until the matching pop_clip_rect. Read more
Source§

fn pop_clip_rect(&mut self)

Restores the clip region saved by push_clip_rect.
Source§

fn scroll_delta_in(&self, rect: [f32; 4]) -> f32

Accumulated scroll-wheel delta this frame while the pointer is inside rect, in points. Positive means the content should move down (the user scrolled towards the top of the list). Read more
Source§

fn dnd_attach_drag_payload(&mut self, payload: u64)

Attaches a drag payload (typically an entity ID packed into a u64) to the last interacted region (the most recent interact_rect call). Should be called immediately after interact_rect. Avoids creating a competing hit-target on the same rect, which would steal pointer events. Default: no-op.
Source§

fn dnd_take_drop_payload(&mut self) -> Option<u64>

If a drag-and-drop just released on the last interacted region, returns its u64 payload. Should be called after interact_rect. Default: no-op.
Source§

fn pointer_position(&self) -> Option<[f32; 2]>

Current pointer (cursor) position in window-space [x, y], or None when the pointer is outside the window or unknown. Drop targets use this to place a dropped item where the cursor released (e.g. unproject the drop point into the 3D scene). Default: None.
Source§

fn is_last_item_dragged(&self) -> bool

Returns true if the last interacted region is currently being dragged. Used by drag sources to paint a cursor-following ghost so the user can see a drag is in progress. Default: false.
Source§

fn is_drag_active(&self) -> bool

true while any u64 drag payload is in flight this frame (a drag started and hasn’t been released). Drop targets use it to show a “droppable here” highlight. Default: false.
Source§

fn inline_text_field( &mut self, rect: [f32; 4], id_salt: &str, text: &mut String, request_focus: bool, ) -> InlineEditEvent

Draws a single-line text editor at an absolute window-space rect and returns its outcome this frame (see [InlineEditEvent]). Unlike the generic region_at + response-tracking helpers, this is self-contained: it owns the widget’s Response, so Enter / Escape / focus-loss are detected reliably. Pass request_focus = true on the frame the field first appears so the user can type immediately. Default: no-op returning [InlineEditEvent::Idle].
Source§

fn overlay_rect_filled( &mut self, min: [f32; 2], size: [f32; 2], color: [f32; 4], rounding: f32, )

Paints a filled rounded rect in an unclipped top overlay layer (above all panels). For cursor-following affordances like drag ghosts that must remain visible outside the current panel’s clip rect. Default: no-op.
Source§

fn overlay_rect_stroke( &mut self, min: [f32; 2], size: [f32; 2], color: [f32; 4], rounding: f32, thickness: f32, )

Stroked rounded rect in the unclipped overlay layer. See overlay_rect_filled. Default: no-op.
Source§

fn overlay_text( &mut self, pos: [f32; 2], text: &str, size: f32, color: [f32; 4], family: FontFamilyHint, )

Text in the unclipped overlay layer. See overlay_rect_filled. Default: no-op.
Source§

fn tooltip_for_last(&mut self, text: &str)

Attaches a tooltip to the most recently created widget / interaction.
Source§

fn region_at( &mut self, id_salt: &str, rect: [f32; 4], f: &mut dyn FnMut(&mut dyn UiBuilder), )

Pushes a child layout region at the given absolute screen-space rect. Inside the closure, &mut dyn UiBuilder reflects the constrained region — egui-native widgets (button, text_edit_singleline, vec3_editor, …) lay out within it instead of the parent panel. Used by composite widgets (inspector cards) that paint their frame absolutely but want native egui controls inside. Read more
Source§

fn cursor_pos(&self) -> [f32; 2]

Returns the current layout cursor in screen-space (x, y). Useful for composites that need to know where to place an absolutely-painted frame before advancing egui’s natural layout.
Source§

fn allocate_size(&mut self, size: [f32; 2]) -> [f32; 4]

Allocates [width, height] of space at the current cursor in the active layout direction. Returns the resulting rect as [x, y, w, h] — feed it to the paint primitives. Read more
Source§

fn measure_text( &self, text: &str, size: f32, family: FontFamilyHint, ) -> [f32; 2]

Measures the rendered size of text at size points using family. Returns [width, height] in logical points. Read more
Source§

fn top_inset_panel( &mut self, id: &str, height: f32, f: &mut dyn FnMut(&mut dyn UiBuilder), )

Inset panel along the top edge of the current region. Read more
Source§

fn bottom_inset_panel( &mut self, id: &str, height: f32, f: &mut dyn FnMut(&mut dyn UiBuilder), )

Inset panel along the bottom edge — counterpart of top_inset_panel.
Source§

fn left_inset_panel( &mut self, id: &str, width: f32, f: &mut dyn FnMut(&mut dyn UiBuilder), )

Inset sidebar on the left edge of the current region. Read more
Source§

fn right_inset_panel( &mut self, id: &str, width: f32, f: &mut dyn FnMut(&mut dyn UiBuilder), )

Inset sidebar on the right edge — counterpart of left_inset_panel.
Source§

fn central_inset(&mut self, f: &mut dyn FnMut(&mut dyn UiBuilder))

Central region — fills whatever space remains after the inset panels above were placed.
Source§

fn modal( &mut self, id: &str, size: [f32; 2], f: &mut dyn FnMut(&mut dyn UiBuilder), )

Open a modal dialog overlaid on top of the current screen. Read more
Source§

fn frame_box( &mut self, margin: Margin, fill: Option<LinearRgba>, stroke: Stroke, radius: CornerRadius, f: &mut dyn FnMut(&mut dyn UiBuilder), )

Wraps f in a visual frame: paints the optional fill / stroke / rounded background first, then runs f inside the inner content rect (after applying margin). Read more

Auto Trait Implementations§

§

impl<'a> Freeze for EguiUiBuilder<'a>

§

impl<'a> !RefUnwindSafe for EguiUiBuilder<'a>

§

impl<'a> Send for EguiUiBuilder<'a>

§

impl<'a> Sync for EguiUiBuilder<'a>

§

impl<'a> Unpin for EguiUiBuilder<'a>

§

impl<'a> UnsafeUnpin for EguiUiBuilder<'a>

§

impl<'a> !UnwindSafe for EguiUiBuilder<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AppLifecycle for T
where T: ?Sized,

§

fn on_start(&mut self, ctx: &mut dyn AppContext)

Called once after the backend is up but before the first update. Apps install their theme / fonts here.
§

fn on_exit(&mut self)

Called once when the window is closing. Persist state here.
§

impl<T> AsAny for T
where T: Any,

§

fn as_any(&self) -> &(dyn Any + 'static)

Returns a reference to the inner value as &dyn Any.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSend for T
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(value: T, _simd: S) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,