From ebeb92aa8e8c88171035354a62023f1f086856ed Mon Sep 17 00:00:00 2001 From: Zhaoxian Li Date: Sun, 21 Jun 2020 22:05:57 +0800 Subject: [PATCH 1/2] Expose background drawlist --- src/lib.rs | 5 +++++ src/window_draw_list.rs | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index e1f326f..9e11184 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -515,6 +515,11 @@ impl<'ui> Ui<'ui> { pub fn get_window_draw_list(&'ui self) -> WindowDrawList<'ui> { WindowDrawList::new(self) } + + #[must_use] + pub fn get_background_draw_list(&'ui self) -> WindowDrawList<'ui> { + WindowDrawList::new(self).background() + } } /// Condition for applying a setting diff --git a/src/window_draw_list.rs b/src/window_draw_list.rs index d5e28ac..090e818 100644 --- a/src/window_draw_list.rs +++ b/src/window_draw_list.rs @@ -82,6 +82,13 @@ impl<'ui> WindowDrawList<'ui> { } } + pub(crate) fn background(&mut self) -> Self { + Self { + draw_list: unsafe { sys::igGetBackgroundDrawList() }, + _phantom: PhantomData, + } + } + /// Split into *channels_count* drawing channels. /// At the end of the closure, the channels are merged. The objects /// are then drawn in the increasing order of their channel number, and not From 464557fdc6b9be73036c063faec701913030beaf Mon Sep 17 00:00:00 2001 From: Zhaoxian Li Date: Sun, 21 Jun 2020 22:30:29 +0800 Subject: [PATCH 2/2] Force background to consume self This is to enforce the consistency WINDOW_DRAW_LIST_LOADED --- src/window_draw_list.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/window_draw_list.rs b/src/window_draw_list.rs index 090e818..5a0cce4 100644 --- a/src/window_draw_list.rs +++ b/src/window_draw_list.rs @@ -82,7 +82,7 @@ impl<'ui> WindowDrawList<'ui> { } } - pub(crate) fn background(&mut self) -> Self { + pub(crate) fn background(self) -> Self { Self { draw_list: unsafe { sys::igGetBackgroundDrawList() }, _phantom: PhantomData,