Wrap ImGui::TreeNode, TreePush, TreePop (#24)

This commit is contained in:
Ollie Charles 2021-01-28 23:28:45 +00:00 committed by GitHub
parent 24903ce76f
commit bb82e87553
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 0 deletions

View File

@ -91,6 +91,15 @@ loop w checked color slider = do
colorPicker3 "Test" color 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 beginMainMenuBar >>= whenTrue do
beginMenu "Hello" >>= whenTrue do beginMenu "Hello" >>= whenTrue do
menuItem "Hello" menuItem "Hello"

View File

@ -83,6 +83,11 @@ module DearImGui
, colorPicker3 , colorPicker3
, colorButton , colorButton
-- * Trees
, treeNode
, treePush
, treePop
-- ** Selectables -- ** Selectables
, selectable , selectable
@ -583,6 +588,25 @@ colorButton desc ref = liftIO do
return changed 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()@. -- | Wraps @ImGui::Selectable()@.
selectable :: MonadIO m => String -> m Bool selectable :: MonadIO m => String -> m Bool