Wrap ImGui::BeginCombo(), EndCombo(), Selectable()

This commit is contained in:
Ollie Charles
2021-01-24 16:14:51 +00:00
parent 5a1f5c78ec
commit aa681fb77d
2 changed files with 43 additions and 0 deletions

View File

@ -60,6 +60,13 @@ module DearImGui
, progressBar
, bullet
-- ** Combo Box
, beginCombo
, endCombo
-- ** Selectables
, selectable
-- * Types
, ImGuiDir
, pattern ImGuiDirLeft
@ -331,6 +338,32 @@ bullet :: IO ()
bullet = [C.exp| void { Bullet() } |]
-- | Begin creating a combo box with a given label and preview value.
--
-- Returns 'True' if the combo box is open. In this state, you should populate
-- the contents of the combo box - for example, by calling 'selectable'.
--
-- Wraps @ImGui::BeginCombo()@.
beginCombo :: String -> String -> IO Bool
beginCombo label previewValue =
withCString label \labelPtr ->
withCString previewValue \previewValuePtr ->
(1 ==) <$> [C.exp| bool { BeginCombo($(char* labelPtr), $(char* previewValuePtr)) } |]
-- | Only call 'endCombo' if 'beginCombon' returns 'True'!
--
-- Wraps @ImGui::EndCombo()@.
endCombo :: IO ()
endCombo = [C.exp| void { EndCombo() } |]
-- | Wraps @ImGui::Selectable()@.
selectable :: String -> IO Bool
selectable label = withCString label \labelPtr ->
(1 == ) <$> [C.exp| bool { Selectable($(char* labelPtr)) } |]
-- | A cardinal direction.
newtype ImGuiDir = ImGuiDir CInt