[][src]Struct imgui::Context

pub struct Context { /* fields omitted */ }

An imgui-rs context.

A context needs to be created to access most library functions. Due to current Dear ImGui design choices, at most one active Context can exist at any time. This limitation will likely be removed in a future Dear ImGui version.

If you need more than one context, you can use suspended contexts. As long as only one context is active at a time, it's possible to have multiple independent contexts.

Examples

Creating a new active context:

let ctx = imgui::Context::create();
// ctx is dropped naturally when it goes out of scope, which deactivates and destroys the
// context

Never try to create an active context when another one is active:

let ctx1 = imgui::Context::create();

let ctx2 = imgui::Context::create(); // PANIC

Suspending an active context allows you to create another active context:

let ctx1 = imgui::Context::create();
let suspended1 = ctx1.suspend();
let ctx2 = imgui::Context::create(); // this is now OK

Methods

impl Context[src]

pub fn create() -> Self[src]

Creates a new active imgui-rs context.

Panics

Panics if an active context already exists

pub fn create_with_shared_font_atlas(
    shared_font_atlas: Rc<RefCell<SharedFontAtlas>>
) -> Self
[src]

Creates a new active imgui-rs context with a shared font atlas.

Panics

Panics if an active context already exists

pub fn suspend(self) -> SuspendedContext[src]

Suspends this context so another context can be the active context.

pub fn ini_filename(&self) -> Option<&ImStr>[src]

pub fn set_ini_filename<T: Into<Option<ImString>>>(&mut self, ini_filename: T)[src]

pub fn log_filename(&self) -> Option<&ImStr>[src]

pub fn set_log_filename<T: Into<Option<ImString>>>(&mut self, log_filename: T)[src]

pub fn platform_name(&self) -> Option<&ImStr>[src]

pub fn set_platform_name<T: Into<Option<ImString>>>(&mut self, platform_name: T)[src]

pub fn renderer_name(&self) -> Option<&ImStr>[src]

pub fn set_renderer_name<T: Into<Option<ImString>>>(&mut self, renderer_name: T)[src]

pub fn load_ini_settings(&mut self, data: &str)[src]

pub fn save_ini_settings(&mut self, buf: &mut String)[src]

impl Context[src]

pub fn io(&self) -> &Io[src]

Returns an immutable reference to the inputs/outputs object

pub fn io_mut(&mut self) -> &mut Io[src]

Returns a mutable reference to the inputs/outputs object

pub fn style(&self) -> &Style[src]

Returns an immutable reference to the user interface style

pub fn style_mut(&mut self) -> &mut Style[src]

Returns a mutable reference to the user interface style

pub fn fonts(&mut self) -> FontAtlasRefMut[src]

Returns a mutable reference to the font atlas.

Panics

Panics if the context uses a shared font atlas that is already borrowed

pub fn frame<'ui, 'a: 'ui>(&'a mut self) -> Ui<'ui>[src]

Panics

Panics if the context uses a shared font atlas that is already borrowed

impl Context[src]

pub fn set_ini_saving_rate(&mut self, value: f32)[src]

Deprecated since 0.1.0:

Access Io::ini_saving_rate directly instead

pub fn set_font_global_scale(&mut self, value: f32)[src]

Deprecated since 0.1.0:

Access Io::font_global_scale directly instead

pub fn set_mouse_double_click_time(&mut self, value: f32)[src]

Deprecated since 0.1.0:

Access Io::mouse_double_click_time directly instead

pub fn set_mouse_double_click_max_dist(&mut self, value: f32)[src]

Deprecated since 0.1.0:

Access Io::mouse_double_click_max_dist directly instead

pub fn set_mouse_drag_threshold(&mut self, value: f32)[src]

Deprecated since 0.1.0:

Access Io::mouse_drag_threshold directly instead

pub fn set_key_repeat_delay(&mut self, value: f32)[src]

Deprecated since 0.1.0:

Access Io::key_repeat_delay directly instead

pub fn set_key_repeat_rate(&mut self, value: f32)[src]

Deprecated since 0.1.0:

Access Io::key_repeat_rate directly instead

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

Deprecated since 0.1.0:

Access Io::display_size directly instead

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

Deprecated since 0.1.0:

Access Io::display_framebuffer_scale directly instead

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

Deprecated since 0.1.0:

Access Io::mouse_pos directly instead

pub fn set_mouse_pos(&mut self, x: f32, y: f32)[src]

Deprecated since 0.1.0:

Access Io::mouse_pos directly instead

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

Deprecated since 0.1.0:

Access Io::mouse_delta directly instead

Get mouse's position's delta between the current and the last frame.

pub fn mouse_down(&self) -> [bool; 5][src]

Deprecated since 0.1.0:

Access Io::mouse_down directly instead

pub fn set_mouse_down(&mut self, states: [bool; 5])[src]

Deprecated since 0.1.0:

Access Io::mouse_down directly instead

pub fn set_mouse_wheel(&mut self, value: f32)[src]

Deprecated since 0.1.0:

Access Io::mouse_wheel directly instead

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

Deprecated since 0.1.0:

Access Io::mouse_wheel directly instead

Get mouse wheel delta

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

Deprecated since 0.1.0:

Use Ui::mouse_drag_delta instead

pub fn set_mouse_draw_cursor(&mut self, value: bool)[src]

Deprecated since 0.1.0:

Access Io::mouse_draw_cursor directly instead

Set to true to have ImGui draw the cursor in software. If false, the OS cursor is used (default to false).

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

Deprecated since 0.1.0:

Access Io::mouse_draw_cursor directly instead

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

Deprecated since 0.1.0:

Use Ui::is_mouse_dragging instead

Returns true if mouse is currently dragging with the button provided as argument.

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

Deprecated since 0.1.0:

Use Ui::is_mouse_down instead

Returns true if the button provided as argument is currently down.

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

Deprecated since 0.1.0:

Use Ui::is_mouse_clicked instead

Returns true if the button provided as argument is being clicked.

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

Deprecated since 0.1.0:

Use Ui::is_mouse_double_clicked instead

Returns true if the button provided as argument is being double-clicked.

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

Deprecated since 0.1.0:

Use Ui::is_mouse_released instead

Returns true if the button provided as argument was released

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

Deprecated since 0.1.0:

Access Io::key_ctrl directly instead

pub fn set_key_ctrl(&mut self, value: bool)[src]

Deprecated since 0.1.0:

Access Io::key_ctrl directly instead

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

Deprecated since 0.1.0:

Access Io::key_shift directly instead

pub fn set_key_shift(&mut self, value: bool)[src]

Deprecated since 0.1.0:

Access Io::key_shift directly instead

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

Deprecated since 0.1.0:

Access Io::key_alt directly instead

pub fn set_key_alt(&mut self, value: bool)[src]

Deprecated since 0.1.0:

Access Io::key_alt directly instead

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

Deprecated since 0.1.0:

Access Io::key_super directly instead

pub fn set_key_super(&mut self, value: bool)[src]

Deprecated since 0.1.0:

Access Io::key_super directly instead

pub fn set_key(&mut self, key: u8, pressed: bool)[src]

Deprecated since 0.1.0:

Access Io::keys_down directly instead

pub fn set_imgui_key(&mut self, key: Key, mapping: u8)[src]

Deprecated since 0.1.0:

Index Io::key_map with the key instead

pub fn get_key_index(&self, key: Key) -> usize[src]

Deprecated since 0.1.0:

Index Io::key_map with the key instead

Map Key values into user's key index

pub fn is_key_down(&self, user_key_index: usize) -> bool[src]

Deprecated since 0.1.0:

Use Ui::is_key_down instead

Return whether specific key is being held

Example

use imgui::{Key, Ui};

fn test(ui: &Ui) {
    let delete_key_index = ui.imgui().get_key_index(Key::Delete);
    if ui.imgui().is_key_down(delete_key_index) {
        println!("Delete is being held!");
    }
}

pub fn is_key_pressed(&self, user_key_index: usize) -> bool[src]

Deprecated since 0.1.0:

Use Ui::is_key_pressed instead

Return whether specific key was pressed

pub fn is_key_released(&self, user_key_index: usize) -> bool[src]

Deprecated since 0.1.0:

Use Ui::is_key_released instead

Return whether specific key was released

pub fn add_input_character(&mut self, character: char)[src]

Deprecated since 0.1.0:

Use Io::add_input_character instead

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

Deprecated since 0.1.0:

Access Io::framerate directly instead

impl Context[src]

pub fn get_time(&self) -> f64[src]

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

Trait Implementations

impl Drop for Context[src]

impl Debug for Context[src]

Auto Trait Implementations

impl !Send for Context

impl Unpin for Context

impl !Sync for Context

impl !UnwindSafe for Context

impl !RefUnwindSafe for Context

Blanket Implementations

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

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

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

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