File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,11 @@ loop w checked = do
60
60
61
61
progressBar 0.314 (Just " Pi" )
62
62
63
+ beginCombo " Label" " Preview" >>= whenTrue do
64
+ selectable " Testing 1"
65
+ selectable " Testing 2"
66
+ endCombo
67
+
63
68
end
64
69
65
70
render
@@ -74,3 +79,8 @@ loop w checked = do
74
79
Just Event { eventPayload } -> case eventPayload of
75
80
QuitEvent -> return ()
76
81
_ -> loop w checked
82
+
83
+
84
+ whenTrue :: IO () -> Bool -> IO ()
85
+ whenTrue io True = io
86
+ whenTrue io False = return ()
Original file line number Diff line number Diff line change @@ -60,6 +60,13 @@ module DearImGui
60
60
, progressBar
61
61
, bullet
62
62
63
+ -- ** Combo Box
64
+ , beginCombo
65
+ , endCombo
66
+
67
+ -- ** Selectables
68
+ , selectable
69
+
63
70
-- * Types
64
71
, ImGuiDir
65
72
, pattern ImGuiDirLeft
@@ -331,6 +338,32 @@ bullet :: IO ()
331
338
bullet = [C. exp | void { Bullet() } |]
332
339
333
340
341
+ -- | Begin creating a combo box with a given label and preview value.
342
+ --
343
+ -- Returns 'True' if the combo box is open. In this state, you should populate
344
+ -- the contents of the combo box - for example, by calling 'selectable'.
345
+ --
346
+ -- Wraps @ImGui::BeginCombo()@.
347
+ beginCombo :: String -> String -> IO Bool
348
+ beginCombo label previewValue =
349
+ withCString label \ labelPtr ->
350
+ withCString previewValue \ previewValuePtr ->
351
+ (1 == ) <$> [C. exp | bool { BeginCombo($(char* labelPtr), $(char* previewValuePtr)) } |]
352
+
353
+
354
+ -- | Only call 'endCombo' if 'beginCombon' returns 'True'!
355
+ --
356
+ -- Wraps @ImGui::EndCombo()@.
357
+ endCombo :: IO ()
358
+ endCombo = [C. exp | void { EndCombo() } |]
359
+
360
+
361
+ -- | Wraps @ImGui::Selectable()@.
362
+ selectable :: String -> IO Bool
363
+ selectable label = withCString label \ labelPtr ->
364
+ (1 == ) <$> [C. exp | bool { Selectable($(char* labelPtr)) } |]
365
+
366
+
334
367
-- | A cardinal direction.
335
368
newtype ImGuiDir = ImGuiDir CInt
336
369
You can’t perform that action at this time.
0 commit comments