{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE ViewPatterns #-}
module DearImGui.Raw.ListClipper
( ListClipper
, new
, delete
, begin
, displayStart
, displayEnd
, step
)
where
import Control.Monad.IO.Class
( MonadIO, liftIO )
import Foreign hiding (new)
import Foreign.C
import System.IO.Unsafe (unsafePerformIO)
import DearImGui.Raw.Context
( imguiContext )
import DearImGui.Structs
( ImGuiListClipper )
import qualified Language.C.Inline as C
import qualified Language.C.Inline.Cpp as Cpp
C.context (Cpp.cppCtx <> C.bsCtx <> imguiContext)
C.include "imgui.h"
Cpp.using "namespace ImGui"
type ListClipper = Ptr ImGuiListClipper
new :: (MonadIO m) => m ListClipper
new :: forall (m :: * -> *). MonadIO m => m ListClipper
new = IO ListClipper -> m ListClipper
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO do
IO ListClipper
[C.block|
ImGuiListClipper* {
return IM_NEW(ImGuiListClipper);
}
|]
delete :: (MonadIO m) => ListClipper -> m ()
delete :: forall (m :: * -> *). MonadIO m => ListClipper -> m ()
delete ListClipper
clipper = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO do
[C.block|
void {
IM_DELETE($(ImGuiListClipper* clipper));
}
|]
begin :: (MonadIO m) => ListClipper -> CInt -> CFloat -> m ()
begin :: forall (m :: * -> *).
MonadIO m =>
ListClipper -> CInt -> CFloat -> m ()
begin ListClipper
clipper CInt
items_count CFloat
items_height = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO do
[C.block|
void {
$(ImGuiListClipper* clipper)->Begin($(int items_count), $(float items_height));
}
|]
displayStart :: ListClipper -> CInt
displayStart :: ListClipper -> CInt
displayStart ListClipper
clipper = IO CInt -> CInt
forall a. IO a -> a
unsafePerformIO do
[C.exp|
int {
$(ImGuiListClipper* clipper)->DisplayStart
}
|]
displayEnd :: ListClipper -> CInt
displayEnd :: ListClipper -> CInt
displayEnd ListClipper
clipper = IO CInt -> CInt
forall a. IO a -> a
unsafePerformIO
[C.exp|
int {
$(ImGuiListClipper* clipper)->DisplayEnd
}
|]
step :: (MonadIO m) => ListClipper -> m Bool
step :: forall (m :: * -> *). MonadIO m => ListClipper -> m Bool
step ListClipper
clipper = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO do
(CBool
0 CBool -> CBool -> Bool
forall a. Eq a => a -> a -> Bool
/=) (CBool -> Bool) -> IO CBool -> IO Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [C.block|
bool {
return $(ImGuiListClipper* clipper)->Step();
}
|]