From 72b496f931a7c474039eb1b84d999d9837166013 Mon Sep 17 00:00:00 2001 From: Axis Sivitz Date: Tue, 12 Aug 2025 13:35:06 -0400 Subject: [PATCH 1/3] Update imgui dependency to 1.91.3 (Released 2024-10-04) This is needed for SDL3 support --- generator/DearImGui/Generator/Parser.hs | 4 +++- imgui | 2 +- src/DearImGui/Raw.hs | 7 +++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/generator/DearImGui/Generator/Parser.hs b/generator/DearImGui/Generator/Parser.hs index b11a968..3254e56 100644 --- a/generator/DearImGui/Generator/Parser.hs +++ b/generator/DearImGui/Generator/Parser.hs @@ -143,7 +143,7 @@ headers = do ) ( try $ many comment >> keyword "struct" >> identifier) - _ <- skipManyTill anySingle ( namedSection "Helpers: Memory allocations macros, ImVector<>" ) + _ <- skipManyTill anySingle ( namedSection "Helpers: Debug log, memory allocations macros, ImVector<>" ) _ <- skipManyTill anySingle ( namedSection "ImGuiStyle" ) @@ -153,6 +153,8 @@ headers = do _ <- skipManyTill anySingle ( namedSection "Helpers (ImGuiOnceUponAFrame, ImGuiTextFilter, ImGuiTextBuffer, ImGuiStorage, ImGuiListClipper, Math Operators, ImColor)" ) + _ <- skipManyTill anySingle ( namedSection "Multi-Select API flags and structures (ImGuiMultiSelectFlags, ImGuiSelectionRequestType, ImGuiSelectionRequest, ImGuiMultiSelectIO, ImGuiSelectionBasicStorage)" ) + _ <- skipManyTill anySingle ( namedSection "Drawing API (ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListSplitter, ImDrawListFlags, ImDrawList, ImDrawData)" ) skipManyTill anySingle ( try . lookAhead $ many comment *> keyword "enum" ) drawingEnums <- many ( enumeration enumNamesAndTypes ) diff --git a/imgui b/imgui index cb16be3..cb16568 160000 --- a/imgui +++ b/imgui @@ -1 +1 @@ -Subproject commit cb16be3a3fc1f9cd146ae24d52b615f8a05fa93d +Subproject commit cb16568fca5297512ff6a8f3b877f461c4323fbe diff --git a/src/DearImGui/Raw.hs b/src/DearImGui/Raw.hs index ff89810..b582578 100644 --- a/src/DearImGui/Raw.hs +++ b/src/DearImGui/Raw.hs @@ -823,23 +823,22 @@ image userTextureIDPtr sizePtr uv0Ptr uv1Ptr tintColPtr borderColPtr = liftIO do -- Negative @frame_padding@ uses default frame padding settings. Set to 0 for no padding. -- -- Wraps @ImGui::ImageButton()@. -imageButton :: (MonadIO m) => Ptr () -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> CInt -> Ptr ImVec4 -> Ptr ImVec4 -> m Bool -imageButton userTextureIDPtr sizePtr uv0Ptr uv1Ptr framePadding bgColPtr tintColPtr = liftIO do +imageButton :: (MonadIO m) => CString -> Ptr () -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec4 -> Ptr ImVec4 -> m Bool +imageButton labelPtr userTextureIDPtr sizePtr uv0Ptr uv1Ptr bgColPtr tintColPtr = liftIO do (0 /=) <$> [C.exp| bool { ImageButton( + $(char* labelPtr), $(void* userTextureIDPtr), *$(ImVec2* sizePtr), *$(ImVec2* uv0Ptr), *$(ImVec2* uv1Ptr), - $(int framePadding), *$(ImVec4* bgColPtr), *$(ImVec4* tintColPtr) ) } |] - -- | Wraps @ImGui::Checkbox()@. checkbox :: (MonadIO m) => CString -> Ptr CBool -> m Bool checkbox labelPtr boolPtr = liftIO do From 44f4c28704b99006527501b610afab0ac6b7be84 Mon Sep 17 00:00:00 2001 From: Axis Sivitz Date: Tue, 12 Aug 2025 14:09:50 -0400 Subject: [PATCH 2/3] Fix examples for imageButton API update --- examples/sdl/Image.hs | 2 +- examples/vulkan/Main.hs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/sdl/Image.hs b/examples/sdl/Image.hs index 3e87c62..9b7f78f 100644 --- a/examples/sdl/Image.hs +++ b/examples/sdl/Image.hs @@ -152,7 +152,7 @@ mainLoop window textures flag = unlessQuit do Foreign.with (ImVec2 1 1) \uv1Ptr -> Foreign.with (ImVec4 1 1 1 1) \tintColPtr -> Foreign.with (ImVec4 1 1 1 1) \bgColPtr -> - Raw.imageButton openGLtextureID sizePtr uv0Ptr uv1Ptr (-1) bgColPtr tintColPtr + Raw.imageButton nullPtr openGLtextureID sizePtr uv0Ptr uv1Ptr bgColPtr tintColPtr else pure False diff --git a/examples/vulkan/Main.hs b/examples/vulkan/Main.hs index d9e9eef..320174a 100644 --- a/examples/vulkan/Main.hs +++ b/examples/vulkan/Main.hs @@ -81,7 +81,7 @@ import qualified DearImGui.Vulkan as ImGui.Vulkan import qualified DearImGui.SDL as ImGui.SDL import qualified DearImGui.SDL.Vulkan as ImGui.SDL.Vulkan import Util (vmaVulkanFunctions) -import Foreign (Ptr, castPtr, copyBytes, with, withForeignPtr, wordPtrToPtr) +import Foreign (Ptr, castPtr, copyBytes, with, withForeignPtr, wordPtrToPtr, nullPtr) import qualified DearImGui.Raw as ImGui.Raw import UnliftIO (MonadUnliftIO) import qualified Vulkan.CStruct.Extends as Vulkan @@ -111,11 +111,11 @@ gui texture = do with (ImGui.Raw.ImVec4 1 1 1 1) \tintColPtr -> with (ImGui.Raw.ImVec4 1 1 1 1) \bgColPtr -> ImGui.Raw.imageButton + nullPtr (snd texture) sizePtr uv0Ptr uv1Ptr - (-1) bgColPtr tintColPtr From 508d332da0d8546831459c02c74f986a74cd8511 Mon Sep 17 00:00:00 2001 From: IC Rainbow Date: Sat, 30 Aug 2025 21:19:45 +0300 Subject: [PATCH 3/3] Fix segfault from passing 0 to a mandatory id field --- examples/sdl/Image.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/sdl/Image.hs b/examples/sdl/Image.hs index 9b7f78f..107a486 100644 --- a/examples/sdl/Image.hs +++ b/examples/sdl/Image.hs @@ -23,6 +23,7 @@ import qualified SDL as SDL -- For the texture creation import Foreign +import Foreign.C.String import qualified Data.Vector.Storable as VS data Texture = Texture @@ -152,7 +153,8 @@ mainLoop window textures flag = unlessQuit do Foreign.with (ImVec2 1 1) \uv1Ptr -> Foreign.with (ImVec4 1 1 1 1) \tintColPtr -> Foreign.with (ImVec4 1 1 1 1) \bgColPtr -> - Raw.imageButton nullPtr openGLtextureID sizePtr uv0Ptr uv1Ptr bgColPtr tintColPtr + withCString "##btn" \idPtr -> + Raw.imageButton idPtr openGLtextureID sizePtr uv0Ptr uv1Ptr bgColPtr tintColPtr else pure False