From 3c3646a645c248dba49a6a6cf20b7e5dd0e087ea Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Sun, 24 Jan 2021 17:39:44 +0000 Subject: [PATCH] Wrap ImGui::Begin/EndTooltip() --- Main.hs | 7 ++++++- src/DearImGui.hs | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Main.hs b/Main.hs index 563fbd2..d540f04 100644 --- a/Main.hs +++ b/Main.hs @@ -48,7 +48,12 @@ loop w checked = do True -> openPopup "Button Popup" False -> return () - beginPopupModal "Button Popup" >>= whenTrue do + isItemHovered >>= whenTrue do + beginTooltip + text "Tooltip?" + endTooltip + + beginPopup "Button Popup" >>= whenTrue do button "Close" >>= whenTrue closeCurrentPopup endPopup diff --git a/src/DearImGui.hs b/src/DearImGui.hs index 2a9bdea..7dfee56 100644 --- a/src/DearImGui.hs +++ b/src/DearImGui.hs @@ -80,6 +80,10 @@ module DearImGui , endMenu , menuItem + -- * Tooltips + , beginTooltip + , endTooltip + -- * Popups/Modals , beginPopup , beginPopupModal @@ -493,6 +497,21 @@ menuItem label = liftIO do (1 ==) <$> [C.exp| bool { MenuItem($(char* labelPtr)) } |] +-- | Begin/append a tooltip window to create full-featured tooltip (with any +-- kind of items). +-- +-- Wraps @ImGui::BeginTooltip()@ +beginTooltip :: MonadIO m => m () +beginTooltip = liftIO do + [C.exp| void { BeginTooltip() } |] + + +-- | Wraps @ImGui::EndTooltip()@ +endTooltip :: MonadIO m => m () +endTooltip = liftIO do + [C.exp| void { EndTooltip() } |] + + -- | Returns 'True' if the popup is open, and you can start outputting to it. -- -- Wraps @ImGui::BeginPopup()@