[][src]Struct imgui::Ui

pub struct Ui<'ui> { /* fields omitted */ }

Methods

impl<'ui> Ui<'ui>[src]

pub fn frame_size(&self) -> FrameSize[src]

pub fn imgui(&self) -> &ImGui[src]

pub fn want_capture_mouse(&self) -> bool[src]

pub fn want_capture_keyboard(&self) -> bool[src]

pub fn set_keyboard_focus_here(&self, offset: i32)[src]

pub fn framerate(&self) -> f32[src]

pub fn metrics_render_vertices(&self) -> i32[src]

pub fn metrics_render_indices(&self) -> i32[src]

pub fn metrics_active_windows(&self) -> i32[src]

pub fn render<F, E>(self, f: F) -> Result<(), E> where
    F: FnOnce(&Ui, DrawData) -> Result<(), E>, 
[src]

pub fn show_user_guide(&self)[src]

pub fn show_default_style_editor(&self)[src]

pub fn show_style_editor<'p>(&self, style: &'p mut ImGuiStyle)[src]

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

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

impl<'a> Ui<'a>[src]

pub unsafe fn current_ui() -> Option<&'a Ui<'a>>[src]

impl<'ui> Ui<'ui>[src]

pub fn window<'p>(&self, name: &'p ImStr) -> Window<'ui, 'p>[src]

pub fn get_window_size(&self) -> (f32, f32)[src]

Get current window's size in pixels

pub fn get_window_pos(&self) -> (f32, f32)[src]

Get current window's position in pixels

pub fn get_window_content_region_min(&self) -> (f32, f32)[src]

pub fn get_window_content_region_max(&self) -> (f32, f32)[src]

impl<'ui> Ui<'ui>[src]

pub fn push_item_width(&self, width: f32)[src]

Pushes a value to the item width stack.

pub fn pop_item_width(&self)[src]

Pops a value from the item width stack.

Aborts

The current process is aborted if the item width stack is empty.

pub fn with_item_width<F>(&self, width: f32, f: F) where
    F: FnOnce(), 
[src]

Runs a function after temporarily pushing a value to the item width stack.

pub fn separator(&self)[src]

pub fn new_line(&self)[src]

pub fn same_line(&self, pos_x: f32)[src]

pub fn same_line_spacing(&self, pos_x: f32, spacing_w: f32)[src]

pub fn spacing(&self)[src]

pub fn columns<'p>(&self, count: i32, id: &'p ImStr, border: bool)[src]

pub fn next_column(&self)[src]

pub fn get_column_index(&self) -> i32[src]

pub fn get_column_offset(&self, column_index: i32) -> f32[src]

pub fn set_column_offset(&self, column_index: i32, offset_x: f32)[src]

pub fn get_column_width(&self, column_index: i32) -> f32[src]

pub fn get_columns_count(&self) -> i32[src]

pub fn dummy<S: Into<ImVec2>>(&self, size: S)[src]

Fill a space of size in pixels with nothing on the current window. Can be used to move the cursor on the window.

pub fn get_cursor_screen_pos(&self) -> (f32, f32)[src]

Get cursor position on the screen, in screen coordinates. This sets the point on which the next widget will be drawn.

This is especially useful for drawing, as the drawing API uses screen coordiantes.

pub fn set_cursor_screen_pos<P: Into<ImVec2>>(&self, pos: P)[src]

Set cursor position on the screen, in screen coordinates. This sets the point on which the next widget will be drawn.

pub fn get_cursor_pos(&self) -> (f32, f32)[src]

Get cursor position on the screen, in window coordinates.

pub fn set_cursor_pos<P: Into<ImVec2>>(&self, pos: P)[src]

Set cursor position on the screen, in window coordinates. This sets the point on which the next widget will be drawn.

pub fn get_content_region_max(&self) -> (f32, f32)[src]

pub fn get_content_region_avail(&self) -> (f32, f32)[src]

Get available space left between the cursor and the edges of the current window.

impl<'ui> Ui<'ui>[src]

pub fn push_id<'a, I: Into<ImId<'a>>>(&self, id: I)[src]

Pushes an identifier to the ID stack.

pub fn pop_id(&self)[src]

Pops an identifier from the ID stack.

Aborts

The current process is aborted if the ID stack is empty.

pub fn with_id<'a, F, I>(&self, id: I, f: F) where
    F: FnOnce(),
    I: Into<ImId<'a>>, 
[src]

Runs a function after temporarily pushing a value to the ID stack.

impl<'ui> Ui<'ui>[src]

pub fn text<T: AsRef<str>>(&self, text: T)[src]

pub fn text_colored<'p, A>(&self, col: A, text: &'p ImStr) where
    A: Into<ImVec4>, 
[src]

pub fn text_disabled<'p>(&self, text: &'p ImStr)[src]

pub fn text_wrapped<'p>(&self, text: &'p ImStr)[src]

pub fn with_text_wrap_pos<F: FnOnce()>(&self, wrap_pos_x: f32, f: F)[src]

Set word-wrapping for text_*() commands.

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

pub fn label_text<'p>(&self, label: &'p ImStr, text: &'p ImStr)[src]

pub fn bullet(&self)[src]

pub fn bullet_text<'p>(&self, text: &'p ImStr)[src]

pub fn button<'p, S: Into<ImVec2>>(&self, label: &'p ImStr, size: S) -> bool[src]

pub fn small_button<'p>(&self, label: &'p ImStr) -> bool[src]

pub fn invisible_button<'p, S: Into<ImVec2>>(
    &self,
    label: &'p ImStr,
    size: S
) -> bool
[src]

Make a invisible event. Can be used to conveniently catch events when mouse hovers or click the area covered by this invisible button.

pub fn checkbox<'p>(&self, label: &'p ImStr, value: &'p mut bool) -> bool[src]

impl<'ui> Ui<'ui>[src]

pub fn input_text<'p>(
    &self,
    label: &'p ImStr,
    buf: &'p mut ImString
) -> InputText<'ui, 'p>
[src]

pub fn input_text_multiline<'p, S: Into<ImVec2>>(
    &self,
    label: &'p ImStr,
    buf: &'p mut ImString,
    size: S
) -> InputTextMultiline<'ui, 'p>
[src]

pub fn input_float<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut f32
) -> InputFloat<'ui, 'p>
[src]

pub fn input_float2<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut [f32; 2]
) -> InputFloat2<'ui, 'p>
[src]

pub fn input_float3<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut [f32; 3]
) -> InputFloat3<'ui, 'p>
[src]

pub fn input_float4<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut [f32; 4]
) -> InputFloat4<'ui, 'p>
[src]

pub fn input_int<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut i32
) -> InputInt<'ui, 'p>
[src]

pub fn input_int2<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut [i32; 2]
) -> InputInt2<'ui, 'p>
[src]

pub fn input_int3<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut [i32; 3]
) -> InputInt3<'ui, 'p>
[src]

pub fn input_int4<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut [i32; 4]
) -> InputInt4<'ui, 'p>
[src]

impl<'ui> Ui<'ui>[src]

pub fn drag_float<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut f32
) -> DragFloat<'ui, 'p>
[src]

pub fn drag_float2<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut [f32; 2]
) -> DragFloat2<'ui, 'p>
[src]

pub fn drag_float3<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut [f32; 3]
) -> DragFloat3<'ui, 'p>
[src]

pub fn drag_float4<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut [f32; 4]
) -> DragFloat4<'ui, 'p>
[src]

pub fn drag_float_range2<'p>(
    &self,
    label: &'p ImStr,
    current_min: &'p mut f32,
    current_max: &'p mut f32
) -> DragFloatRange2<'ui, 'p>
[src]

pub fn drag_int<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut i32
) -> DragInt<'ui, 'p>
[src]

pub fn drag_int2<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut [i32; 2]
) -> DragInt2<'ui, 'p>
[src]

pub fn drag_int3<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut [i32; 3]
) -> DragInt3<'ui, 'p>
[src]

pub fn drag_int4<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut [i32; 4]
) -> DragInt4<'ui, 'p>
[src]

pub fn drag_int_range2<'p>(
    &self,
    label: &'p ImStr,
    current_min: &'p mut i32,
    current_max: &'p mut i32
) -> DragIntRange2<'ui, 'p>
[src]

impl<'ui> Ui<'ui>[src]

pub fn slider_float<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut f32,
    min: f32,
    max: f32
) -> SliderFloat<'ui, 'p>
[src]

pub fn slider_float2<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut [f32; 2],
    min: f32,
    max: f32
) -> SliderFloat2<'ui, 'p>
[src]

pub fn slider_float3<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut [f32; 3],
    min: f32,
    max: f32
) -> SliderFloat3<'ui, 'p>
[src]

pub fn slider_float4<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut [f32; 4],
    min: f32,
    max: f32
) -> SliderFloat4<'ui, 'p>
[src]

pub fn slider_int<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut i32,
    min: i32,
    max: i32
) -> SliderInt<'ui, 'p>
[src]

pub fn slider_int2<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut [i32; 2],
    min: i32,
    max: i32
) -> SliderInt2<'ui, 'p>
[src]

pub fn slider_int3<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut [i32; 3],
    min: i32,
    max: i32
) -> SliderInt3<'ui, 'p>
[src]

pub fn slider_int4<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut [i32; 4],
    min: i32,
    max: i32
) -> SliderInt4<'ui, 'p>
[src]

impl<'ui> Ui<'ui>[src]

pub fn color_edit<'p, V: Into<EditableColor<'p>>>(
    &self,
    label: &'p ImStr,
    value: V
) -> ColorEdit<'ui, 'p>
[src]

Constructs a new color editor builder.

pub fn color_picker<'p, V: Into<EditableColor<'p>>>(
    &self,
    label: &'p ImStr,
    value: V
) -> ColorPicker<'ui, 'p>
[src]

Constructs a new color picker builder.

pub fn color_button<'p, C: Into<ImVec4>>(
    &self,
    desc_id: &'p ImStr,
    color: C
) -> ColorButton<'ui, 'p>
[src]

Constructs a new color button builder.

pub fn set_color_edit_options(&self, flags: ImGuiColorEditFlags)[src]

Initialize current 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.

impl<'ui> Ui<'ui>[src]

pub fn tree_node<'p>(&self, id: &'p ImStr) -> TreeNode<'ui, 'p>[src]

pub fn collapsing_header<'p>(
    &self,
    label: &'p ImStr
) -> CollapsingHeader<'ui, 'p>
[src]

impl<'ui> Ui<'ui>[src]

pub fn selectable<'p, S: Into<ImVec2>>(
    &self,
    label: &'p ImStr,
    selected: bool,
    flags: ImGuiSelectableFlags,
    size: S
) -> bool
[src]

impl<'ui> Ui<'ui>[src]

pub fn tooltip<F: FnOnce()>(&self, f: F)[src]

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!"));
        });
    }
}

pub fn tooltip_text<T: AsRef<str>>(&self, text: T)[src]

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!");
    }
}

impl<'ui> Ui<'ui>[src]

pub fn main_menu_bar<F>(&self, f: F) where
    F: FnOnce(), 
[src]

pub fn menu_bar<F>(&self, f: F) where
    F: FnOnce(), 
[src]

pub fn menu<'p>(&self, label: &'p ImStr) -> Menu<'ui, 'p>[src]

pub fn menu_item<'p>(&self, label: &'p ImStr) -> MenuItem<'ui, 'p>[src]

impl<'ui> Ui<'ui>[src]

pub fn open_popup<'p>(&self, str_id: &'p ImStr)[src]

pub fn popup<'p, F>(&self, str_id: &'p ImStr, f: F) where
    F: FnOnce(), 
[src]

pub fn popup_modal<'p>(&self, str_id: &'p ImStr) -> PopupModal<'ui, 'p>[src]

Create a modal pop-up.

Example

if ui.button(im_str!("Show modal"), (0.0, 0.0)) {
    ui.open_popup(im_str!("modal"));
}
ui.popup_modal(im_str!("modal")).build(|| {
    ui.text("Content of my modal");
    if ui.button(im_str!("OK"), (0.0, 0.0)) {
        ui.close_current_popup();
    }
});

pub fn close_current_popup(&self)[src]

Close a popup. Should be called within the closure given as argument to Ui::popup or Ui::popup_modal.

impl<'ui> Ui<'ui>[src]

pub fn combo<'p>(
    &self,
    label: &'p ImStr,
    current_item: &mut i32,
    items: &'p [&'p ImStr],
    height_in_items: i32
) -> bool
[src]

impl<'ui> Ui<'ui>[src]

pub fn list_box<'p>(
    &self,
    label: &'p ImStr,
    current_item: &mut i32,
    items: &'p [&'p ImStr],
    height_in_items: i32
) -> bool
[src]

impl<'ui> Ui<'ui>[src]

pub fn radio_button<'p>(
    &self,
    label: &'p ImStr,
    value: &'p mut i32,
    wanted: i32
) -> bool
[src]

Creates a radio button for selecting an integer value. Returns true if pressed.

Example

ui.radio_button(im_str!("Item 1"), &mut selected_radio_value, 1);
ui.radio_button(im_str!("Item 2"), &mut selected_radio_value, 2);
ui.radio_button(im_str!("Item 3"), &mut selected_radio_value, 3);

pub fn radio_button_bool<'p>(&self, label: &'p ImStr, value: bool) -> bool[src]

Creates a radio button that shows as selected if the given value is true. Returns true if pressed.

Example

if ui.radio_button_bool(im_str!("Cats"), radio_button_test == "cats") {
    radio_button_test = "cats".to_string();
}
if ui.radio_button_bool(im_str!("Dogs"), radio_button_test == "dogs") {
    radio_button_test = "dogs".to_string();
}

impl<'ui> Ui<'ui>[src]

pub fn plot_lines<'p>(
    &self,
    label: &'p ImStr,
    values: &'p [f32]
) -> PlotLines<'ui, 'p>
[src]

impl<'ui> Ui<'ui>[src]

pub fn plot_histogram<'p>(
    &self,
    label: &'p ImStr,
    values: &'p [f32]
) -> PlotHistogram<'ui, 'p>
[src]

impl<'ui> Ui<'ui>[src]

pub fn image<S>(&self, texture: ImTexture, size: S) -> Image where
    S: Into<ImVec2>, 
[src]

impl<'ui> Ui<'ui>[src]

pub fn image_button<S>(&self, texture: ImTexture, size: S) -> ImageButton where
    S: Into<ImVec2>, 
[src]

impl<'ui> Ui<'ui>[src]

pub fn calc_text_size(
    &self,
    text: &ImStr,
    hide_text_after_double_hash: bool,
    wrap_width: f32
) -> ImVec2
[src]

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.

impl<'ui> Ui<'ui>[src]

pub fn get_text_line_height_with_spacing(&self) -> f32[src]

Get height of a line of previously drawn text item

pub fn get_item_rect_size(&self) -> (f32, f32)[src]

Get previously drawn item's size

impl<'ui> Ui<'ui>[src]

pub fn progress_bar<'p>(&self, fraction: f32) -> ProgressBar<'ui, 'p>[src]

Creates a progress bar. Fraction is the progress level with 0.0 = 0% and 1.0 = 100%.

Example

ui.progress_bar(0.6)
    .size((100.0, 12.0))
    .overlay_text(im_str!("Progress!"))
    .build();

impl<'ui> Ui<'ui>[src]

pub fn child_frame<'p, S: Into<ImVec2>>(
    &self,
    name: &'p ImStr,
    size: S
) -> ChildFrame<'ui, 'p>
[src]

Creates a child frame. Size is size of child_frame within parent window.

Example

ui.window(im_str!("ChatWindow"))
    .title_bar(true)
    .scrollable(false)
    .build(|| {
        ui.separator();

        ui.child_frame(im_str!("child frame"), (400.0, 100.0))
            .show_borders(true)
            .always_show_vertical_scroll_bar(true)
            .build(|| {
                ui.text_colored((1.0, 0.0, 0.0, 1.0), im_str!("hello mate!"));
            });
});

impl<'ui> Ui<'ui>[src]

pub fn with_style_var<F: FnOnce()>(&self, style_var: StyleVar, f: F)[src]

Runs a function after temporarily pushing a value to the style stack.

Example

ui.with_style_var(StyleVar::Alpha(0.2), || {
    ui.text(im_str!("AB"));
});

pub fn with_style_vars<F: FnOnce()>(&self, style_vars: &[StyleVar], f: F)[src]

Runs a function after temporarily pushing an array of values into the stack. Supporting multiple is also easy since you can freely mix and match them in a safe manner.

Example

ui.with_style_vars(&styles, || {
    ui.text(im_str!("A"));
    ui.text(im_str!("B"));
    ui.text(im_str!("C"));
    ui.text(im_str!("D"));
});

impl<'ui> Ui<'ui>[src]

pub fn with_color_var<F: FnOnce(), C: Into<ImVec4> + Copy>(
    &self,
    var: ImGuiCol,
    color: C,
    f: F
)
[src]

Runs a function after temporarily pushing a value to the color stack.

Example

ui.with_color_var(ImGuiCol::Text, (1.0, 0.0, 0.0, 1.0), || {
    ui.text_wrapped(im_str!("AB"));
});

pub fn with_color_vars<F: FnOnce(), C: Into<ImVec4> + Copy>(
    &self,
    color_vars: &[(ImGuiCol, C)],
    f: F
)
[src]

Runs a function after temporarily pushing an array of values to the color stack.

Example

let red = (1.0, 0.0, 0.0, 1.0);
let green = (0.0, 1.0, 0.0, 1.0);
ui.with_color_vars(&vars, || {
    ui.text_wrapped(im_str!("AB"));
});

impl<'ui> Ui<'ui>[src]

pub fn with_style_and_color_vars<F, C>(
    &self,
    style_vars: &[StyleVar],
    color_vars: &[(ImGuiCol, C)],
    f: F
) where
    F: FnOnce(),
    C: Into<ImVec4> + Copy
[src]

Runs a function after temporarily pushing an array of values to the style and color stack.

impl<'ui> Ui<'ui>[src]

pub fn is_item_hovered(&self) -> bool[src]

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

Examples

fn user_interface(ui: &Ui) {
    ui.text("Hover over me");
    let is_hover_over_me_text_hovered = ui.is_item_hovered();
}

pub fn is_item_hovered_with_flags(&self, flags: ImGuiHoveredFlags) -> bool[src]

pub fn is_window_hovered(&self) -> bool[src]

Return true if the current window is being hovered by the mouse.

pub fn is_window_hovered_with_flags(&self, flags: ImGuiHoveredFlags) -> bool[src]

pub fn is_window_focused(&self) -> bool[src]

Return true if the current window is currently focused.

pub fn is_root_window_focused(&self) -> bool[src]

Return true if the current root window is currently focused.

pub fn is_child_window_focused(&self) -> bool[src]

Return true if the current child window is currently focused.

pub fn is_item_active(&self) -> bool[src]

Returns true if the last item is being active.

pub fn group<F: FnOnce()>(&self, f: F)[src]

Group items together as a single item.

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

impl<'ui> Ui<'ui>[src]

pub fn get_window_draw_list(&'ui self) -> WindowDrawList<'ui>[src]

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 WindowDrawList 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();
}

Trait Implementations

impl<'a> Drop for Ui<'a>[src]

Auto Trait Implementations

impl<'ui> Send for Ui<'ui>

impl<'ui> Sync for Ui<'ui>

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.