mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-21 10:28:37 +00:00
added end frame handle
This commit is contained in:
parent
2a8374a339
commit
5bdd4f819c
@ -505,17 +505,14 @@ impl Context {
|
|||||||
unsafe { &mut *(self.io_mut().fonts as *mut FontAtlas) }
|
unsafe { &mut *(self.io_mut().fonts as *mut FontAtlas) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Starts a new frame.
|
/// Starts a new frame. Use [`new_frame`] instead.
|
||||||
|
///
|
||||||
|
/// [`new_frame`]: Self::new_frame
|
||||||
pub fn frame(&mut self) -> &mut Ui {
|
pub fn frame(&mut self) -> &mut Ui {
|
||||||
self.new_frame()
|
self.new_frame()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Starts a new frame and returns an `Ui` instance for constructing a user interface.
|
/// 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.
|
|
||||||
/// Do not attempt to borrow the context afterwards, if you are using a shared font atlas.
|
|
||||||
#[doc(alias = "NewFame")]
|
#[doc(alias = "NewFame")]
|
||||||
pub fn new_frame(&mut self) -> &mut Ui {
|
pub fn new_frame(&mut self) -> &mut Ui {
|
||||||
// Clear default font if it no longer exists. This could be an error in the future
|
// Clear default font if it no longer exists. This could be an error in the future
|
||||||
|
|||||||
@ -119,7 +119,7 @@ impl Context {
|
|||||||
/// A reference for building the user interface for one frame
|
/// A reference for building the user interface for one frame
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Ui {
|
pub struct Ui {
|
||||||
// our scratch sheet
|
/// our scratch sheet
|
||||||
buffer: cell::UnsafeCell<string::UiBuffer>,
|
buffer: cell::UnsafeCell<string::UiBuffer>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,10 +189,36 @@ impl Ui {
|
|||||||
pub fn fonts(&self) -> &FontAtlas {
|
pub fn fonts(&self) -> &FontAtlas {
|
||||||
unsafe { &*(self.io().fonts as *const FontAtlas) }
|
unsafe { &*(self.io().fonts as *const FontAtlas) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a clone of the user interface style
|
/// Returns a clone of the user interface style
|
||||||
pub fn clone_style(&self) -> Style {
|
pub fn clone_style(&self) -> Style {
|
||||||
unsafe { *self.style() }
|
unsafe { *self.style() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This function, and the library's api, has been changed as of `0.9`!
|
||||||
|
/// Do not use this function! Instead, use [`Context::render`],
|
||||||
|
/// which does what this function in `0.8` used to do.
|
||||||
|
///
|
||||||
|
/// This function right now simply **ends** the current frame, but does not
|
||||||
|
/// return draw data. If you want to end the frame without generated draw data,
|
||||||
|
/// and thus save some CPU time, use [`end_frame_early`].
|
||||||
|
#[deprecated(
|
||||||
|
since = "0.9.0",
|
||||||
|
note = "use `Context::render` to render frames, or `end_frame_early` to not render at all"
|
||||||
|
)]
|
||||||
|
pub fn render(&mut self) {
|
||||||
|
self.end_frame_early();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Use this function to end the frame early.
|
||||||
|
/// After this call, you should **stop using the `Ui` object till `new_frame` has been called.**
|
||||||
|
///
|
||||||
|
/// You probably *don't want this function.* If you want to render your data, use `Context::render` now.
|
||||||
|
pub fn end_frame_early(&mut self) {
|
||||||
|
unsafe {
|
||||||
|
sys::igEndFrame();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # Demo, debug, information
|
/// # Demo, debug, information
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user