From 48486ee8c2e67352a1fd2bd7b2857f5463e41248 Mon Sep 17 00:00:00 2001 From: Tristan de Cacqueray Date: Mon, 28 Nov 2022 12:56:27 +0000 Subject: [PATCH] Add setNextItemOpen (#161) This change enables starting a new TreeNode open. --- src/DearImGui.hs | 4 ++++ src/DearImGui/Raw.hs | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/DearImGui.hs b/src/DearImGui.hs index f608843..3f3e8d3 100644 --- a/src/DearImGui.hs +++ b/src/DearImGui.hs @@ -226,6 +226,7 @@ module DearImGui , treeNode , treePush , Raw.treePop + , setNextItemOpen -- ** Selectables , selectable @@ -1546,6 +1547,9 @@ treePush :: MonadIO m => Text -> m () treePush label = liftIO do Text.withCString label Raw.treePush +-- | Wraps @ImGui::SetNextItemOpen()@. +setNextItemOpen :: MonadIO m => Bool -> m () +setNextItemOpen is_open = Raw.setNextItemOpen (bool 0 1 is_open) -- | Wraps @ImGui::Selectable()@ with default options. selectable :: MonadIO m => Text -> m Bool diff --git a/src/DearImGui/Raw.hs b/src/DearImGui/Raw.hs index 89ed760..24b00c7 100644 --- a/src/DearImGui/Raw.hs +++ b/src/DearImGui/Raw.hs @@ -185,6 +185,7 @@ module DearImGui.Raw , treeNode , treePush , treePop + , setNextItemOpen -- ** Selectables , selectable @@ -1233,6 +1234,11 @@ treePop = liftIO do [C.exp| void { TreePop() } |] +-- | Wraps @ImGui::SetNextItemOpen()@. +setNextItemOpen :: (MonadIO m) => CBool -> m () +setNextItemOpen is_open = liftIO do + [C.exp| void { SetNextItemOpen($(bool is_open)) } |] + -- -- | Wraps @ImGui::Selectable()@. -- selectable :: (MonadIO m) => CString -> m Bool -- selectable labelPtr = liftIO do