diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index da7db45..880eaf4 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -801,7 +801,7 @@ extern "C" { // Parameter stack (current window) extern "C" { pub fn igPushItemWidth(item_width: c_float); - pub fn igPopitemWidth(); + pub fn igPopItemWidth(); pub fn igCalcItemWidth() -> c_float; pub fn igPushTextWrapPos(wrap_pos_x: c_float); pub fn igPopTextWrapPos(); diff --git a/src/lib.rs b/src/lib.rs index 4d45c94..81a8883 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -400,6 +400,13 @@ impl<'ui> Ui<'ui> { // Layout impl<'ui> Ui<'ui> { + pub fn push_item_width(&self, width: f32) { unsafe { imgui_sys::igPushItemWidth(width) } } + pub fn pop_item_width(&self) { unsafe { imgui_sys::igPopItemWidth() } } + pub fn with_item_width(&self, width: f32, f: F) where F: FnOnce() { + self.push_item_width(width); + f(); + self.pop_item_width(); + } pub fn separator(&self) { unsafe { imgui_sys::igSeparator() }; } pub fn same_line(&self, pos_x: f32) { unsafe { imgui_sys::igSameLine(pos_x, -1.0f32) } } pub fn same_line_spacing(&self, pos_x: f32, spacing_w: f32) {