mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2024-11-22 16:57:00 +00:00
Wrap ImGui::ProgressBar()
This commit is contained in:
parent
1bd51ab35e
commit
5a1f5c78ec
2
Main.hs
2
Main.hs
@ -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
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user