mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-27 21:38:34 +00:00
Basic i32 ID stack manipulation
This commit is contained in:
parent
ef6cb15c61
commit
b807b8755e
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
- Support for progress bar
|
- Support for progress bar
|
||||||
- Support for push/pop item width
|
- Support for push/pop item width
|
||||||
|
- Support for ID stack manipulation (integer values)
|
||||||
- `ImVec4::zero()`
|
- `ImVec4::zero()`
|
||||||
- `Into` array and tuple conversions for ImVec2 and ImVec4
|
- `Into` array and tuple conversions for ImVec2 and ImVec4
|
||||||
|
|
||||||
|
|||||||
25
src/lib.rs
25
src/lib.rs
@ -409,7 +409,7 @@ impl<'ui> Ui<'ui> {
|
|||||||
/// The current process is aborted if the item width stack is empty.
|
/// The current process is aborted if the item width stack is empty.
|
||||||
pub fn pop_item_width(&self) { unsafe { imgui_sys::igPopItemWidth() } }
|
pub fn pop_item_width(&self) { unsafe { imgui_sys::igPopItemWidth() } }
|
||||||
|
|
||||||
/// Runs a function with a value temporarily pushed to the item width stack.
|
/// Runs a function after temporarily pushing a value to the item width stack.
|
||||||
pub fn with_item_width<F>(&self, width: f32, f: F) where F: FnOnce() {
|
pub fn with_item_width<F>(&self, width: f32, f: F) where F: FnOnce() {
|
||||||
self.push_item_width(width);
|
self.push_item_width(width);
|
||||||
f();
|
f();
|
||||||
@ -446,6 +446,29 @@ impl<'ui> Ui<'ui> {
|
|||||||
pub fn get_columns_count(&self) -> i32 { unsafe { imgui_sys::igGetColumnsCount() } }
|
pub fn get_columns_count(&self) -> i32 { unsafe { imgui_sys::igGetColumnsCount() } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ID scopes
|
||||||
|
impl<'ui> Ui<'ui> {
|
||||||
|
/// Pushes an identifier to the ID stack.
|
||||||
|
pub fn push_id(&self, id: i32) {
|
||||||
|
unsafe { imgui_sys::igPushIdInt(id) };
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Pops an identifier from the ID stack.
|
||||||
|
///
|
||||||
|
/// # Aborts
|
||||||
|
/// The current process is aborted if the ID stack is empty.
|
||||||
|
pub fn pop_id(&self) {
|
||||||
|
unsafe { imgui_sys::igPopId() };
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Runs a function after temporarily pushing a value to the ID stack.
|
||||||
|
pub fn with_id<F>(&self, id: i32, f: F) where F: FnOnce() {
|
||||||
|
self.push_id(id);
|
||||||
|
f();
|
||||||
|
self.pop_id();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Widgets
|
// Widgets
|
||||||
impl<'ui> Ui<'ui> {
|
impl<'ui> Ui<'ui> {
|
||||||
pub fn text<'p>(&self, text: ImStr<'p>) {
|
pub fn text<'p>(&self, text: ImStr<'p>) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user