Skip to main content

Ui

Struct Ui 

Source
pub struct Ui { /* private fields */ }
Expand description

Represents the Dear ImGui user interface for one frame

Implementations§

Source§

impl Ui

Docking-related functionality

Source

pub fn dockspace(&self) -> DockspaceBuilder<'_, 'static>

Configure and submit a dockspace through the canonical builder.

Source

pub fn dock_space_over_main_viewport_raw( &self, dockspace_id: Id, flags: DockNodeFlags, ) -> Id

Submit Dear ImGui’s low-level dockspace-over-viewport operation for the main viewport.

This creates Dear ImGui’s hidden main-viewport host window, applies the viewport work rectangle and platform ownership, and submits a dockspace within that host. Submit it before every window that can be hosted by this dockspace. A KEEP_ALIVE_ONLY submission may be made later because it does not create a visible host. Without an earlier submission, Dear ImGui may already undock a window when that window is begun, before this method can diagnose the ordering error.

§Parameters
  • dockspace_id - The ID for the dockspace (use 0 to auto-generate)
  • flags - Dock node flags
§Returns

The ID of the created dockspace

§Panics

Panics when docking was not enabled before the first frame, when the effective dockspace ID names a child of another dock tree, when the dockspace was already submitted without KEEP_ALIVE_ONLY during this frame, or when a hosted window was submitted before a visible dockspace submission while that window is still attached. KEEP_ALIVE_ONLY remains valid after hosted windows.

§Example
let dockspace_id = ui.dock_space_over_main_viewport_raw(
    0.into(),
    DockNodeFlags::PASSTHRU_CENTRAL_NODE
);
Source

pub fn dock_space_raw( &self, id: Id, size: [f32; 2], flags: DockNodeFlags, window_class: Option<&WindowClass>, ) -> Id

Submit Dear ImGui’s low-level dockspace operation in the current window.

Submit it before every window that can be hosted by this dockspace. A KEEP_ALIVE_ONLY submission may be made later because it does not create a visible host. Without an earlier submission, Dear ImGui may already undock a window when that window is begun, before this method can diagnose the ordering error.

§Parameters
  • id - The non-zero ID for the dockspace. Use Ui::get_id to create one.
  • size - The size of the dockspace in pixels
  • flags - Dock node flags
  • window_class - Optional window class for docking configuration
§Returns

The ID of the created dockspace

§Panics

Panics when docking was not enabled before the first frame, when id names a child of another dock tree, when id was already submitted without KEEP_ALIVE_ONLY during this frame, or when a hosted window was submitted before a visible dockspace submission while that window is still attached. KEEP_ALIVE_ONLY remains valid after hosted windows.

§Example
let dockspace_id = ui.get_id("MyDockspace");
let dockspace_id = ui.dock_space_raw(
    dockspace_id,
    [800.0, 600.0],
    DockNodeFlags::NO_DOCKING_SPLIT,
    Some(&WindowClass::new(Id::from(1u32)))
);
Source

pub fn set_next_window_dock_id_with_cond(&self, dock_id: Id, cond: Condition)

Sets the dock ID for the next window with condition

This function must be called before creating a window to dock it to a specific dock node.

§Panics

Panics when docking was not enabled before the first frame.

§Parameters
  • dock_id - The ID of the dock node to dock the next window to
  • cond - Condition for when to apply the docking
§Example
let dockspace_id = ui.dockspace().build()?;
ui.set_next_window_dock_id_with_cond(dockspace_id, Condition::FirstUseEver);
ui.window("Docked Window").build(|| {
    ui.text("This window will be docked!");
});
Source

pub fn set_next_window_dock_id(&self, dock_id: Id)

Sets the dock ID for the next window

This function must be called before creating a window to dock it to a specific dock node. Uses Condition::Always by default.

§Panics

Panics when docking was not enabled before the first frame.

§Parameters
  • dock_id - The ID of the dock node to dock the next window to
§Example
let dockspace_id = ui.dockspace().build()?;
ui.set_next_window_dock_id(dockspace_id);
ui.window("Docked Window").build(|| {
    ui.text("This window will be docked!");
});
Source

pub fn set_next_window_class(&self, window_class: &WindowClass)

Sets the window class for the next window

This function must be called before creating a window to apply the window class configuration.

§Parameters
  • window_class - The window class configuration
§Example
let window_class = WindowClass::new(Id::from(1u32)).docking_always_tab_bar(true);
ui.set_next_window_class(&window_class);
ui.window("Classed Window").build(|| {
    ui.text("This window has a custom class!");
});
Source

pub fn get_window_dock_id(&self) -> Id

Gets the dock ID of the current window

§Returns

The dock ID of the current window, or 0 if the window is not docked

§Example
ui.window("My Window").build(|| {
    let dock_id = ui.get_window_dock_id();
    if dock_id != 0.into() {
        ui.text(format!("This window is docked with ID: {}", dock_id.raw()));
    } else {
        ui.text("This window is not docked");
    }
});
Source

pub fn is_window_docked(&self) -> bool

Checks if the current window is docked

§Returns

true if the current window is docked, false otherwise

§Example
ui.window("My Window").build(|| {
    if ui.is_window_docked() {
        ui.text("This window is docked!");
    } else {
        ui.text("This window is floating");
    }
});
Source§

impl Ui

Source

pub fn custom_rect(&self, id: CustomRectId) -> Option<CustomRectSnapshot<'_>>

Query a custom rectangle for immediate use in the current frame.

Source

pub fn image_custom_rect(&self, id: CustomRectId, size: [f32; 2]) -> bool

Draw a custom rectangle using its latest texture reference and UVs.

Returns false if the rectangle has been removed.

Source§

impl Ui

Source

pub fn font_atlas_texture(&self) -> Option<FontAtlasTexture<'_>>

Lease the current Context’s font-atlas texture for immediate image submission.

Source§

impl Ui

Source

pub fn current_baked_font(&self) -> BakedFont<'_>

Return baked data for the currently bound font, size, and rasterizer density.

let baked = {
    let mut ctx = Context::create();
    let ui = ctx.frame();
    ui.current_baked_font()
};
baked.size();
Source

pub fn baked_font(&self, font: FontId, size: f32) -> Option<BakedFont<'_>>

Return baked data for a font at the requested size and its current rasterizer density.

Returns None for a legacy renderer while the atlas is locked, because creating an arbitrary baked size during that frame is unsupported by Dear ImGui.

Source

pub fn baked_font_with_density( &self, font: FontId, size: f32, density: f32, ) -> Option<BakedFont<'_>>

Return baked data for a font at an explicit size and rasterizer density.

Returns None for a legacy renderer while the atlas is locked.

Source§

impl Ui

§Fonts

Source

pub fn current_font(&self) -> FontId

Return the persistent, atlas-validated ID of the current font.

Source

pub fn current_font_size(&self) -> f32

Returns the current font size (= height in pixels) with font scale applied

Source

pub fn push_font_with_size( &self, font: Option<FontId>, size: f32, ) -> FontStackToken<'_>

Push a font with dynamic size support (v1.92+ feature).

This allows changing font size at runtime without pre-loading different sizes. Pass None to keep the current font. A size of 0.0 keeps the current size, so push_font_with_size(Some(font), 0.0) changes only the font. A non-zero size is the base size before Dear ImGui applies global and DPI font scaling; Ui::current_font_size already includes those scales.

Returns a FontStackToken that pops the font stack when dropped or when crate::FontStackToken::pop is called.

Source

pub fn with_font_and_size<F, R>( &self, font: Option<FontId>, size: f32, f: F, ) -> R
where F: FnOnce() -> R,

Execute a closure with a specific font and size (v1.92+ dynamic fonts)

Source

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

Returns the UV coordinate for a white pixel.

Useful for drawing custom shapes with the draw list API.

Source

pub fn set_window_font_scale(&self, scale: f32)

Sets the legacy per-window font scale of the current window.

Prefer Ui::push_font_with_size or style.FontScaleMain for new code.

Source§

impl Ui

Source

pub fn is_key_down(&self, key: Key) -> bool

Check if a key is being held down

Source

pub fn is_key_pressed(&self, key: Key) -> bool

Check if a key was pressed (went from !Down to Down)

Source

pub fn is_key_pressed_with_repeat(&self, key: Key, repeat: bool) -> bool

Check if a key was pressed (went from !Down to Down), with repeat

Source

pub fn is_key_released(&self, key: Key) -> bool

Check if a key was released (went from Down to !Down)

Source

pub fn is_key_chord_pressed(&self, key_chord: KeyChord) -> bool

Check if a key chord was pressed (e.g. Ctrl+S).

Source

pub fn shortcut(&self, key_chord: KeyChord) -> bool

Call ImGui shortcut routing with default flags.

Source

pub fn shortcut_with_flags( &self, key_chord: KeyChord, flags: impl Into<ShortcutOptions>, ) -> bool

Call ImGui shortcut routing with explicit input options.

Source

pub fn set_next_item_shortcut(&self, key_chord: KeyChord)

Set the next item’s shortcut with default flags.

Source

pub fn set_next_item_shortcut_with_flags( &self, key_chord: KeyChord, flags: impl Into<NextItemShortcutOptions>, )

Set the next item’s shortcut with explicit options.

Source

pub fn set_next_frame_want_capture_keyboard(&self, want_capture_keyboard: bool)

Overrides io.WantCaptureKeyboard for the next frame.

Source

pub fn set_next_frame_want_capture_mouse(&self, want_capture_mouse: bool)

Overrides io.WantCaptureMouse for the next frame.

Source

pub fn is_mouse_down(&self, button: MouseButton) -> bool

Check if a mouse button is being held down

Source

pub fn is_mouse_clicked(&self, button: MouseButton) -> bool

Check if a mouse button was clicked (went from !Down to Down)

Source

pub fn is_mouse_clicked_with_repeat( &self, button: MouseButton, repeat: bool, ) -> bool

Check if a mouse button was clicked, with repeat

Source

pub fn is_mouse_released(&self, button: MouseButton) -> bool

Check if a mouse button was released (went from Down to !Down)

Source

pub fn is_mouse_double_clicked(&self, button: MouseButton) -> bool

Check if a mouse button was double-clicked

Source

pub fn is_mouse_pos_valid(&self) -> bool

Returns true if the mouse position is valid (not NaN).

This checks the current mouse position as known by Dear ImGui.

Source

pub fn is_mouse_pos_valid_at(&self, pos: [f32; 2]) -> bool

Returns true if the provided mouse position is valid (not NaN).

Source

pub fn is_mouse_released_with_delay( &self, button: MouseButton, delay: f32, ) -> bool

Returns true if the mouse button was released and the given delay has passed.

Source

pub fn is_mouse_released_with_single_click_delay( &self, button: MouseButton, ) -> bool

Returns true when a mouse release reaches Io::mouse_single_click_delay.

Source

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

Get mouse position in screen coordinates

Source

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

Get mouse position when a specific button was clicked

Source

pub fn is_mouse_hovering_rect(&self, r_min: [f32; 2], r_max: [f32; 2]) -> bool

Check if mouse is hovering given rectangle

Source

pub fn is_mouse_hovering_rect_with_clip( &self, r_min: [f32; 2], r_max: [f32; 2], clip: bool, ) -> bool

Check if mouse is hovering given rectangle (with clipping test)

Source

pub fn is_mouse_dragging(&self, button: MouseButton) -> bool

Check if mouse is dragging

Source

pub fn is_mouse_dragging_with_threshold( &self, button: MouseButton, lock_threshold: f32, ) -> bool

Check if mouse is dragging with threshold

Source

pub fn mouse_drag_delta(&self, button: MouseButton) -> [f32; 2]

Get mouse drag delta

Source

pub fn mouse_drag_delta_with_threshold( &self, button: MouseButton, lock_threshold: f32, ) -> [f32; 2]

Get mouse drag delta with threshold

Source

pub fn reset_mouse_drag_delta(&self, button: MouseButton)

Reset mouse drag delta for a specific button

Source

pub fn is_item_toggled_selection(&self) -> bool

Returns true if the last item toggled its selection state in a multi-select scope.

This only makes sense when used between BeginMultiSelect() / EndMultiSelect() (or helpers built on top of them).

Source§

impl Ui

Source

pub fn with_current_state_storage<R>( &self, f: impl for<'storage> FnOnce(StateStorage<'storage>) -> R, ) -> R

Accesses the current window’s state storage inside a non-escaping closure.

The storage view cannot outlive this call. The owning context remains current for the duration of f, including nested calls into other contexts.

Source

pub fn with_state_storage<R>( &self, storage: &mut OwnedStateStorage, f: impl for<'storage> FnOnce(StateStorage<'storage>) -> R, ) -> R

Overrides the current state storage while f runs.

The owning context remains current throughout the call. Nested overrides restore in LIFO order, and restoration also runs if f panics. The replacement storage and its scoped view cannot escape the closure.

use dear_imgui_rs::{Context, OwnedStateStorage, StateStorage};

let mut context = Context::create();
let ui = context.frame();
let mut replacement = OwnedStateStorage::new();
let escaped: StateStorage<'_> =
    ui.with_state_storage(&mut replacement, |storage| storage);
Source

pub fn set_next_item_storage_id(&self, storage_id: Id)

Set the storage ID for the next item.

Source§

impl Ui

Source

pub fn binding(&self) -> ContextBinding

Returns a persistent capability for the Context that owns this Ui.

Source

pub fn context_id(&self) -> ContextId

Returns the process-unique identity of the Context that owns this Ui.

Source

pub fn with_bound_context<R>(&self, f: impl FnOnce() -> R) -> R

Runs a closure while this Ui’s owning ImGui context is current.

The previously current context is restored before this method returns, including when the closure panics. This is primarily intended for extension crates that need to call raw Dear ImGui-adjacent FFI while still honoring the Ui that created the safe wrapper.

Source

pub fn io(&self) -> &Io

Returns an immutable reference to the inputs/outputs object

Source

pub fn get_id(&self, label: &str) -> Id

Returns an ID from a string label in the current ID scope.

This mirrors ImGui::GetID(label). Useful for building stable IDs for widgets or dockspaces inside the current window/scope.

Source§

impl Ui

Source

pub fn show_demo_window(&self, opened: &mut bool)

Renders Dear ImGui’s demo window without its destructive font-atlas debug controls.

This preserves the ordinary demo, Metrics/Debugger, and Style Editor controls. Only the panels backed by upstream ShowFontAtlas() are omitted, so the safe API does not bypass Rust’s font-atlas lifetime and generation tracking.

Use show_upstream_demo_window to opt into the exact upstream window, including its font-atlas controls.

Source

pub unsafe fn show_upstream_demo_window(&self, opened: &mut bool)

Renders the exact upstream Dear ImGui demo window, including font-atlas debug controls.

Prefer show_demo_window unless the application deliberately owns the full font-atlas mutation contract.

§Safety

With BackendFlags::RENDERER_HAS_TEXTURES, the upstream Fonts panel can delete an ImFont and continue reading it in the same native call. Other destructive controls also bypass Rust’s atlas-generation tracking. The caller must prevent those controls from being activated or otherwise uphold the native font-atlas contract.

Source

pub fn show_about_window(&self, opened: &mut bool)

Renders an about window.

Displays the Dear ImGui version/credits, and build/system information.

Source

pub fn show_metrics_window(&self, opened: &mut bool)

Renders a metrics/debug window without its destructive font-atlas tree.

Displays Dear ImGui internals: draw commands (with individual draw calls and vertices), window list, basic internal state, etc.

Source

pub unsafe fn show_upstream_metrics_window(&self, opened: &mut bool)

Renders the exact upstream metrics/debug window, including its font-atlas tree.

§Safety

The upstream Fonts tree can mutate or destroy font-atlas data while Rust font handles and renderer state are live. The caller must uphold the native font-atlas contract.

Source

pub unsafe fn show_font_atlas_debug_panel(&self)

Renders upstream’s internal Font Atlas debug panel for this context.

This is the isolated font-specific part omitted from the safe demo, metrics, and style editor APIs.

§Safety

The panel exposes destructive atlas operations and may continue using native font pointers after a control mutates the atlas. The caller must uphold the native font-atlas contract.

Source

pub fn show_user_guide(&self)

Renders a basic help/info block (not a window)

Source

pub fn show_debug_log_window(&self, opened: &mut bool)

Renders a debug log window.

Displays a simplified log of important dear imgui events.

Source

pub fn show_id_stack_tool_window(&self, opened: &mut bool)

Renders an ID stack tool window.

Hover items with mouse to query information about the source of their unique ID.

Source

pub fn debug_text_encoding(&self, text: impl AsRef<str>)

Renders a table that breaks text down into UTF-8 bytes and codepoints.

This is intended for diagnosing text encoding and missing-glyph issues.

§Panics

Panics if text contains an interior NUL byte, which the upstream NUL-terminated API cannot represent.

Source

pub fn debug_flash_style_color(&self, color: StyleColor)

Temporarily flashes a style color in Dear ImGui’s debug tools.

Source

pub fn debug_start_item_picker(&self)

Starts Dear ImGui’s interactive item picker debug tool.

Source

pub fn get_version(&self) -> &str

Returns the Dear ImGui version string

Source§

impl Ui

Source

pub fn get_window_draw_list(&self) -> DrawListMut<'_>

Access to the current window’s draw list

Source

pub fn get_background_draw_list(&self) -> DrawListMut<'_>

Access to the background draw list

Source

pub fn get_foreground_draw_list(&self) -> DrawListMut<'_>

Access to the foreground draw list

Source§

impl Ui

Source

pub fn mouse_cursor(&self) -> Option<MouseCursor>

Returns the currently desired mouse cursor type

Returns None if no cursor should be displayed

Source

pub fn set_mouse_cursor(&self, cursor_type: Option<MouseCursor>)

Sets the desired mouse cursor type

Passing None hides the mouse cursor

Source

pub fn set_mouse_draw_cursor(&self, draw: bool)

Controls whether Dear ImGui renders its own mouse cursor for this Context.

This is the frame-scoped alternative to mutably borrowing crate::Io while a Ui is live. Platform backends should hide the OS cursor while this value is enabled.

Source

pub fn set_keyboard_focus_here(&self)

Focuses keyboard on the next widget.

This is the equivalent to set_keyboard_focus_here_with_offset with offset set to 0.

Source

pub fn set_keyboard_focus_here_with_offset(&self, offset: i32)

Focuses keyboard on a widget relative to current position.

Use positive offset to focus on next widgets, negative offset to focus on previous widgets.

Source

pub fn set_nav_cursor_visible(&self, visible: bool)

Shows or hides the navigation cursor (a small marker indicating nav focus).

Source§

impl Ui

Source

pub fn show_style_editor(&self, style: &mut Style)

Renders a style editor block (not a window) for the given Style structure.

The safe editor retains all upstream style controls except its destructive Fonts tab. Font selection and font-scale controls remain available because they do not mutate the atlas topology.

Source

pub fn show_default_style_editor(&self)

Renders a style editor block (not a window) for the currently active style.

The safe editor retains all upstream style controls except its destructive Fonts tab.

Source

pub unsafe fn show_upstream_style_editor(&self, style: &mut Style)

Renders the exact upstream style editor for the given Style structure.

Prefer show_style_editor unless the application deliberately owns the full font-atlas mutation contract.

§Safety

The upstream Fonts tab exposes destructive font-atlas operations that bypass Rust’s atlas generation tracking. The caller must uphold the native font-atlas contract.

Source

pub unsafe fn show_upstream_default_style_editor(&self)

Renders the exact upstream style editor for the active style.

§Safety

The upstream Fonts tab exposes destructive font-atlas operations that bypass Rust’s atlas generation tracking. The caller must uphold the native font-atlas contract.

Source

pub unsafe fn style(&self) -> &Style

Returns a shared reference to the current crate::Style.

§Safety

This function is tagged as unsafe because pushing via push_style_color or push_style_var or popping via ColorStackToken::pop or StyleStackToken::pop will modify the values in the returned shared reference. Therefore, you should not retain this reference across calls to push and pop. The clone_style version may instead be used to avoid unsafe.

Source

pub fn clone_style(&self) -> Style

Returns a copy of the current style.

This is a safe alternative to style that avoids the lifetime issues.

Source

pub fn style_colors_dark(&self)

Apply the built-in Dark style to the current style.

Source

pub fn style_colors_light(&self)

Apply the built-in Light style to the current style.

Source

pub fn style_colors_classic(&self)

Apply the built-in Classic style to the current style.

Source

pub fn style_colors_dark_into(&self, dst: &mut Style)

Write the Dark style values into the provided crate::Style object.

Source

pub fn style_colors_light_into(&self, dst: &mut Style)

Write the Light style values into the provided crate::Style object.

Source

pub fn style_colors_classic_into(&self, dst: &mut Style)

Write the Classic style values into the provided crate::Style object.

Source

pub fn show_style_selector(&self, label: impl AsRef<str>) -> bool

Renders a style selector combo box.

Returns true when a different style was selected.

Source

pub fn show_font_selector(&self, label: impl AsRef<str>)

Renders a font selector combo box.

Source§

impl Ui

Source

pub fn main_viewport(&self) -> &Viewport

Returns a reference to the main Dear ImGui viewport (safe wrapper)

Same viewport used by Ui::dockspace’s default host.

The returned reference is owned by the currently active ImGui context and must not be used after the context is destroyed.

Source

pub fn set_next_window_viewport(&self, viewport_id: Id)

Set the viewport for the next window.

This is a convenience wrapper over ImGui::SetNextWindowViewport. Useful when hosting a fullscreen DockSpace window inside the main viewport.

Source

pub fn window_viewport(&self) -> &Viewport

Returns the viewport of the current window.

This requires a current window (i.e. must be called between Begin/End).

Source

pub fn find_viewport_by_id(&self, viewport_id: Id) -> Option<&Viewport>

Find a viewport by ID.

Source

pub fn find_viewport_by_platform_handle( &self, platform_handle: *mut c_void, ) -> Option<&Viewport>

Find a viewport by its platform handle.

The platform handle type depends on the backend (e.g. HWND on Windows).

Source§

impl Ui

Source

pub fn text<T>(&self, text: T)
where T: AsRef<str>,

Display text

Source

pub fn image_with_bg<'tex>( &self, texture: impl Into<TextureRef<'tex>>, size: [f32; 2], bg_color: [f32; 4], tint_color: [f32; 4], )

Convenience: draw an image with background and tint (ImGui 1.92+)

Equivalent to using image_config(...).build_with_bg(bg, tint) but in one call.

Source

pub fn drag_float(&self, label: impl AsRef<str>, value: &mut f32) -> bool

Creates a drag float slider

Source

pub fn drag_float_config<L>(&self, label: L) -> Drag<f32, L>
where L: AsRef<str>,

Creates a drag float slider with configuration

Source

pub fn drag_int(&self, label: impl AsRef<str>, value: &mut i32) -> bool

Creates a drag int slider

Source

pub fn drag_int_config<L>(&self, label: L) -> Drag<i32, L>
where L: AsRef<str>,

Creates a drag int slider with configuration

Source

pub fn drag_float_range2( &self, label: impl AsRef<str>, min: &mut f32, max: &mut f32, ) -> bool

Creates a drag float range slider

Source

pub fn drag_float_range2_config<L>(&self, label: L) -> DragRange<f32, L>
where L: AsRef<str>,

Creates a drag float range slider with configuration

Source

pub fn drag_int_range2( &self, label: impl AsRef<str>, min: &mut i32, max: &mut i32, ) -> bool

Creates a drag int range slider

Source

pub fn drag_int_range2_config<L>(&self, label: L) -> DragRange<i32, L>
where L: AsRef<str>,

Creates a drag int range slider with configuration

Source

pub fn set_next_item_open(&self, is_open: bool)

Set next item to be open by default.

This is useful for tree nodes, collapsing headers, etc.

Source

pub fn set_next_item_open_with_cond(&self, is_open: bool, cond: Condition)

Set next item to be open by default with condition.

Source

pub fn set_next_item_width(&self, item_width: f32)

Set next item width.

Set to 0.0 for default width, >0.0 for explicit width, <0.0 for relative width.

Source

pub fn value_bool(&self, prefix: impl AsRef<str>, v: bool)

Display a text label with a boolean value (for quick debug UIs).

Source§

impl Ui

Source

pub fn window<'ui>(&'ui self, name: impl Into<WindowLabel<'ui>>) -> Window<'ui>

Creates a window builder

Source

pub fn set_window_focus(&self, name: Option<&str>)

Focus a window by name, or clear focus from all windows.

Passing None is equivalent to ImGui::SetWindowFocus(NULL) in the C++ API. This can be used to “unfocus” the entire UI (e.g. on Escape, to behave like clicking outside of the UI).

Source

pub fn set_window_pos(&self, pos: [f32; 2])

Sets the position of the current window.

Source

pub fn set_window_pos_with_cond(&self, pos: [f32; 2], cond: Condition)

Sets the position of the current window with a condition.

Source

pub fn set_window_pos_by_name(&self, name: impl AsRef<str>, pos: [f32; 2])

Sets the position of a named window.

Source

pub fn set_window_pos_by_name_with_cond( &self, name: impl AsRef<str>, pos: [f32; 2], cond: Condition, )

Sets the position of a named window with a condition.

Source

pub fn set_window_size(&self, size: [f32; 2])

Sets the size of the current window.

Source

pub fn set_window_size_with_cond(&self, size: [f32; 2], cond: Condition)

Sets the size of the current window with a condition.

Source

pub fn set_window_size_by_name(&self, name: impl AsRef<str>, size: [f32; 2])

Sets the size of a named window.

Source

pub fn set_window_size_by_name_with_cond( &self, name: impl AsRef<str>, size: [f32; 2], cond: Condition, )

Sets the size of a named window with a condition.

Source

pub fn set_window_collapsed(&self, collapsed: bool)

Collapses or expands the current window.

Source

pub fn set_window_collapsed_with_cond(&self, collapsed: bool, cond: Condition)

Collapses or expands the current window with a condition.

Source

pub fn set_window_collapsed_by_name( &self, name: impl AsRef<str>, collapsed: bool, )

Collapses or expands a named window.

Source

pub fn set_window_collapsed_by_name_with_cond( &self, name: impl AsRef<str>, collapsed: bool, cond: Condition, )

Collapses or expands a named window with a condition.

Source

pub fn window_dpi_scale(&self) -> f32

Returns DPI scale currently associated to the current window’s viewport.

Source

pub fn window_width(&self) -> f32

Get current window width (shortcut for GetWindowSize().x).

Source

pub fn window_height(&self) -> f32

Get current window height (shortcut for GetWindowSize().y).

Source

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

Get current window position in screen space.

Source

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

Get current window size.

Source§

impl Ui

Source

pub fn time(&self) -> f64

Get global imgui time. Incremented by io.DeltaTime every frame.

Source

pub fn frame_count(&self) -> usize

Get global imgui frame count. Incremented by 1 every frame.

Source

pub fn calc_item_width(&self) -> f32

Returns the width of an item based on the current layout state.

Source§

impl Ui

Source

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

Get cursor position in screen coordinates.

Source

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

Get available content region size.

Source

pub fn is_point_in_rect( &self, point: [f32; 2], rect_min: [f32; 2], rect_max: [f32; 2], ) -> bool

Check if a point is inside a rectangle.

Source

pub fn distance(&self, p1: [f32; 2], p2: [f32; 2]) -> f32

Calculate distance between two points.

Source

pub fn distance_squared(&self, p1: [f32; 2], p2: [f32; 2]) -> f32

Calculate squared distance between two points (faster than distance).

Source

pub fn line_segments_intersect( &self, p1: [f32; 2], p2: [f32; 2], p3: [f32; 2], p4: [f32; 2], ) -> bool

Check if two line segments intersect.

Source

pub fn normalize(&self, v: [f32; 2]) -> [f32; 2]

Normalize a 2D vector.

Source

pub fn dot_product(&self, v1: [f32; 2], v2: [f32; 2]) -> f32

Calculate dot product of two 2D vectors.

Source

pub fn angle_between_vectors(&self, v1: [f32; 2], v2: [f32; 2]) -> f32

Calculate the angle between two vectors in radians.

Source

pub fn is_point_in_circle( &self, point: [f32; 2], center: [f32; 2], radius: f32, ) -> bool

Check if a point is inside a circle.

Source

pub fn triangle_area(&self, p1: [f32; 2], p2: [f32; 2], p3: [f32; 2]) -> f32

Calculate the area of a triangle given three points.

Source§

impl Ui

Source

pub fn get_key_pressed_amount( &self, key: Key, repeat_delay: f32, rate: f32, ) -> usize

Returns the number of times the key was pressed in the current frame

Source

pub fn get_key_name(&self, key: Key) -> &str

Returns the name of a key

Source

pub fn get_mouse_clicked_count(&self, button: MouseButton) -> usize

Returns the number of times the mouse button was clicked in the current frame

Source

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

Returns the mouse position in screen coordinates

Source

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

Returns the mouse position when the button was clicked

Source

pub fn get_mouse_drag_delta( &self, button: MouseButton, lock_threshold: f32, ) -> [f32; 2]

Returns the mouse drag delta

Source

pub fn get_mouse_wheel(&self) -> f32

Returns the mouse wheel delta

Source

pub fn get_mouse_wheel_h(&self) -> f32

Returns the horizontal mouse wheel delta

Source

pub fn is_any_mouse_down(&self) -> bool

Returns true if any mouse button is down

Source§

impl Ui

Source

pub fn item_clicked_count_with_single_click_delay(&self) -> usize

Returns a delayed single-click count, or an immediate count for repeated clicks.

This uses the left mouse button and Io::mouse_single_click_delay.

Source

pub fn item_clicked_count_with_single_click_delay_for( &self, button: MouseButton, ) -> usize

Returns a delayed single-click count for button, or an immediate count for repeated clicks.

Source

pub fn item_clicked_count_with_delay( &self, button: MouseButton, delay: f32, ) -> usize

Returns a delayed single-click count using an explicit delay.

Dear ImGui clamps the delay to remain longer than the configured double-click time.

Source

pub fn is_item_toggled_open(&self) -> bool

Returns true if the last item open state was toggled

Source

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

Returns the upper-left bounding rectangle of the last item (screen space)

Source

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

Returns the lower-right bounding rectangle of the last item (screen space)

Source

pub fn set_next_item_allow_overlap(&self)

Allows the next item to be overlapped by a subsequent item.

Source§

impl Ui

Source

pub fn log_to_tty(&self, auto_open_depth: impl Into<LogAutoOpenDepth>)

Start logging to TTY.

Source

pub fn log_to_file_default(&self, auto_open_depth: impl Into<LogAutoOpenDepth>)

Start logging to file with the default filename.

Source

pub fn log_to_file( &self, auto_open_depth: impl Into<LogAutoOpenDepth>, filename: &Path, ) -> Result<(), ImGuiError>

Start logging to file.

§Errors

Returns an error if filename contains NUL bytes.

Source

pub fn log_to_clipboard(&self, auto_open_depth: impl Into<LogAutoOpenDepth>)

Start logging to clipboard.

Source

pub fn log_buttons(&self)

Show ImGui’s logging buttons (TTY/File/Clipboard).

Source

pub fn log_finish(&self)

Finish logging (close file / copy to clipboard as needed).

Source§

impl Ui

Source

pub fn style_color(&self, style_color: StyleColor) -> [f32; 4]

Returns a single style color from the user interface style.

Use this function if you need to access the colors, but don’t want to clone the entire style object.

Source

pub fn get_color_u32(&self, style_color: StyleColor) -> u32

Returns an ImGui-packed ABGR color (ImU32) from a style color.

This is a convenience wrapper over ImGui::GetColorU32(ImGuiCol, alpha_mul).

Source

pub fn get_color_u32_with_alpha( &self, style_color: StyleColor, alpha_mul: f32, ) -> u32

Returns an ImGui-packed ABGR color (ImU32) from a style color, with alpha multiplier.

Source

pub fn get_color_u32_from_rgba(&self, rgba: [f32; 4]) -> u32

Returns an ImGui-packed ABGR color (ImU32) from an RGBA float color.

Note: Dear ImGui applies the global style alpha when converting colors for rendering.

Source

pub fn get_color_u32_from_packed(&self, abgr: u32, alpha_mul: f32) -> u32

Returns an ImGui-packed ABGR color (ImU32) from an existing packed color, with alpha multiplier.

Source

pub fn style_color_name(&self, style_color: StyleColor) -> &'static str

Returns the name of a style color.

This queries Dear ImGui’s static name table for the provided StyleColor.

Source§

impl Ui

Source

pub fn is_rect_visible(&self, size: [f32; 2]) -> bool

Test if rectangle (of given size, starting from cursor position) is visible / not clipped.

Source

pub fn is_rect_visible_ex(&self, rect_min: [f32; 2], rect_max: [f32; 2]) -> bool

Test if rectangle (in screen space) is visible / not clipped.

Source§

impl Ui

Source

pub fn is_window_hovered(&self) -> bool

Returns true if the current window is hovered (and typically: not blocked by a popup/modal)

Source

pub fn is_window_hovered_with_flags(&self, flags: WindowHoveredFlags) -> bool

Returns true if the current window is hovered based on the given flags

Source

pub fn is_window_focused(&self) -> bool

Returns true if the current window is focused (and typically: not blocked by a popup/modal)

Source

pub fn is_window_focused_with_flags(&self, flags: FocusedFlags) -> bool

Returns true if the current window is focused based on the given flags

Source

pub fn is_window_appearing(&self) -> bool

Returns true if the current window is appearing this frame.

Source

pub fn is_window_collapsed(&self) -> bool

Returns true if the current window is collapsed.

Source§

impl Ui

Source

pub fn button(&self, label: impl AsRef<str>) -> bool

Creates a button with the given label

Source

pub fn button_with_size( &self, label: impl AsRef<str>, size: impl Into<[f32; 2]>, ) -> bool

Creates a button with the given label and size

Source

pub fn button_config<'ui>( &'ui self, label: impl Into<Cow<'ui, str>>, ) -> Button<'ui>

Creates a button builder

Source§

impl Ui

Source

pub fn checkbox(&self, label: impl AsRef<str>, value: &mut bool) -> bool

Creates a checkbox

Source

pub fn radio_button(&self, label: impl AsRef<str>, active: bool) -> bool

Creates a radio button

Source

pub fn radio_button_int( &self, label: impl AsRef<str>, v: &mut i32, v_button: i32, ) -> bool

Creates a radio button with integer value

Source

pub fn radio_button_bool(&self, label: impl AsRef<str>, active: bool) -> bool

Creates a radio button suitable for choosing an arbitrary value.

Returns true if this radio button was clicked.

Source

pub fn checkbox_flags<T>( &self, label: impl AsRef<str>, flags: &mut T, mask: T, ) -> bool
where T: Copy + PartialEq + BitOrAssign + BitAndAssign + BitAnd<Output = T> + Not<Output = T>,

Renders a checkbox suitable for toggling bit flags using a mask.

Returns true if this checkbox was clicked.

This matches the semantics of Dear ImGui’s CheckboxFlags() helpers: the checkbox is checked when (*flags & mask) == mask, and clicking it toggles the bits in mask.

Source§

impl Ui

§Color Edit Widgets

Source

pub fn color_edit3(&self, label: impl AsRef<str>, color: &mut [f32; 3]) -> bool

Creates a color edit widget for 3 components (RGB)

Source

pub fn color_edit4(&self, label: impl AsRef<str>, color: &mut [f32; 4]) -> bool

Creates a color edit widget for 4 components (RGBA)

Source

pub fn color_picker3( &self, label: impl AsRef<str>, color: &mut [f32; 3], ) -> bool

Creates a color picker widget for 3 components (RGB)

Source

pub fn color_picker4( &self, label: impl AsRef<str>, color: &mut [f32; 4], ) -> bool

Creates a color picker widget for 4 components (RGBA)

Source

pub fn color_button(&self, desc_id: impl AsRef<str>, color: [f32; 4]) -> bool

Creates a color button widget

Source

pub fn color_edit3_config<'ui, 'p>( &'ui self, label: impl Into<Cow<'ui, str>>, color: &'p mut [f32; 3], ) -> ColorEdit3<'ui, 'p>

Creates a color edit builder for 3 components

Source

pub fn color_edit4_config<'ui, 'p>( &'ui self, label: impl Into<Cow<'ui, str>>, color: &'p mut [f32; 4], ) -> ColorEdit4<'ui, 'p>

Creates a color edit builder for 4 components

Source

pub fn color_picker3_config<'ui, 'p>( &'ui self, label: impl Into<Cow<'ui, str>>, color: &'p mut [f32; 3], ) -> ColorPicker3<'ui, 'p>

Creates a color picker builder for 3 components

Source

pub fn color_picker4_config<'ui, 'p>( &'ui self, label: impl Into<Cow<'ui, str>>, color: &'p mut [f32; 4], ) -> ColorPicker4<'ui, 'p>

Creates a color picker builder for 4 components

Source

pub fn color_button_config<'ui>( &'ui self, desc_id: impl Into<Cow<'ui, str>>, color: [f32; 4], ) -> ColorButton<'ui>

Creates a color button builder

Source§

impl Ui

§Combo Box Widgets

Source

pub fn begin_combo( &self, label: impl AsRef<str>, preview_value: impl AsRef<str>, ) -> Option<ComboBoxToken<'_>>

Creates a combo box and starts appending to it.

Returns Some(ComboBoxToken) if the combo box is open. After content has been rendered, the token must be ended by calling .end().

Returns None if the combo box is not open and no content should be rendered.

Source

pub fn begin_combo_with_flags( &self, label: impl AsRef<str>, preview_value: impl AsRef<str>, flags: impl Into<ComboBoxOptions>, ) -> Option<ComboBoxToken<'_>>

Creates a combo box with flags and starts appending to it.

Returns Some(ComboBoxToken) if the combo box is open. After content has been rendered, the token must be ended by calling .end(). Returns None if the combo box is not open and no content should be rendered.

Source

pub fn begin_combo_no_preview( &self, label: impl AsRef<str>, ) -> Option<ComboBoxToken<'_>>

Creates a combo box without preview value.

Returns Some(ComboBoxToken) if the combo box is open. After content has been rendered, the token must be ended by calling .end().

Returns None if the combo box is not open and no content should be rendered.

Source

pub fn begin_combo_no_preview_with_flags( &self, label: impl AsRef<str>, flags: impl Into<ComboBoxOptions>, ) -> Option<ComboBoxToken<'_>>

Creates a combo box without preview value and with flags.

Returns Some(ComboBoxToken) if the combo box is open. After content has been rendered, the token must be ended by calling .end().

Returns None if the combo box is not open and no content should be rendered.

Source

pub fn combo<V, L>( &self, label: impl AsRef<str>, current_item: &mut usize, items: &[V], label_fn: L, ) -> bool
where L: for<'b> Fn(&'b V) -> Cow<'b, str>,

Builds a simple combo box for choosing from a slice of values.

Source

pub fn combo_i32<V, L>( &self, label: impl AsRef<str>, current_item: &mut i32, items: &[V], label_fn: L, ) -> bool
where L: for<'b> Fn(&'b V) -> Cow<'b, str>,

Builds a simple combo box using an i32 index (ImGui-style).

This is useful when you want to represent "no selection" with -1, matching Dear ImGui’s Combo() API.

Source

pub fn combo_simple_string( &self, label: impl AsRef<str>, current_item: &mut usize, items: &[impl AsRef<str>], ) -> bool

Builds a simple combo box for choosing from a slice of strings

Source

pub fn combo_simple_string_i32( &self, label: impl AsRef<str>, current_item: &mut i32, items: &[impl AsRef<str>], ) -> bool

Builds a simple combo box for choosing from a slice of strings using an i32 index.

Source

pub fn set_item_default_focus(&self)

Makes the last submitted item the default focus of a newly appearing window.

Source§

impl Ui

Source

pub fn drag<T, K>(&self, label: T, value: &mut K) -> bool
where T: AsRef<str>, K: DataTypeKind,

Creates a new drag slider widget. Returns true if the value has been edited.

Source

pub fn drag_config<T, K>(&self, label: T) -> Drag<K, T>
where T: AsRef<str>, K: DataTypeKind,

Creates a new unbuilt Drag.

Source

pub fn drag_float2(&self, label: impl AsRef<str>, values: &mut [f32; 2]) -> bool

Creates a drag float2 slider (2 floats)

Source

pub fn drag_float3(&self, label: impl AsRef<str>, values: &mut [f32; 3]) -> bool

Creates a drag float3 slider (3 floats)

Source

pub fn drag_float4(&self, label: impl AsRef<str>, values: &mut [f32; 4]) -> bool

Creates a drag float4 slider (4 floats)

Source

pub fn drag_int2(&self, label: impl AsRef<str>, values: &mut [i32; 2]) -> bool

Creates a drag int2 slider (2 ints)

Source

pub fn drag_int3(&self, label: impl AsRef<str>, values: &mut [i32; 3]) -> bool

Creates a drag int3 slider (3 ints)

Source

pub fn drag_int4(&self, label: impl AsRef<str>, values: &mut [i32; 4]) -> bool

Creates a drag int4 slider (4 ints)

Source§

impl Ui

§Image Widgets

Examples

  • Using a plain texture id:
let tex_id = texture::TextureId::new(0xDEAD_BEEF);
ui.image(tex_id, [128.0, 128.0]);
  • Using an ImGui-managed texture:
let tex = texture::OwnedTextureData::from_pixels(
    texture::TextureFormat::RGBA32,
    64,
    64,
    &vec![255; 64 * 64 * 4],
)?;
let tex = context.register_texture(tex);
let ui = context.frame();
ui.image(tex, [64.0, 64.0]);
Source

pub fn image<'tex>(&self, texture: impl Into<TextureRef<'tex>>, size: [f32; 2])

Creates an image widget

Source

pub fn image_button<'tex>( &self, str_id: impl AsRef<str>, texture: impl Into<TextureRef<'tex>>, size: [f32; 2], ) -> bool

Creates an image button widget

Source

pub fn image_config<'ui, 'tex>( &'ui self, texture: impl Into<TextureRef<'tex>>, size: [f32; 2], ) -> Image<'ui, 'tex>

Creates an image builder

Source

pub fn image_button_config<'ui, 'tex>( &'ui self, str_id: impl Into<Cow<'ui, str>>, texture: impl Into<TextureRef<'tex>>, size: [f32; 2], ) -> ImageButton<'ui, 'tex>

Creates an image button builder

Source§

impl Ui

§Input Widgets

Source

pub fn input_text<'ui, 'p>( &'ui self, label: impl Into<Cow<'ui, str>>, buf: &'p mut String, ) -> InputText<'ui, 'p>

Creates a single-line text input widget builder.

§Examples
let mut text = String::new();
if ui.input_text("Label", &mut text).build() {
    println!("Text changed: {}", text);
}
Source

pub fn input_text_imstr<'ui, 'p>( &'ui self, label: impl Into<Cow<'ui, str>>, buf: &'p mut ImString, ) -> InputTextImStr<'ui, 'p>

Creates a single-line text input backed by ImString (zero-copy)

Source

pub fn input_text_multiline<'ui, 'p>( &'ui self, label: impl Into<Cow<'ui, str>>, buf: &'p mut String, size: impl Into<[f32; 2]>, ) -> InputTextMultiline<'ui, 'p>

Creates a multi-line text input widget builder.

§Examples
let mut text = String::new();
if ui.input_text_multiline("Label", &mut text, [200.0, 100.0]).build() {
    println!("Text changed: {}", text);
}
Source

pub fn input_text_multiline_imstr<'ui, 'p>( &'ui self, label: impl Into<Cow<'ui, str>>, buf: &'p mut ImString, size: impl Into<[f32; 2]>, ) -> InputTextMultilineImStr<'ui, 'p>

Creates a multi-line text input backed by ImString (zero-copy)

Source

pub fn input_int(&self, label: impl AsRef<str>, value: &mut i32) -> bool

Creates an integer input widget.

Returns true if the value was edited.

Source

pub fn input_float(&self, label: impl AsRef<str>, value: &mut f32) -> bool

Creates a float input widget.

Returns true if the value was edited.

Source

pub fn input_double(&self, label: impl AsRef<str>, value: &mut f64) -> bool

Creates a double input widget.

Returns true if the value was edited.

Source

pub fn input_int_config<'ui>( &'ui self, label: impl Into<Cow<'ui, str>>, ) -> InputInt<'ui>

Creates an integer input builder

Source

pub fn input_float_config<'ui>( &'ui self, label: impl Into<Cow<'ui, str>>, ) -> InputFloat<'ui>

Creates a float input builder

Source

pub fn input_double_config<'ui>( &'ui self, label: impl Into<Cow<'ui, str>>, ) -> InputDouble<'ui>

Creates a double input builder

Source

pub fn input_scalar<'p, L, T>( &self, label: L, value: &'p mut T, ) -> InputScalar<'_, 'p, T, L>
where L: AsRef<str>, T: DataTypeKind,

Shows an input field for a scalar value. This is not limited to f32 and i32 and can be used with any primitive scalar type e.g. u8 and f64.

Source

pub fn input_scalar_n<'p, L, T>( &self, label: L, values: &'p mut [T], ) -> InputScalarN<'_, 'p, T, L>
where L: AsRef<str>, T: DataTypeKind,

Shows a horizontal array of scalar value input fields. See input_scalar.

Source

pub fn input_float2<'p, L>( &self, label: L, value: &'p mut [f32; 2], ) -> InputFloat2<'_, 'p, L>
where L: AsRef<str>,

Widget to edit two floats

Source

pub fn input_float3<'p, L>( &self, label: L, value: &'p mut [f32; 3], ) -> InputFloat3<'_, 'p, L>
where L: AsRef<str>,

Widget to edit three floats

Source

pub fn input_float4<'p, L>( &self, label: L, value: &'p mut [f32; 4], ) -> InputFloat4<'_, 'p, L>
where L: AsRef<str>,

Widget to edit four floats

Source

pub fn input_int2<'p, L>( &self, label: L, value: &'p mut [i32; 2], ) -> InputInt2<'_, 'p, L>
where L: AsRef<str>,

Widget to edit two integers

Source

pub fn input_int3<'p, L>( &self, label: L, value: &'p mut [i32; 3], ) -> InputInt3<'_, 'p, L>
where L: AsRef<str>,

Widget to edit three integers

Source

pub fn input_int4<'p, L>( &self, label: L, value: &'p mut [i32; 4], ) -> InputInt4<'_, 'p, L>
where L: AsRef<str>,

Widget to edit four integers

Source§

impl Ui

§List Box Widgets

Source

pub fn list_box_config<T>(&self, label: T) -> ListBox<T>
where T: AsRef<str>,

Constructs a new list box builder.

Source§

impl Ui

Source

pub fn begin_main_menu_bar(&self) -> Option<MainMenuBarToken<'_>>

Creates and starts appending to a full-screen menu bar.

Returns Some(MainMenuBarToken) if the menu bar is visible. After content has been rendered, the token must be ended by calling .end().

Returns None if the menu bar is not visible and no content should be rendered.

Source

pub fn main_menu_bar<R>(&self, f: impl FnOnce() -> R) -> Option<R>

Creates the full-screen main menu bar and runs a closure to construct its contents.

Returns None without calling f when the menu bar is not visible. The menu bar is ended before a successful closure result is returned and during unwinding if f panics.

Source

pub fn begin_menu_bar(&self) -> Option<MenuBarToken<'_>>

Creates and starts appending to a menu bar for a window.

Returns Some(MenuBarToken) if the menu bar is visible. After content has been rendered, the token must be ended by calling .end().

Returns None if the menu bar is not visible and no content should be rendered.

Source

pub fn menu_bar<R>(&self, f: impl FnOnce() -> R) -> Option<R>

Creates the current window’s menu bar and runs a closure to construct its contents.

Returns None without calling f when the menu bar is not visible. The menu bar is ended before a successful closure result is returned and during unwinding if f panics.

Source

pub fn begin_menu(&self, label: impl AsRef<str>) -> Option<MenuToken<'_>>

Creates a menu and starts appending to it.

Returns Some(MenuToken) if the menu is open. After content has been rendered, the token must be ended by calling .end().

Returns None if the menu is not open and no content should be rendered.

Source

pub fn begin_menu_with_enabled( &self, label: impl AsRef<str>, enabled: bool, ) -> Option<MenuToken<'_>>

Creates a menu with enabled state and starts appending to it.

Returns Some(MenuToken) if the menu is open. After content has been rendered, the token must be ended by calling .end().

Returns None if the menu is not open and no content should be rendered.

Source

pub fn menu<F>(&self, label: impl AsRef<str>, f: F)
where F: FnOnce(),

Creates a menu and runs a closure to construct the contents.

Note: the closure is not called if the menu is not visible.

This is the equivalent of menu_with_enabled with enabled set to true.

Source

pub fn menu_with_enabled<F>(&self, label: impl AsRef<str>, enabled: bool, f: F)
where F: FnOnce(),

Creates a menu and runs a closure to construct the contents.

Note: the closure is not called if the menu is not visible.

Source§

impl Ui

Source

pub fn menu_item(&self, label: impl AsRef<str>) -> bool

Creates a menu item.

Returns true if the menu item is activated.

Source

pub fn menu_item_with_shortcut( &self, label: impl AsRef<str>, shortcut: impl AsRef<str>, ) -> bool

Creates a menu item with a shortcut.

Returns true if the menu item is activated.

Source

pub fn menu_item_enabled_selected( &self, label: impl AsRef<str>, shortcut: Option<impl AsRef<str>>, selected: bool, enabled: bool, ) -> bool

Creates a menu item with explicit enabled/selected state. Returns true if the menu item is activated.

Source

pub fn menu_item_enabled_selected_no_shortcut( &self, label: impl AsRef<str>, selected: bool, enabled: bool, ) -> bool

Creates a menu item with explicit enabled/selected state (no shortcut).

Returns true if the menu item is activated.

Source

pub fn menu_item_enabled_selected_with_shortcut( &self, label: impl AsRef<str>, shortcut: impl AsRef<str>, selected: bool, enabled: bool, ) -> bool

Creates a menu item with explicit enabled/selected state and a shortcut.

Returns true if the menu item is activated.

Source

pub fn menu_item_toggle( &self, label: impl AsRef<str>, shortcut: Option<impl AsRef<str>>, selected: &mut bool, enabled: bool, ) -> bool

Creates a toggleable menu item bound to selected (updated in place). Returns true if the menu item is activated.

Source

pub fn menu_item_toggle_no_shortcut( &self, label: impl AsRef<str>, selected: &mut bool, enabled: bool, ) -> bool

Creates a toggleable menu item bound to selected (no shortcut).

Returns true if the menu item is activated.

Source

pub fn menu_item_toggle_with_shortcut( &self, label: impl AsRef<str>, shortcut: impl AsRef<str>, selected: &mut bool, enabled: bool, ) -> bool

Creates a toggleable menu item bound to selected with a shortcut.

Returns true if the menu item is activated.

Source§

impl Ui

Source

pub fn bullet(&self)

Creates a bullet point

Source

pub fn bullet_text(&self, text: impl AsRef<str>)

Creates a bullet point with text

Source§

impl Ui

Source

pub fn small_button(&self, label: impl AsRef<str>) -> bool

Creates a small button

Source§

impl Ui

Source

pub fn push_button_repeat(&self, repeat: bool) -> ItemFlagStackToken<'_>

Enable/disable repeating behavior for subsequent buttons.

Internally uses PushItemFlag(ImGuiItemFlags_ButtonRepeat, repeat).

Source

pub fn with_button_repeat<R>(&self, repeat: bool, f: impl FnOnce() -> R) -> R

Push a button repeat item flag, run f, then pop the flag.

The flag is popped during unwinding if f panics.

Source§

impl Ui

Source

pub fn begin_disabled(&self) -> DisabledToken<'_>

Begin a disabled scope for subsequent items.

All following widgets will be disabled (grayed out and non-interactive) until the returned token is dropped.

Source

pub fn begin_disabled_with_cond(&self, disabled: bool) -> DisabledToken<'_>

Begin a conditionally disabled scope for subsequent items.

If disabled is false, this still needs to be paired with the returned token being dropped to correctly balance the internal stack.

Source

pub fn with_disabled<R>(&self, f: impl FnOnce() -> R) -> R

Runs f while subsequent items are disabled.

The disabled scope is ended before a successful closure result is returned and during unwinding if f panics.

Source

pub fn with_disabled_if<R>(&self, disabled: bool, f: impl FnOnce() -> R) -> R

Runs f inside a conditionally disabled scope.

Dear ImGui requires a balanced BeginDisabled/EndDisabled pair even when disabled is false. This helper preserves that balance before returning or during unwinding.

Source§

impl Ui

Source

pub fn invisible_button( &self, str_id: impl AsRef<str>, size: impl Into<[f32; 2]>, ) -> bool

Creates an invisible button

Source

pub fn invisible_button_flags( &self, str_id: impl AsRef<str>, size: impl Into<[f32; 2]>, flags: ButtonFlags, ) -> bool

Creates an invisible button with independent flags.

Use Self::invisible_button_options to choose a mouse button other than the default left button.

Source

pub fn invisible_button_options( &self, str_id: impl AsRef<str>, size: impl Into<[f32; 2]>, options: impl Into<InvisibleButtonOptions>, ) -> bool

Creates an invisible button with complete options.

Source

pub fn arrow_button(&self, str_id: impl AsRef<str>, dir: Direction) -> bool

Creates an arrow button

Source§

impl Ui

Source

pub fn set_item_key_owner(&self, key: Key) -> bool

Set the key owner for the last item, without flags.

Returns true when ownership was requested for the item.

Source

pub fn set_item_key_owner_with_flags( &self, key: Key, flags: ItemKeyOwnerFlags, ) -> bool

Set the key owner for the last item with input flags.

Returns true when ownership was requested for the item.

Source§

impl Ui

Source

pub fn with_multi_select( &self, flags: impl Into<MultiSelectOptions>, selection_size: Option<i32>, items_count: usize, render: impl FnOnce(&mut MultiSelectScope<'_>), ) -> MultiSelectResult

Run an advanced multi-select block and return an owned copy of its final requests.

The scope exposes only operations that are valid between BeginMultiSelect() and EndMultiSelect(). EndMultiSelect() runs exactly once even if render panics, and the returned MultiSelectResult contains no native pointers.

Source

pub fn multi_select_indexed<S, F>( &self, storage: &mut S, flags: impl Into<MultiSelectOptions>, render_item: F, )

Multi-select helper for index-based storage.

This wraps BeginMultiSelect() / EndMultiSelect() and applies selection requests to an index-addressable selection container.

Typical usage:

let mut selected = vec![false; 128];

ui.multi_select_indexed(&mut selected, MultiSelectOptions::new(), |ui, idx, is_selected| {
    ui.text(format!(
        "{} {}",
        if is_selected { "[x]" } else { "[ ]" },
        idx
    ));
});

Notes:

  • storage.len() defines items_count.
  • This helper uses the “external storage” pattern where selection is stored entirely on the application side.
  • Per-item selection toggles can be queried via Ui::is_item_toggled_selection.
Source

pub fn table_multi_select_indexed<S, F>( &self, storage: &mut S, flags: impl Into<MultiSelectOptions>, build_row: F, )

Multi-select helper for index-based storage inside an active table.

This is a convenience wrapper over Ui::multi_select_indexed that automatically advances table rows and starts each row at column 0.

It expects to be called between BeginTable/EndTable.

Source

pub fn multi_select_basic<G, F>( &self, selection: &mut BasicSelection, flags: impl Into<MultiSelectOptions>, items_count: usize, id_at_index: G, render_item: F, )
where G: FnMut(usize) -> Id, F: FnMut(&Ui, usize, Id, bool),

Multi-select helper using BasicSelection as underlying storage.

This variant is suitable when items are naturally identified by ImGuiID (e.g. stable ids for rows or tree nodes).

  • items_count: number of items in the scope.
  • id_at_index: maps [0, items_count) to the corresponding item id.
  • render_item: called once per index to emit widgets for that item.
Source§

impl Ui

§Plot Widgets

Source

pub fn plot_lines(&self, label: impl AsRef<str>, values: &[f32])

Creates a plot lines widget

Source

pub fn plot_histogram(&self, label: impl AsRef<str>, values: &[f32])

Creates a plot histogram widget

Source

pub fn plot_lines_config<'ui, 'p>( &'ui self, label: impl Into<Cow<'ui, str>>, values: &'p [f32], ) -> PlotLines<'ui, 'p>

Creates a plot lines builder

Source

pub fn plot_histogram_config<'ui, 'p>( &'ui self, label: impl Into<Cow<'ui, str>>, values: &'p [f32], ) -> PlotHistogram<'ui, 'p>

Creates a plot histogram builder

Source§

impl Ui

Source

pub fn open_popup(&self, str_id: impl AsRef<str>) -> bool

Instructs ImGui that a popup is open.

You should call this function once while calling any of the following per-frame:

The confusing aspect to popups is that ImGui holds control over the popup itself.

Returns true when this request toggles the popup toward its open state. Existing callers that do not need to initialize popup-local state may ignore the result.

Source

pub fn open_popup_with_flags( &self, str_id: impl AsRef<str>, flags: PopupOpenFlags, ) -> bool

Instructs ImGui that a popup is open with flags.

Returns true when this request toggles the popup toward its open state.

Source

pub fn open_popup_id(&self, id: Id) -> bool

Opens a popup by an ID from the current ID stack.

Returns true when the popup is toggled open.

Source

pub fn open_popup_id_with_flags(&self, id: Id, flags: PopupOpenFlags) -> bool

Opens a popup by an ID from the current ID stack, with flags.

Returns true when the popup is toggled open.

Source

pub fn open_popup_on_item_click(&self, str_id: Option<&str>) -> bool

Opens a popup when the last item is clicked (typically right-click).

If str_id is None, the popup is associated with the last item ID. Returns true only when the click opens the popup.

Source

pub fn open_popup_on_item_click_with_flags( &self, str_id: Option<&str>, flags: impl Into<PopupContextOptions>, ) -> bool

Opens a popup when the last item is clicked, with explicit flags.

Returns true only when the configured click opens the popup.

Source

pub fn begin_popup(&self, str_id: impl AsRef<str>) -> Option<PopupToken<'_>>

Construct a popup that can have any kind of content.

This should be called per frame, whereas open_popup should be called once to signal that this popup is active.

Source

pub fn begin_popup_with_flags( &self, str_id: impl AsRef<str>, flags: WindowFlags, ) -> Option<PopupToken<'_>>

Construct a popup with window flags.

Source

pub fn popup<F>(&self, str_id: impl AsRef<str>, f: F)
where F: FnOnce(),

Construct a popup that can have any kind of content.

This should be called per frame, whereas open_popup should be called once to signal that this popup is active.

Source

pub fn begin_modal_popup( &self, name: impl AsRef<str>, ) -> Option<ModalPopupToken<'_>>

Creates a modal popup.

Modal popups block interaction with the rest of the application until closed.

Source

pub fn begin_modal_popup_with_opened( &self, name: impl AsRef<str>, opened: &mut bool, ) -> Option<ModalPopupToken<'_>>

Creates a modal popup with an opened-state tracking variable.

Passing opened enables the title-bar close button (X). When clicked, ImGui will set *opened = false and close the popup.

Notes:

Source

pub fn begin_modal_popup_config<'a>(&'a self, name: &'a str) -> ModalPopup<'a>

Creates a modal popup builder.

Source

pub fn modal_popup<F, R>(&self, name: impl AsRef<str>, f: F) -> Option<R>
where F: FnOnce() -> R,

Creates a modal popup and runs a closure to construct the contents.

Returns the result of the closure if the popup is open.

Source

pub fn modal_popup_with_opened<F, R>( &self, name: impl AsRef<str>, opened: &mut bool, f: F, ) -> Option<R>
where F: FnOnce() -> R,

Creates a modal popup with an opened-state tracking variable and runs a closure to construct the contents.

Returns the result of the closure if the popup is open.

Source

pub fn close_current_popup(&self)

Closes the current popup.

Source

pub fn is_popup_open(&self, str_id: impl AsRef<str>) -> bool

Returns true if the popup is open.

Source

pub fn is_popup_open_with_flags( &self, str_id: impl AsRef<str>, flags: PopupQueryFlags, ) -> bool

Returns true if the popup is open with flags.

Source

pub fn begin_popup_context_item(&self) -> Option<PopupToken<'_>>

Begin a popup context menu for the last item.

Source

pub fn begin_popup_context_item_with_label( &self, str_id: Option<&str>, ) -> Option<PopupToken<'_>>

Begin a popup context menu for the last item with a custom label.

Source

pub fn begin_popup_context_item_with_flags( &self, str_id: Option<&str>, flags: impl Into<PopupContextOptions>, ) -> Option<PopupToken<'_>>

Begin a popup context menu for the last item with explicit popup flags.

Source

pub fn begin_popup_context_window(&self) -> Option<PopupToken<'_>>

Begin a popup context menu for the current window.

Source

pub fn begin_popup_context_window_with_label( &self, str_id: Option<&str>, ) -> Option<PopupToken<'_>>

Begin a popup context menu for the current window with a custom label.

Source

pub fn begin_popup_context_window_with_flags( &self, str_id: Option<&str>, flags: impl Into<PopupContextOptions>, ) -> Option<PopupToken<'_>>

Begin a popup context menu for the current window with explicit popup flags.

Source

pub fn begin_popup_context_void(&self) -> Option<PopupToken<'_>>

Begin a popup context menu for empty space (void).

Source

pub fn begin_popup_context_void_with_label( &self, str_id: Option<&str>, ) -> Option<PopupToken<'_>>

Begin a popup context menu for empty space with a custom label.

Source

pub fn begin_popup_context_void_with_flags( &self, str_id: Option<&str>, flags: impl Into<PopupContextOptions>, ) -> Option<PopupToken<'_>>

Begin a popup context menu for empty space (void) with explicit popup flags.

Source§

impl Ui

§Progress Bar Widgets

Source

pub fn progress_bar(&self, fraction: f32) -> ProgressBar<'_>

Creates a progress bar widget.

The fraction should be between 0.0 (0%) and 1.0 (100%).

Source

pub fn progress_bar_with_overlay<'ui>( &'ui self, fraction: f32, overlay: impl Into<Cow<'ui, str>>, ) -> ProgressBar<'ui>

Creates a progress bar with overlay text.

Source§

impl Ui

Source

pub fn selectable<T>(&self, label: T) -> bool
where T: AsRef<str>,

Constructs a new simple selectable.

Use selectable_config for a builder with additional options.

Source

pub fn selectable_config<T>(&self, label: T) -> Selectable<'_, T>
where T: AsRef<str>,

Constructs a new selectable builder.

Source§

impl Ui

Source

pub fn slider<T, K>(&self, label: T, min: K, max: K, value: &mut K) -> bool
where T: AsRef<str>, K: DataTypeKind,

Creates a new slider widget. Returns true if the value has been edited.

Source

pub fn slider_config<T, K>(&self, label: T, min: K, max: K) -> Slider<'_, T, K>
where T: AsRef<str>, K: DataTypeKind,

Creates a new unbuilt Slider.

Source

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

Creates a float slider

Source

pub fn slider_i32( &self, label: impl AsRef<str>, value: &mut i32, min: i32, max: i32, ) -> bool

Creates an integer slider

Source

pub fn slider_float2( &self, label: impl AsRef<str>, value: &mut [f32; 2], min: f32, max: f32, ) -> bool

Creates a float2 slider

Source

pub fn slider_float3( &self, label: impl AsRef<str>, value: &mut [f32; 3], min: f32, max: f32, ) -> bool

Creates a float3 slider

Source

pub fn slider_float4( &self, label: impl AsRef<str>, value: &mut [f32; 4], min: f32, max: f32, ) -> bool

Creates a float4 slider

Source

pub fn slider_int2( &self, label: impl AsRef<str>, value: &mut [i32; 2], min: i32, max: i32, ) -> bool

Creates an int2 slider

Source

pub fn slider_int3( &self, label: impl AsRef<str>, value: &mut [i32; 3], min: i32, max: i32, ) -> bool

Creates an int3 slider

Source

pub fn slider_int4( &self, label: impl AsRef<str>, value: &mut [i32; 4], min: i32, max: i32, ) -> bool

Creates an int4 slider

Source

pub fn v_slider_f32( &self, label: impl AsRef<str>, size: impl Into<[f32; 2]>, value: &mut f32, min: f32, max: f32, ) -> bool

Creates a vertical slider

Source

pub fn v_slider_i32( &self, label: impl AsRef<str>, size: impl Into<[f32; 2]>, value: &mut i32, min: i32, max: i32, ) -> bool

Creates a vertical integer slider

Source

pub fn slider_angle(&self, label: impl AsRef<str>, value_rad: &mut f32) -> bool

Creates an angle slider (value in radians)

Source§

impl Ui

§Tab Widgets

Source

pub fn tab_bar(&self, id: impl AsRef<str>) -> Option<TabBarToken<'_>>

Creates a tab bar and returns a tab bar token, allowing you to append Tab items afterwards. This passes no flags. To pass flags explicitly, use tab_bar_with_flags.

Source

pub fn tab_bar_with_flags( &self, id: impl AsRef<str>, flags: impl Into<TabBarOptions>, ) -> Option<TabBarToken<'_>>

Creates a tab bar and returns a tab bar token, allowing you to append Tab items afterwards.

Source

pub fn tab_item(&self, label: impl AsRef<str>) -> Option<TabItemToken<'_>>

Creates a new tab item and returns a token if its contents are visible.

By default, this doesn’t pass an opened bool nor any flags. See tab_item_with_opened and tab_item_with_flags for more.

Source

pub fn tab_item_with_opened( &self, label: impl AsRef<str>, opened: &mut bool, ) -> Option<TabItemToken<'_>>

Creates a new tab item and returns a token if its contents are visible.

By default, this doesn’t pass any flags. See Self::tab_item_with_flags for more.

Source

pub fn tab_item_with_flags( &self, label: impl AsRef<str>, opened: Option<&mut bool>, flags: impl Into<TabItemOptions>, ) -> Option<TabItemToken<'_>>

Creates a new tab item and returns a token if its contents are visible.

Source

pub fn tab_item_button(&self, label: impl AsRef<str>) -> bool

Creates a button on the current tab bar (e.g. to append a + new-tab button).

Source

pub fn tab_item_button_with_flags( &self, label: impl AsRef<str>, flags: impl Into<TabItemOptions>, ) -> bool

Creates a button on the current tab bar with explicit flags.

Source

pub fn set_tab_item_closed(&self, tab_or_docked_window_label: impl AsRef<str>)

Notifies Dear ImGui that a tab (or docked window) has been closed.

Source§

impl Ui

§Table Widgets

Source

pub fn table<'ui>( &'ui self, str_id: impl Into<Cow<'ui, str>>, ) -> TableBuilder<'ui>

Start a Table builder for ergonomic setup + headers + options.

Example

ui.table("perf")
    .flags(TableFlags::RESIZABLE | TableFlags::SORTABLE)
    .outer_size([600.0, 240.0])
    .freeze(1, 1)
    .column("Name").width(140.0).done()
    .column("Value").weight(1.0).done()
    .headers(true)
    .build(|ui| {
        ui.table_next_row();
        ui.table_next_column(); ui.text("CPU");
        ui.table_next_column(); ui.text("Intel");
    });
Source

pub fn begin_table( &self, str_id: impl AsRef<str>, column_count: usize, ) -> Option<TableToken<'_>>

Begins a table with no flags and with standard sizing constraints.

This does no work on styling the headers (the top row) – see either begin_table_header or the more complex table_setup_column.

§Panics

Panics if column_count is zero or reaches Dear ImGui’s column limit.

Source

pub fn begin_table_with_flags( &self, str_id: impl AsRef<str>, column_count: usize, flags: impl Into<TableOptions>, ) -> Option<TableToken<'_>>

Begins a table with flags and with standard sizing constraints.

§Panics

Panics for an invalid column count or incompatible table options.

Source

pub fn begin_table_with_sizing( &self, str_id: impl AsRef<str>, column_count: usize, flags: impl Into<TableOptions>, outer_size: impl Into<[f32; 2]>, inner_width: f32, ) -> Option<TableToken<'_>>

Begins a table with all flags and sizing constraints. This is the base method, and gives users the most flexibility.

§Panics

Panics for an invalid column count or table option, non-finite sizing, a negative inner_width when horizontal scrolling is enabled, or an active table draw-channel scope on the current table cell.

Source

pub fn begin_table_header<Name, const N: usize>( &self, str_id: impl AsRef<str>, column_data: [TableColumnSetup<Name>; N], ) -> Option<TableToken<'_>>
where Name: AsRef<str>,

Begins a table with no flags and with standard sizing constraints.

Takes an array of table header information, the length of which determines how many columns will be created.

§Panics

Panics if the array is empty, reaches Dear ImGui’s column limit, or contains invalid column setup data.

Source

pub fn begin_table_header_with_flags<Name, const N: usize>( &self, str_id: impl AsRef<str>, column_data: [TableColumnSetup<Name>; N], flags: impl Into<TableOptions>, ) -> Option<TableToken<'_>>
where Name: AsRef<str>,

Begins a table with flags and with standard sizing constraints.

Takes an array of table header information, the length of which determines how many columns will be created.

§Panics

Panics for an invalid column count, table option, or column setup value.

Source

pub fn table_setup_column( &self, label: impl AsRef<str>, flags: TableColumnFlags, width: Option<TableColumnWidth>, )

Setup a column for the current table.

§Panics

Panics outside a table, after table layout has started, after all declared columns have already been configured, or for an invalid flag/width combination or non-finite width.

Source

pub fn table_setup_column_with_user_data( &self, label: impl AsRef<str>, flags: TableColumnFlags, width: Option<TableColumnWidth>, user_data: impl Into<TableColumnUserData>, )

Setup a column for the current table with opaque application data.

§Panics

Has the same validation and phase requirements as Ui::table_setup_column.

Source

pub fn table_setup_column_with_indent( &self, label: impl AsRef<str>, flags: TableColumnFlags, width: Option<TableColumnWidth>, indent: Option<TableColumnIndent>, )

Setup a column for the current table, including explicit indent policy.

§Panics

Has the same validation and phase requirements as Ui::table_setup_column.

Source

pub fn table_setup_column_with_indent_and_user_data( &self, label: impl AsRef<str>, flags: TableColumnFlags, width: Option<TableColumnWidth>, indent: Option<TableColumnIndent>, user_data: impl Into<TableColumnUserData>, )

Setup a column with explicit indent policy and opaque application data.

§Panics

Panics outside a table, after table layout has started, after all declared columns have already been configured, or for invalid flags, indent/width combinations, or non-finite width/weight values.

Source

pub fn table_setup_column_fixed_width( &self, label: impl AsRef<str>, flags: TableColumnFlags, width: f32, )

Setup a column with a fixed initial width.

§Panics

Has the same validation and phase requirements as Ui::table_setup_column.

Source

pub fn table_setup_column_stretch_weight( &self, label: impl AsRef<str>, flags: TableColumnFlags, weight: f32, )

Setup a column with a stretch weight.

§Panics

Has the same validation and phase requirements as Ui::table_setup_column.

Source

pub fn table_headers_row(&self)

Submit all header cells based on data provided to TableSetupColumn() and submit the context-menu target.

§Panics

Panics outside a table or while a table draw-channel scope is active.

Source

pub fn table_next_column(&self) -> bool

Append into the next column, or the first column of the next row when currently in the last column.

Returns false when no table is current.

§Panics

Panics while a table draw-channel scope is active.

Source

pub fn table_set_column_index( &self, column: impl Into<TableColumnIndex>, ) -> bool

Append into the specified column.

Returns false when no table is current.

§Panics

Panics if column is outside the current table or while a table draw-channel scope is active.

Source

pub fn table_next_row(&self)

Append into the next row.

§Panics

Panics outside a table or while a table draw-channel scope is active.

Source

pub fn table_next_row_with_flags( &self, flags: TableRowFlags, min_row_height: f32, )

Append into the next row with flags and minimum height.

§Panics

Panics outside a table, while a table draw-channel scope is active, or when min_row_height is negative or non-finite.

Source

pub fn table_setup_scroll_freeze(&self, frozen_cols: usize, frozen_rows: usize)

Freeze columns/rows so they stay visible when scrolling.

§Panics

Panics outside a table, after the table setup phase, or when either freeze count exceeds Dear ImGui’s supported range.

Source

pub fn table_header(&self, label: impl AsRef<str>)

Submit one header cell at the current column position.

§Panics

Panics unless a table cell is current.

Source

pub fn table_get_column_count(&self) -> usize

Return the current table’s column count, or zero when no table is current.

Source

pub fn table_get_column_index(&self) -> Option<TableColumnIndex>

Return current column index, or None when no table cell is current.

Source

pub fn table_get_row_index(&self) -> Option<TableRowIndex>

Return current row index, or None when no table row is current.

Source

pub fn table_get_column_name(&self, column: impl Into<TableColumnRef>) -> &str

Return the name of a column by index.

Returns an empty string when no table is current.

§Panics

Panics when a table is current and the requested/current column is invalid.

Source

pub fn table_get_column_flags( &self, column: impl Into<TableColumnRef>, ) -> TableColumnStateFlags

Return the flags of a column by index.

Returns empty flags when no table is current.

§Panics

Panics when a table is current and the requested/current column is invalid.

Source

pub fn table_set_column_enabled( &self, column: impl Into<TableColumnRef>, enabled: bool, )

Enable or disable a column by index.

§Panics

Panics outside a table, when the table lacks TableFlags::HIDEABLE, or when the requested/current column is invalid.

Source

pub fn table_get_hovered_column(&self) -> TableHoveredColumn

Return the hovered column, unused table space, or TableHoveredColumn::None when no table column is hovered.

Source

pub fn table_set_column_width( &self, column: impl Into<TableColumnIndex>, width: f32, )

Set column width for a fixed-width column.

§Panics

Panics outside a table, after table layout is locked, before layout metrics are available, for an invalid column, or when width is negative or non-finite.

Source

pub fn table_set_cell_bg_color_u32( &self, color: u32, column: impl Into<TableColumnRef>, )

Set a table background color target.

Color must be an ImGui-packed ImU32 in ABGR order (IM_COL32). Use crate::colors::Color::to_imgui_u32() to convert RGBA floats.

§Panics

Panics unless a table row is current or when the requested/current column is invalid.

Source

pub fn table_set_cell_bg_color( &self, rgba: [f32; 4], column: impl Into<TableColumnRef>, )

Set a table cell background color using RGBA color (0..=1 floats).

§Panics

Has the same phase and column requirements as Ui::table_set_cell_bg_color_u32.

Source

pub fn table_set_row_bg0_color_u32(&self, color: u32)

Set the first row background color for the current table row.

§Panics

Panics unless a table row is current.

Source

pub fn table_set_row_bg0_color(&self, rgba: [f32; 4])

Set the first row background color using RGBA color (0..=1 floats).

§Panics

Panics unless a table row is current.

Source

pub fn table_set_row_bg1_color_u32(&self, color: u32)

Set the second row background color for the current table row.

§Panics

Panics unless a table row is current.

Source

pub fn table_set_row_bg1_color(&self, rgba: [f32; 4])

Set the second row background color using RGBA color (0..=1 floats).

§Panics

Panics unless a table row is current.

Source

pub fn table_get_hovered_row(&self) -> TableHoveredRow

Return hovered row from the previous frame.

Source

pub fn table_get_header_row_height(&self) -> f32

Header row height in pixels.

§Panics

Panics outside a table.

Source

pub fn table_set_column_sort_direction( &self, column: impl Into<TableColumnIndex>, dir: SortDirection, append_to_sort_specs: bool, )

Set sort direction for a column. Optionally append to existing sort specs (multi-sort).

§Panics

Panics outside a table, when the table lacks TableFlags::SORTABLE, for an invalid column, or when SortDirection::None is used without TableFlags::SORT_TRISTATE.

Source

pub fn table_get_sort_specs(&self) -> Option<TableSortSpecs>

Get current table sort specifications, if any. When non-None and is_dirty() is true, the application should sort its data and then call TableSortSpecs::clear_dirty while this table is still current. Returns None outside a table or when the table has no sort specifications. On a sortable table, this may lock table layout, so finish all setup calls first.

Source§

impl Ui

Source

pub fn table_get_header_angled_max_label_width(&self) -> f32

Maximum label width used for angled headers when enabled in style/options.

§Panics

Panics outside a table.

Source

pub fn table_angled_headers_row(&self)

Submit an angled headers row (requires style/flags enabling angled headers).

§Panics

Panics outside a table, after the first row has started, or while a table draw-channel scope is active.

Source

pub fn table_angled_headers_row_ex_with_data( &self, row_id: u32, angle: f32, max_label_width: f32, headers: &[TableHeaderData], )

Submit angled headers row with explicit data (Ex variant).

  • row_id: ImGuiID for the row. Use 0 for automatic if not needed.
  • angle: Angle in radians for headers.
  • max_label_width: Maximum label width for angled headers.
  • headers: Per-column header data.
§Panics

Panics outside a table, after the first row has started, while a table draw-channel scope is active, for a non-finite/out-of-range angle, for a negative/non-finite maximum width, for an invalid column, or when headers are not ordered left-to-right without duplicates.

Source

pub fn with_table_background_channel<R>(&self, f: impl FnOnce() -> R) -> R

Run a closure while drawing into the current table’s background channel.

The channel cannot escape this closure. Row, column, nested-channel, and table-end transitions are rejected before FFI while it is active.

§Panics

Panics if there is no current table cell or another table channel is active.

Source

pub fn with_table_column_channel<R>( &self, column: impl Into<TableColumnIndex>, f: impl FnOnce() -> R, ) -> R

Run a closure while drawing into a selected table column channel.

The channel cannot escape this closure. Row, column, nested-channel, and table-end transitions are rejected before FFI while it is active.

§Panics

Panics if there is no current table cell, column is invalid, or another table channel is active.

Source

pub fn table_open_context_menu(&self, target: impl Into<TableContextMenuTarget>)

Open the table context menu for the current/default column.

§Panics

Panics outside a table or when an explicit column is outside the current table.

Source§

impl Ui

Source

pub fn calc_text_size(&self, text: impl AsRef<str>) -> [f32; 2]

Calculates the size required to render text with the current font and font size.

This is equivalent to Ui::calc_text_size_with_opts with hide_text_after_double_hash set to false and wrapping disabled.

Source

pub fn calc_text_size_with_opts( &self, text: impl AsRef<str>, hide_text_after_double_hash: bool, wrap_width: f32, ) -> [f32; 2]

Calculates the size required to render text with explicit display options.

When hide_text_after_double_hash is true, the ## label suffix is excluded from the measurement. A positive wrap_width enables wrapping; values at or below zero disable it.

§Panics

Panics if wrap_width is not finite.

Source

pub fn text_colored(&self, color: [f32; 4], text: impl AsRef<str>)

Display colored text

This implementation uses zero-copy optimization with igTextEx, avoiding string allocation and null-termination overhead.

§Example
ui.text_colored([1.0, 0.0, 0.0, 1.0], "Red text");
ui.text_colored([0.0, 1.0, 0.0, 1.0], "Green text");
Source

pub fn text_disabled(&self, text: impl AsRef<str>)

Display disabled (grayed out) text

This implementation uses zero-copy optimization with igTextEx, avoiding string allocation and null-termination overhead.

§Example
ui.text_disabled("This option is not available");
Source

pub fn text_wrapped(&self, text: impl AsRef<str>)

Display text wrapped to fit the current item width

This uses PushTextWrapPos + TextUnformatted + PopTextWrapPos to avoid calling C variadic APIs and to keep the input string unformatted.

Source

pub fn label_text(&self, label: impl AsRef<str>, text: impl AsRef<str>)

Display a label and text on the same line

Render a hyperlink-style text button. Returns true when clicked.

Render a hyperlink-style text button, and open the given URL when clicked. Returns true when clicked.

Source§

impl Ui

§Tooltip Widgets

Source

pub fn tooltip<F>(&self, f: F)
where F: FnOnce(),

Construct a tooltip window that can have any kind of content.

Typically used with Ui::is_item_hovered() or some other conditional check.

§Examples
ui.text("Hover over me");
if ui.is_item_hovered() {
    ui.tooltip(|| {
        ui.text_colored([1.0, 0.0, 0.0, 1.0], "I'm red!");
    });
}
Source

pub fn begin_tooltip(&self) -> Option<TooltipToken<'_>>

Construct a tooltip window that can have any kind of content.

Returns a TooltipToken that must be ended by calling .end() or by dropping.

Source

pub fn tooltip_text(&self, text: impl AsRef<str>)

Shortcut to call Self::tooltip with simple text content.

§Examples
ui.text("Hover over me");
if ui.is_item_hovered() {
    ui.tooltip_text("I'm a tooltip!");
}
Source

pub fn set_tooltip(&self, text: impl AsRef<str>)

Sets a tooltip with simple text content.

This renders unformatted text (no %-style formatting) and avoids calling C variadic APIs.

Source

pub fn set_tooltip_formatted(&self, text: impl AsRef<str>)

Sets a tooltip with formatted text content.

Source

pub fn set_item_tooltip(&self, text: impl AsRef<str>)

Sets a tooltip for the last item with simple text content.

Uses the non-variadic BeginItemTooltip path and renders unformatted text.

Source§

impl Ui

§Item/Widget Utilities and Query Functions

Source

pub fn is_item_hovered(&self) -> bool

Returns true if the last item is being hovered by mouse (and usable). This is typically used to show tooltips.

Source

pub fn is_item_hovered_with_flags(&self, flags: ItemHoveredFlags) -> bool

Returns true if the last item is being hovered by mouse with specific flags.

Source

pub fn is_item_active(&self) -> bool

Returns true if the last item is active (e.g. button being held, text field being edited).

Source

pub fn is_item_focused(&self) -> bool

Returns true if the last item is focused (e.g. text input field).

Source

pub fn is_item_clicked(&self) -> bool

Returns true if the last item was just clicked.

Source

pub fn is_item_clicked_with_button(&self, mouse_button: MouseButton) -> bool

Returns true if the last item was clicked with specific mouse button.

Source

pub fn is_item_visible(&self) -> bool

Returns true if the last item is visible (not clipped).

Source

pub fn is_item_activated(&self) -> bool

Returns true if the last item was just made active (e.g. button was pressed).

Source

pub fn is_item_deactivated(&self) -> bool

Returns true if the last item was just made inactive (e.g. button was released).

Source

pub fn is_item_deactivated_after_edit(&self) -> bool

Returns true if the last item was just made inactive and was edited.

Source

pub fn is_item_edited(&self) -> bool

Returns true if the last item was edited.

This is typically used to detect value changes for widgets.

Source

pub fn is_any_item_active(&self) -> bool

Returns true if any item is active.

Source

pub fn is_any_item_focused(&self) -> bool

Returns true if any item is focused.

Source

pub fn is_any_item_hovered(&self) -> bool

Returns true if any item is hovered.

Source

pub fn item_rect(&self) -> ([f32; 2], [f32; 2])

Gets the bounding rectangle of the last item in screen space.

Source

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

Gets the size of the last item.

Source

pub fn item_id(&self) -> Id

Returns the ImGui ID of the last item.

Source§

impl Ui

§Tree Node Widgets

Source

pub fn tree_node<I, T>(&self, id: I) -> Option<TreeNodeToken<'_>>
where I: Into<TreeNodeId<T>>, T: AsRef<str>,

Constructs a new tree node with just a name, and pushes it.

Use tree_node_config to access a builder to put additional configurations on the tree node.

Source

pub fn tree_node_config<I, T>(&self, id: I) -> TreeNode<'_, T>
where I: Into<TreeNodeId<T>>, T: AsRef<str>,

Constructs a new tree node builder.

Use tree_node to build a simple node with just a name.

Source

pub fn tree_push(&self, id: impl AsRef<str>) -> TreeNodeToken<'_>

Starts a tree indentation and ID scope without rendering a tree node.

The returned token restores the tree depth, indentation, and ID stack when dropped.

Source

pub fn tree_push_ptr<T>(&self, id: *const T) -> TreeNodeToken<'_>

Starts a tree indentation and ID scope using a pointer value as the ID.

The pointer is used only as an identifier and is not dereferenced.

Source

pub fn collapsing_header( &self, label: impl AsRef<str>, flags: TreeNodeFlags, ) -> bool

Creates a collapsing header widget

Source

pub fn collapsing_header_with_visible( &self, label: impl AsRef<str>, visible: &mut bool, flags: TreeNodeFlags, ) -> bool

Creates a collapsing header widget with a visibility tracking variable.

Passing visible enables a close button on the header. When clicked, ImGui will set *visible = false. As with other immediate-mode widgets, you should stop submitting the header when *visible == false.

Source

pub fn tree_node_to_label_spacing(&self) -> f32

Returns the distance from the start of a tree node to the label text.

Source

pub fn tree_node_get_open(&self, storage_id: Id) -> bool

Returns whether the tree node identified by storage_id is open in storage.

Source§

impl Ui

Source

pub fn child_window<'ui>( &'ui self, name: impl Into<Cow<'ui, str>>, ) -> ChildWindow<'ui>

Creates a child window builder

Source§

impl Ui

Source

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

Returns the size of the content region available for widgets

This is the size of the window minus decorations (title bar, scrollbars, etc.)

Source

pub fn content_region_avail_width(&self) -> f32

Returns the width of the content region available for widgets

This is equivalent to content_region_avail()[0]

Source

pub fn content_region_avail_height(&self) -> f32

Returns the height of the content region available for widgets

This is equivalent to content_region_avail()[1]

Source§

impl Ui

Source

pub fn scroll_x(&self) -> f32

Returns the current scroll position of the window

Source

pub fn scroll_y(&self) -> f32

Returns the current vertical scroll position of the window

Source

pub fn scroll_max_x(&self) -> f32

Returns the maximum horizontal scroll position

Source

pub fn scroll_max_y(&self) -> f32

Returns the maximum vertical scroll position

Source

pub fn set_scroll_x(&self, scroll_x: f32)

Sets the horizontal scroll position

Source

pub fn set_scroll_y(&self, scroll_y: f32)

Sets the vertical scroll position

Source

pub fn set_scroll_from_pos_x(&self, local_x: f32, center_x_ratio: f32)

Sets the horizontal scroll position to center on the given position

The center_x_ratio parameter should be between 0.0 (left) and 1.0 (right)

Source

pub fn set_scroll_from_pos_y(&self, local_y: f32, center_y_ratio: f32)

Sets the vertical scroll position to center on the given position

The center_y_ratio parameter should be between 0.0 (top) and 1.0 (bottom)

Source

pub fn set_scroll_here_x(&self, center_x_ratio: f32)

Scrolls to make the current item visible

This is useful when you want to ensure a specific item is visible in a scrollable region

Source

pub fn set_scroll_here_y(&self, center_y_ratio: f32)

Scrolls to make the current item visible vertically

This is useful when you want to ensure a specific item is visible in a scrollable region

Source§

impl Ui

§Parameter stacks (shared)

Source

pub fn push_font(&self, id: FontId) -> FontStackToken<'_>

Switches to the given font at its configured reference size.

Dear ImGui 1.92 can rasterize a font at multiple sizes. This convenience method preserves the pre-1.92 behavior by using the reference size supplied when the font was added. Use Ui::push_font_with_size to preserve the current size or select another runtime size explicitly. A font without a reference size also preserves the current size.

Returns a FontStackToken that must be popped by calling .pop()

§Panics

Panics before calling Dear ImGui if the FontId came from a different atlas, was invalidated by font atlas mutation, or is no longer present in the current context’s atlas.

§Examples
// At initialization time
let my_custom_font = ctx.font_atlas().add_font(&font_data_sources);
// During UI construction
let font = ui.push_font(my_custom_font);
ui.text("I use the custom font!");
font.pop();
Source§

impl Ui

§ID stack

Source

pub fn push_id<'a, T>(&self, id: T) -> IdStackToken<'_>
where T: Into<Id<'a>>,

Pushes an identifier to the ID stack.

Returns an IdStackToken that can be popped by calling .end() or by dropping manually.

§Examples

Dear ImGui uses labels to uniquely identify widgets. For a good explanation, see this part of the Dear ImGui FAQ

In dear-imgui-rs the same applies, we can manually specify labels with the ## syntax:


ui.button("Click##button1");
ui.button("Click##button2");

But sometimes we want to create widgets in a loop, or we want to avoid having to manually give each widget a unique label. In these cases, we can push an ID to the ID stack:


for i in 0..10 {
    let _id = ui.push_id(i);
    ui.button("Click");
}
Source§

impl Ui

Source

pub fn push_focus_scope(&self, id: Id) -> FocusScopeToken<'_>

Push a focus scope (affects e.g. navigation focus allocation).

Returns a FocusScopeToken which will pop the focus scope when dropped.

Source§

impl Ui

Source

pub fn item_flags(&self) -> ItemStateFlags

Returns the flags recorded for the last submitted item.

Unknown bits introduced by newer Dear ImGui versions are retained.

Source

pub fn push_item_flag( &self, flags: ItemFlags, enabled: bool, ) -> ItemFlagStackToken<'_>

Enables or disables flags for subsequently submitted items.

The returned token restores the previous item flags when dropped.

Source

pub fn with_item_flag<R>( &self, flags: ItemFlags, enabled: bool, f: impl FnOnce() -> R, ) -> R

Runs f with the requested item flags enabled or disabled.

The previous flags are restored even if f panics.

Source§

impl Ui

§Parameter stacks (current window)

Source

pub fn push_item_width(&self, item_width: f32) -> ItemWidthStackToken<'_>

Changes the item width by pushing a change to the item width stack.

Returns an ItemWidthStackToken. The pushed width item is popped when either ItemWidthStackToken goes out of scope, or .end() is called.

  • > 0.0: width is item_width pixels
  • = 0.0: default to ~2/3 of window width
  • < 0.0: item_width pixels relative to the right of window (-1.0 always aligns width to the right side)
Source

pub fn push_item_width_text( &self, text: impl AsRef<str>, ) -> ItemWidthStackToken<'_>

Sets the width of the next item(s) to be the same as the width of the given text.

Text is measured with Ui::calc_text_size using its default options.

Returns an ItemWidthStackToken. The pushed width item is popped when either ItemWidthStackToken goes out of scope, or .end() is called.

Source

pub fn push_text_wrap_pos(&self, wrap_pos_x: f32) -> TextWrapPosStackToken<'_>

Sets the position where text will wrap around.

Returns a TextWrapPosStackToken. The pushed wrap position is popped when either TextWrapPosStackToken goes out of scope, or .end() is called.

  • wrap_pos_x < 0.0: no wrapping
  • wrap_pos_x = 0.0: wrap to end of window (or column)
  • wrap_pos_x > 0.0: wrap at wrap_pos_x position in window local space
Source§

impl Ui

Source

pub fn push_style_color( &self, style_color: StyleColor, color: impl Into<[f32; 4]>, ) -> ColorStackToken<'_>

Changes a style color by pushing a change to the color stack.

Returns a ColorStackToken that must be popped by calling .pop()

§Examples
const RED: [f32; 4] = [1.0, 0.0, 0.0, 1.0];
let color = ui.push_style_color(StyleColor::Text, RED);
ui.text("I'm red!");
color.pop();
Source

pub fn push_style_var(&self, style_var: StyleVar) -> StyleStackToken<'_>

Changes a style variable by pushing a change to the style stack.

Returns a StyleStackToken that can be popped by calling .end() or by allowing to drop.

StyleVar::Alpha participates in the same restoration order as an effective disabled scope. Keep those two scopes lexically nested, or use a closure helper, so the saved alpha value is restored by the operation that owns it.

§Examples
let style = ui.push_style_var(StyleVar::Alpha(0.2));
ui.text("I'm transparent!");
style.pop();
Source

pub fn push_style_var_x( &self, style_var: StyleVarVec2, value: f32, ) -> StyleStackToken<'_>

Overrides the X component of a two-component style variable.

Source

pub fn push_style_var_y( &self, style_var: StyleVarVec2, value: f32, ) -> StyleStackToken<'_>

Overrides the Y component of a two-component style variable.

Source§

impl Ui

Source

pub fn push_clip_rect( &self, min: impl Into<[f32; 2]>, max: impl Into<[f32; 2]>, intersect_with_current: bool, ) -> ClipRectToken<'_>

Push a clipping rectangle in screen space.

Source

pub fn with_clip_rect<R>( &self, min: impl Into<[f32; 2]>, max: impl Into<[f32; 2]>, intersect_with_current: bool, f: impl FnOnce() -> R, ) -> R

Run a closure with a clip rect pushed and automatically popped.

Source

pub fn is_rect_visible_min_max( &self, rect_min: impl Into<[f32; 2]>, rect_max: impl Into<[f32; 2]>, ) -> bool

Returns true if the specified rectangle (min,max) is visible (not clipped).

Source

pub fn is_rect_visible_with_size(&self, size: impl Into<[f32; 2]>) -> bool

Returns true if a rectangle of given size at the current cursor pos is visible.

Source§

impl Ui

Source

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

Returns the cursor position (in window coordinates)

Source

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

Returns the cursor position (in absolute screen coordinates)

Source

pub fn set_cursor_pos(&self, pos: impl Into<[f32; 2]>)

Sets the cursor position (in window coordinates)

Source

pub fn set_cursor_screen_pos(&self, pos: impl Into<[f32; 2]>)

Sets the cursor position (in absolute screen coordinates)

Source

pub fn cursor_pos_x(&self) -> f32

Returns the X cursor position (in window coordinates)

Source

pub fn cursor_pos_y(&self) -> f32

Returns the Y cursor position (in window coordinates)

Source

pub fn set_cursor_pos_x(&self, x: f32)

Sets the X cursor position (in window coordinates)

Source

pub fn set_cursor_pos_y(&self, y: f32)

Sets the Y cursor position (in window coordinates)

Source

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

Returns the initial cursor position (in window coordinates)

Source§

impl Ui

Source

pub fn begin_group(&self) -> GroupToken<'_>

Creates a layout group and starts appending to it.

Returns a GroupToken that must be ended by calling .end().

Source

pub fn group<R, F>(&self, f: F) -> R
where F: FnOnce() -> R,

Creates a layout group and runs a closure to construct the contents.

May be useful to handle the same mouse event on a group of items, for example.

Source§

impl Ui

Source

pub fn text_line_height(&self) -> f32

Return ~ FontSize.

Source

pub fn text_line_height_with_spacing(&self) -> f32

Return ~ FontSize + style.ItemSpacing.y.

Source

pub fn frame_height(&self) -> f32

Return ~ FontSize + style.FramePadding.y * 2.

Source

pub fn frame_height_with_spacing(&self) -> f32

Return ~ FontSize + style.FramePadding.y * 2 + style.ItemSpacing.y.

Source§

impl Ui

Source

pub fn separator(&self)

Renders a separator (generally horizontal).

This becomes a vertical separator inside a menu bar or in horizontal layout mode.

Source

pub fn separator_with_text(&self, text: impl AsRef<str>)

Renders a separator with text.

Source

pub fn separator_vertical(&self)

Creates a vertical separator

Source

pub fn separator_horizontal(&self)

Creates a horizontal separator

Source§

impl Ui

Source

pub fn same_line(&self)

Call between widgets or groups to layout them horizontally.

X position is given in window coordinates.

This is equivalent to calling same_line_with_pos with the pos set to 0.0, which uses Style::item_spacing.

Source

pub fn same_line_with_pos(&self, pos_x: f32)

Call between widgets or groups to layout them horizontally.

X position is given in window coordinates.

This is equivalent to calling same_line_with_spacing with the spacing set to -1.0, which means no extra spacing.

Source

pub fn same_line_with_spacing(&self, pos_x: f32, spacing_w: f32)

Call between widgets or groups to layout them horizontally.

X position is given in window coordinates.

Source

pub fn new_line(&self)

Undo a same_line call or force a new line when in horizontal layout mode

Source

pub fn spacing(&self)

Adds vertical spacing

Source

pub fn dummy(&self, size: impl Into<[f32; 2]>)

Fills a space of size in pixels with nothing on the current window.

Can be used to move the cursor on the window.

Source

pub fn indent(&self)

Moves content position to the right by Style::indent_spacing

This is equivalent to indent_by with width set to Style::indent_spacing.

Source

pub fn indent_by(&self, width: f32)

Moves content position to the right by width

Source

pub fn begin_indent(&self) -> IndentToken<'_>

Starts an indentation scope using Style::indent_spacing.

The returned token restores the exact width captured at creation and may be dropped in any order relative to other indentation tokens from the same window.

Source

pub fn begin_indent_by(&self, width: f32) -> IndentToken<'_>

Starts an indentation scope with a custom width.

Passing 0.0 snapshots the current Style::indent_spacing so a later style change cannot alter restoration.

Source

pub fn with_indent<R>(&self, f: impl FnOnce() -> R) -> R

Runs f in an indentation scope using Style::indent_spacing.

The indentation is restored if f returns early or panics. Prefer this closure-based scope over manually pairing Self::indent and Self::unindent.

Source

pub fn with_indent_by<R>(&self, width: f32, f: impl FnOnce() -> R) -> R

Runs f in an indentation scope with a custom width.

The indentation is restored if f returns early or panics.

Source

pub fn unindent(&self)

Moves content position to the left by Style::indent_spacing

This is equivalent to unindent_by with width set to Style::indent_spacing.

Source

pub fn unindent_by(&self, width: f32)

Moves content position to the left by width

Source§

impl Ui

Source

pub fn align_text_to_frame_padding(&self)

Vertically align upcoming text baseline to FramePadding.y (align text to framed items).

Source§

impl Ui

Source

pub fn drag_drop_source_config<T>(&self, name: T) -> DragDropSource<'_, T>
where T: AsRef<str>,

Creates a new drag drop source configuration

§Arguments
  • name - Identifier for this drag source (must match target name)
§Example
ui.button("Drag me!");
if let Some(source) = ui.drag_drop_source_config("MY_DATA")
    .flags(DragDropSourceFlags::NO_PREVIEW_TOOLTIP)
    .begin() {
    ui.text("Custom drag tooltip");
    source.end();
}
Source

pub fn drag_drop_target(&self) -> Option<DragDropTarget<'_>>

Creates a drag drop target for the last item

Returns Some(DragDropTarget) if the last item can accept drops, None otherwise.

§Example
ui.button("Drop target");
if let Some(target) = ui.drag_drop_target() {
    if target.accept_payload_empty("MY_DATA", DragDropTargetFlags::NONE).is_some() {
        println!("Received drop!");
    }
    target.pop();
}
Source

pub fn drag_drop_payload(&self) -> Option<DragDropPayload>

Returns the current drag and drop payload, if any.

This is a convenience wrapper over ImGui::GetDragDropPayload.

The returned payload is owned and managed by Dear ImGui and may become invalid after the drag operation completes. Do not cache it beyond the current frame.

Source§

impl Ui

Source

pub fn text_filter(&self, label: impl Into<String>) -> TextFilter

Creates a new TextFilter with an empty pattern.

This is a convenience method equivalent to TextFilter::new.

§Arguments
  • label - The label to display for the filter input
§Examples
let filter = ui.text_filter("Search");
Source

pub fn text_filter_with_filter( &self, label: impl Into<String>, filter: impl AsRef<str>, ) -> TextFilter

Creates a new TextFilter with a custom filter pattern.

This is a convenience method equivalent to TextFilter::new_with_filter.

§Arguments
  • label - The label to display for the filter input
  • filter - The initial filter pattern
§Examples
let filter = ui.text_filter_with_filter(
    "Search",
    "include,-exclude"
);

Trait Implementations§

Source§

impl Debug for Ui

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl ImPlotExt for Ui

Source§

fn implot<'ui>(&'ui self, ctx: &'ui PlotContext) -> PlotUi<'ui>

Auto Trait Implementations§

§

impl !Freeze for Ui

§

impl !RefUnwindSafe for Ui

§

impl !Send for Ui

§

impl !Sync for Ui

§

impl !UnwindSafe for Ui

§

impl Unpin for Ui

§

impl UnsafeUnpin for Ui

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
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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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