Add getCursorPos (#176)

This commit is contained in:
Tristan de Cacqueray 2023-07-02 21:48:44 +00:00 committed by GitHub
parent 0cc654f190
commit ea3ad959f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -110,6 +110,7 @@ module DearImGui
, Raw.endGroup , Raw.endGroup
, setCursorPos , setCursorPos
, Raw.getCursorPos
, Raw.alignTextToFramePadding , Raw.alignTextToFramePadding
-- * ID stack -- * ID stack

View File

@ -90,6 +90,7 @@ module DearImGui.Raw
, popItemWidth , popItemWidth
, beginGroup , beginGroup
, endGroup , endGroup
, getCursorPos
, setCursorPos , setCursorPos
, getCursorScreenPos , getCursorScreenPos
, alignTextToFramePadding , alignTextToFramePadding
@ -1671,6 +1672,20 @@ setCursorPos :: (MonadIO m) => Ptr ImVec2 -> m ()
setCursorPos posPtr = liftIO do setCursorPos posPtr = liftIO do
[C.exp| void { SetCursorPos(*$(ImVec2* posPtr)) } |] [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. -- | Cursor position in absolute coordinates.
-- --
-- Useful to work with 'DrawList' API. -- Useful to work with 'DrawList' API.