Struct imgui::Ui [−][src]
pub struct Ui<'ui> { /* fields omitted */ }
Expand description
A temporary reference for building the user interface for one frame
Implementations
Returns the current clipboard contents as text, or None if the clipboard is empty or cannot be accessed
Sets the clipboard contents.
Does nothing if the clipboard cannot be accessed.
Switches to the next column.
If the current row is finished, switches to first column of the next row
Returns the index of the current column
Returns the width of the current column (in pixels)
Returns the width of the given column (in pixels)
Sets the width of the current column (in pixels)
Sets the width of the given column (in pixels)
Returns the offset of the current column (in pixels from the left side of the content region)
Returns the offset of the given column (in pixels from the left side of the content region)
Sets the offset of the current column (in pixels from the left side of the content region)
Sets the offset of the given column (in pixels from the left side of the content region)
Returns the current amount of columns
Returns the current font
Returns the current font size (= height in pixels) with font scale applied
Returns the UV coordinate for a white pixel.
Useful for drawing custom shapes with the draw list API.
Sets the font scale of the current window
Returns true if the key is being held.
Equivalent to indexing the Io struct keys_down
field: ui.io().keys_down[key_index]
Same as is_key_down
but takes a key index. The meaning of
index is defined by your backend implementation.
Returns true if the key was pressed (went from !down to down).
Affected by key repeat settings (io.key_repeat_delay
, io.key_repeat_rate
)
Same as is_key_pressed
but takes a key index.
The meaning of index is defined by your backend implementation.
Returns true if the key was pressed (went from !down to down).
Is not affected by key repeat settings (io.key_repeat_delay
, io.key_repeat_rate
)
Same as is_key_pressed_no_repeat
but takes a key index.
The meaning of index is defined by your backend implementation.
Returns true if the key was released (went from down to !down)
Same as is_key_released
but takes a key index.
The meaning of index is defined by your backend implementation.
Returns a count of key presses using the given repeat rate/delay settings.
Usually returns 0 or 1, but might be >1 if rate
is small enough that io.delta_time
>
rate
.
Focuses keyboard on the next widget.
This is the equivalent to set_keyboard_focus_here_with_offset
with target_widget
set to FocusedWidget::Next
.
Focuses keyboard on a widget relative to current position.
Returns true if the given mouse button is held down.
Equivalent to indexing the Io struct with the button, e.g. ui.io()[button]
.
Returns true if any mouse button is held down
Returns true if the given mouse button was clicked (went from !down to down)
Returns true if the given mouse button was double-clicked
Returns true if the given mouse button was released (went from down to !down)
Returns true if the mouse is currently dragging with the given mouse button held down
Returns true if the mouse is currently dragging with the given mouse button held down.
If the given threshold is invalid or negative, the global distance threshold is used
(io.mouse_drag_threshold
).
Returns true if the mouse is hovering over the given bounding rect.
Clipped by current clipping settings, but disregards other factors like focus, window ordering, modal popup blocking.
Returns the mouse position backed up at the time of opening a popup
Returns the delta from the initial position when the left mouse button clicked.
This is locked and returns [0.0, 0.0] until the mouse has moved past the global distance
threshold (io.mouse_drag_threshold
).
This is the same as mouse_drag_delta_with_button with
button
set to MouseButton::Left
.
Returns the delta from the initial position when the given button was clicked.
This is locked and returns [0.0, 0.0] until the mouse has moved past the global distance
threshold (io.mouse_drag_threshold
).
This is the same as mouse_drag_delta_with_threshold with
threshold
set to -1.0
, which uses the global threshold io.mouse_drag_threshold
.
pub fn mouse_drag_delta_with_threshold(
&self,
button: MouseButton,
threshold: f32
) -> [f32; 2]
pub fn mouse_drag_delta_with_threshold(
&self,
button: MouseButton,
threshold: f32
) -> [f32; 2]
Returns the delta from the initial clicking position.
This is locked and returns [0.0, 0.0] until the mouse has moved past the given threshold.
If the given threshold is invalid or negative, the global distance threshold is used
(io.mouse_drag_threshold
).
Resets the current delta from initial clicking position.
Returns the currently desired mouse cursor type.
Returns None
if no cursor should be displayed
Sets the desired mouse cursor type.
Passing None
hides the mouse cursor.
Renders a separator (generally horizontal).
This becomes a vertical separator inside a menu bar or in horizontal layout mode.
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
.
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.
Call between widgets or groups to layout them horizontally.
X position is given in window coordinates.
Fills a space of size
in pixels with nothing on the current window.
Can be used to move the cursor on the window.
Moves content position to the right by Style::indent_spacing
This is equivalent to indent_by with width
set to
Style::ident_spacing
.
Moves content position to the left by Style::indent_spacing
This is equivalent to unindent_by with width
set to
Style::ident_spacing
.
Moves content position to the left by width
Groups items together as a single item.
May be useful to handle the same mouse event on a group of items, for example.
Returns a GroupToken
that must be ended by calling .end()
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.
Returns the cursor position (in window coordinates)
Sets the cursor position (in window coordinates).
This sets the point on which the next widget will be drawn.
Returns the initial cursor position (in window coordinates)
Returns the cursor position (in absolute screen coordinates).
This is especially useful for drawing, as the drawing API uses screen coordinates.
Sets the cursor position (in absolute screen coordinates)
Vertically aligns text baseline so that it will align properly to regularly frame items.
Call this if you have text on a line before a framed item.
Instructs ImGui to open a popup, which must be began with either begin_popup
or popup
. You also use this function to begin PopupModal.
The confusing aspect to popups is that ImGui holds “control” over the popup fundamentally, so that ImGui
can also force close a popup when a user clicks outside a popup. If you do not want users to be
able to close a popup without selected an option, use PopupModal
.
Construct a popup that can have any kind of content.
This should be called per frame, whereas open_popup
should be called once
when you want to actual create the popup.
Construct a popup that can have any kind of content.
This should be called per frame, whereas open_popup
should be called once
when you want to actual create the popup.
Creates a PopupModal directly.
Close a popup. Should be called within the closure given as argument to
Ui::popup
or Ui::popup_modal
.
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();
pub fn push_style_color(
&self,
style_color: StyleColor,
color: [f32; 4]
) -> ColorStackToken<'_>
pub fn push_style_color(
&self,
style_color: StyleColor,
color: [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();
pub fn push_style_colors<'a, I>(&self, style_colors: I) -> MultiColorStackToken where
I: IntoIterator<Item = &'a (StyleColor, [f32; 4])>,
👎 Deprecated: deprecated in 0.7.0. Use push_style_color
multiple times for similar effect.
pub fn push_style_colors<'a, I>(&self, style_colors: I) -> MultiColorStackToken where
I: IntoIterator<Item = &'a (StyleColor, [f32; 4])>,
deprecated in 0.7.0. Use push_style_color
multiple times for similar effect.
Changes style colors by pushing several changes 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];
const GREEN: [f32; 4] = [0.0, 1.0, 0.0, 1.0];
let colors = ui.push_style_colors(&[
(StyleColor::Text, RED),
(StyleColor::TextDisabled, GREEN),
]);
ui.text("I'm red!");
ui.text_disabled("I'm green!");
colors.pop(&ui);
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();
pub fn push_style_vars<'a, I>(&self, style_vars: I) -> MultiStyleStackToken where
I: IntoIterator<Item = &'a StyleVar>,
👎 Deprecated: deprecated in 0.7.0. Use push_style_var
multiple times for similar effect.
pub fn push_style_vars<'a, I>(&self, style_vars: I) -> MultiStyleStackToken where
I: IntoIterator<Item = &'a StyleVar>,
deprecated in 0.7.0. Use push_style_var
multiple times for similar effect.
Changes style variables by pushing several changes to the style stack.
Returns a StyleStackToken
that must be popped by calling .pop()
Examples
let styles = ui.push_style_vars(&[
StyleVar::Alpha(0.2),
StyleVar::ItemSpacing([50.0, 50.0])
]);
ui.text("We're transparent...");
ui.text("...with large spacing as well");
styles.pop(&ui);
Changes the item width by pushing a change to the item width stack.
Returns an ItemWidthStackToken
that may be popped by calling .pop()
> 0.0
: width isitem_width
pixels= 0.0
: default to ~2/3 of window width< 0.0
:item_width
pixels relative to the right of window (-1.0 always aligns width to the right side)
Sets the width of the next item.
> 0.0
: width isitem_width
pixels= 0.0
: default to ~2/3 of window width< 0.0
:item_width
pixels relative to the right of window (-1.0 always aligns width to the right side)
Returns the width of the item given the pushed settings and the current cursor position.
This is NOT necessarily the width of last item.
Changes the text wrapping position to the end of window (or column), which is generally the default.
This is the same as calling push_text_wrap_pos_with_pos
with wrap_pos_x
set to 0.0.
Returns a TextWrapPosStackToken
that may be popped by calling .pop()
Changes the text wrapping position by pushing a change to the text wrapping position stack.
Returns a TextWrapPosStackToken
that may be popped by calling .pop()
> 0.0
: wrap atwrap_pos_x
position in window local space= 0.0
: wrap to end of window (or column)< 0.0
: no wrapping
Changes an item flag by pushing a change to the item flag stack.
Returns a ItemFlagsStackToken
that may be popped by calling .pop()
Pushes an identifier to the ID stack.
Returns an IdStackToken
that can be popped by calling .end()
or by dropping manually.
Returns true
if the last item is hovered
Returns true
if the last item is hovered based on the given flags
Returns true
if the last item is active
Returns true
if the last item is focused for keyboard/gamepad navigation
Returns true
if the last item is being clicked by MouseButton::Left
.
This is the same as is_item_clicked_with_button
with button
set to MouseButton::Left
.
Returns true
if the last item is being clicked
Returns true
if the last item is visible
Returns true
if the last item modified its underlying value this frame or was pressed
Returns true
if the last item was just made active
Returns true
if the last item was just made inactive
Returns true
if the last item was just made inactive and made a value change when it was
active
Returns true
if the last item open state was toggled
Returns true
if any item is hovered
Returns true
if any item is active
Returns true
if any item is focused
Returns the upper-left bounding rectangle of the last item (in screen coordinates)
Returns the lower-right bounding rectangle of the last item (in screen coordinates)
Returns the size of the last item
Allows the last item to be overlapped by a subsequent item.
Both may be activated during the same frame before the later one takes priority.
Makes the last item the default focused item of the window
Returns true
if the rectangle (of given size, starting from cursor position) is visible
Returns true
if the rectangle (in screen coordinates) is visible
Returns the global imgui-rs time.
Incremented by Io::delta_time every frame.
Returns the global imgui-rs frame count.
Incremented by 1 every frame.
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.
Initializes current color editor/picker options (generally on application startup) if you want to select a default format, picker type, etc. Users will be able to change many settings, unless you use .options(false) in your widget builders.
pub fn begin_combo(
&self,
label: impl AsRef<str>,
preview_value: impl AsRef<str>
) -> Option<ComboBoxToken<'ui>>
pub fn begin_combo(
&self,
label: impl AsRef<str>,
preview_value: impl AsRef<str>
) -> Option<ComboBoxToken<'ui>>
Creates a combo box which can be appended to with Selectable::new
.
If you do not want to provide a preview, use begin_combo_no_preview
. If you want
to pass flags, use begin_combo_with_flags
.
Returns None
if the combo box is not open and no content should be rendered.
pub fn begin_combo_with_flags(
&self,
label: impl AsRef<str>,
preview_value: impl AsRef<str>,
flags: ComboBoxFlags
) -> Option<ComboBoxToken<'ui>>
pub fn begin_combo_with_flags(
&self,
label: impl AsRef<str>,
preview_value: impl AsRef<str>,
flags: ComboBoxFlags
) -> Option<ComboBoxToken<'ui>>
Creates a combo box which can be appended to with Selectable::new
.
If you do not want to provide a preview, use begin_combo_no_preview.
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.
Creates a combo box which can be appended to with Selectable::new
.
If you want to provide a preview, use begin_combo. If you want to pass flags, use begin_combo_no_preview_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.
pub fn begin_combo_no_preview_with_flags(
&self,
label: impl AsRef<str>,
flags: ComboBoxFlags
) -> Option<ComboBoxToken<'ui>>
pub fn begin_combo_no_preview_with_flags(
&self,
label: impl AsRef<str>,
flags: ComboBoxFlags
) -> Option<ComboBoxToken<'ui>>
Creates a combo box which can be appended to with Selectable::new
.
If you do not want to provide a preview, use begin_combo_no_preview.
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.
Builds a simple combo box for choosing from a slice of values
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 a full-screen main menu bar and runs a closure to construct the contents.
Note: the closure is not called if the menu bar is not visible.
Creates and starts appending to the menu bar of the current 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 bar in the current window and runs a closure to construct the contents.
Note: the closure is not called if the menu bar is not visible.
Creates and starts appending to a sub-menu entry.
Returns Some(MenuToken)
if the menu is visible. After content has been
rendered, the token must be ended by calling .end()
.
Returns None
if the menu is not visible and no content should be rendered.
This is the equivalent of begin_menu_with_enabled
with enabled
set to true
.
Creates and starts appending to a sub-menu entry.
Returns Some(MenuToken)
if the menu is visible. After content has been
rendered, the token must be ended by calling .end()
.
Returns None
if the menu is not visible 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.
Renders a clickable button.
Returns true if this button was clicked.
This is the equivalent of button_with_size
with size
set to [0.0, 0.0]
, which will size the button to the
label’s width in the current style.
the current style.
Renders a clickable button.
Returns true if this button was clicked.
Setting size
as [0.0, 0.0]
will size the button to the label’s width in
the current style.
Renders a small clickable button that is easy to embed in text.
Returns true if this button was clicked.
Renders a widget with button behaviour without the visual look.
Returns true if this button was clicked.
Renders a widget with button behaviour without the visual look.
Returns true if this button was clicked.
Renders a square button with an arrow shape.
Returns true if this button was clicked.
Renders a simple checkbox.
Returns true if this checkbox was clicked.
pub fn checkbox_flags<T>(
&self,
label: impl AsRef<str>,
flags: &mut T,
mask: T
) -> bool where
T: Copy + PartialEq + BitOrAssign + BitAndAssign + BitAnd<Output = T> + Not<Output = T>,
pub fn checkbox_flags<T>(
&self,
label: impl AsRef<str>,
flags: &mut T,
mask: T
) -> bool where
T: Copy + PartialEq + BitOrAssign + BitAndAssign + BitAnd<Output = T> + Not<Output = T>,
Renders a checkbox suitable for toggling bit flags using a mask.
Returns true if this checkbox was clicked.
Renders a simple radio button.
Returns true if this radio button was clicked.
Renders a radio button suitable for choosing an arbitrary value.
Returns true if this radio button was clicked.
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.
pub 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.
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.
pub 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.
pub 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.
Renders simple text using the given text color
Renders simple text using StyleColor::TextDisabled
color
Renders text wrapped to the end of window (or column)
Render a text + label combination aligned the same way as value+label widgets
Renders text with a little bullet aligned to the typical tree node
Constructs a new collapsing header
Constructs a new collapsing header
Returns the current content boundaries (in window coordinates)
Equal to ui.content_region_max()
- ui.cursor_pos()
Content boundaries min (in window coordinates).
Roughly equal to [0.0, 0.0] - scroll.
Content boundaries max (in window coordinates).
Roughly equal to [0.0, 0.0] + size - scroll.
Returns the horizontal scrolling position.
Value is between 0.0 and self.scroll_max_x().
Returns the vertical scrolling position.
Value is between 0.0 and self.scroll_max_y().
Returns the maximum horizontal scrolling position.
Roughly equal to content size X - window size X.
Returns the maximum vertical scrolling position.
Roughly equal to content size Y - window size Y.
Sets the horizontal scrolling position
Sets the vertical scroll position
Adjusts the horizontal scroll position to make the current cursor position visible.
This is the same as set_scroll_here_x_with_ratio but with ratio
at 0.5.
Adjusts the horizontal scroll position to make the current cursor position visible.
center_x_ratio:
0.0
: left0.5
: center1.0
: right
Adjusts the vertical scroll position to make the current cursor position visible
This is the same as set_scroll_here_y_with_ratio but with ratio
at 0.5.
Adjusts the vertical scroll position to make the current cursor position visible.
center_y_ratio:
0.0
: top0.5
: center1.0
: bottom
Adjusts the horizontal scroll position to make the given position visible
This is the same as set_scroll_from_pos_x_with_ratio
but with ratio
at 0.5.
Adjusts the horizontal scroll position to make the given position visible.
center_x_ratio:
0.0
: left0.5
: center1.0
: right
Adjusts the vertical scroll position to make the given position visible
This is the same as set_scroll_from_pos_y_with_ratio
but with ratio
at 0.5.
Adjusts the vertical scroll position to make the given position visible.
center_y_ratio:
0.0
: top0.5
: center1.0
: bottom
Returns true if the current window appeared during this frame
Returns true if the current window is in collapsed state (= only the title bar is visible)
Returns true if the current window is focused
Returns true if the current window is focused based on the given flags
Returns true if the current window is hovered
Returns true if the current window is hovered based on the given flags
Returns the position of the current window (in screen space)
Returns the size of the current window
Returns an immutable reference to the font atlas
Returns a clone of the user interface style
Renders a demo window (previously called a test window), which demonstrates most Dear Imgui features.
Renders an about window.
Displays the Dear ImGui version/credits, and build/system information.
Renders a metrics/debug window.
Displays Dear ImGui internals: draw commands (with individual draw calls and vertices), window list, basic internal state, etc.
Renders a style editor block (not a window) for the given Style
structure
Renders a style editor block (not a window) for the currently active style
Renders a basic help/info block (not a window)
pub fn input_text<'p, L: AsRef<str>>(
&'ui self,
label: L,
buf: &'p mut String
) -> InputText<'ui, 'p, L>
pub fn input_text_multiline<'p, L: AsRef<str>>(
&'ui self,
label: L,
buf: &'p mut String,
size: [f32; 2]
) -> InputTextMultiline<'ui, 'p, L>
pub fn input_float<'p, L: AsRef<str>>(
&'ui self,
label: L,
value: &'p mut f32
) -> InputFloat<'ui, 'p, L>
pub fn input_float2<'p, L: AsRef<str>>(
&'ui self,
label: L,
value: &'p mut [f32; 2]
) -> InputFloat2<'ui, 'p, L>
pub fn input_float3<'p, L: AsRef<str>>(
&'ui self,
label: L,
value: &'p mut [f32; 3]
) -> InputFloat3<'ui, 'p, L>
pub fn input_float4<'p, L: AsRef<str>>(
&'ui self,
label: L,
value: &'p mut [f32; 4]
) -> InputFloat4<'ui, 'p, L>
pub fn input_int<'p, L: AsRef<str>>(
&'ui self,
label: L,
value: &'p mut i32
) -> InputInt<'ui, 'p, L>
pub fn input_int2<'p, L: AsRef<str>>(
&'ui self,
label: L,
value: &'p mut [i32; 2]
) -> InputInt2<'ui, 'p, L>
Construct a tooltip window that can have any kind of content.
Typically used with Ui::is_item_hovered()
or some other conditional check.
Examples
fn user_interface(ui: &Ui) {
ui.text("Hover over me");
if ui.is_item_hovered() {
ui.tooltip(|| {
ui.text_colored([1.0, 0.0, 0.0, 1.0], im_str!("I'm red!"));
});
}
}
Construct a tooltip window that can have any kind of content.
Returns a TooltipToken
that must be ended by calling .end()
Construct a tooltip window with simple text content.
Typically used with Ui::is_item_hovered()
or some other conditional check.
Examples
fn user_interface(ui: &Ui) {
ui.text("Hover over me");
if ui.is_item_hovered() {
ui.tooltip_text("I'm a tooltip!");
}
}
Disabling widgets
imgui can disable widgets so they don’t react to mouse/keyboard
inputs, and are displayed differently (currently dimmed by an
amount set in Style::disabled_alpha
)
Creates a scope where interactions are disabled.
Scope ends when returned token is dropped, or .end()
is
explicitly called
Examples
fn user_interface(ui: &Ui) {
let disable_buttons = true;
let _d = ui.begin_disabled(disable_buttons);
ui.button(im_str!("Dangerous button"));
}
Identical to Ui::begin_disabled
but exists to allow avoiding a
double-negative, for example begin_enabled(enable_buttons)
instead of begin_disabled(!enable_buttons)
)
Helper to create a disabled section of widgets
Examples
fn user_interface(ui: &Ui) {
let safe_mode = true;
ui.disabled(safe_mode, || {
ui.button(im_str!("Dangerous button"));
});
}
Same as Ui::disabled
but with logic reversed. See
Ui::begin_enabled
.
pub fn plot_histogram<'p, Label: AsRef<str>>(
&'ui self,
label: Label,
values: &'p [f32]
) -> PlotHistogram<'ui, 'p, Label>
Calculate the size required for a given text string.
This is the same as calc_text_size_with_opts
with hide_text_after_double_hash
set to false and wrap_width
set to -1.0
.
Calculate the size required for a given text string.
hide_text_after_double_hash allows the user to insert comments into their text, using a double hash-tag prefix. This is a feature of imgui.
wrap_width allows you to request a width at which to wrap the text to a newline for the calculation.
Get access to drawing API
Examples
fn custom_draw(ui: &Ui) {
let draw_list = ui.get_window_draw_list();
// Draw a line
const WHITE: [f32; 3] = [1.0, 1.0, 1.0];
draw_list.add_line([100.0, 100.0], [200.0, 200.0], WHITE).build();
// Continue drawing ...
}
This function will panic if several instances of DrawListMut
coexist. Before a new instance is got, a previous instance should be
dropped.
fn custom_draw(ui: &Ui) {
let draw_list = ui.get_window_draw_list();
// Draw something...
// This second call will panic!
let draw_list = ui.get_window_draw_list();
}