From d970e287d1c7fe3e5723b6e5c7e2541c7a87632e Mon Sep 17 00:00:00 2001 From: Joonas Javanainen Date: Tue, 18 Aug 2015 19:56:11 +0300 Subject: [PATCH] Add f32 constructors for ImVec2/ImVec4 --- src/ffi.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ffi.rs b/src/ffi.rs index 77c0d4d..35b4376 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -211,6 +211,15 @@ pub struct ImVec2 { pub y: c_float } +impl ImVec2 { + pub fn new(x: f32, y: f32) -> ImVec2 { + ImVec2 { + x: x as c_float, + y: y as c_float + } + } +} + #[repr(C)] #[derive(Copy, Clone, Debug, Default)] pub struct ImVec4 { @@ -220,6 +229,17 @@ pub struct ImVec4 { pub w: c_float } +impl ImVec4 { + pub fn new(x: f32, y: f32, z: f32, w: f32) -> ImVec4 { + ImVec4 { + x: x as c_float, + y: y as c_float, + z: z as c_float, + w: w as c_float + } + } +} + #[repr(C)] pub struct ImGuiStyle { pub alpha: c_float,