[−][src]Struct imgui::Context
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
Implementations
impl Context
[src]
pub fn create() -> Self
[src]
pub fn create_with_shared_font_atlas(
shared_font_atlas: Rc<RefCell<SharedFontAtlas>>
) -> Self
[src]
shared_font_atlas: Rc<RefCell<SharedFontAtlas>>
) -> Self
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<PathBuf>
[src]
Returns the path to the ini file, or None if not set
pub fn set_ini_filename<T: Into<Option<PathBuf>>>(&mut self, ini_filename: T)
[src]
Sets the path to the ini file (default is "imgui.ini")
Pass None to disable automatic .Ini saving.
pub fn log_filename(&self) -> Option<PathBuf>
[src]
Returns the path to the log file, or None if not set
pub fn set_log_filename<T: Into<Option<PathBuf>>>(&mut self, log_filename: T)
[src]
Sets the log filename (default is "imgui_log.txt").
pub fn platform_name(&self) -> Option<&ImStr>
[src]
Returns the backend platform name, or None if not set
pub fn set_platform_name<T: Into<Option<ImString>>>(&mut self, platform_name: T)
[src]
Sets the backend platform name
pub fn renderer_name(&self) -> Option<&ImStr>
[src]
Returns the backend renderer name, or None if not set
pub fn set_renderer_name<T: Into<Option<ImString>>>(&mut self, renderer_name: T)
[src]
Sets the backend renderer name
pub fn load_ini_settings(&mut self, data: &str)
[src]
Loads settings from a string slice containing settings in .Ini file format
pub fn save_ini_settings(&mut self, buf: &mut String)
[src]
Saves settings to a mutable string buffer in .Ini file format
pub fn set_clipboard_backend(&mut self, backend: Box<dyn ClipboardBackend>)
[src]
Sets the clipboard backend used for clipboard operations
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(&mut self) -> Ui<'_>
[src]
Starts a new frame and returns an Ui
instance for constructing a user interface.
Panics
Panics if the context uses a shared font atlas that is already borrowed
impl Context
[src]
pub fn time(&self) -> f64
[src]
Returns the global imgui-rs time.
Incremented by Io::delta_time every frame.
pub fn frame_count(&self) -> i32
[src]
Returns the global imgui-rs frame count.
Incremented by 1 every frame.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Context
impl !Send for Context
impl !Sync for Context
impl Unpin for Context
impl !UnwindSafe for Context
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,