Merge pull request #63 from bjadamson/into-imvec2

Use Into<ImVec2> instead of ImVec2 directly
This commit is contained in:
Joonas Javanainen 2017-07-09 15:16:13 +03:00 committed by GitHub
commit c1fc7cfbec
2 changed files with 8 additions and 8 deletions

View File

@ -486,8 +486,8 @@ impl<'ui> Ui<'ui> {
imgui_sys::igBulletText(fmt_ptr(), text.as_ptr()); imgui_sys::igBulletText(fmt_ptr(), text.as_ptr());
} }
} }
pub fn button<'p>(&self, label: &'p ImStr, size: ImVec2) -> bool { pub fn button<'p, S: Into<ImVec2>>(&self, label: &'p ImStr, size: S) -> bool {
unsafe { imgui_sys::igButton(label.as_ptr(), size) } unsafe { imgui_sys::igButton(label.as_ptr(), size.into()) }
} }
pub fn small_button<'p>(&self, label: &'p ImStr) -> bool { pub fn small_button<'p>(&self, label: &'p ImStr) -> bool {
unsafe { imgui_sys::igSmallButton(label.as_ptr()) } unsafe { imgui_sys::igSmallButton(label.as_ptr()) }
@ -627,13 +627,13 @@ impl<'ui> Ui<'ui> {
// Widgets: Selectable / Lists // Widgets: Selectable / Lists
impl<'ui> Ui<'ui> { impl<'ui> Ui<'ui> {
pub fn selectable<'p>(&self, pub fn selectable<'p, S: Into<ImVec2>>(&self,
label: &'p ImStr, label: &'p ImStr,
selected: bool, selected: bool,
flags: ImGuiSelectableFlags, flags: ImGuiSelectableFlags,
size: ImVec2) size: S)
-> bool { -> bool {
unsafe { imgui_sys::igSelectable(label.as_ptr(), selected, flags, size) } unsafe { imgui_sys::igSelectable(label.as_ptr(), selected, flags, size.into()) }
} }
} }
@ -751,7 +751,7 @@ impl<'ui> Ui<'ui> {
/// # let mut imgui = ImGui::init(); /// # let mut imgui = ImGui::init();
/// # let ui = imgui.frame((0, 0), (0, 0), 0.1); /// # let ui = imgui.frame((0, 0), (0, 0), 0.1);
/// ui.progress_bar(0.6) /// ui.progress_bar(0.6)
/// .size(imgui::ImVec2::new(100.0, 12.0)) /// .size((100.0, 12.0))
/// .overlay_text(im_str!("Progress!")) /// .overlay_text(im_str!("Progress!"))
/// .build(); /// .build();
/// ``` /// ```

View File

@ -38,8 +38,8 @@ impl<'p> ProgressBar<'p> {
/// align to the end of the axis, zero will let the progress bar choose a /// align to the end of the axis, zero will let the progress bar choose a
/// size and positive values will use the given size. /// size and positive values will use the given size.
#[inline] #[inline]
pub fn size(mut self, size: ImVec2) -> Self { pub fn size<S: Into<ImVec2>>(mut self, size: S) -> Self {
self.size = size; self.size = size.into();
self self
} }