Struct arcdps_imgui::Context

source ·
pub struct Context { /* private fields */ }
Expand description

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 = arcdps_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 = arcdps_imgui::Context::create();

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

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

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

Implementations§

source§

impl Context

source

pub fn create() -> Self

Creates a new active imgui-rs context.

§Panics

Panics if an active context already exists

source

pub fn create_with_shared_font_atlas( 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

source

pub fn current() -> Self

Gets the current context

source

pub fn suspend(self) -> SuspendedContext

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

source

pub fn ini_filename(&self) -> Option<PathBuf>

Returns the path to the ini file, or None if not set

source

pub fn set_ini_filename<T: Into<Option<PathBuf>>>(&mut self, ini_filename: T)

Sets the path to the ini file (default is “imgui.ini”)

Pass None to disable automatic .Ini saving.

source

pub fn log_filename(&self) -> Option<PathBuf>

Returns the path to the log file, or None if not set

source

pub fn set_log_filename<T: Into<Option<PathBuf>>>(&mut self, log_filename: T)

Sets the log filename (default is “imgui_log.txt”).

source

pub fn platform_name(&self) -> Option<&str>

Returns the backend platform name, or None if not set

source

pub fn set_platform_name<T: Into<Option<String>>>(&mut self, platform_name: T)

Sets the backend platform name

source

pub fn renderer_name(&self) -> Option<&str>

Returns the backend renderer name, or None if not set

source

pub fn set_renderer_name<T: Into<Option<String>>>(&mut self, renderer_name: T)

Sets the backend renderer name

source

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

Loads settings from a string slice containing settings in .Ini file format

source

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

Saves settings to a mutable string buffer in .Ini file format

source

pub fn set_clipboard_backend<T: ClipboardBackend>(&mut self, backend: T)

Sets the clipboard backend used for clipboard operations

source§

impl Context

source

pub fn io(&self) -> &Io

Returns an immutable reference to the inputs/outputs object

source

pub fn io_mut(&mut self) -> &mut Io

Returns a mutable reference to the inputs/outputs object

source

pub fn style(&self) -> &Style

Returns an immutable reference to the user interface style

source

pub fn style_mut(&mut self) -> &mut Style

Returns a mutable reference to the user interface style

source

pub fn fonts(&mut self) -> FontAtlasRefMut<'_>

Returns a mutable reference to the font atlas.

§Panics

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

source

pub fn frame(&mut self) -> Ui<'_>

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

source§

impl Context

source

pub fn time(&self) -> f64

Returns the global imgui-rs time.

Incremented by Io::delta_time every frame.

source

pub fn frame_count(&self) -> i32

Returns the global imgui-rs frame count.

Incremented by 1 every frame.

Trait Implementations§

source§

impl Debug for Context

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Context

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Context

§

impl !RefUnwindSafe for Context

§

impl !Send for Context

§

impl !Sync for Context

§

impl Unpin for Context

§

impl !UnwindSafe for Context

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.