mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2025-07-06 04:58:48 +02:00
Add isPopupOpen and wrappers (#134)
This commit is contained in:
committed by
GitHub
parent
b837d583a5
commit
4517af8123
@ -199,6 +199,7 @@ module DearImGui.Raw
|
||||
, openPopup
|
||||
, openPopupOnItemClick
|
||||
, closeCurrentPopup
|
||||
, isPopupOpen
|
||||
|
||||
-- * ID stack/scopes
|
||||
, pushIDInt
|
||||
@ -1253,7 +1254,10 @@ openPopup :: (MonadIO m) => CString -> m ()
|
||||
openPopup popupIdPtr = liftIO do
|
||||
[C.exp| void { OpenPopup($(char* popupIdPtr)) } |]
|
||||
|
||||
-- | Call to mark popup as open (don't call every frame!).
|
||||
|
||||
-- | helper to open popup when clicked on last item.
|
||||
--
|
||||
-- Note: actually triggers on the mouse _released_ event to be consistent with popup behaviors.
|
||||
--
|
||||
-- Wraps @ImGui::OpenPopupOnItemClick()@
|
||||
openPopupOnItemClick :: (MonadIO m) => CString -> ImGuiPopupFlags-> m ()
|
||||
@ -1269,6 +1273,18 @@ closeCurrentPopup = liftIO do
|
||||
[C.exp| void { CloseCurrentPopup() } |]
|
||||
|
||||
|
||||
-- | Query popup status
|
||||
--
|
||||
-- - return 'True' if the popup is open at the current 'beginPopup' level of the popup stack.
|
||||
-- - with 'ImGuiPopupFlags_AnyPopupId': return 'True' if any popup is open at the current 'beginPopup' level of the popup stack.
|
||||
-- - with 'ImGuiPopupFlags_AnyPopupId' | 'ImGuiPopupFlags_AnyPopupLevel': return 'True' if any popup is open.
|
||||
--
|
||||
-- Wraps @ImGui::IsPopupOpen()@
|
||||
isPopupOpen :: (MonadIO m) => CString -> ImGuiPopupFlags-> m Bool
|
||||
isPopupOpen popupIdPtr flags = liftIO do
|
||||
(0 /=) <$> [C.exp| bool { IsPopupOpen($(char* popupIdPtr), $(ImGuiPopupFlags flags)) } |]
|
||||
|
||||
|
||||
-- | Is the last item hovered? (and usable, aka not blocked by a popup, etc.).
|
||||
--
|
||||
-- Wraps @ImGui::IsItemHovered()@
|
||||
|
Reference in New Issue
Block a user