From d1879b2a04c74b94463a91aba918053797b40b81 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Thu, 29 Mar 2018 10:41:02 +0900 Subject: [PATCH] window_draw_list.rs: Add add_rect_filled_multicolor As `add_rect_filled_multicolor` does not have any option, the `build` pattern is not used and calling `add_rect_filled_multicolor` directly draws the rectangle on the window. --- src/window_draw_list.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/window_draw_list.rs b/src/window_draw_list.rs index c2216a3..53ebb88 100644 --- a/src/window_draw_list.rs +++ b/src/window_draw_list.rs @@ -137,6 +137,40 @@ macro_rules! impl_draw_list_methods { { Rect::new(self, p1, p2, c) } + + /// Draw a rectangle whose upper-left corner is at point `p1` + /// and lower-right corner is at point `p2`. + /// The remains parameters are the respective color of the corners + /// in the counter-clockwise starting from the upper-left corner + /// first. + pub fn add_rect_filled_multicolor( + &self, + p1: P1, + p2: P2, + col_upr_left: C1, + col_upr_right: C2, + col_bot_right: C3, + col_bot_left: C4, + ) where + P1: Into, + P2: Into, + C1: Into, + C2: Into, + C3: Into, + C4: Into, + { + unsafe { + sys::ImDrawList_AddRectFilledMultiColor( + self.draw_list(), + p1.into(), + p2.into(), + col_upr_left.into().into(), + col_upr_right.into().into(), + col_bot_right.into().into(), + col_bot_left.into().into(), + ); + } + } } }; }