Add functions for getting window position and size (#89)

- getWindowPos
- getWindowSize
- getWindowWidth
- getWindowHeight

Closes #88
This commit is contained in:
Alexander Bondarenko 2021-09-11 13:09:11 +03:00 committed by GitHub
parent 08b3139477
commit be7aa1e9b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 2 deletions

View File

@ -49,6 +49,15 @@ module DearImGui
, begin , begin
, Raw.end , Raw.end
-- ** Utilities
, Raw.getWindowPos
, Raw.getWindowSize
, Raw.getWindowWidth
, Raw.getWindowHeight
-- ** Manipulation
, setNextWindowPos , setNextWindowPos
, setNextWindowSize , setNextWindowSize
, Raw.setNextWindowFullscreen , Raw.setNextWindowFullscreen
@ -57,7 +66,7 @@ module DearImGui
, setNextWindowCollapsed , setNextWindowCollapsed
, setNextWindowBgAlpha , setNextWindowBgAlpha
-- * Child Windows -- ** Child Windows
, withChild , withChild
, withChildOpen , withChildOpen
, beginChild , beginChild

View File

@ -43,6 +43,16 @@ module DearImGui.Raw
-- * Windows -- * Windows
, begin , begin
, end , end
-- ** Utilities
, getWindowPos
, getWindowSize
, getWindowWidth
, getWindowHeight
-- ** Manipulation
, setNextWindowPos , setNextWindowPos
, setNextWindowSize , setNextWindowSize
, setNextWindowFullscreen , setNextWindowFullscreen
@ -51,7 +61,7 @@ module DearImGui.Raw
, setNextWindowCollapsed , setNextWindowCollapsed
, setNextWindowBgAlpha , setNextWindowBgAlpha
-- * Child Windows -- ** Child Windows
, beginChild , beginChild
, endChild , endChild
@ -1088,6 +1098,31 @@ isItemHovered :: (MonadIO m) => m Bool
isItemHovered = liftIO do isItemHovered = liftIO do
(0 /=) <$> [C.exp| bool { IsItemHovered() } |] (0 /=) <$> [C.exp| bool { IsItemHovered() } |]
getWindowPos :: (MonadIO m) => m ImVec2
getWindowPos = liftIO do
C.withPtr_ \ptr ->
[C.block|
void {
*$(ImVec2 * ptr) = GetWindowPos();
}
|]
getWindowSize :: (MonadIO m) => m ImVec2
getWindowSize = liftIO do
C.withPtr_ \ptr ->
[C.block|
void {
*$(ImVec2 * ptr) = GetWindowSize();
}
|]
getWindowWidth :: (MonadIO m) => m CFloat
getWindowWidth = liftIO do
[C.exp| float { GetWindowWidth() } |]
getWindowHeight :: (MonadIO m) => m CFloat
getWindowHeight = liftIO do
[C.exp| float { GetWindowHeight() } |]
-- | Set next window position. Call before `begin` Use pivot=(0.5,0.5) to center on given point, etc. -- | Set next window position. Call before `begin` Use pivot=(0.5,0.5) to center on given point, etc.
-- --