From 7d56866c8634901c074754f27d7fa6de987d054b Mon Sep 17 00:00:00 2001 From: orhanbalci Date: Thu, 26 May 2016 00:21:53 +0300 Subject: [PATCH] combo and listbox functions added --- src/lib.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index ac43177..9903bdf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -86,7 +86,7 @@ impl<'a> ImStr<'a> { bytes: Cow::Borrowed(bytes) } } - pub fn as_ptr(&self) -> *const c_char { self.bytes.as_ptr() as *const c_char } + fn as_ptr(&self) -> *const c_char { self.bytes.as_ptr() as *const c_char } } impl<'a> From<&'a str> for ImStr<'a> { @@ -496,3 +496,21 @@ impl<'ui> Ui<'ui> { pub fn menu<'p>(&self, label: ImStr<'p>) -> Menu<'ui, 'p> { Menu::new(label) } pub fn menu_item<'p>(&self, label: ImStr<'p>) -> MenuItem<'ui, 'p> { MenuItem::new(label) } } + +//Widgets: Combos +impl<'ui> Ui<'ui> { + pub fn combo<'p>(&self, label : ImStr<'p>, current_item :&mut i32, items : ImStr<'p>, height_in_items : i32) -> bool { + unsafe{ + imgui_sys::igCombo2(label.as_ptr(), current_item, items.as_ptr(), height_in_items) + } + } +} +//Widgets: ListBox +impl<'ui> Ui<'ui> { + pub fn list_box<'p>(&self, label : ImStr<'p>, current_item : &mut i32, items : &mut Vec>, items_count : i32, height_in_items : i32)-> bool{ + unsafe{ + let items_inner : Vec<*const c_char> = items.into_iter().map(|item| item.as_ptr()).collect(); + imgui_sys::igListBox(label.as_ptr(), current_item, items_inner.as_ptr() as *mut *const c_char,items_count, height_in_items) + } + } +}