From 435eeaf8924b751fe79c376defa781d6fbbd575e Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Mon, 26 Mar 2018 16:47:40 +0900 Subject: [PATCH] imgui: Add with_style_and_color_vars convenient function Wraps with_style_vars and with_color_vars inside a single call. --- src/lib.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 7bee4ba..2be116b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1088,6 +1088,24 @@ impl<'ui> Ui<'ui> { } } +impl<'ui> Ui<'ui> { + /// Runs a function after temporarily pushing an array of values to the + /// style and color stack. + pub fn with_style_and_color_vars( + &self, + style_vars: &[StyleVar], + color_vars: &[(ImGuiCol, C)], + f: F, + ) where + F: FnOnce(), + C: Into + Copy, + { + self.with_style_vars(style_vars, || { + self.with_color_vars(color_vars, f); + }); + } +} + /// # Utilities impl<'ui> Ui<'ui> { /// Returns `true` if the last item is being hovered by the mouse.