From 6ac40b11006f40567fc728601c3a602993445e62 Mon Sep 17 00:00:00 2001 From: Joonas Javanainen Date: Sat, 4 Nov 2017 10:44:16 +0200 Subject: [PATCH] Take ref_color by reference --- imgui-examples/examples/test_window_impl.rs | 2 +- src/color_editors.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/imgui-examples/examples/test_window_impl.rs b/imgui-examples/examples/test_window_impl.rs index edcab61..01ae2f5 100644 --- a/imgui-examples/examples/test_window_impl.rs +++ b/imgui-examples/examples/test_window_impl.rs @@ -505,7 +505,7 @@ fn show_test_window<'a>(ui: &Ui<'a>, state: &mut State, opened: &mut bool) { .rgb(true); if s.ref_color { - b = b.reference_color(s.ref_color_v) + b = b.reference_color(&s.ref_color_v) } b.build(); }); diff --git a/src/color_editors.rs b/src/color_editors.rs index b0d66bc..16b31fb 100644 --- a/src/color_editors.rs +++ b/src/color_editors.rs @@ -178,7 +178,7 @@ pub struct ColorPicker<'ui, 'p> { label: &'p ImStr, value: EditableColor<'p>, flags: ImGuiColorEditFlags, - ref_color: Option<[f32; 4]>, + ref_color: Option<&'p [f32; 4]>, _phantom: PhantomData<&'ui Ui<'ui>>, } @@ -284,7 +284,7 @@ impl<'ui, 'p> ColorPicker<'ui, 'p> { self } #[inline] - pub fn reference_color(mut self, ref_color: [f32; 4]) -> Self { + pub fn reference_color(mut self, ref_color: &'p [f32; 4]) -> Self { self.ref_color = Some(ref_color); self } @@ -292,7 +292,7 @@ impl<'ui, 'p> ColorPicker<'ui, 'p> { if let EditableColor::Float3(_) = self.value { self.flags.insert(ImGuiColorEditFlags::NoAlpha); } - let ref_color = self.ref_color.as_ref().map(|c| c.as_ptr()).unwrap_or( + let ref_color = self.ref_color.map(|c| c.as_ptr()).unwrap_or( ptr::null(), ); unsafe {