@@ -80,6 +80,13 @@ module DearImGui
80
80
, endMenu
81
81
, menuItem
82
82
83
+ -- * Popups/Modals
84
+ , beginPopup
85
+ , beginPopupModal
86
+ , endPopup
87
+ , openPopup
88
+ , closeCurrentPopup
89
+
83
90
-- * Types
84
91
, ImGuiDir
85
92
, pattern ImGuiDirLeft
@@ -483,6 +490,49 @@ menuItem label = liftIO do
483
490
(1 == ) <$> [C. exp | bool { MenuItem($(char* labelPtr)) } |]
484
491
485
492
493
+ -- | Returns 'True' if the popup is open, and you can start outputting to it.
494
+ --
495
+ -- Wraps @ImGui::BeginPopup()@
496
+ beginPopup :: MonadIO m => String -> m Bool
497
+ beginPopup popupId = liftIO do
498
+ withCString popupId \ popupIdPtr ->
499
+ (1 == ) <$> [C. exp | bool { BeginPopup($(char* popupIdPtr)) } |]
500
+
501
+
502
+ -- | Returns 'True' if the modal is open, and you can start outputting to it.
503
+ --
504
+ -- Wraps @ImGui::BeginPopupModal()@
505
+ beginPopupModal :: MonadIO m => String -> m Bool
506
+ beginPopupModal popupId = liftIO do
507
+ withCString popupId \ popupIdPtr ->
508
+ (1 == ) <$> [C. exp | bool { BeginPopupModal($(char* popupIdPtr)) } |]
509
+
510
+
511
+ -- | Only call 'endPopup' if 'beginPopup' or 'beginPopupModal' returns 'True'!
512
+ --
513
+ -- Wraps @ImGui::BeginPopupModal()@
514
+ endPopup :: MonadIO m => m ()
515
+ endPopup = liftIO do
516
+ [C. exp | void { EndPopup() } |]
517
+
518
+
519
+ -- | Call to mark popup as open (don't call every frame!).
520
+ --
521
+ -- Wraps @ImGui::OpenPopup()@
522
+ openPopup :: MonadIO m => String -> m ()
523
+ openPopup popupId = liftIO do
524
+ withCString popupId \ popupIdPtr ->
525
+ [C. exp | void { OpenPopup($(char* popupIdPtr)) } |]
526
+
527
+
528
+ -- | Manually close the popup we have begin-ed into.
529
+ --
530
+ -- Wraps @ImGui::ClosePopup()@
531
+ closeCurrentPopup :: MonadIO m => m ()
532
+ closeCurrentPopup = liftIO do
533
+ [C. exp | void { CloseCurrentPopup() } |]
534
+
535
+
486
536
-- | A cardinal direction.
487
537
newtype ImGuiDir = ImGuiDir CInt
488
538
0 commit comments