Wrap ImGui::ArrowButton()

This commit is contained in:
Ollie Charles 2021-01-24 15:54:39 +00:00
parent 4398950053
commit 0fb690d832
2 changed files with 30 additions and 0 deletions

View File

@ -51,6 +51,8 @@ loop w = do
True -> putStrLn "Oh hi Mark" True -> putStrLn "Oh hi Mark"
False -> return () False -> return ()
arrowButton "Arrow" ImGuiDirUp
end end
render render

View File

@ -1,6 +1,7 @@
{-# LANGUAGE BlockArguments #-} {-# LANGUAGE BlockArguments #-}
{-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TemplateHaskell #-}
@ -53,6 +54,14 @@ module DearImGui
-- ** Main -- ** Main
, button , button
, smallButton , smallButton
, arrowButton
-- * Types
, ImGuiDir
, pattern ImGuiDirLeft
, pattern ImGuiDirRight
, pattern ImGuiDirUp
, pattern ImGuiDirDown
) )
where where
@ -278,3 +287,22 @@ button label = withCString label \labelPtr ->
smallButton :: String -> IO Bool smallButton :: String -> IO Bool
smallButton label = withCString label \labelPtr -> smallButton label = withCString label \labelPtr ->
(1 ==) <$> [C.exp| bool { SmallButton($(char* labelPtr)) } |] (1 ==) <$> [C.exp| bool { SmallButton($(char* labelPtr)) } |]
-- | Square button with an arrow shape.
--
-- Wraps @ImGui::ArrowButton()@.
arrowButton :: String -> ImGuiDir -> IO Bool
arrowButton strId (ImGuiDir dir) = withCString strId \strIdPtr ->
(1 ==) <$> [C.exp| bool { ArrowButton($(char* strIdPtr), $(int dir)) } |]
-- | A cardinal direction.
newtype ImGuiDir = ImGuiDir CInt
pattern ImGuiDirLeft, ImGuiDirRight, ImGuiDirUp, ImGuiDirDown :: ImGuiDir
pattern ImGuiDirLeft = ImGuiDir 0
pattern ImGuiDirRight = ImGuiDir 1
pattern ImGuiDirUp = ImGuiDir 2
pattern ImGuiDirDown = ImGuiDir 3