From dab5937eee30fbed34a6f5859ed326c4df8b1e94 Mon Sep 17 00:00:00 2001 From: Axis Sivitz Date: Tue, 30 Aug 2022 14:57:08 -0400 Subject: [PATCH 1/5] Fix compilation on MacOS / GHC 8.10.7 (#156) Fixes errors along the lines of: dear-imgui > [ 2 of 17] Compiling DearImGui.GLFW dear-imgui > error: unknown type name 'constexpr' So the "-std=c++11" option is not being passed to the C++ compiler on MacOS. The issue seems related to https://github.com/haskell/cabal/issues/6421 --- dear-imgui.cabal | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dear-imgui.cabal b/dear-imgui.cabal index 963693e..1db7fe6 100644 --- a/dear-imgui.cabal +++ b/dear-imgui.cabal @@ -185,6 +185,10 @@ library , vector , text + if os(darwin) + ghc-options: + -optcxx-std=c++11 + if flag(disable-obsolete) cxx-options: -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS From 9dac0f9fbef9f58527148b773ee07d40e43e96f3 Mon Sep 17 00:00:00 2001 From: Alexander Bondarenko <486682+dpwiz@users.noreply.github.com> Date: Wed, 31 Aug 2022 00:13:04 +0300 Subject: [PATCH 2/5] Prepare 2.1.1 (#157) --- ChangeLog.md | 6 ++++++ dear-imgui.cabal | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 46ac282..1680671 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,9 @@ # Changelog for dear-imgui +## [2.1.1] + +- Build flag fix for MacOS. + ## [2.1.0] - `imgui` updated to [1.88]. @@ -87,6 +91,8 @@ Initial Hackage release based on [1.83]. [1.4.0]: https://github.com/haskell-game/dear-imgui.hs/tree/v1.4.0 [1.5.0]: https://github.com/haskell-game/dear-imgui.hs/tree/v1.5.0 [2.0.0]: https://github.com/haskell-game/dear-imgui.hs/tree/v2.0.0 +[2.1.0]: https://github.com/haskell-game/dear-imgui.hs/tree/v2.1.0 +[2.1.1]: https://github.com/haskell-game/dear-imgui.hs/tree/v2.1.1 [1.87]: https://github.com/ocornut/imgui/releases/tag/v1.87 [1.86]: https://github.com/ocornut/imgui/releases/tag/v1.86 diff --git a/dear-imgui.cabal b/dear-imgui.cabal index 1db7fe6..393b0bd 100644 --- a/dear-imgui.cabal +++ b/dear-imgui.cabal @@ -1,7 +1,7 @@ cabal-version: 3.0 name: dear-imgui -version: 2.1.0 +version: 2.1.1 author: Oliver Charles maintainer: ollie@ocharles.org.uk, aenor.realm@gmail.com license: BSD-3-Clause From 051a17a1c54190724cfa739d3155e6d307961fa4 Mon Sep 17 00:00:00 2001 From: Tristan de Cacqueray Date: Sun, 20 Nov 2022 15:57:15 +0000 Subject: [PATCH 3/5] Add plotLines (#158) --- src/DearImGui.hs | 7 +++++++ src/DearImGui/Raw.hs | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/src/DearImGui.hs b/src/DearImGui.hs index 6ac731f..f608843 100644 --- a/src/DearImGui.hs +++ b/src/DearImGui.hs @@ -237,6 +237,7 @@ module DearImGui , listBox -- ** Data Plotting + , plotLines , plotHistogram -- ** Menus @@ -1590,6 +1591,12 @@ listBox label selectedIndex items = liftIO $ Managed.with m return return changed +-- | Wraps @ImGui::PlotLines()@. +plotLines :: MonadIO m => Text -> [CFloat] -> m () +plotLines label values = liftIO $ + withArrayLen values \len valuesPtr -> + Text.withCString label \labelPtr -> + Raw.plotLines labelPtr valuesPtr (fromIntegral len) -- | Wraps @ImGui::PlotHistogram()@. plotHistogram :: MonadIO m => Text -> [CFloat] -> m () diff --git a/src/DearImGui/Raw.hs b/src/DearImGui/Raw.hs index 72e2cd1..89ed760 100644 --- a/src/DearImGui/Raw.hs +++ b/src/DearImGui/Raw.hs @@ -193,6 +193,7 @@ module DearImGui.Raw , listBox -- * Data Plotting + , plotLines , plotHistogram -- ** Menus @@ -1250,6 +1251,10 @@ listBox :: (MonadIO m) => CString -> Ptr CInt -> Ptr CString -> CInt -> m Bool listBox labelPtr iPtr itemsPtr itemsLen = liftIO do (0 /=) <$> [C.exp| bool { ListBox($(char* labelPtr), $(int* iPtr), $(char** itemsPtr), $(int itemsLen)) }|] +-- | Wraps @ImGui::PlotLines()@. +plotLines :: (MonadIO m) => CString -> Ptr CFloat -> CInt -> m () +plotLines labelPtr valuesPtr valuesLen = liftIO do + [C.exp| void { PlotLines($(char* labelPtr), $(float* valuesPtr), $(int valuesLen)) } |] -- | Wraps @ImGui::PlotHistogram()@. plotHistogram :: (MonadIO m) => CString -> Ptr CFloat -> CInt -> m () From a2feb73fa5cdd3c4b4b43338e20e482477c1eb7f Mon Sep 17 00:00:00 2001 From: Tristan de Cacqueray Date: Tue, 22 Nov 2022 19:13:18 +0000 Subject: [PATCH 4/5] Fix the glfw example build condition (#159) The example needs the opengl2 flag. --- dear-imgui.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dear-imgui.cabal b/dear-imgui.cabal index 393b0bd..f3f4c4e 100644 --- a/dear-imgui.cabal +++ b/dear-imgui.cabal @@ -329,7 +329,7 @@ executable glfw main-is: Main.hs hs-source-dirs: examples/glfw default-language: Haskell2010 - if (!flag(examples) || !flag(glfw) || !flag(opengl3)) + if (!flag(examples) || !flag(glfw) || !flag(opengl2)) buildable: False else build-depends: base, GLFW-b, gl, dear-imgui, managed, text From 48486ee8c2e67352a1fd2bd7b2857f5463e41248 Mon Sep 17 00:00:00 2001 From: Tristan de Cacqueray Date: Mon, 28 Nov 2022 12:56:27 +0000 Subject: [PATCH 5/5] Add setNextItemOpen (#161) This change enables starting a new TreeNode open. --- src/DearImGui.hs | 4 ++++ src/DearImGui/Raw.hs | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/DearImGui.hs b/src/DearImGui.hs index f608843..3f3e8d3 100644 --- a/src/DearImGui.hs +++ b/src/DearImGui.hs @@ -226,6 +226,7 @@ module DearImGui , treeNode , treePush , Raw.treePop + , setNextItemOpen -- ** Selectables , selectable @@ -1546,6 +1547,9 @@ treePush :: MonadIO m => Text -> m () treePush label = liftIO do Text.withCString label Raw.treePush +-- | Wraps @ImGui::SetNextItemOpen()@. +setNextItemOpen :: MonadIO m => Bool -> m () +setNextItemOpen is_open = Raw.setNextItemOpen (bool 0 1 is_open) -- | Wraps @ImGui::Selectable()@ with default options. selectable :: MonadIO m => Text -> m Bool diff --git a/src/DearImGui/Raw.hs b/src/DearImGui/Raw.hs index 89ed760..24b00c7 100644 --- a/src/DearImGui/Raw.hs +++ b/src/DearImGui/Raw.hs @@ -185,6 +185,7 @@ module DearImGui.Raw , treeNode , treePush , treePop + , setNextItemOpen -- ** Selectables , selectable @@ -1233,6 +1234,11 @@ treePop = liftIO do [C.exp| void { TreePop() } |] +-- | Wraps @ImGui::SetNextItemOpen()@. +setNextItemOpen :: (MonadIO m) => CBool -> m () +setNextItemOpen is_open = liftIO do + [C.exp| void { SetNextItemOpen($(bool is_open)) } |] + -- -- | Wraps @ImGui::Selectable()@. -- selectable :: (MonadIO m) => CString -> m Bool -- selectable labelPtr = liftIO do