Wrap ImGui::ProgressBar()

This commit is contained in:
Ollie Charles 2021-01-24 16:03:18 +00:00
parent 1bd51ab35e
commit 5a1f5c78ec
2 changed files with 16 additions and 0 deletions

View File

@ -58,6 +58,8 @@ loop w checked = do
True -> readIORef checked >>= print True -> readIORef checked >>= print
False -> return () False -> return ()
progressBar 0.314 (Just "Pi")
end end
render render

View File

@ -57,6 +57,7 @@ module DearImGui
, smallButton , smallButton
, arrowButton , arrowButton
, checkbox , checkbox
, progressBar
, bullet , bullet
-- * Types -- * Types
@ -316,6 +317,14 @@ checkbox label ref = do
return changed return changed
progressBar :: Float -> Maybe String -> IO ()
progressBar progress overlay = withCStringOrNull overlay \overlayPtr ->
[C.exp| void { ProgressBar($(float c'progress), ImVec2(-FLT_MIN, 0), $(char* overlayPtr)) } |]
where
c'progress :: CFloat
c'progress = realToFrac progress
-- | Draw a small circle + keep the cursor on the same line. Advance cursor x -- | Draw a small circle + keep the cursor on the same line. Advance cursor x
-- position by 'getTreeNodeToLabelSpacing', same distance that 'treeNode' uses. -- position by 'getTreeNodeToLabelSpacing', same distance that 'treeNode' uses.
bullet :: IO () bullet :: IO ()
@ -331,3 +340,8 @@ pattern ImGuiDirLeft = ImGuiDir 0
pattern ImGuiDirRight = ImGuiDir 1 pattern ImGuiDirRight = ImGuiDir 1
pattern ImGuiDirUp = ImGuiDir 2 pattern ImGuiDirUp = ImGuiDir 2
pattern ImGuiDirDown = ImGuiDir 3 pattern ImGuiDirDown = ImGuiDir 3
withCStringOrNull :: Maybe String -> (Ptr CChar -> IO a) -> IO a
withCStringOrNull Nothing k = k nullPtr
withCStringOrNull (Just s) k = withCString s k