Basic wrapper for plotHistogram

This commit is contained in:
Oliver Charles 2021-01-24 20:23:58 +00:00
parent ff989ba403
commit ecab9d37a2
2 changed files with 14 additions and 0 deletions

View File

@ -78,6 +78,8 @@ loop w checked = do
selectable "Testing 2" selectable "Testing 2"
endCombo endCombo
plotHistogram "A histogram" [ 10, 10, 20, 30, 90 ]
beginMainMenuBar >>= whenTrue do beginMainMenuBar >>= whenTrue do
beginMenu "Hello" >>= whenTrue do beginMenu "Hello" >>= whenTrue do
menuItem "Hello" menuItem "Hello"

View File

@ -65,6 +65,9 @@ module DearImGui
-- ** Selectables -- ** Selectables
, selectable , selectable
-- * Data Plotting
, plotHistogram
-- ** Menus -- ** Menus
, beginMenuBar , beginMenuBar
, endMenuBar , endMenuBar
@ -371,6 +374,15 @@ selectable label = liftIO do
(1 == ) <$> [C.exp| bool { Selectable($(char* labelPtr)) } |] (1 == ) <$> [C.exp| bool { Selectable($(char* labelPtr)) } |]
-- | Wraps @ImGui::PlotHistogram()@.
plotHistogram :: MonadIO m => String -> [CFloat] -> m ()
plotHistogram label values = liftIO $
withArrayLen values \len valuesPtr ->
withCString label \labelPtr -> do
let c'len = fromIntegral len
[C.exp| void { PlotHistogram($(char* labelPtr), $(float* valuesPtr), $(int c'len)) } |]
-- | Append to menu-bar of current window (requires 'ImGuiWindowFlagsMenuBar' -- | Append to menu-bar of current window (requires 'ImGuiWindowFlagsMenuBar'
-- flag set on parent window). -- flag set on parent window).
-- --