Use Into<ImVec2> instead of ImVec2 directly

This commit is contained in:
Benjamin Adamson 2017-07-08 16:14:19 -07:00
parent fe7f4ed277
commit 0c483e9d44
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());
}
}
pub fn button<'p>(&self, label: &'p ImStr, size: ImVec2) -> bool {
unsafe { imgui_sys::igButton(label.as_ptr(), size) }
pub fn button<'p, S: Into<ImVec2>>(&self, label: &'p ImStr, size: S) -> bool {
unsafe { imgui_sys::igButton(label.as_ptr(), size.into()) }
}
pub fn small_button<'p>(&self, label: &'p ImStr) -> bool {
unsafe { imgui_sys::igSmallButton(label.as_ptr()) }
@ -627,13 +627,13 @@ impl<'ui> Ui<'ui> {
// Widgets: Selectable / Lists
impl<'ui> Ui<'ui> {
pub fn selectable<'p>(&self,
pub fn selectable<'p, S: Into<ImVec2>>(&self,
label: &'p ImStr,
selected: bool,
flags: ImGuiSelectableFlags,
size: ImVec2)
size: S)
-> 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 ui = imgui.frame((0, 0), (0, 0), 0.1);
/// ui.progress_bar(0.6)
/// .size(imgui::ImVec2::new(100.0, 12.0))
/// .size((100.0, 12.0))
/// .overlay_text(im_str!("Progress!"))
/// .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
/// size and positive values will use the given size.
#[inline]
pub fn size(mut self, size: ImVec2) -> Self {
self.size = size;
pub fn size<S: Into<ImVec2>>(mut self, size: S) -> Self {
self.size = size.into();
self
}