Add push/pop item width and convenience function that calls push and pop either side of a closure

This commit is contained in:
andystanton 2017-03-14 17:56:43 +00:00
parent 87b31d6601
commit c1ca4aafe5
2 changed files with 8 additions and 1 deletions

View File

@ -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();

View File

@ -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<F>(&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) {