diff --git a/Main.hs b/Main.hs index 35b6bd1..f28d0e0 100644 --- a/Main.hs +++ b/Main.hs @@ -91,6 +91,15 @@ loop w checked color slider = do colorPicker3 "Test" color + treeNode "Tree Node 1" >>= whenTrue do + treeNode "Tree Node 2" >>= whenTrue do + treePop + + treeNode "Tree Node 3" >>= whenTrue do + treePop + + treePop + beginMainMenuBar >>= whenTrue do beginMenu "Hello" >>= whenTrue do menuItem "Hello" diff --git a/src/DearImGui.hs b/src/DearImGui.hs index 4f6bdc5..4c458fa 100644 --- a/src/DearImGui.hs +++ b/src/DearImGui.hs @@ -83,6 +83,11 @@ module DearImGui , colorPicker3 , colorButton + -- * Trees + , treeNode + , treePush + , treePop + -- ** Selectables , selectable @@ -583,6 +588,25 @@ colorButton desc ref = liftIO do return changed +-- | Wraps @ImGui::TreeNode()@. +treeNode :: MonadIO m => String -> m Bool +treeNode label = liftIO do + withCString label \labelPtr -> + (0 /=) <$> [C.exp| bool { TreeNode($(char* labelPtr)) } |] + + +-- | Wraps @ImGui::TreePush()@. +treePush :: MonadIO m => String -> m () +treePush label = liftIO do + withCString label \labelPtr -> + [C.exp| void { TreePush($(char* labelPtr)) } |] + + +-- | Wraps @ImGui::TreePop()@. +treePop :: MonadIO m => m () +treePop = liftIO do + [C.exp| void { TreePop() } |] + -- | Wraps @ImGui::Selectable()@. selectable :: MonadIO m => String -> m Bool