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_over_main_viewport_with_flags(
&self,
dockspace_id: Id,
flags: DockNodeFlags,
) -> Id
pub fn dockspace_over_main_viewport_with_flags( &self, dockspace_id: Id, flags: DockNodeFlags, ) -> Id
Creates a dockspace over the main viewport
This is a convenience function that creates a dockspace covering the entire main viewport.
It’s equivalent to calling dock_space with the main viewport’s ID and size.
§Parameters
dockspace_id- The ID for the dockspace (use 0 to auto-generate)flags- Dock node flags
§Returns
The ID of the created dockspace
§Example
let dockspace_id = ui.dockspace_over_main_viewport_with_flags(
0,
DockNodeFlags::PASSTHRU_CENTRAL_NODE
);Sourcepub fn dockspace_over_main_viewport(&self) -> Id
pub fn dockspace_over_main_viewport(&self) -> Id
Sourcepub fn dock_space_with_class(
&self,
id: Id,
size: [f32; 2],
flags: DockNodeFlags,
window_class: Option<&WindowClass>,
) -> Id
pub fn dock_space_with_class( &self, id: Id, size: [f32; 2], flags: DockNodeFlags, window_class: Option<&WindowClass>, ) -> Id
Creates a dockspace with the specified ID, size, and flags
§Parameters
id- The ID for the dockspace (use 0 to auto-generate)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
§Example
let dockspace_id = ui.dock_space_with_class(
0,
[800.0, 600.0],
DockNodeFlags::NO_DOCKING_SPLIT,
Some(&WindowClass::new(1))
);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.
§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_over_main_viewport();
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.
§Parameters
dock_id- The ID of the dock node to dock the next window to
§Example
let dockspace_id = ui.dockspace_over_main_viewport();
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(1).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 {
ui.text(format!("This window is docked with ID: {}", dock_id));
} 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
§Fonts
impl Ui
§Fonts
Sourcepub fn current_font(&self) -> &Font
pub fn current_font(&self) -> &Font
Returns 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<&Font>, size: f32)
pub fn push_font_with_size(&self, font: Option<&Font>, size: f32)
Push a font with dynamic size support (v1.92+ feature)
This allows changing font size at runtime without pre-loading different sizes. Pass None for font to use the current font with the new size.
Sourcepub fn with_font_and_size<F, R>(
&self,
font: Option<&Font>,
size: f32,
f: F,
) -> Rwhere
F: FnOnce() -> R,
pub fn with_font_and_size<F, R>(
&self,
font: Option<&Font>,
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 font scale of the current window
Note: This function is not available in our Dear ImGui version. Font scaling should be handled through font size instead.
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_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 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
Source§impl Ui
impl Ui
Sourcepub fn main_viewport(&self) -> &'static Viewport
pub fn main_viewport(&self) -> &'static Viewport
Returns a reference to the main Dear ImGui viewport (safe wrapper)
Same viewport used by dockspace_over_main_viewport().
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 get_id(&self, label: &str) -> Id
pub fn get_id(&self, label: &str) -> Id
Returns an ID from a string label in the current ID scope.
This mirrors ImGui::GetID(label). Useful for building stable IDs
for widgets or dockspaces inside the current window/scope.
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
Sourcepub fn show_demo_window(&self, opened: &mut bool)
pub fn show_demo_window(&self, opened: &mut bool)
Renders a demo window (previously called a test window), which demonstrates most Dear ImGui features.
Sourcepub fn image_with_bg(
&self,
texture: impl Into<TextureRef>,
size: [f32; 2],
bg_color: [f32; 4],
tint_color: [f32; 4],
)
pub fn image_with_bg( &self, texture: impl Into<TextureRef>, 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 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.
Displays Dear ImGui internals: draw commands (with individual draw calls and vertices), window list, basic internal state, etc.
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
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
Sourcepub fn show_user_guide(&self)
pub fn show_user_guide(&self)
Renders a basic help/info block (not a window)
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: AsRef<str>>(&self, label: L) -> Drag<f32, L>
pub fn drag_float_config<L: AsRef<str>>(&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: AsRef<str>>(&self, label: L) -> Drag<i32, L>
pub fn drag_int_config<L: AsRef<str>>(&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: AsRef<str>>(
&self,
label: L,
) -> DragRange<f32, L>
pub fn drag_float_range2_config<L: AsRef<str>>( &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: AsRef<str>>(
&self,
label: L,
) -> DragRange<i32, L>
pub fn drag_int_range2_config<L: AsRef<str>>( &self, label: L, ) -> DragRange<i32, L>
Creates a drag int range slider with configuration
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_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.
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 unsafe fn style(&self) -> &Style
pub unsafe fn style(&self) -> &Style
Returns a shared reference to the current [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 [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 [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 [Style] object.
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 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).
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.
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 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.
Sourcepub fn get_version(&self) -> &str
pub fn get_version(&self) -> &str
Returns the Dear ImGui version string
Source§impl Ui
Utility functions for Dear ImGui
impl Ui
Utility functions for Dear ImGui
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 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: HoveredFlags) -> bool
pub fn is_window_hovered_with_flags(&self, flags: HoveredFlags) -> 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_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.
Sourcepub fn get_key_pressed_amount(
&self,
key: Key,
repeat_delay: f32,
rate: f32,
) -> i32
pub fn get_key_pressed_amount( &self, key: Key, repeat_delay: f32, rate: f32, ) -> i32
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) -> i32
pub fn get_mouse_clicked_count(&self, button: MouseButton) -> i32
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
Sourcepub fn frame_count(&self) -> i32
pub fn frame_count(&self) -> i32
Get global imgui frame count. Incremented by 1 every frame.
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 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 is just a wrapper around calling name on StyleColor.
Sourcepub fn is_rect_visible(&self, size: [f32; 2]) -> bool
pub fn is_rect_visible(&self, size: [f32; 2]) -> bool
Test if rectangle (of given size, starting from cursor position) is visible / not clipped.
Sourcepub fn is_rect_visible_ex(&self, rect_min: [f32; 2], rect_max: [f32; 2]) -> bool
pub fn is_rect_visible_ex(&self, rect_min: [f32; 2], rect_max: [f32; 2]) -> bool
Test if rectangle (in screen space) is visible / not clipped.
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.
Sourcepub fn is_point_in_circle(
&self,
point: [f32; 2],
center: [f32; 2],
radius: f32,
) -> bool
pub fn is_point_in_circle( &self, point: [f32; 2], center: [f32; 2], radius: f32, ) -> bool
Check if a point is inside a circle.
Sourcepub fn triangle_area(&self, p1: [f32; 2], p2: [f32; 2], p3: [f32; 2]) -> f32
pub fn triangle_area(&self, p1: [f32; 2], p2: [f32; 2], p3: [f32; 2]) -> f32
Calculate the area of a triangle given three points.
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
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.
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<'p>(
&self,
label: impl AsRef<str>,
color: &'p mut [f32; 3],
) -> ColorEdit3<'_, 'p>
pub fn color_edit3_config<'p>( &self, label: impl AsRef<str>, color: &'p mut [f32; 3], ) -> ColorEdit3<'_, 'p>
Creates a color edit builder for 3 components
Sourcepub fn color_edit4_config<'p>(
&self,
label: impl AsRef<str>,
color: &'p mut [f32; 4],
) -> ColorEdit4<'_, 'p>
pub fn color_edit4_config<'p>( &self, label: impl AsRef<str>, color: &'p mut [f32; 4], ) -> ColorEdit4<'_, 'p>
Creates a color edit builder for 4 components
Sourcepub fn color_picker3_config<'p>(
&self,
label: impl AsRef<str>,
color: &'p mut [f32; 3],
) -> ColorPicker3<'_, 'p>
pub fn color_picker3_config<'p>( &self, label: impl AsRef<str>, color: &'p mut [f32; 3], ) -> ColorPicker3<'_, 'p>
Creates a color picker builder for 3 components
Sourcepub fn color_picker4_config<'p>(
&self,
label: impl AsRef<str>,
color: &'p mut [f32; 4],
) -> ColorPicker4<'_, 'p>
pub fn color_picker4_config<'p>( &self, label: impl AsRef<str>, color: &'p mut [f32; 4], ) -> ColorPicker4<'_, '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: ComboBoxFlags,
) -> Option<ComboBoxToken<'_>>
pub fn begin_combo_with_flags( &self, label: impl AsRef<str>, preview_value: impl AsRef<str>, flags: ComboBoxFlags, ) -> 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: ComboBoxFlags,
) -> Option<ComboBoxToken<'_>>
pub fn begin_combo_no_preview_with_flags( &self, label: impl AsRef<str>, flags: ComboBoxFlags, ) -> 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_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 set_item_default_focus(&self)
pub fn set_item_default_focus(&self)
Sets the default focus for the next item
Source§impl Ui
impl Ui
Sourcepub fn drag<T: AsRef<str>, K: DataTypeKind>(
&self,
label: T,
value: &mut K,
) -> bool
pub fn drag<T: AsRef<str>, K: DataTypeKind>( &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: AsRef<str>, K: DataTypeKind>(
&self,
label: T,
) -> Drag<K, T>
pub fn drag_config<T: AsRef<str>, K: DataTypeKind>( &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 mut tex = texture::TextureData::new();
tex.create(texture::TextureFormat::RGBA32, 64, 64);
ui.image(&mut *tex, [64.0, 64.0]);Creates an image button widget
Sourcepub fn image_config(
&self,
texture: impl Into<TextureRef>,
size: [f32; 2],
) -> Image<'_>
pub fn image_config( &self, texture: impl Into<TextureRef>, size: [f32; 2], ) -> Image<'_>
Creates an image builder
Creates an image button builder
Source§impl Ui
§Input Widgets
impl Ui
§Input Widgets
Sourcepub fn input_text<'p>(
&self,
label: impl AsRef<str>,
buf: &'p mut String,
) -> InputText<'_, 'p, String, String, PassthroughCallback>
pub fn input_text<'p>( &self, label: impl AsRef<str>, buf: &'p mut String, ) -> InputText<'_, 'p, String, String, PassthroughCallback>
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<'p>(
&self,
label: impl AsRef<str>,
buf: &'p mut ImString,
) -> InputTextImStr<'_, 'p, String, String, PassthroughCallback>
pub fn input_text_imstr<'p>( &self, label: impl AsRef<str>, buf: &'p mut ImString, ) -> InputTextImStr<'_, 'p, String, String, PassthroughCallback>
Creates a single-line text input backed by ImString (zero-copy)
Sourcepub fn input_text_multiline<'p>(
&self,
label: impl AsRef<str>,
buf: &'p mut String,
size: impl Into<[f32; 2]>,
) -> InputTextMultiline<'_, 'p>
pub fn input_text_multiline<'p>( &self, label: impl AsRef<str>, buf: &'p mut String, size: impl Into<[f32; 2]>, ) -> InputTextMultiline<'_, '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<'p>(
&self,
label: impl AsRef<str>,
buf: &'p mut ImString,
size: impl Into<[f32; 2]>,
) -> InputTextMultilineImStr<'_, 'p>
pub fn input_text_multiline_imstr<'p>( &self, label: impl AsRef<str>, buf: &'p mut ImString, size: impl Into<[f32; 2]>, ) -> InputTextMultilineImStr<'_, '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(&self, label: impl AsRef<str>) -> InputInt<'_>
pub fn input_int_config(&self, label: impl AsRef<str>) -> InputInt<'_>
Creates an integer input builder
Sourcepub fn input_float_config(&self, label: impl AsRef<str>) -> InputFloat<'_>
pub fn input_float_config(&self, label: impl AsRef<str>) -> InputFloat<'_>
Creates a float input builder
Sourcepub fn input_double_config(&self, label: impl AsRef<str>) -> InputDouble<'_>
pub fn input_double_config(&self, label: impl AsRef<str>) -> InputDouble<'_>
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
§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 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 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.
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 toggleable menu item bound to selected (updated in place).
Returns true if the menu item is activated.
Source§impl Ui
impl Ui
Creates a small button
Creates an invisible button
Creates an invisible button with flags
Creates an arrow button
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.
Source§impl Ui
impl Ui
Enable/disable repeating behavior for subsequent buttons.
Internally uses PushItemFlag(ImGuiItemFlags_ButtonRepeat, repeat).
Pop the button repeat item flag.
Source§impl Ui
impl Ui
Sourcepub fn set_item_key_owner(&self, key: Key)
pub fn set_item_key_owner(&self, key: Key)
Set the key owner for the last item, without flags.
Sourcepub fn set_item_key_owner_with_flags(&self, key: Key, flags: ImGuiInputFlags)
pub fn set_item_key_owner_with_flags(&self, key: Key, flags: ImGuiInputFlags)
Set the key owner for the last item with input flags.
Pass a combination of ImGuiInputFlags_* from dear_imgui_sys.
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<'p>(
&self,
label: impl AsRef<str>,
values: &'p [f32],
) -> PlotLines<'_, 'p>
pub fn plot_lines_config<'p>( &self, label: impl AsRef<str>, values: &'p [f32], ) -> PlotLines<'_, 'p>
Creates a plot lines builder
Sourcepub fn plot_histogram_config<'p>(
&self,
label: impl AsRef<str>,
values: &'p [f32],
) -> PlotHistogram<'_, 'p>
pub fn plot_histogram_config<'p>( &self, label: impl AsRef<str>, values: &'p [f32], ) -> PlotHistogram<'_, '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>)
pub fn open_popup(&self, str_id: impl AsRef<str>)
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.
Sourcepub fn open_popup_with_flags(&self, str_id: impl AsRef<str>, flags: PopupFlags)
pub fn open_popup_with_flags(&self, str_id: impl AsRef<str>, flags: PopupFlags)
Instructs ImGui that a popup is open with flags.
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_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 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: PopupFlags,
) -> bool
pub fn is_popup_open_with_flags( &self, str_id: impl AsRef<str>, flags: PopupFlags, ) -> 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. This is typically used with right-click context menus.
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_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_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.
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(
&self,
fraction: f32,
overlay: impl AsRef<str>,
) -> ProgressBar<'_>
pub fn progress_bar_with_overlay( &self, fraction: f32, overlay: impl AsRef<str>, ) -> ProgressBar<'_>
Creates a progress bar with overlay text.
Source§impl Ui
impl Ui
Sourcepub fn selectable<T: AsRef<str>>(&self, label: T) -> bool
pub fn selectable<T: AsRef<str>>(&self, label: T) -> bool
Constructs a new simple selectable.
Use selectable_config for a builder with additional options.
Sourcepub fn selectable_config<T: AsRef<str>>(&self, label: T) -> Selectable<'_, T>
pub fn selectable_config<T: AsRef<str>>(&self, label: T) -> Selectable<'_, T>
Constructs a new selectable builder.
Source§impl Ui
impl Ui
Sourcepub fn slider<T: AsRef<str>, K: DataTypeKind>(
&self,
label: T,
min: K,
max: K,
value: &mut K,
) -> bool
pub fn slider<T: AsRef<str>, K: DataTypeKind>( &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: AsRef<str>, K: DataTypeKind>(
&self,
label: T,
min: K,
max: K,
) -> Slider<'_, T, K>
pub fn slider_config<T: AsRef<str>, K: DataTypeKind>( &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 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: TabBarFlags,
) -> Option<TabBarToken<'_>>
pub fn tab_bar_with_flags( &self, id: impl AsRef<str>, flags: TabBarFlags, ) -> 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 [tab_item_with_flags] for more.
Sourcepub fn tab_item_with_flags(
&self,
label: impl AsRef<str>,
opened: Option<&mut bool>,
flags: TabItemFlags,
) -> Option<TabItemToken<'_>>
pub fn tab_item_with_flags( &self, label: impl AsRef<str>, opened: Option<&mut bool>, flags: TabItemFlags, ) -> Option<TabItemToken<'_>>
Creates a new tab item and returns a token if its contents are visible.
Source§impl Ui
§Table Widgets
impl Ui
§Table Widgets
Sourcepub fn table(&self, str_id: impl AsRef<str>) -> TableBuilder<'_>
pub fn table(&self, str_id: impl AsRef<str>) -> TableBuilder<'_>
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.
Sourcepub fn begin_table_with_flags(
&self,
str_id: impl AsRef<str>,
column_count: usize,
flags: TableFlags,
) -> Option<TableToken<'_>>
pub fn begin_table_with_flags( &self, str_id: impl AsRef<str>, column_count: usize, flags: TableFlags, ) -> Option<TableToken<'_>>
Begins a table with flags and with standard sizing constraints.
Sourcepub fn begin_table_with_sizing(
&self,
str_id: impl AsRef<str>,
column_count: usize,
flags: TableFlags,
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: TableFlags, 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.
Sourcepub fn begin_table_header<Name: AsRef<str>, const N: usize>(
&self,
str_id: impl AsRef<str>,
column_data: [TableColumnSetup<Name>; N],
) -> Option<TableToken<'_>>
pub fn begin_table_header<Name: AsRef<str>, 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.
Sourcepub fn begin_table_header_with_flags<Name: AsRef<str>, const N: usize>(
&self,
str_id: impl AsRef<str>,
column_data: [TableColumnSetup<Name>; N],
flags: TableFlags,
) -> Option<TableToken<'_>>
pub fn begin_table_header_with_flags<Name: AsRef<str>, const N: usize>( &self, str_id: impl AsRef<str>, column_data: [TableColumnSetup<Name>; N], flags: TableFlags, ) -> 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.
Sourcepub fn table_setup_column(
&self,
label: impl AsRef<str>,
flags: TableColumnFlags,
init_width_or_weight: f32,
user_id: u32,
)
pub fn table_setup_column( &self, label: impl AsRef<str>, flags: TableColumnFlags, init_width_or_weight: f32, user_id: u32, )
Setup a column for the current table
Sourcepub fn table_headers_row(&self)
pub fn table_headers_row(&self)
Submit all headers cells based on data provided to TableSetupColumn() + submit context menu
Sourcepub fn table_next_column(&self) -> bool
pub fn table_next_column(&self) -> bool
Append into the next column (or first column of next row if currently in last column)
Sourcepub fn table_set_column_index(&self, column_n: i32) -> bool
pub fn table_set_column_index(&self, column_n: i32) -> bool
Append into the specified column
Sourcepub fn table_next_row(&self)
pub fn table_next_row(&self)
Append into the next row
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
Sourcepub fn table_setup_scroll_freeze(&self, frozen_cols: i32, frozen_rows: i32)
pub fn table_setup_scroll_freeze(&self, frozen_cols: i32, frozen_rows: i32)
Freeze columns/rows so they stay visible when scrolling.
Sourcepub fn table_header(&self, label: impl AsRef<str>)
pub fn table_header(&self, label: impl AsRef<str>)
Submit one header cell at current column position.
Sourcepub fn table_get_column_count(&self) -> i32
pub fn table_get_column_count(&self) -> i32
Return columns count.
Sourcepub fn table_get_column_index(&self) -> i32
pub fn table_get_column_index(&self) -> i32
Return current column index.
Sourcepub fn table_get_row_index(&self) -> i32
pub fn table_get_row_index(&self) -> i32
Return current row index.
Sourcepub fn table_get_column_name(&self, column_n: i32) -> &str
pub fn table_get_column_name(&self, column_n: i32) -> &str
Return the name of a column by index.
Sourcepub fn table_get_column_flags(&self, column_n: i32) -> TableColumnFlags
pub fn table_get_column_flags(&self, column_n: i32) -> TableColumnFlags
Return the flags of a column by index.
Sourcepub fn table_set_column_enabled(&self, column_n: i32, enabled: bool)
pub fn table_set_column_enabled(&self, column_n: i32, enabled: bool)
Enable/disable a column by index.
Sourcepub fn table_get_hovered_column(&self) -> i32
pub fn table_get_hovered_column(&self) -> i32
Return hovered column index, or -1 when none.
Sourcepub fn table_set_column_width(&self, column_n: i32, width: f32)
pub fn table_set_column_width(&self, column_n: i32, width: f32)
Set column width (for fixed-width columns).
Sourcepub fn table_set_bg_color_u32(
&self,
target: TableBgTarget,
color: u32,
column_n: i32,
)
pub fn table_set_bg_color_u32( &self, target: TableBgTarget, color: u32, column_n: i32, )
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.
Sourcepub fn table_set_bg_color(
&self,
target: TableBgTarget,
rgba: [f32; 4],
column_n: i32,
)
pub fn table_set_bg_color( &self, target: TableBgTarget, rgba: [f32; 4], column_n: i32, )
Set a table background color target using RGBA color (0..=1 floats).
Sourcepub fn table_get_hovered_row(&self) -> i32
pub fn table_get_hovered_row(&self) -> i32
Return hovered row index, or -1 when none.
Sourcepub fn table_get_header_row_height(&self) -> f32
pub fn table_get_header_row_height(&self) -> f32
Header row height in pixels.
Sourcepub fn table_set_column_sort_direction(
&self,
column_n: i32,
dir: SortDirection,
append_to_sort_specs: bool,
)
pub fn table_set_column_sort_direction( &self, column_n: i32, dir: SortDirection, append_to_sort_specs: bool, )
Set sort direction for a column. Optionally append to existing sort specs (multi-sort).
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 clear_dirty().
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).
Sourcepub fn table_angled_headers_row(&self)
pub fn table_angled_headers_row(&self)
Submit angled headers row (requires style/flags enabling angled headers).
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.
Sourcepub fn table_push_background_channel(&self)
pub fn table_push_background_channel(&self)
Push background draw channel for the current table and return a token to pop it.
Sourcepub fn table_pop_background_channel(&self)
pub fn table_pop_background_channel(&self)
Pop background draw channel for the current table.
Sourcepub fn table_push_column_channel(&self, column_n: i32)
pub fn table_push_column_channel(&self, column_n: i32)
Push column draw channel for the given column index and return a token to pop it.
Sourcepub fn table_pop_column_channel(&self)
pub fn table_pop_column_channel(&self)
Pop column draw channel.
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 after pushing table background channel (auto-pop on return).
Sourcepub fn with_table_column_channel<R>(
&self,
column_n: i32,
f: impl FnOnce() -> R,
) -> R
pub fn with_table_column_channel<R>( &self, column_n: i32, f: impl FnOnce() -> R, ) -> R
Run a closure after pushing a table column channel (auto-pop on return).
Open the table context menu for a given column (use -1 for current/default).
Source§impl Ui
impl Ui
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
§Note
This function currently uses the scratch buffer implementation. Optimization for this function requires additional investigation.
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: FnOnce()>(&self, f: F)
pub fn tooltip<F: FnOnce()>(&self, f: F)
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 is more efficient than begin_tooltip/end_tooltip for simple text.
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. More efficient than building a tooltip window for simple cases.
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: HoveredFlags) -> bool
pub fn is_item_hovered_with_flags(&self, flags: HoveredFlags) -> 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_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 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
Source§impl Ui
impl Ui
Sourcepub fn child_window(&self, name: impl Into<String>) -> ChildWindow<'_>
pub fn child_window(&self, name: impl Into<String>) -> ChildWindow<'_>
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 by pushing it to the font stack.
Returns a FontStackToken that must be popped by calling .pop()
§Panics
Panics if the font atlas does not contain the given font
§Examples
// At initialization time
let my_custom_font = ctx.fonts().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();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.
§Examples
let style = ui.push_style_var(StyleVar::Alpha(0.2));
ui.text("I'm transparent!");
style.pop();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.
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
§ID stack
impl Ui
§ID stack
Sourcepub fn push_id<'a, T: Into<Id<'a>>>(&self, id: T) -> IdStackToken<'_>
pub fn push_id<'a, T: Into<Id<'a>>>(&self, id: T) -> IdStackToken<'_>
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: ImGuiID) -> FocusScopeToken<'_>
pub fn push_focus_scope(&self, id: ImGuiID) -> 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
§Cursor / Layout
impl Ui
§Cursor / Layout
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
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 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
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().
Sourcepub fn group<R, F: FnOnce() -> R>(&self, f: F) -> R
pub fn group<R, F: FnOnce() -> R>(&self, f: F) -> R
Creates a layout group and runs a closure to construct the contents.
May be useful to handle the same mouse event on a group of items, for example.
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 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.
Sourcepub fn push_clip_rect(
&self,
min: impl Into<[f32; 2]>,
max: impl Into<[f32; 2]>,
intersect_with_current: bool,
)
pub fn push_clip_rect( &self, min: impl Into<[f32; 2]>, max: impl Into<[f32; 2]>, intersect_with_current: bool, )
Push a clipping rectangle in screen space.
Sourcepub fn pop_clip_rect(&self)
pub fn pop_clip_rect(&self)
Pop a clipping rectangle from the stack.
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.
Sourcepub fn is_rect_visible_min_max(
&self,
rect_min: impl Into<[f32; 2]>,
rect_max: impl Into<[f32; 2]>,
) -> bool
pub fn is_rect_visible_min_max( &self, rect_min: impl Into<[f32; 2]>, rect_max: impl Into<[f32; 2]>, ) -> bool
Returns true if the specified rectangle (min,max) is visible (not clipped).
Sourcepub fn is_rect_visible_with_size(&self, size: impl Into<[f32; 2]>) -> bool
pub fn is_rect_visible_with_size(&self, size: impl Into<[f32; 2]>) -> bool
Returns true if a rectangle of given size at the current cursor pos is visible.
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: AsRef<str>>(
&self,
name: T,
) -> DragDropSource<'_, T>
pub fn drag_drop_source_config<T: AsRef<str>>( &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(DragDropFlags::SOURCE_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", DragDropFlags::NONE).is_some() {
println!("Received drop!");
}
target.pop();
}Source§impl Ui
impl Ui
Sourcepub fn text_filter(&self, label: String) -> TextFilter
pub fn text_filter(&self, label: 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".to_string());Sourcepub fn text_filter_with_filter(
&self,
label: String,
filter: String,
) -> TextFilter
pub fn text_filter_with_filter( &self, label: String, filter: String, ) -> 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".to_string(),
"include,-exclude".to_string()
);Source§impl Ui
§Columns
impl Ui
§Columns
Sourcepub fn columns(&self, count: i32, id: impl AsRef<str>, border: bool)
pub fn columns(&self, count: i32, id: impl AsRef<str>, border: bool)
Creates columns layout.
§Arguments
count- Number of columns (must be >= 1)id- Optional ID for the columns (can be empty string)border- Whether to draw borders between columns
Sourcepub fn begin_columns(
&self,
id: impl AsRef<str>,
count: i32,
flags: OldColumnFlags,
)
pub fn begin_columns( &self, id: impl AsRef<str>, count: i32, flags: OldColumnFlags, )
Begin columns layout with advanced flags.
§Arguments
id- ID for the columnscount- Number of columns (must be >= 1)flags- Column flags
Sourcepub fn end_columns(&self)
pub fn end_columns(&self)
End columns layout.
Sourcepub fn next_column(&self)
pub fn next_column(&self)
Switches to the next column.
If the current row is finished, switches to first column of the next row
Sourcepub fn current_column_index(&self) -> i32
pub fn current_column_index(&self) -> i32
Returns the index of the current column
Sourcepub fn current_column_width(&self) -> f32
pub fn current_column_width(&self) -> f32
Returns the width of the current column (in pixels)
Sourcepub fn column_width(&self, column_index: i32) -> f32
pub fn column_width(&self, column_index: i32) -> f32
Returns the width of the given column (in pixels)
Sourcepub fn set_current_column_width(&self, width: f32)
pub fn set_current_column_width(&self, width: f32)
Sets the width of the current column (in pixels)
Sourcepub fn set_column_width(&self, column_index: i32, width: f32)
pub fn set_column_width(&self, column_index: i32, width: f32)
Sets the width of the given column (in pixels)
Sourcepub fn current_column_offset(&self) -> f32
pub fn current_column_offset(&self) -> f32
Returns the offset of the current column (in pixels from the left side of the content region)
Sourcepub fn column_offset(&self, column_index: i32) -> f32
pub fn column_offset(&self, column_index: i32) -> f32
Returns the offset of the given column (in pixels from the left side of the content region)
Sourcepub fn set_current_column_offset(&self, offset_x: f32)
pub fn set_current_column_offset(&self, offset_x: f32)
Sets the offset of the current column (in pixels from the left side of the content region)
Sourcepub fn set_column_offset(&self, column_index: i32, offset_x: f32)
pub fn set_column_offset(&self, column_index: i32, offset_x: f32)
Sets the offset of the given column (in pixels from the left side of the content region)
Sourcepub fn column_count(&self) -> i32
pub fn column_count(&self) -> i32
Returns the current amount of columns
Sourcepub fn push_column_clip_rect(&self, column_index: i32)
pub fn push_column_clip_rect(&self, column_index: i32)
Push column clip rect for the given column index. This is useful for custom drawing within columns.
Sourcepub fn push_columns_background(&self)
pub fn push_columns_background(&self)
Push columns background for drawing.
Sourcepub fn pop_columns_background(&self)
pub fn pop_columns_background(&self)
Pop columns background.
Sourcepub fn get_columns_id(&self, str_id: impl AsRef<str>, count: i32) -> u32
pub fn get_columns_id(&self, str_id: impl AsRef<str>, count: i32) -> u32
Get columns ID for the given string ID and count.
Sourcepub fn is_any_column_resizing(&self) -> bool
pub fn is_any_column_resizing(&self) -> bool
Check if any column is being resized. Note: This is a placeholder implementation as the underlying C++ function is not available
Sourcepub fn get_columns_total_width(&self) -> f32
pub fn get_columns_total_width(&self) -> f32
Get the total width of all columns.
Sourcepub fn set_columns_equal_width(&self)
pub fn set_columns_equal_width(&self)
Set all columns to equal width.
Sourcepub fn get_column_width_percentage(&self, column_index: i32) -> f32
pub fn get_column_width_percentage(&self, column_index: i32) -> f32
Get column width as a percentage of total width.
Sourcepub fn set_column_width_percentage(&self, column_index: i32, percentage: f32)
pub fn set_column_width_percentage(&self, column_index: i32, percentage: f32)
Set column width as a percentage of total width.