pub struct Ui { /* private fields */ }Expand description
Represents the Dear ImGui user interface for one frame
Implementations§
Source§impl Ui
Docking-related functionality
impl Ui
Docking-related functionality
Sourcepub fn dockspace(&self) -> DockspaceBuilder<'_, 'static>
pub fn dockspace(&self) -> DockspaceBuilder<'_, 'static>
Configure and submit a dockspace through the canonical builder.
Sourcepub fn dock_space_over_main_viewport_raw(
&self,
dockspace_id: Id,
flags: DockNodeFlags,
) -> Id
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
);Sourcepub fn dock_space_raw(
&self,
id: Id,
size: [f32; 2],
flags: DockNodeFlags,
window_class: Option<&WindowClass>,
) -> Id
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. UseUi::get_idto create one.size- The size of the dockspace in pixelsflags- Dock node flagswindow_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)))
);Sourcepub fn set_next_window_dock_id_with_cond(&self, dock_id: Id, cond: Condition)
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 tocond- 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!");
});Sourcepub fn set_next_window_dock_id(&self, dock_id: Id)
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!");
});Sourcepub fn set_next_window_class(&self, window_class: &WindowClass)
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!");
});Sourcepub fn get_window_dock_id(&self) -> Id
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");
}
});Sourcepub fn is_window_docked(&self) -> bool
pub fn is_window_docked(&self) -> bool
Source§impl Ui
impl Ui
Sourcepub fn custom_rect(&self, id: CustomRectId) -> Option<CustomRectSnapshot<'_>>
pub fn custom_rect(&self, id: CustomRectId) -> Option<CustomRectSnapshot<'_>>
Query a custom rectangle for immediate use in the current frame.
Sourcepub fn image_custom_rect(&self, id: CustomRectId, size: [f32; 2]) -> bool
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
impl Ui
Sourcepub fn font_atlas_texture(&self) -> Option<FontAtlasTexture<'_>>
pub fn font_atlas_texture(&self) -> Option<FontAtlasTexture<'_>>
Lease the current Context’s font-atlas texture for immediate image submission.
Source§impl Ui
impl Ui
Sourcepub fn current_baked_font(&self) -> BakedFont<'_>
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();Sourcepub fn baked_font(&self, font: FontId, size: f32) -> Option<BakedFont<'_>>
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§impl Ui
§Fonts
impl Ui
§Fonts
Sourcepub fn current_font(&self) -> FontId
pub fn current_font(&self) -> FontId
Return the persistent, atlas-validated ID of the current font.
Sourcepub fn current_font_size(&self) -> f32
pub fn current_font_size(&self) -> f32
Returns the current font size (= height in pixels) with font scale applied
Sourcepub fn push_font_with_size(
&self,
font: Option<FontId>,
size: f32,
) -> FontStackToken<'_>
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.
Sourcepub fn with_font_and_size<F, R>(
&self,
font: Option<FontId>,
size: f32,
f: F,
) -> Rwhere
F: FnOnce() -> R,
pub fn with_font_and_size<F, R>(
&self,
font: Option<FontId>,
size: f32,
f: F,
) -> Rwhere
F: FnOnce() -> R,
Execute a closure with a specific font and size (v1.92+ dynamic fonts)
Sourcepub fn font_tex_uv_white_pixel(&self) -> [f32; 2]
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.
Sourcepub fn set_window_font_scale(&self, scale: f32)
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
impl Ui
Sourcepub fn is_key_down(&self, key: Key) -> bool
pub fn is_key_down(&self, key: Key) -> bool
Check if a key is being held down
Sourcepub fn is_key_pressed(&self, key: Key) -> bool
pub fn is_key_pressed(&self, key: Key) -> bool
Check if a key was pressed (went from !Down to Down)
Sourcepub fn is_key_pressed_with_repeat(&self, key: Key, repeat: bool) -> bool
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
Sourcepub fn is_key_released(&self, key: Key) -> bool
pub fn is_key_released(&self, key: Key) -> bool
Check if a key was released (went from Down to !Down)
Sourcepub fn is_key_chord_pressed(&self, key_chord: KeyChord) -> bool
pub fn is_key_chord_pressed(&self, key_chord: KeyChord) -> bool
Check if a key chord was pressed (e.g. Ctrl+S).
Sourcepub fn shortcut(&self, key_chord: KeyChord) -> bool
pub fn shortcut(&self, key_chord: KeyChord) -> bool
Call ImGui shortcut routing with default flags.
Sourcepub fn shortcut_with_flags(
&self,
key_chord: KeyChord,
flags: impl Into<ShortcutOptions>,
) -> bool
pub fn shortcut_with_flags( &self, key_chord: KeyChord, flags: impl Into<ShortcutOptions>, ) -> bool
Call ImGui shortcut routing with explicit input options.
Sourcepub fn set_next_item_shortcut(&self, key_chord: KeyChord)
pub fn set_next_item_shortcut(&self, key_chord: KeyChord)
Set the next item’s shortcut with default flags.
Sourcepub fn set_next_item_shortcut_with_flags(
&self,
key_chord: KeyChord,
flags: impl Into<NextItemShortcutOptions>,
)
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.
Sourcepub fn set_next_frame_want_capture_keyboard(&self, want_capture_keyboard: bool)
pub fn set_next_frame_want_capture_keyboard(&self, want_capture_keyboard: bool)
Overrides io.WantCaptureKeyboard for the next frame.
Sourcepub fn set_next_frame_want_capture_mouse(&self, want_capture_mouse: bool)
pub fn set_next_frame_want_capture_mouse(&self, want_capture_mouse: bool)
Overrides io.WantCaptureMouse for the next frame.
Sourcepub fn is_mouse_down(&self, button: MouseButton) -> bool
pub fn is_mouse_down(&self, button: MouseButton) -> bool
Check if a mouse button is being held down
Sourcepub fn is_mouse_clicked(&self, button: MouseButton) -> bool
pub fn is_mouse_clicked(&self, button: MouseButton) -> bool
Check if a mouse button was clicked (went from !Down to Down)
Sourcepub fn is_mouse_clicked_with_repeat(
&self,
button: MouseButton,
repeat: bool,
) -> bool
pub fn is_mouse_clicked_with_repeat( &self, button: MouseButton, repeat: bool, ) -> bool
Check if a mouse button was clicked, with repeat
Sourcepub fn is_mouse_released(&self, button: MouseButton) -> bool
pub fn is_mouse_released(&self, button: MouseButton) -> bool
Check if a mouse button was released (went from Down to !Down)
Sourcepub fn is_mouse_double_clicked(&self, button: MouseButton) -> bool
pub fn is_mouse_double_clicked(&self, button: MouseButton) -> bool
Check if a mouse button was double-clicked
Sourcepub fn is_mouse_pos_valid(&self) -> bool
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.
Sourcepub fn is_mouse_pos_valid_at(&self, pos: [f32; 2]) -> bool
pub fn is_mouse_pos_valid_at(&self, pos: [f32; 2]) -> bool
Returns true if the provided mouse position is valid (not NaN).
Sourcepub fn is_mouse_released_with_delay(
&self,
button: MouseButton,
delay: f32,
) -> bool
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.
Sourcepub fn is_mouse_released_with_single_click_delay(
&self,
button: MouseButton,
) -> bool
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.
Sourcepub fn mouse_pos_on_opening_current_popup(&self) -> [f32; 2]
pub fn mouse_pos_on_opening_current_popup(&self) -> [f32; 2]
Get mouse position when a specific button was clicked
Sourcepub fn is_mouse_hovering_rect(&self, r_min: [f32; 2], r_max: [f32; 2]) -> bool
pub fn is_mouse_hovering_rect(&self, r_min: [f32; 2], r_max: [f32; 2]) -> bool
Check if mouse is hovering given rectangle
Sourcepub fn is_mouse_hovering_rect_with_clip(
&self,
r_min: [f32; 2],
r_max: [f32; 2],
clip: bool,
) -> bool
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)
Sourcepub fn is_mouse_dragging(&self, button: MouseButton) -> bool
pub fn is_mouse_dragging(&self, button: MouseButton) -> bool
Check if mouse is dragging
Sourcepub fn is_mouse_dragging_with_threshold(
&self,
button: MouseButton,
lock_threshold: f32,
) -> bool
pub fn is_mouse_dragging_with_threshold( &self, button: MouseButton, lock_threshold: f32, ) -> bool
Check if mouse is dragging with threshold
Sourcepub fn mouse_drag_delta(&self, button: MouseButton) -> [f32; 2]
pub fn mouse_drag_delta(&self, button: MouseButton) -> [f32; 2]
Get mouse drag delta
Sourcepub fn mouse_drag_delta_with_threshold(
&self,
button: MouseButton,
lock_threshold: f32,
) -> [f32; 2]
pub fn mouse_drag_delta_with_threshold( &self, button: MouseButton, lock_threshold: f32, ) -> [f32; 2]
Get mouse drag delta with threshold
Sourcepub fn reset_mouse_drag_delta(&self, button: MouseButton)
pub fn reset_mouse_drag_delta(&self, button: MouseButton)
Reset mouse drag delta for a specific button
Sourcepub fn is_item_toggled_selection(&self) -> bool
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
impl Ui
Sourcepub fn with_current_state_storage<R>(
&self,
f: impl for<'storage> FnOnce(StateStorage<'storage>) -> R,
) -> R
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.
Sourcepub fn with_state_storage<R>(
&self,
storage: &mut OwnedStateStorage,
f: impl for<'storage> FnOnce(StateStorage<'storage>) -> R,
) -> R
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);Sourcepub fn set_next_item_storage_id(&self, storage_id: Id)
pub fn set_next_item_storage_id(&self, storage_id: Id)
Set the storage ID for the next item.
Source§impl Ui
impl Ui
Sourcepub fn binding(&self) -> ContextBinding
pub fn binding(&self) -> ContextBinding
Returns a persistent capability for the Context that owns this Ui.
Sourcepub fn context_id(&self) -> ContextId
pub fn context_id(&self) -> ContextId
Returns the process-unique identity of the Context that owns this Ui.
Sourcepub fn with_bound_context<R>(&self, f: impl FnOnce() -> R) -> R
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§impl Ui
impl Ui
Sourcepub fn show_demo_window(&self, opened: &mut bool)
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.
Sourcepub unsafe fn show_upstream_demo_window(&self, opened: &mut bool)
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.
Sourcepub fn show_about_window(&self, opened: &mut bool)
pub fn show_about_window(&self, opened: &mut bool)
Renders an about window.
Displays the Dear ImGui version/credits, and build/system information.
Sourcepub fn show_metrics_window(&self, opened: &mut bool)
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.
Sourcepub unsafe fn show_upstream_metrics_window(&self, opened: &mut bool)
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.
Sourcepub unsafe fn show_font_atlas_debug_panel(&self)
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.
Sourcepub fn show_user_guide(&self)
pub fn show_user_guide(&self)
Renders a basic help/info block (not a window)
Sourcepub fn show_debug_log_window(&self, opened: &mut bool)
pub fn show_debug_log_window(&self, opened: &mut bool)
Renders a debug log window.
Displays a simplified log of important dear imgui events.
Sourcepub fn show_id_stack_tool_window(&self, opened: &mut bool)
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.
Sourcepub fn debug_text_encoding(&self, text: impl AsRef<str>)
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.
Sourcepub fn debug_flash_style_color(&self, color: StyleColor)
pub fn debug_flash_style_color(&self, color: StyleColor)
Temporarily flashes a style color in Dear ImGui’s debug tools.
Sourcepub fn debug_start_item_picker(&self)
pub fn debug_start_item_picker(&self)
Starts Dear ImGui’s interactive item picker debug tool.
Sourcepub fn get_version(&self) -> &str
pub fn get_version(&self) -> &str
Returns the Dear ImGui version string
Source§impl Ui
impl Ui
Sourcepub fn get_window_draw_list(&self) -> DrawListMut<'_>
pub fn get_window_draw_list(&self) -> DrawListMut<'_>
Access to the current window’s draw list
Sourcepub fn get_background_draw_list(&self) -> DrawListMut<'_>
pub fn get_background_draw_list(&self) -> DrawListMut<'_>
Access to the background draw list
Sourcepub fn get_foreground_draw_list(&self) -> DrawListMut<'_>
pub fn get_foreground_draw_list(&self) -> DrawListMut<'_>
Access to the foreground draw list
Source§impl Ui
impl Ui
Sourcepub fn mouse_cursor(&self) -> Option<MouseCursor>
pub fn mouse_cursor(&self) -> Option<MouseCursor>
Returns the currently desired mouse cursor type
Returns None if no cursor should be displayed
Sourcepub fn set_mouse_cursor(&self, cursor_type: Option<MouseCursor>)
pub fn set_mouse_cursor(&self, cursor_type: Option<MouseCursor>)
Sets the desired mouse cursor type
Passing None hides the mouse cursor
Sourcepub fn set_mouse_draw_cursor(&self, draw: bool)
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.
Sourcepub fn set_keyboard_focus_here(&self)
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.
Sourcepub fn set_keyboard_focus_here_with_offset(&self, offset: i32)
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.
Shows or hides the navigation cursor (a small marker indicating nav focus).
Source§impl Ui
impl Ui
Sourcepub fn show_style_editor(&self, style: &mut Style)
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.
Sourcepub fn show_default_style_editor(&self)
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.
Sourcepub unsafe fn show_upstream_style_editor(&self, style: &mut Style)
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.
Sourcepub unsafe fn show_upstream_default_style_editor(&self)
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.
Sourcepub unsafe fn style(&self) -> &Style
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.
Sourcepub fn clone_style(&self) -> Style
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.
Sourcepub fn style_colors_dark(&self)
pub fn style_colors_dark(&self)
Apply the built-in Dark style to the current style.
Sourcepub fn style_colors_light(&self)
pub fn style_colors_light(&self)
Apply the built-in Light style to the current style.
Sourcepub fn style_colors_classic(&self)
pub fn style_colors_classic(&self)
Apply the built-in Classic style to the current style.
Sourcepub fn style_colors_dark_into(&self, dst: &mut Style)
pub fn style_colors_dark_into(&self, dst: &mut Style)
Write the Dark style values into the provided crate::Style object.
Sourcepub fn style_colors_light_into(&self, dst: &mut Style)
pub fn style_colors_light_into(&self, dst: &mut Style)
Write the Light style values into the provided crate::Style object.
Sourcepub fn style_colors_classic_into(&self, dst: &mut Style)
pub fn style_colors_classic_into(&self, dst: &mut Style)
Write the Classic style values into the provided crate::Style object.
Sourcepub fn show_style_selector(&self, label: impl AsRef<str>) -> bool
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.
Sourcepub fn show_font_selector(&self, label: impl AsRef<str>)
pub fn show_font_selector(&self, label: impl AsRef<str>)
Renders a font selector combo box.
Source§impl Ui
impl Ui
Sourcepub fn main_viewport(&self) -> &Viewport
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.
Sourcepub fn set_next_window_viewport(&self, viewport_id: Id)
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.
Sourcepub fn window_viewport(&self) -> &Viewport
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).
Sourcepub fn find_viewport_by_id(&self, viewport_id: Id) -> Option<&Viewport>
pub fn find_viewport_by_id(&self, viewport_id: Id) -> Option<&Viewport>
Find a viewport by ID.
Source§impl Ui
impl Ui
Sourcepub fn image_with_bg<'tex>(
&self,
texture: impl Into<TextureRef<'tex>>,
size: [f32; 2],
bg_color: [f32; 4],
tint_color: [f32; 4],
)
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.
Sourcepub fn drag_float(&self, label: impl AsRef<str>, value: &mut f32) -> bool
pub fn drag_float(&self, label: impl AsRef<str>, value: &mut f32) -> bool
Creates a drag float slider
Sourcepub fn drag_float_config<L>(&self, label: L) -> Drag<f32, L>
pub fn drag_float_config<L>(&self, label: L) -> Drag<f32, L>
Creates a drag float slider with configuration
Sourcepub fn drag_int(&self, label: impl AsRef<str>, value: &mut i32) -> bool
pub fn drag_int(&self, label: impl AsRef<str>, value: &mut i32) -> bool
Creates a drag int slider
Sourcepub fn drag_int_config<L>(&self, label: L) -> Drag<i32, L>
pub fn drag_int_config<L>(&self, label: L) -> Drag<i32, L>
Creates a drag int slider with configuration
Sourcepub fn drag_float_range2(
&self,
label: impl AsRef<str>,
min: &mut f32,
max: &mut f32,
) -> bool
pub fn drag_float_range2( &self, label: impl AsRef<str>, min: &mut f32, max: &mut f32, ) -> bool
Creates a drag float range slider
Sourcepub fn drag_float_range2_config<L>(&self, label: L) -> DragRange<f32, L>
pub fn drag_float_range2_config<L>(&self, label: L) -> DragRange<f32, L>
Creates a drag float range slider with configuration
Sourcepub fn drag_int_range2(
&self,
label: impl AsRef<str>,
min: &mut i32,
max: &mut i32,
) -> bool
pub fn drag_int_range2( &self, label: impl AsRef<str>, min: &mut i32, max: &mut i32, ) -> bool
Creates a drag int range slider
Sourcepub fn drag_int_range2_config<L>(&self, label: L) -> DragRange<i32, L>
pub fn drag_int_range2_config<L>(&self, label: L) -> DragRange<i32, L>
Creates a drag int range slider with configuration
Sourcepub fn set_next_item_open(&self, is_open: bool)
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.
Sourcepub fn set_next_item_open_with_cond(&self, is_open: bool, cond: Condition)
pub fn set_next_item_open_with_cond(&self, is_open: bool, cond: Condition)
Set next item to be open by default with condition.
Sourcepub fn set_next_item_width(&self, item_width: f32)
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.
Sourcepub fn value_bool(&self, prefix: impl AsRef<str>, v: bool)
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
impl Ui
Sourcepub fn window<'ui>(&'ui self, name: impl Into<WindowLabel<'ui>>) -> Window<'ui>
pub fn window<'ui>(&'ui self, name: impl Into<WindowLabel<'ui>>) -> Window<'ui>
Creates a window builder
Sourcepub fn set_window_focus(&self, name: Option<&str>)
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).
Sourcepub fn set_window_pos(&self, pos: [f32; 2])
pub fn set_window_pos(&self, pos: [f32; 2])
Sets the position of the current window.
Sourcepub fn set_window_pos_with_cond(&self, pos: [f32; 2], cond: Condition)
pub fn set_window_pos_with_cond(&self, pos: [f32; 2], cond: Condition)
Sets the position of the current window with a condition.
Sourcepub fn set_window_pos_by_name(&self, name: impl AsRef<str>, pos: [f32; 2])
pub fn set_window_pos_by_name(&self, name: impl AsRef<str>, pos: [f32; 2])
Sets the position of a named window.
Sourcepub fn set_window_pos_by_name_with_cond(
&self,
name: impl AsRef<str>,
pos: [f32; 2],
cond: Condition,
)
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.
Sourcepub fn set_window_size(&self, size: [f32; 2])
pub fn set_window_size(&self, size: [f32; 2])
Sets the size of the current window.
Sourcepub fn set_window_size_with_cond(&self, size: [f32; 2], cond: Condition)
pub fn set_window_size_with_cond(&self, size: [f32; 2], cond: Condition)
Sets the size of the current window with a condition.
Sourcepub fn set_window_size_by_name(&self, name: impl AsRef<str>, size: [f32; 2])
pub fn set_window_size_by_name(&self, name: impl AsRef<str>, size: [f32; 2])
Sets the size of a named window.
Sourcepub fn set_window_size_by_name_with_cond(
&self,
name: impl AsRef<str>,
size: [f32; 2],
cond: Condition,
)
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.
Sourcepub fn set_window_collapsed(&self, collapsed: bool)
pub fn set_window_collapsed(&self, collapsed: bool)
Collapses or expands the current window.
Sourcepub fn set_window_collapsed_with_cond(&self, collapsed: bool, cond: Condition)
pub fn set_window_collapsed_with_cond(&self, collapsed: bool, cond: Condition)
Collapses or expands the current window with a condition.
Sourcepub fn set_window_collapsed_by_name(
&self,
name: impl AsRef<str>,
collapsed: bool,
)
pub fn set_window_collapsed_by_name( &self, name: impl AsRef<str>, collapsed: bool, )
Collapses or expands a named window.
Sourcepub fn set_window_collapsed_by_name_with_cond(
&self,
name: impl AsRef<str>,
collapsed: bool,
cond: Condition,
)
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.
Sourcepub fn window_dpi_scale(&self) -> f32
pub fn window_dpi_scale(&self) -> f32
Returns DPI scale currently associated to the current window’s viewport.
Sourcepub fn window_width(&self) -> f32
pub fn window_width(&self) -> f32
Get current window width (shortcut for GetWindowSize().x).
Sourcepub fn window_height(&self) -> f32
pub fn window_height(&self) -> f32
Get current window height (shortcut for GetWindowSize().y).
Sourcepub fn window_pos(&self) -> [f32; 2]
pub fn window_pos(&self) -> [f32; 2]
Get current window position in screen space.
Sourcepub fn window_size(&self) -> [f32; 2]
pub fn window_size(&self) -> [f32; 2]
Get current window size.
Source§impl Ui
impl Ui
Sourcepub fn frame_count(&self) -> usize
pub fn frame_count(&self) -> usize
Get global imgui frame count. Incremented by 1 every frame.
Sourcepub fn calc_item_width(&self) -> f32
pub fn calc_item_width(&self) -> f32
Returns the width of an item based on the current layout state.
Source§impl Ui
impl Ui
Sourcepub fn get_cursor_screen_pos(&self) -> [f32; 2]
pub fn get_cursor_screen_pos(&self) -> [f32; 2]
Get cursor position in screen coordinates.
Sourcepub fn get_content_region_avail(&self) -> [f32; 2]
pub fn get_content_region_avail(&self) -> [f32; 2]
Get available content region size.
Sourcepub fn is_point_in_rect(
&self,
point: [f32; 2],
rect_min: [f32; 2],
rect_max: [f32; 2],
) -> bool
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.
Sourcepub fn distance(&self, p1: [f32; 2], p2: [f32; 2]) -> f32
pub fn distance(&self, p1: [f32; 2], p2: [f32; 2]) -> f32
Calculate distance between two points.
Sourcepub fn distance_squared(&self, p1: [f32; 2], p2: [f32; 2]) -> f32
pub fn distance_squared(&self, p1: [f32; 2], p2: [f32; 2]) -> f32
Calculate squared distance between two points (faster than distance).
Sourcepub fn line_segments_intersect(
&self,
p1: [f32; 2],
p2: [f32; 2],
p3: [f32; 2],
p4: [f32; 2],
) -> bool
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.
Sourcepub fn dot_product(&self, v1: [f32; 2], v2: [f32; 2]) -> f32
pub fn dot_product(&self, v1: [f32; 2], v2: [f32; 2]) -> f32
Calculate dot product of two 2D vectors.
Sourcepub fn angle_between_vectors(&self, v1: [f32; 2], v2: [f32; 2]) -> f32
pub fn angle_between_vectors(&self, v1: [f32; 2], v2: [f32; 2]) -> f32
Calculate the angle between two vectors in radians.
Source§impl Ui
impl Ui
Sourcepub fn get_key_pressed_amount(
&self,
key: Key,
repeat_delay: f32,
rate: f32,
) -> usize
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
Sourcepub fn get_key_name(&self, key: Key) -> &str
pub fn get_key_name(&self, key: Key) -> &str
Returns the name of a key
Sourcepub fn get_mouse_clicked_count(&self, button: MouseButton) -> usize
pub fn get_mouse_clicked_count(&self, button: MouseButton) -> usize
Returns the number of times the mouse button was clicked in the current frame
Sourcepub fn get_mouse_pos(&self) -> [f32; 2]
pub fn get_mouse_pos(&self) -> [f32; 2]
Returns the mouse position in screen coordinates
Sourcepub fn get_mouse_pos_on_opening_current_popup(&self) -> [f32; 2]
pub fn get_mouse_pos_on_opening_current_popup(&self) -> [f32; 2]
Returns the mouse position when the button was clicked
Sourcepub fn get_mouse_drag_delta(
&self,
button: MouseButton,
lock_threshold: f32,
) -> [f32; 2]
pub fn get_mouse_drag_delta( &self, button: MouseButton, lock_threshold: f32, ) -> [f32; 2]
Returns the mouse drag delta
Sourcepub fn get_mouse_wheel(&self) -> f32
pub fn get_mouse_wheel(&self) -> f32
Returns the mouse wheel delta
Sourcepub fn get_mouse_wheel_h(&self) -> f32
pub fn get_mouse_wheel_h(&self) -> f32
Returns the horizontal mouse wheel delta
Sourcepub fn is_any_mouse_down(&self) -> bool
pub fn is_any_mouse_down(&self) -> bool
Returns true if any mouse button is down
Source§impl Ui
impl Ui
Sourcepub fn item_clicked_count_with_single_click_delay(&self) -> usize
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.
Sourcepub fn item_clicked_count_with_single_click_delay_for(
&self,
button: MouseButton,
) -> usize
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.
Sourcepub fn item_clicked_count_with_delay(
&self,
button: MouseButton,
delay: f32,
) -> usize
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.
Sourcepub fn is_item_toggled_open(&self) -> bool
pub fn is_item_toggled_open(&self) -> bool
Returns true if the last item open state was toggled
Sourcepub fn item_rect_min(&self) -> [f32; 2]
pub fn item_rect_min(&self) -> [f32; 2]
Returns the upper-left bounding rectangle of the last item (screen space)
Sourcepub fn item_rect_max(&self) -> [f32; 2]
pub fn item_rect_max(&self) -> [f32; 2]
Returns the lower-right bounding rectangle of the last item (screen space)
Sourcepub fn set_next_item_allow_overlap(&self)
pub fn set_next_item_allow_overlap(&self)
Allows the next item to be overlapped by a subsequent item.
Source§impl Ui
impl Ui
Sourcepub fn log_to_tty(&self, auto_open_depth: impl Into<LogAutoOpenDepth>)
pub fn log_to_tty(&self, auto_open_depth: impl Into<LogAutoOpenDepth>)
Start logging to TTY.
Sourcepub fn log_to_file_default(&self, auto_open_depth: impl Into<LogAutoOpenDepth>)
pub fn log_to_file_default(&self, auto_open_depth: impl Into<LogAutoOpenDepth>)
Start logging to file with the default filename.
Sourcepub fn log_to_file(
&self,
auto_open_depth: impl Into<LogAutoOpenDepth>,
filename: &Path,
) -> Result<(), ImGuiError>
pub fn log_to_file( &self, auto_open_depth: impl Into<LogAutoOpenDepth>, filename: &Path, ) -> Result<(), ImGuiError>
Sourcepub fn log_to_clipboard(&self, auto_open_depth: impl Into<LogAutoOpenDepth>)
pub fn log_to_clipboard(&self, auto_open_depth: impl Into<LogAutoOpenDepth>)
Start logging to clipboard.
Show ImGui’s logging buttons (TTY/File/Clipboard).
Sourcepub fn log_finish(&self)
pub fn log_finish(&self)
Finish logging (close file / copy to clipboard as needed).
Source§impl Ui
impl Ui
Sourcepub fn style_color(&self, style_color: StyleColor) -> [f32; 4]
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.
Sourcepub fn get_color_u32(&self, style_color: StyleColor) -> u32
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).
Sourcepub fn get_color_u32_with_alpha(
&self,
style_color: StyleColor,
alpha_mul: f32,
) -> u32
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.
Sourcepub fn get_color_u32_from_rgba(&self, rgba: [f32; 4]) -> u32
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.
Sourcepub fn get_color_u32_from_packed(&self, abgr: u32, alpha_mul: f32) -> u32
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.
Sourcepub fn style_color_name(&self, style_color: StyleColor) -> &'static str
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
impl Ui
Sourcepub fn is_window_hovered(&self) -> bool
pub fn is_window_hovered(&self) -> bool
Returns true if the current window is hovered (and typically: not blocked by a popup/modal)
Sourcepub fn is_window_hovered_with_flags(&self, flags: WindowHoveredFlags) -> bool
pub fn is_window_hovered_with_flags(&self, flags: WindowHoveredFlags) -> bool
Returns true if the current window is hovered based on the given flags
Sourcepub fn is_window_focused(&self) -> bool
pub fn is_window_focused(&self) -> bool
Returns true if the current window is focused (and typically: not blocked by a popup/modal)
Sourcepub fn is_window_focused_with_flags(&self, flags: FocusedFlags) -> bool
pub fn is_window_focused_with_flags(&self, flags: FocusedFlags) -> bool
Returns true if the current window is focused based on the given flags
Sourcepub fn is_window_appearing(&self) -> bool
pub fn is_window_appearing(&self) -> bool
Returns true if the current window is appearing this frame.
Sourcepub fn is_window_collapsed(&self) -> bool
pub fn is_window_collapsed(&self) -> bool
Returns true if the current window is collapsed.
Source§impl Ui
impl Ui
Creates a button with the given label
Creates a button with the given label and size
Creates a button builder
Source§impl Ui
impl Ui
Creates a radio button
Creates a radio button with integer value
Creates a radio button suitable for choosing an arbitrary value.
Returns true if this radio button was clicked.
Sourcepub fn checkbox_flags<T>(
&self,
label: impl AsRef<str>,
flags: &mut T,
mask: T,
) -> bool
pub fn checkbox_flags<T>( &self, label: impl AsRef<str>, flags: &mut T, mask: T, ) -> bool
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
impl Ui
§Color Edit Widgets
Sourcepub fn color_edit3(&self, label: impl AsRef<str>, color: &mut [f32; 3]) -> bool
pub fn color_edit3(&self, label: impl AsRef<str>, color: &mut [f32; 3]) -> bool
Creates a color edit widget for 3 components (RGB)
Sourcepub fn color_edit4(&self, label: impl AsRef<str>, color: &mut [f32; 4]) -> bool
pub fn color_edit4(&self, label: impl AsRef<str>, color: &mut [f32; 4]) -> bool
Creates a color edit widget for 4 components (RGBA)
Sourcepub fn color_picker3(
&self,
label: impl AsRef<str>,
color: &mut [f32; 3],
) -> bool
pub fn color_picker3( &self, label: impl AsRef<str>, color: &mut [f32; 3], ) -> bool
Creates a color picker widget for 3 components (RGB)
Sourcepub fn color_picker4(
&self,
label: impl AsRef<str>,
color: &mut [f32; 4],
) -> bool
pub fn color_picker4( &self, label: impl AsRef<str>, color: &mut [f32; 4], ) -> bool
Creates a color picker widget for 4 components (RGBA)
Creates a color button widget
Sourcepub fn color_edit3_config<'ui, 'p>(
&'ui self,
label: impl Into<Cow<'ui, str>>,
color: &'p mut [f32; 3],
) -> ColorEdit3<'ui, 'p>
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
Sourcepub fn color_edit4_config<'ui, 'p>(
&'ui self,
label: impl Into<Cow<'ui, str>>,
color: &'p mut [f32; 4],
) -> ColorEdit4<'ui, 'p>
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
Sourcepub fn color_picker3_config<'ui, 'p>(
&'ui self,
label: impl Into<Cow<'ui, str>>,
color: &'p mut [f32; 3],
) -> ColorPicker3<'ui, 'p>
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
Sourcepub fn color_picker4_config<'ui, 'p>(
&'ui self,
label: impl Into<Cow<'ui, str>>,
color: &'p mut [f32; 4],
) -> ColorPicker4<'ui, 'p>
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
Creates a color button builder
Source§impl Ui
§Combo Box Widgets
impl Ui
§Combo Box Widgets
Sourcepub fn begin_combo(
&self,
label: impl AsRef<str>,
preview_value: impl AsRef<str>,
) -> Option<ComboBoxToken<'_>>
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.
Sourcepub fn begin_combo_with_flags(
&self,
label: impl AsRef<str>,
preview_value: impl AsRef<str>,
flags: impl Into<ComboBoxOptions>,
) -> Option<ComboBoxToken<'_>>
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.
Sourcepub fn begin_combo_no_preview(
&self,
label: impl AsRef<str>,
) -> Option<ComboBoxToken<'_>>
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.
Sourcepub fn begin_combo_no_preview_with_flags(
&self,
label: impl AsRef<str>,
flags: impl Into<ComboBoxOptions>,
) -> Option<ComboBoxToken<'_>>
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.
Sourcepub fn combo<V, L>(
&self,
label: impl AsRef<str>,
current_item: &mut usize,
items: &[V],
label_fn: L,
) -> bool
pub fn combo<V, L>( &self, label: impl AsRef<str>, current_item: &mut usize, items: &[V], label_fn: L, ) -> bool
Builds a simple combo box for choosing from a slice of values.
Sourcepub fn combo_i32<V, L>(
&self,
label: impl AsRef<str>,
current_item: &mut i32,
items: &[V],
label_fn: L,
) -> bool
pub fn combo_i32<V, L>( &self, label: impl AsRef<str>, current_item: &mut i32, items: &[V], label_fn: L, ) -> bool
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.
Sourcepub fn combo_simple_string(
&self,
label: impl AsRef<str>,
current_item: &mut usize,
items: &[impl AsRef<str>],
) -> bool
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
Sourcepub fn combo_simple_string_i32(
&self,
label: impl AsRef<str>,
current_item: &mut i32,
items: &[impl AsRef<str>],
) -> bool
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.
Sourcepub fn set_item_default_focus(&self)
pub fn set_item_default_focus(&self)
Makes the last submitted item the default focus of a newly appearing window.
Source§impl Ui
impl Ui
Sourcepub fn drag<T, K>(&self, label: T, value: &mut K) -> bool
pub fn drag<T, K>(&self, label: T, value: &mut K) -> bool
Creates a new drag slider widget. Returns true if the value has been edited.
Sourcepub fn drag_config<T, K>(&self, label: T) -> Drag<K, T>
pub fn drag_config<T, K>(&self, label: T) -> Drag<K, T>
Creates a new unbuilt Drag.
Sourcepub fn drag_float2(&self, label: impl AsRef<str>, values: &mut [f32; 2]) -> bool
pub fn drag_float2(&self, label: impl AsRef<str>, values: &mut [f32; 2]) -> bool
Creates a drag float2 slider (2 floats)
Sourcepub fn drag_float3(&self, label: impl AsRef<str>, values: &mut [f32; 3]) -> bool
pub fn drag_float3(&self, label: impl AsRef<str>, values: &mut [f32; 3]) -> bool
Creates a drag float3 slider (3 floats)
Sourcepub fn drag_float4(&self, label: impl AsRef<str>, values: &mut [f32; 4]) -> bool
pub fn drag_float4(&self, label: impl AsRef<str>, values: &mut [f32; 4]) -> bool
Creates a drag float4 slider (4 floats)
Sourcepub fn drag_int2(&self, label: impl AsRef<str>, values: &mut [i32; 2]) -> bool
pub fn drag_int2(&self, label: impl AsRef<str>, values: &mut [i32; 2]) -> bool
Creates a drag int2 slider (2 ints)
Source§impl Ui
§Image Widgets
Examples
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]);Sourcepub fn image<'tex>(&self, texture: impl Into<TextureRef<'tex>>, size: [f32; 2])
pub fn image<'tex>(&self, texture: impl Into<TextureRef<'tex>>, size: [f32; 2])
Creates an image widget
Creates an image button widget
Sourcepub fn image_config<'ui, 'tex>(
&'ui self,
texture: impl Into<TextureRef<'tex>>,
size: [f32; 2],
) -> Image<'ui, 'tex>
pub fn image_config<'ui, 'tex>( &'ui self, texture: impl Into<TextureRef<'tex>>, size: [f32; 2], ) -> Image<'ui, 'tex>
Creates an image builder
Creates an image button builder
Source§impl Ui
§Input Widgets
impl Ui
§Input Widgets
Sourcepub fn input_text<'ui, 'p>(
&'ui self,
label: impl Into<Cow<'ui, str>>,
buf: &'p mut String,
) -> InputText<'ui, 'p>
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);
}Sourcepub fn input_text_imstr<'ui, 'p>(
&'ui self,
label: impl Into<Cow<'ui, str>>,
buf: &'p mut ImString,
) -> InputTextImStr<'ui, 'p>
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)
Sourcepub 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>
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);
}Sourcepub 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>
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)
Sourcepub fn input_int(&self, label: impl AsRef<str>, value: &mut i32) -> bool
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.
Sourcepub fn input_float(&self, label: impl AsRef<str>, value: &mut f32) -> bool
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.
Sourcepub fn input_double(&self, label: impl AsRef<str>, value: &mut f64) -> bool
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.
Sourcepub fn input_int_config<'ui>(
&'ui self,
label: impl Into<Cow<'ui, str>>,
) -> InputInt<'ui>
pub fn input_int_config<'ui>( &'ui self, label: impl Into<Cow<'ui, str>>, ) -> InputInt<'ui>
Creates an integer input builder
Sourcepub fn input_float_config<'ui>(
&'ui self,
label: impl Into<Cow<'ui, str>>,
) -> InputFloat<'ui>
pub fn input_float_config<'ui>( &'ui self, label: impl Into<Cow<'ui, str>>, ) -> InputFloat<'ui>
Creates a float input builder
Sourcepub fn input_double_config<'ui>(
&'ui self,
label: impl Into<Cow<'ui, str>>,
) -> InputDouble<'ui>
pub fn input_double_config<'ui>( &'ui self, label: impl Into<Cow<'ui, str>>, ) -> InputDouble<'ui>
Creates a double input builder
Sourcepub fn input_scalar<'p, L, T>(
&self,
label: L,
value: &'p mut T,
) -> InputScalar<'_, 'p, T, L>
pub fn input_scalar<'p, L, T>( &self, label: L, value: &'p mut T, ) -> InputScalar<'_, 'p, T, L>
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.
Sourcepub fn input_scalar_n<'p, L, T>(
&self,
label: L,
values: &'p mut [T],
) -> InputScalarN<'_, 'p, T, L>
pub fn input_scalar_n<'p, L, T>( &self, label: L, values: &'p mut [T], ) -> InputScalarN<'_, 'p, T, L>
Shows a horizontal array of scalar value input fields. See input_scalar.
Sourcepub fn input_float2<'p, L>(
&self,
label: L,
value: &'p mut [f32; 2],
) -> InputFloat2<'_, 'p, L>
pub fn input_float2<'p, L>( &self, label: L, value: &'p mut [f32; 2], ) -> InputFloat2<'_, 'p, L>
Widget to edit two floats
Sourcepub fn input_float3<'p, L>(
&self,
label: L,
value: &'p mut [f32; 3],
) -> InputFloat3<'_, 'p, L>
pub fn input_float3<'p, L>( &self, label: L, value: &'p mut [f32; 3], ) -> InputFloat3<'_, 'p, L>
Widget to edit three floats
Sourcepub fn input_float4<'p, L>(
&self,
label: L,
value: &'p mut [f32; 4],
) -> InputFloat4<'_, 'p, L>
pub fn input_float4<'p, L>( &self, label: L, value: &'p mut [f32; 4], ) -> InputFloat4<'_, 'p, L>
Widget to edit four floats
Sourcepub fn input_int2<'p, L>(
&self,
label: L,
value: &'p mut [i32; 2],
) -> InputInt2<'_, 'p, L>
pub fn input_int2<'p, L>( &self, label: L, value: &'p mut [i32; 2], ) -> InputInt2<'_, 'p, L>
Widget to edit two integers
Sourcepub fn input_int3<'p, L>(
&self,
label: L,
value: &'p mut [i32; 3],
) -> InputInt3<'_, 'p, L>
pub fn input_int3<'p, L>( &self, label: L, value: &'p mut [i32; 3], ) -> InputInt3<'_, 'p, L>
Widget to edit three integers
Source§impl Ui
§List Box Widgets
impl Ui
§List Box Widgets
Sourcepub fn list_box_config<T>(&self, label: T) -> ListBox<T>
pub fn list_box_config<T>(&self, label: T) -> ListBox<T>
Constructs a new list box builder.
Source§impl Ui
§Menu Widgets
impl Ui
§Menu Widgets
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.
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.
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.
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.
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.
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.
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.
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
impl Ui
Creates a menu item.
Returns true if the menu item is activated.
Creates a menu item with a shortcut.
Returns true if the menu item is activated.
Creates a menu item with explicit enabled/selected state. Returns true if the menu item is activated.
Creates a menu item with explicit enabled/selected state (no shortcut).
Returns true if the menu item is activated.
Creates a menu item with explicit enabled/selected state and a shortcut.
Returns true if the menu item is activated.
Creates a toggleable menu item bound to selected (updated in place).
Returns true if the menu item is activated.
Creates a toggleable menu item bound to selected (no shortcut).
Returns true if the menu item is activated.
Creates a toggleable menu item bound to selected with a shortcut.
Returns true if the menu item is activated.
Source§impl Ui
impl Ui
Enable/disable repeating behavior for subsequent buttons.
Internally uses PushItemFlag(ImGuiItemFlags_ButtonRepeat, repeat).
Push a button repeat item flag, run f, then pop the flag.
The flag is popped during unwinding if f panics.
Source§impl Ui
impl Ui
Sourcepub fn begin_disabled(&self) -> DisabledToken<'_>
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.
Sourcepub fn begin_disabled_with_cond(&self, disabled: bool) -> DisabledToken<'_>
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.
Sourcepub fn with_disabled<R>(&self, f: impl FnOnce() -> R) -> R
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.
Sourcepub fn with_disabled_if<R>(&self, disabled: bool, f: impl FnOnce() -> R) -> R
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
impl Ui
Creates an invisible button
Creates an invisible button with independent flags.
Use Self::invisible_button_options to choose a mouse button other
than the default left button.
Creates an invisible button with complete options.
Creates an arrow button
Source§impl Ui
impl Ui
Sourcepub fn set_item_key_owner(&self, key: Key) -> bool
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.
Sourcepub fn set_item_key_owner_with_flags(
&self,
key: Key,
flags: ItemKeyOwnerFlags,
) -> bool
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
impl Ui
Sourcepub fn with_multi_select(
&self,
flags: impl Into<MultiSelectOptions>,
selection_size: Option<i32>,
items_count: usize,
render: impl FnOnce(&mut MultiSelectScope<'_>),
) -> MultiSelectResult
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.
Sourcepub fn multi_select_indexed<S, F>(
&self,
storage: &mut S,
flags: impl Into<MultiSelectOptions>,
render_item: F,
)
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()definesitems_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.
Sourcepub fn table_multi_select_indexed<S, F>(
&self,
storage: &mut S,
flags: impl Into<MultiSelectOptions>,
build_row: F,
)
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.
Sourcepub fn multi_select_basic<G, F>(
&self,
selection: &mut BasicSelection,
flags: impl Into<MultiSelectOptions>,
items_count: usize,
id_at_index: G,
render_item: F,
)
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, )
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
impl Ui
§Plot Widgets
Sourcepub fn plot_lines(&self, label: impl AsRef<str>, values: &[f32])
pub fn plot_lines(&self, label: impl AsRef<str>, values: &[f32])
Creates a plot lines widget
Sourcepub fn plot_histogram(&self, label: impl AsRef<str>, values: &[f32])
pub fn plot_histogram(&self, label: impl AsRef<str>, values: &[f32])
Creates a plot histogram widget
Sourcepub fn plot_lines_config<'ui, 'p>(
&'ui self,
label: impl Into<Cow<'ui, str>>,
values: &'p [f32],
) -> PlotLines<'ui, 'p>
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
Sourcepub fn plot_histogram_config<'ui, 'p>(
&'ui self,
label: impl Into<Cow<'ui, str>>,
values: &'p [f32],
) -> PlotHistogram<'ui, 'p>
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
§Popup Widgets
impl Ui
§Popup Widgets
Sourcepub fn open_popup(&self, str_id: impl AsRef<str>) -> bool
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.
Sourcepub fn open_popup_with_flags(
&self,
str_id: impl AsRef<str>,
flags: PopupOpenFlags,
) -> bool
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.
Sourcepub fn open_popup_id(&self, id: Id) -> bool
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.
Sourcepub fn open_popup_id_with_flags(&self, id: Id, flags: PopupOpenFlags) -> bool
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.
Sourcepub fn open_popup_on_item_click(&self, str_id: Option<&str>) -> bool
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.
Sourcepub fn open_popup_on_item_click_with_flags(
&self,
str_id: Option<&str>,
flags: impl Into<PopupContextOptions>,
) -> bool
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.
Sourcepub fn begin_popup(&self, str_id: impl AsRef<str>) -> Option<PopupToken<'_>>
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.
Sourcepub fn begin_popup_with_flags(
&self,
str_id: impl AsRef<str>,
flags: WindowFlags,
) -> Option<PopupToken<'_>>
pub fn begin_popup_with_flags( &self, str_id: impl AsRef<str>, flags: WindowFlags, ) -> Option<PopupToken<'_>>
Construct a popup with window flags.
Sourcepub fn popup<F>(&self, str_id: impl AsRef<str>, f: F)where
F: FnOnce(),
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.
Sourcepub fn begin_modal_popup(
&self,
name: impl AsRef<str>,
) -> Option<ModalPopupToken<'_>>
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.
Sourcepub fn begin_modal_popup_with_opened(
&self,
name: impl AsRef<str>,
opened: &mut bool,
) -> Option<ModalPopupToken<'_>>
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:
- You still need to call
open_popuponce to open the modal. - To pass window flags, use
begin_modal_popup_config.
Sourcepub fn begin_modal_popup_config<'a>(&'a self, name: &'a str) -> ModalPopup<'a>
pub fn begin_modal_popup_config<'a>(&'a self, name: &'a str) -> ModalPopup<'a>
Creates a modal popup builder.
Sourcepub fn modal_popup<F, R>(&self, name: impl AsRef<str>, f: F) -> Option<R>where
F: FnOnce() -> R,
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.
Sourcepub fn modal_popup_with_opened<F, R>(
&self,
name: impl AsRef<str>,
opened: &mut bool,
f: F,
) -> Option<R>where
F: FnOnce() -> R,
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.
Sourcepub fn close_current_popup(&self)
pub fn close_current_popup(&self)
Closes the current popup.
Sourcepub fn is_popup_open(&self, str_id: impl AsRef<str>) -> bool
pub fn is_popup_open(&self, str_id: impl AsRef<str>) -> bool
Returns true if the popup is open.
Sourcepub fn is_popup_open_with_flags(
&self,
str_id: impl AsRef<str>,
flags: PopupQueryFlags,
) -> bool
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.
Sourcepub fn begin_popup_context_item(&self) -> Option<PopupToken<'_>>
pub fn begin_popup_context_item(&self) -> Option<PopupToken<'_>>
Begin a popup context menu for the last item.
Sourcepub fn begin_popup_context_item_with_label(
&self,
str_id: Option<&str>,
) -> Option<PopupToken<'_>>
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.
Sourcepub fn begin_popup_context_item_with_flags(
&self,
str_id: Option<&str>,
flags: impl Into<PopupContextOptions>,
) -> Option<PopupToken<'_>>
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.
Sourcepub fn begin_popup_context_window(&self) -> Option<PopupToken<'_>>
pub fn begin_popup_context_window(&self) -> Option<PopupToken<'_>>
Begin a popup context menu for the current window.
Sourcepub fn begin_popup_context_window_with_label(
&self,
str_id: Option<&str>,
) -> Option<PopupToken<'_>>
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.
Sourcepub fn begin_popup_context_window_with_flags(
&self,
str_id: Option<&str>,
flags: impl Into<PopupContextOptions>,
) -> Option<PopupToken<'_>>
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.
Sourcepub fn begin_popup_context_void(&self) -> Option<PopupToken<'_>>
pub fn begin_popup_context_void(&self) -> Option<PopupToken<'_>>
Begin a popup context menu for empty space (void).
Sourcepub fn begin_popup_context_void_with_label(
&self,
str_id: Option<&str>,
) -> Option<PopupToken<'_>>
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.
Sourcepub fn begin_popup_context_void_with_flags(
&self,
str_id: Option<&str>,
flags: impl Into<PopupContextOptions>,
) -> Option<PopupToken<'_>>
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
impl Ui
§Progress Bar Widgets
Sourcepub fn progress_bar(&self, fraction: f32) -> ProgressBar<'_>
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%).
Sourcepub fn progress_bar_with_overlay<'ui>(
&'ui self,
fraction: f32,
overlay: impl Into<Cow<'ui, str>>,
) -> ProgressBar<'ui>
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
impl Ui
Sourcepub fn selectable<T>(&self, label: T) -> bool
pub fn selectable<T>(&self, label: T) -> bool
Constructs a new simple selectable.
Use selectable_config for a builder with additional options.
Sourcepub fn selectable_config<T>(&self, label: T) -> Selectable<'_, T>
pub fn selectable_config<T>(&self, label: T) -> Selectable<'_, T>
Constructs a new selectable builder.
Source§impl Ui
impl Ui
Sourcepub fn slider<T, K>(&self, label: T, min: K, max: K, value: &mut K) -> bool
pub fn slider<T, K>(&self, label: T, min: K, max: K, value: &mut K) -> bool
Creates a new slider widget. Returns true if the value has been edited.
Sourcepub fn slider_config<T, K>(&self, label: T, min: K, max: K) -> Slider<'_, T, K>
pub fn slider_config<T, K>(&self, label: T, min: K, max: K) -> Slider<'_, T, K>
Creates a new unbuilt Slider.
Sourcepub fn slider_f32(
&self,
label: impl AsRef<str>,
value: &mut f32,
min: f32,
max: f32,
) -> bool
pub fn slider_f32( &self, label: impl AsRef<str>, value: &mut f32, min: f32, max: f32, ) -> bool
Creates a float slider
Sourcepub fn slider_i32(
&self,
label: impl AsRef<str>,
value: &mut i32,
min: i32,
max: i32,
) -> bool
pub fn slider_i32( &self, label: impl AsRef<str>, value: &mut i32, min: i32, max: i32, ) -> bool
Creates an integer slider
Sourcepub fn slider_float2(
&self,
label: impl AsRef<str>,
value: &mut [f32; 2],
min: f32,
max: f32,
) -> bool
pub fn slider_float2( &self, label: impl AsRef<str>, value: &mut [f32; 2], min: f32, max: f32, ) -> bool
Creates a float2 slider
Sourcepub fn slider_float3(
&self,
label: impl AsRef<str>,
value: &mut [f32; 3],
min: f32,
max: f32,
) -> bool
pub fn slider_float3( &self, label: impl AsRef<str>, value: &mut [f32; 3], min: f32, max: f32, ) -> bool
Creates a float3 slider
Sourcepub fn slider_float4(
&self,
label: impl AsRef<str>,
value: &mut [f32; 4],
min: f32,
max: f32,
) -> bool
pub fn slider_float4( &self, label: impl AsRef<str>, value: &mut [f32; 4], min: f32, max: f32, ) -> bool
Creates a float4 slider
Sourcepub fn slider_int2(
&self,
label: impl AsRef<str>,
value: &mut [i32; 2],
min: i32,
max: i32,
) -> bool
pub fn slider_int2( &self, label: impl AsRef<str>, value: &mut [i32; 2], min: i32, max: i32, ) -> bool
Creates an int2 slider
Sourcepub fn slider_int3(
&self,
label: impl AsRef<str>,
value: &mut [i32; 3],
min: i32,
max: i32,
) -> bool
pub fn slider_int3( &self, label: impl AsRef<str>, value: &mut [i32; 3], min: i32, max: i32, ) -> bool
Creates an int3 slider
Sourcepub fn slider_int4(
&self,
label: impl AsRef<str>,
value: &mut [i32; 4],
min: i32,
max: i32,
) -> bool
pub fn slider_int4( &self, label: impl AsRef<str>, value: &mut [i32; 4], min: i32, max: i32, ) -> bool
Creates an int4 slider
Sourcepub fn v_slider_f32(
&self,
label: impl AsRef<str>,
size: impl Into<[f32; 2]>,
value: &mut f32,
min: f32,
max: f32,
) -> bool
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§impl Ui
§Tab Widgets
impl Ui
§Tab Widgets
Sourcepub fn tab_bar(&self, id: impl AsRef<str>) -> Option<TabBarToken<'_>>
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.
Sourcepub fn tab_bar_with_flags(
&self,
id: impl AsRef<str>,
flags: impl Into<TabBarOptions>,
) -> Option<TabBarToken<'_>>
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.
Sourcepub fn tab_item(&self, label: impl AsRef<str>) -> Option<TabItemToken<'_>>
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.
Sourcepub fn tab_item_with_opened(
&self,
label: impl AsRef<str>,
opened: &mut bool,
) -> Option<TabItemToken<'_>>
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.
Sourcepub fn tab_item_with_flags(
&self,
label: impl AsRef<str>,
opened: Option<&mut bool>,
flags: impl Into<TabItemOptions>,
) -> Option<TabItemToken<'_>>
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.
Creates a button on the current tab bar (e.g. to append a + new-tab button).
Creates a button on the current tab bar with explicit flags.
Sourcepub fn set_tab_item_closed(&self, tab_or_docked_window_label: impl AsRef<str>)
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
impl Ui
§Table Widgets
Sourcepub fn table<'ui>(
&'ui self,
str_id: impl Into<Cow<'ui, str>>,
) -> TableBuilder<'ui>
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");
});Sourcepub fn begin_table(
&self,
str_id: impl AsRef<str>,
column_count: usize,
) -> Option<TableToken<'_>>
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.
Sourcepub fn begin_table_with_flags(
&self,
str_id: impl AsRef<str>,
column_count: usize,
flags: impl Into<TableOptions>,
) -> Option<TableToken<'_>>
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.
Sourcepub 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<'_>>
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.
Sourcepub fn begin_table_header<Name, const N: usize>(
&self,
str_id: impl AsRef<str>,
column_data: [TableColumnSetup<Name>; N],
) -> Option<TableToken<'_>>
pub fn begin_table_header<Name, const N: usize>( &self, str_id: impl AsRef<str>, column_data: [TableColumnSetup<Name>; N], ) -> Option<TableToken<'_>>
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.
Sourcepub 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<'_>>
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<'_>>
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.
Sourcepub fn table_setup_column(
&self,
label: impl AsRef<str>,
flags: TableColumnFlags,
width: Option<TableColumnWidth>,
)
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.
Sourcepub fn table_setup_column_with_user_data(
&self,
label: impl AsRef<str>,
flags: TableColumnFlags,
width: Option<TableColumnWidth>,
user_data: impl Into<TableColumnUserData>,
)
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.
Sourcepub fn table_setup_column_with_indent(
&self,
label: impl AsRef<str>,
flags: TableColumnFlags,
width: Option<TableColumnWidth>,
indent: Option<TableColumnIndent>,
)
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.
Sourcepub 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>,
)
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.
Sourcepub fn table_setup_column_fixed_width(
&self,
label: impl AsRef<str>,
flags: TableColumnFlags,
width: f32,
)
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.
Sourcepub fn table_setup_column_stretch_weight(
&self,
label: impl AsRef<str>,
flags: TableColumnFlags,
weight: f32,
)
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.
Sourcepub fn table_headers_row(&self)
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.
Sourcepub fn table_next_column(&self) -> bool
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.
Sourcepub fn table_set_column_index(
&self,
column: impl Into<TableColumnIndex>,
) -> bool
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.
Sourcepub fn table_next_row(&self)
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.
Sourcepub fn table_next_row_with_flags(
&self,
flags: TableRowFlags,
min_row_height: f32,
)
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.
Sourcepub fn table_setup_scroll_freeze(&self, frozen_cols: usize, frozen_rows: usize)
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.
Sourcepub fn table_header(&self, label: impl AsRef<str>)
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.
Sourcepub fn table_get_column_count(&self) -> usize
pub fn table_get_column_count(&self) -> usize
Return the current table’s column count, or zero when no table is current.
Sourcepub fn table_get_column_index(&self) -> Option<TableColumnIndex>
pub fn table_get_column_index(&self) -> Option<TableColumnIndex>
Return current column index, or None when no table cell is current.
Sourcepub fn table_get_row_index(&self) -> Option<TableRowIndex>
pub fn table_get_row_index(&self) -> Option<TableRowIndex>
Return current row index, or None when no table row is current.
Sourcepub fn table_get_column_name(&self, column: impl Into<TableColumnRef>) -> &str
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.
Sourcepub fn table_get_column_flags(
&self,
column: impl Into<TableColumnRef>,
) -> TableColumnStateFlags
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.
Sourcepub fn table_set_column_enabled(
&self,
column: impl Into<TableColumnRef>,
enabled: bool,
)
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.
Sourcepub fn table_get_hovered_column(&self) -> TableHoveredColumn
pub fn table_get_hovered_column(&self) -> TableHoveredColumn
Return the hovered column, unused table space, or TableHoveredColumn::None when no
table column is hovered.
Sourcepub fn table_set_column_width(
&self,
column: impl Into<TableColumnIndex>,
width: f32,
)
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.
Sourcepub fn table_set_cell_bg_color_u32(
&self,
color: u32,
column: impl Into<TableColumnRef>,
)
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.
Sourcepub fn table_set_cell_bg_color(
&self,
rgba: [f32; 4],
column: impl Into<TableColumnRef>,
)
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.
Sourcepub fn table_set_row_bg0_color_u32(&self, color: u32)
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.
Sourcepub fn table_set_row_bg0_color(&self, rgba: [f32; 4])
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.
Sourcepub fn table_set_row_bg1_color_u32(&self, color: u32)
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.
Sourcepub fn table_set_row_bg1_color(&self, rgba: [f32; 4])
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.
Sourcepub fn table_get_hovered_row(&self) -> TableHoveredRow
pub fn table_get_hovered_row(&self) -> TableHoveredRow
Return hovered row from the previous frame.
Sourcepub fn table_get_header_row_height(&self) -> f32
pub fn table_get_header_row_height(&self) -> f32
Sourcepub fn table_set_column_sort_direction(
&self,
column: impl Into<TableColumnIndex>,
dir: SortDirection,
append_to_sort_specs: bool,
)
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.
Sourcepub fn table_get_sort_specs(&self) -> Option<TableSortSpecs>
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
impl Ui
Sourcepub fn table_get_header_angled_max_label_width(&self) -> f32
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.
Sourcepub fn table_angled_headers_row(&self)
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.
Sourcepub fn table_angled_headers_row_ex_with_data(
&self,
row_id: u32,
angle: f32,
max_label_width: f32,
headers: &[TableHeaderData],
)
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.
Sourcepub fn with_table_background_channel<R>(&self, f: impl FnOnce() -> R) -> R
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.
Sourcepub fn with_table_column_channel<R>(
&self,
column: impl Into<TableColumnIndex>,
f: impl FnOnce() -> R,
) -> R
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.
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
impl Ui
Sourcepub fn calc_text_size(&self, text: impl AsRef<str>) -> [f32; 2]
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.
Sourcepub fn calc_text_size_with_opts(
&self,
text: impl AsRef<str>,
hide_text_after_double_hash: bool,
wrap_width: f32,
) -> [f32; 2]
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.
Sourcepub fn text_colored(&self, color: [f32; 4], text: impl AsRef<str>)
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");Sourcepub fn text_disabled(&self, text: impl AsRef<str>)
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");Sourcepub fn text_wrapped(&self, text: impl AsRef<str>)
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.
Sourcepub fn label_text(&self, label: impl AsRef<str>, text: impl AsRef<str>)
pub fn label_text(&self, label: impl AsRef<str>, text: impl AsRef<str>)
Display a label and text on the same line
Source§impl Ui
§Tooltip Widgets
impl Ui
§Tooltip Widgets
Sourcepub fn tooltip<F>(&self, f: F)where
F: FnOnce(),
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!");
});
}Sourcepub fn begin_tooltip(&self) -> Option<TooltipToken<'_>>
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.
Sourcepub fn tooltip_text(&self, text: impl AsRef<str>)
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!");
}Sourcepub fn set_tooltip(&self, text: impl AsRef<str>)
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.
Sourcepub fn set_tooltip_formatted(&self, text: impl AsRef<str>)
pub fn set_tooltip_formatted(&self, text: impl AsRef<str>)
Sets a tooltip with formatted text content.
Sourcepub fn set_item_tooltip(&self, text: impl AsRef<str>)
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
impl Ui
§Item/Widget Utilities and Query Functions
Sourcepub fn is_item_hovered(&self) -> bool
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.
Sourcepub fn is_item_hovered_with_flags(&self, flags: ItemHoveredFlags) -> bool
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.
Sourcepub fn is_item_active(&self) -> bool
pub fn is_item_active(&self) -> bool
Returns true if the last item is active (e.g. button being held, text field being edited).
Sourcepub fn is_item_focused(&self) -> bool
pub fn is_item_focused(&self) -> bool
Returns true if the last item is focused (e.g. text input field).
Sourcepub fn is_item_clicked(&self) -> bool
pub fn is_item_clicked(&self) -> bool
Returns true if the last item was just clicked.
Returns true if the last item was clicked with specific mouse button.
Sourcepub fn is_item_visible(&self) -> bool
pub fn is_item_visible(&self) -> bool
Returns true if the last item is visible (not clipped).
Sourcepub fn is_item_activated(&self) -> bool
pub fn is_item_activated(&self) -> bool
Returns true if the last item was just made active (e.g. button was pressed).
Sourcepub fn is_item_deactivated(&self) -> bool
pub fn is_item_deactivated(&self) -> bool
Returns true if the last item was just made inactive (e.g. button was released).
Sourcepub fn is_item_deactivated_after_edit(&self) -> bool
pub fn is_item_deactivated_after_edit(&self) -> bool
Returns true if the last item was just made inactive and was edited.
Sourcepub fn is_item_edited(&self) -> bool
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.
Sourcepub fn is_any_item_active(&self) -> bool
pub fn is_any_item_active(&self) -> bool
Returns true if any item is active.
Sourcepub fn is_any_item_focused(&self) -> bool
pub fn is_any_item_focused(&self) -> bool
Returns true if any item is focused.
Sourcepub fn is_any_item_hovered(&self) -> bool
pub fn is_any_item_hovered(&self) -> bool
Returns true if any item is hovered.
Sourcepub fn item_rect(&self) -> ([f32; 2], [f32; 2])
pub fn item_rect(&self) -> ([f32; 2], [f32; 2])
Gets the bounding rectangle of the last item in screen space.
Sourcepub fn item_rect_size(&self) -> [f32; 2]
pub fn item_rect_size(&self) -> [f32; 2]
Gets the size of the last item.
Source§impl Ui
§Tree Node Widgets
impl Ui
§Tree Node Widgets
Sourcepub fn tree_node<I, T>(&self, id: I) -> Option<TreeNodeToken<'_>>
pub fn tree_node<I, T>(&self, id: I) -> Option<TreeNodeToken<'_>>
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.
Sourcepub fn tree_node_config<I, T>(&self, id: I) -> TreeNode<'_, T>
pub fn tree_node_config<I, T>(&self, id: I) -> TreeNode<'_, T>
Constructs a new tree node builder.
Use tree_node to build a simple node with just a name.
Sourcepub fn tree_push(&self, id: impl AsRef<str>) -> TreeNodeToken<'_>
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.
Sourcepub fn tree_push_ptr<T>(&self, id: *const T) -> TreeNodeToken<'_>
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.
Sourcepub fn collapsing_header(
&self,
label: impl AsRef<str>,
flags: TreeNodeFlags,
) -> bool
pub fn collapsing_header( &self, label: impl AsRef<str>, flags: TreeNodeFlags, ) -> bool
Creates a collapsing header widget
Sourcepub fn collapsing_header_with_visible(
&self,
label: impl AsRef<str>,
visible: &mut bool,
flags: TreeNodeFlags,
) -> bool
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.
Sourcepub fn tree_node_to_label_spacing(&self) -> f32
pub fn tree_node_to_label_spacing(&self) -> f32
Returns the distance from the start of a tree node to the label text.
Sourcepub fn tree_node_get_open(&self, storage_id: Id) -> bool
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
impl Ui
Sourcepub fn child_window<'ui>(
&'ui self,
name: impl Into<Cow<'ui, str>>,
) -> ChildWindow<'ui>
pub fn child_window<'ui>( &'ui self, name: impl Into<Cow<'ui, str>>, ) -> ChildWindow<'ui>
Creates a child window builder
Source§impl Ui
impl Ui
Sourcepub fn content_region_avail(&self) -> [f32; 2]
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.)
Sourcepub fn content_region_avail_width(&self) -> f32
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]
Sourcepub fn content_region_avail_height(&self) -> f32
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
impl Ui
Sourcepub fn scroll_max_x(&self) -> f32
pub fn scroll_max_x(&self) -> f32
Returns the maximum horizontal scroll position
Sourcepub fn scroll_max_y(&self) -> f32
pub fn scroll_max_y(&self) -> f32
Returns the maximum vertical scroll position
Sourcepub fn set_scroll_x(&self, scroll_x: f32)
pub fn set_scroll_x(&self, scroll_x: f32)
Sets the horizontal scroll position
Sourcepub fn set_scroll_y(&self, scroll_y: f32)
pub fn set_scroll_y(&self, scroll_y: f32)
Sets the vertical scroll position
Sourcepub fn set_scroll_from_pos_x(&self, local_x: f32, center_x_ratio: f32)
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)
Sourcepub fn set_scroll_from_pos_y(&self, local_y: f32, center_y_ratio: f32)
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)
Sourcepub fn set_scroll_here_x(&self, center_x_ratio: f32)
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
Sourcepub fn set_scroll_here_y(&self, center_y_ratio: f32)
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)
impl Ui
§Parameter stacks (shared)
Sourcepub fn push_font(&self, id: FontId) -> FontStackToken<'_>
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
impl Ui
§ID stack
Sourcepub fn push_id<'a, T>(&self, id: T) -> IdStackToken<'_>where
T: Into<Id<'a>>,
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
impl Ui
Sourcepub fn push_focus_scope(&self, id: Id) -> FocusScopeToken<'_>
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
impl Ui
Sourcepub fn item_flags(&self) -> ItemStateFlags
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.
Sourcepub fn push_item_flag(
&self,
flags: ItemFlags,
enabled: bool,
) -> ItemFlagStackToken<'_>
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.
Sourcepub fn with_item_flag<R>(
&self,
flags: ItemFlags,
enabled: bool,
f: impl FnOnce() -> R,
) -> R
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)
impl Ui
§Parameter stacks (current window)
Sourcepub fn push_item_width(&self, item_width: f32) -> ItemWidthStackToken<'_>
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 isitem_widthpixels= 0.0: default to ~2/3 of window width< 0.0:item_widthpixels relative to the right of window (-1.0 always aligns width to the right side)
Sourcepub fn push_item_width_text(
&self,
text: impl AsRef<str>,
) -> ItemWidthStackToken<'_>
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.
Sourcepub fn push_text_wrap_pos(&self, wrap_pos_x: f32) -> TextWrapPosStackToken<'_>
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 wrappingwrap_pos_x = 0.0: wrap to end of window (or column)wrap_pos_x > 0.0: wrap atwrap_pos_xposition in window local space
Source§impl Ui
impl Ui
Sourcepub fn push_style_color(
&self,
style_color: StyleColor,
color: impl Into<[f32; 4]>,
) -> ColorStackToken<'_>
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();Sourcepub fn push_style_var(&self, style_var: StyleVar) -> StyleStackToken<'_>
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();Sourcepub fn push_style_var_x(
&self,
style_var: StyleVarVec2,
value: f32,
) -> StyleStackToken<'_>
pub fn push_style_var_x( &self, style_var: StyleVarVec2, value: f32, ) -> StyleStackToken<'_>
Overrides the X component of a two-component style variable.
Sourcepub fn push_style_var_y(
&self,
style_var: StyleVarVec2,
value: f32,
) -> StyleStackToken<'_>
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
impl Ui
Sourcepub fn push_clip_rect(
&self,
min: impl Into<[f32; 2]>,
max: impl Into<[f32; 2]>,
intersect_with_current: bool,
) -> ClipRectToken<'_>
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.
Sourcepub 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
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§impl Ui
impl Ui
Sourcepub fn cursor_pos(&self) -> [f32; 2]
pub fn cursor_pos(&self) -> [f32; 2]
Returns the cursor position (in window coordinates)
Sourcepub fn cursor_screen_pos(&self) -> [f32; 2]
pub fn cursor_screen_pos(&self) -> [f32; 2]
Returns the cursor position (in absolute screen coordinates)
Sourcepub fn set_cursor_pos(&self, pos: impl Into<[f32; 2]>)
pub fn set_cursor_pos(&self, pos: impl Into<[f32; 2]>)
Sets the cursor position (in window coordinates)
Sourcepub fn set_cursor_screen_pos(&self, pos: impl Into<[f32; 2]>)
pub fn set_cursor_screen_pos(&self, pos: impl Into<[f32; 2]>)
Sets the cursor position (in absolute screen coordinates)
Sourcepub fn cursor_pos_x(&self) -> f32
pub fn cursor_pos_x(&self) -> f32
Returns the X cursor position (in window coordinates)
Sourcepub fn cursor_pos_y(&self) -> f32
pub fn cursor_pos_y(&self) -> f32
Returns the Y cursor position (in window coordinates)
Sourcepub fn set_cursor_pos_x(&self, x: f32)
pub fn set_cursor_pos_x(&self, x: f32)
Sets the X cursor position (in window coordinates)
Sourcepub fn set_cursor_pos_y(&self, y: f32)
pub fn set_cursor_pos_y(&self, y: f32)
Sets the Y cursor position (in window coordinates)
Sourcepub fn cursor_start_pos(&self) -> [f32; 2]
pub fn cursor_start_pos(&self) -> [f32; 2]
Returns the initial cursor position (in window coordinates)
Source§impl Ui
impl Ui
Sourcepub fn begin_group(&self) -> GroupToken<'_>
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§impl Ui
impl Ui
Sourcepub fn text_line_height(&self) -> f32
pub fn text_line_height(&self) -> f32
Return ~ FontSize.
Sourcepub fn text_line_height_with_spacing(&self) -> f32
pub fn text_line_height_with_spacing(&self) -> f32
Return ~ FontSize + style.ItemSpacing.y.
Sourcepub fn frame_height(&self) -> f32
pub fn frame_height(&self) -> f32
Return ~ FontSize + style.FramePadding.y * 2.
Sourcepub fn frame_height_with_spacing(&self) -> f32
pub fn frame_height_with_spacing(&self) -> f32
Return ~ FontSize + style.FramePadding.y * 2 + style.ItemSpacing.y.
Source§impl Ui
impl Ui
Sourcepub fn separator(&self)
pub fn separator(&self)
Renders a separator (generally horizontal).
This becomes a vertical separator inside a menu bar or in horizontal layout mode.
Sourcepub fn separator_with_text(&self, text: impl AsRef<str>)
pub fn separator_with_text(&self, text: impl AsRef<str>)
Renders a separator with text.
Sourcepub fn separator_vertical(&self)
pub fn separator_vertical(&self)
Creates a vertical separator
Sourcepub fn separator_horizontal(&self)
pub fn separator_horizontal(&self)
Creates a horizontal separator
Source§impl Ui
impl Ui
Sourcepub fn same_line(&self)
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.
Sourcepub fn same_line_with_pos(&self, pos_x: f32)
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.
Sourcepub fn same_line_with_spacing(&self, pos_x: f32, spacing_w: f32)
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.
Sourcepub fn new_line(&self)
pub fn new_line(&self)
Undo a same_line call or force a new line when in horizontal layout mode
Sourcepub fn dummy(&self, size: impl Into<[f32; 2]>)
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.
Sourcepub fn indent(&self)
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.
Sourcepub fn begin_indent(&self) -> IndentToken<'_>
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.
Sourcepub fn begin_indent_by(&self, width: f32) -> IndentToken<'_>
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.
Sourcepub fn with_indent<R>(&self, f: impl FnOnce() -> R) -> R
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.
Sourcepub fn with_indent_by<R>(&self, width: f32, f: impl FnOnce() -> R) -> R
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.
Sourcepub fn unindent(&self)
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.
Sourcepub fn unindent_by(&self, width: f32)
pub fn unindent_by(&self, width: f32)
Moves content position to the left by width
Source§impl Ui
impl Ui
Sourcepub fn align_text_to_frame_padding(&self)
pub fn align_text_to_frame_padding(&self)
Vertically align upcoming text baseline to FramePadding.y (align text to framed items).
Source§impl Ui
impl Ui
Sourcepub fn drag_drop_source_config<T>(&self, name: T) -> DragDropSource<'_, T>
pub fn drag_drop_source_config<T>(&self, name: T) -> DragDropSource<'_, T>
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();
}Sourcepub fn drag_drop_target(&self) -> Option<DragDropTarget<'_>>
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();
}Sourcepub fn drag_drop_payload(&self) -> Option<DragDropPayload>
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
impl Ui
Sourcepub fn text_filter(&self, label: impl Into<String>) -> TextFilter
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");Sourcepub fn text_filter_with_filter(
&self,
label: impl Into<String>,
filter: impl AsRef<str>,
) -> TextFilter
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 inputfilter- The initial filter pattern
§Examples
let filter = ui.text_filter_with_filter(
"Search",
"include,-exclude"
);