Skip to content

Commit 0fb690d

Browse files
committed
Wrap ImGui::ArrowButton()
1 parent 4398950 commit 0fb690d

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

Main.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ loop w = do
5151
True -> putStrLn "Oh hi Mark"
5252
False -> return ()
5353

54+
arrowButton "Arrow" ImGuiDirUp
55+
5456
end
5557

5658
render

src/DearImGui.hs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{-# LANGUAGE BlockArguments #-}
22
{-# LANGUAGE NamedFieldPuns #-}
33
{-# LANGUAGE OverloadedStrings #-}
4+
{-# LANGUAGE PatternSynonyms #-}
45
{-# LANGUAGE QuasiQuotes #-}
56
{-# LANGUAGE TemplateHaskell #-}
67

@@ -53,6 +54,14 @@ module DearImGui
5354
-- ** Main
5455
, button
5556
, smallButton
57+
, arrowButton
58+
59+
-- * Types
60+
, ImGuiDir
61+
, pattern ImGuiDirLeft
62+
, pattern ImGuiDirRight
63+
, pattern ImGuiDirUp
64+
, pattern ImGuiDirDown
5665
)
5766
where
5867

@@ -278,3 +287,22 @@ button label = withCString label \labelPtr ->
278287
smallButton :: String -> IO Bool
279288
smallButton label = withCString label \labelPtr ->
280289
(1 ==) <$> [C.exp| bool { SmallButton($(char* labelPtr)) } |]
290+
291+
292+
-- | Square button with an arrow shape.
293+
--
294+
-- Wraps @ImGui::ArrowButton()@.
295+
arrowButton :: String -> ImGuiDir -> IO Bool
296+
arrowButton strId (ImGuiDir dir) = withCString strId \strIdPtr ->
297+
(1 ==) <$> [C.exp| bool { ArrowButton($(char* strIdPtr), $(int dir)) } |]
298+
299+
300+
-- | A cardinal direction.
301+
newtype ImGuiDir = ImGuiDir CInt
302+
303+
304+
pattern ImGuiDirLeft, ImGuiDirRight, ImGuiDirUp, ImGuiDirDown :: ImGuiDir
305+
pattern ImGuiDirLeft = ImGuiDir 0
306+
pattern ImGuiDirRight = ImGuiDir 1
307+
pattern ImGuiDirUp = ImGuiDir 2
308+
pattern ImGuiDirDown = ImGuiDir 3

0 commit comments

Comments
 (0)