diff --git a/src/DearImGui.hs b/src/DearImGui.hs index 82dcd0f..3c669c6 100644 --- a/src/DearImGui.hs +++ b/src/DearImGui.hs @@ -110,6 +110,7 @@ module DearImGui , Raw.endGroup , setCursorPos + , Raw.getCursorPos , Raw.alignTextToFramePadding -- * ID stack diff --git a/src/DearImGui/Raw.hs b/src/DearImGui/Raw.hs index 4aa0579..749ba4b 100644 --- a/src/DearImGui/Raw.hs +++ b/src/DearImGui/Raw.hs @@ -90,6 +90,7 @@ module DearImGui.Raw , popItemWidth , beginGroup , endGroup + , getCursorPos , setCursorPos , getCursorScreenPos , alignTextToFramePadding @@ -1671,6 +1672,20 @@ setCursorPos :: (MonadIO m) => Ptr ImVec2 -> m () setCursorPos posPtr = liftIO do [C.exp| void { SetCursorPos(*$(ImVec2* posPtr)) } |] +-- | Get cursor position in window-local coordinates. +-- +-- Useful to overlap draw using 'setCursorPos'. +-- +-- Wraps @ImGui::SetCursorPos()@ +getCursorPos :: (MonadIO m) => m ImVec2 +getCursorPos = liftIO do + C.withPtr_ \ptr -> + [C.block| + void { + *$(ImVec2 * ptr) = GetCursorPos(); + } + |] + -- | Cursor position in absolute coordinates. -- -- Useful to work with 'DrawList' API.