Skip to content

Commit e2719a1

Browse files
authored
Bump to 1.91.9b (#217)
* Bump to 1.91.9b * Update changelog
1 parent ae366c1 commit e2719a1

File tree

12 files changed

+82
-54
lines changed

12 files changed

+82
-54
lines changed

ChangeLog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog for dear-imgui
22

3+
## [2.4.0]
4+
5+
- `imgui` updated to [1.91.9b].
6+
* Breaking: `ImTextureID` switched to a Word64 as a base type (was: pointer).
7+
+ Remove your *ToPtr casts and just use ImTextureID type (a Word64 alias).
8+
* Breaking: `setGlyphExtraSpacing` renamed to `setGlyphExtraAdvanceX`.
9+
* Breaking: Some flags got updated, consult the [changelog](https://github.com/ocornut/imgui/blob/v1.91.9b/docs/CHANGELOG.txt) for migration hints.
10+
311
## [2.3.1]
412

513
- Extended DragDrop API.
@@ -147,7 +155,9 @@ Initial Hackage release based on [1.83].
147155
[2.2.1]: https://github.com/haskell-game/dear-imgui.hs/tree/v2.2.1
148156
[2.3.0]: https://github.com/haskell-game/dear-imgui.hs/tree/v2.3.0
149157
[2.3.1]: https://github.com/haskell-game/dear-imgui.hs/tree/v2.3.1
158+
[2.4.0]: https://github.com/haskell-game/dear-imgui.hs/tree/v2.4.0
150159

160+
[1.91.9b]: https://github.com/ocornut/imgui/releases/tag/v1.91.9b
151161
[1.90.9]: https://github.com/ocornut/imgui/releases/tag/v1.90.9
152162
[1.89.9]: https://github.com/ocornut/imgui/releases/tag/v1.89.9
153163
[1.87]: https://github.com/ocornut/imgui/releases/tag/v1.87

dear-imgui.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cabal-version: 3.0
22

33
name: dear-imgui
4-
version: 2.3.1
4+
version: 2.4.0
55
author: Oliver Charles
66
77
license: BSD-3-Clause

examples/sdl/Image.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ mainLoop window textures flag = unlessQuit do
139139
let texture = if flag then fst textures else snd textures
140140
-- Drawing images require some backend-specific code.
141141
-- Meanwhile, we have to deal with raw bindings.
142-
let openGLtextureID = intPtrToPtr $ fromIntegral $ textureID texture
142+
let openGLtextureID = fromIntegral $ textureID texture
143143

144144
-- Build the GUI
145145
clicked <- withWindow "Image example" \open ->

examples/vulkan/Main.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ import qualified DearImGui.Vulkan as ImGui.Vulkan
8181
import qualified DearImGui.SDL as ImGui.SDL
8282
import qualified DearImGui.SDL.Vulkan as ImGui.SDL.Vulkan
8383
import Util (vmaVulkanFunctions)
84-
import Foreign (Ptr, castPtr, copyBytes, with, withForeignPtr, wordPtrToPtr, nullPtr)
84+
import Foreign (castPtr, copyBytes, with, withForeignPtr)
8585
import Foreign.C.String (withCString)
8686
import qualified DearImGui.Raw as ImGui.Raw
8787
import UnliftIO (MonadUnliftIO)
@@ -95,7 +95,7 @@ type Handler = LogMessage -> ResourceT IO ()
9595
deriving via ( ReaderT Handler (ResourceT IO) )
9696
instance MonadResource ( LoggingT LogMessage (ResourceT IO) )
9797

98-
gui :: MonadUnliftIO m => (ImGui.Raw.ImVec2, Ptr ()) -> m ImGui.DrawData
98+
gui :: MonadUnliftIO m => (ImGui.Raw.ImVec2, ImGui.Raw.ImTextureID) -> m ImGui.DrawData
9999
gui texture = do
100100
-- Prepare frame
101101
ImGui.Vulkan.vulkanNewFrame
@@ -505,7 +505,7 @@ app = do
505505
logDebug "Adding imgui texture"
506506
Vulkan.DescriptorSet ds <- ImGui.Vulkan.vulkanAddTexture sampler imageView Vulkan.IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
507507
let textureSize = ImGui.Raw.ImVec2 (fromIntegral textureWidth) (fromIntegral textureHeight)
508-
let texture = (textureSize, wordPtrToPtr $ fromIntegral ds)
508+
let texture = (textureSize, fromIntegral ds)
509509

510510
let
511511
mainLoop :: AppState m -> m ()

generator/DearImGui/Generator/Parser.hs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,11 @@ headers :: MonadParsec CustomParseError [Tok] m => m ( Headers () )
120120
headers = do
121121
_ <- skipManyTill anySingle ( namedSection "Header mess" )
122122

123-
_ <- skipManyTill anySingle ( namedSection "Forward declarations" )
123+
_ <- skipManyTill anySingle ( namedSection "Forward declarations and basic types" )
124124
( _structNames, enumNamesAndTypes ) <- forwardDeclarations
125125

126+
_ <- skipManyTill anySingle ( namedSection "Texture identifier (ImTextureID)" )
127+
126128
_ <- skipManyTill anySingle ( namedSection "Dear ImGui end-user API functions" )
127129

128130
_ <- skipManyTill anySingle ( namedSection "Flags & Enumerations" )
@@ -191,7 +193,16 @@ forwardDeclarations = do
191193
doc <- comment
192194
pure (typeName, (signed, width, doc))
193195
_ <- many comment
194-
structs <- many do
196+
structs1 <- many do
197+
-- // Forward declarations: ImDrawList, ImFontAtlas layer
198+
keyword "struct"
199+
structName <- identifier
200+
reservedSymbol ';'
201+
doc <- comment
202+
pure ( structName, doc )
203+
_ <- many comment
204+
structs2 <- many do
205+
-- // Forward declarations: ImGui layer
195206
keyword "struct"
196207
structName <- identifier
197208
reservedSymbol ';'
@@ -219,14 +230,15 @@ forwardDeclarations = do
219230
_ <- many comment
220231
pure ( enumName, ( ty, CommentText <$> Text.drop 2 . snd $ Text.breakOn "//" doc ) )
221232
-- Stopping after simple structs and enums for now.
222-
pure ( HashMap.fromList structs, HashMap.fromList (enums <> typedefs) )
233+
pure ( HashMap.fromList (structs1 <> structs2), HashMap.fromList (enums <> typedefs) )
223234

224235
cTypeName :: MonadParsec e [Tok] m => m TH.Name
225236
cTypeName =
226237
choice
227238
[ try $ (keyword "char") $> ''CChar
228239
, try $ (keyword "signed" >> keyword "int") $> ''CInt
229240
, try $ (keyword "unsigned" >> keyword "int") $> ''CUInt
241+
, try $ (keyword "unsigned" >> keyword "short") $> ''CUShort
230242
, try $ (keyword "unsigned" >> keyword "char") $> ''CUChar
231243
, try $ (identifier' "ImS8") $> ''CChar
232244
, try $ (identifier' "ImU8") $> ''CUChar
@@ -236,6 +248,7 @@ cTypeName =
236248
, try $ (identifier' "ImU32") $> ''CUInt
237249
, try $ (identifier' "ImS64") $> ''CLLong
238250
, try $ (identifier' "ImU64") $> ''CULLong
251+
, try $ (identifier' "ImTextureID") $> ''CULLong
239252
, keyword "int" $> ''CInt
240253
]
241254
<?> "cTypeName"

imgui

Submodule imgui updated 117 files

src/DearImGui/FontAtlas.hs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ module DearImGui.FontAtlas
5252
, oversampleH
5353
, oversampleV
5454
, pixelSnapH
55-
, glyphExtraSpacing
5655
, glyphOffset
5756
, glyphRanges
57+
, glyphExtraAdvanceX
5858
, glyphMinAdvanceX
5959
, glyphMaxAdvanceX
6060
, mergeMode
@@ -413,16 +413,6 @@ pixelSnapH value =
413413
ConfigSetup \fc ->
414414
FontConfig.setPixelSnapH fc (bool 0 1 value)
415415

416-
-- | Extra spacing (in pixels) between glyphs.
417-
--
418-
-- Only X axis is supported for now.
419-
--
420-
-- By default, it is @0, 0@
421-
glyphExtraSpacing :: (Float, Float) -> ConfigSetup
422-
glyphExtraSpacing (x, y) =
423-
ConfigSetup \fc ->
424-
Foreign.with (ImVec2 x y) (FontConfig.setGlyphExtraSpacing fc)
425-
426416
-- | Offset all glyphs from this font input.
427417
--
428418
-- By default, it is @0, 0@
@@ -443,6 +433,14 @@ glyphRanges value =
443433
ConfigSetup \fc ->
444434
FontConfig.setGlyphRanges fc value
445435

436+
-- | Extra spacing (in pixels) between glyphs.
437+
--
438+
-- By default, it is @0@
439+
glyphExtraAdvanceX :: Float -> ConfigSetup
440+
glyphExtraAdvanceX x =
441+
ConfigSetup \fc ->
442+
FontConfig.setGlyphExtraAdvanceX fc (CFloat x)
443+
446444
-- | Minimum AdvanceX for glyphs.
447445
--
448446
-- Set Min to align font icons, set both Min/Max to enforce mono-space font.

src/DearImGui/Raw.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -803,12 +803,12 @@ arrowButton strIdPtr dir = liftIO do
803803
-- See @examples/sdl/Image.hs@ for the whole process.
804804
--
805805
-- Wraps @ImGui::Image()@.
806-
image :: (MonadIO m) => Ptr () -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec4 -> Ptr ImVec4 -> m ()
807-
image userTextureIDPtr sizePtr uv0Ptr uv1Ptr tintColPtr borderColPtr = liftIO do
806+
image :: (MonadIO m) => ImTextureID -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec4 -> Ptr ImVec4 -> m ()
807+
image userTextureID sizePtr uv0Ptr uv1Ptr tintColPtr borderColPtr = liftIO do
808808
[C.exp|
809809
void {
810810
Image(
811-
$(void* userTextureIDPtr),
811+
$(ImTextureID userTextureID),
812812
*$(ImVec2* sizePtr),
813813
*$(ImVec2* uv0Ptr),
814814
*$(ImVec2* uv1Ptr),
@@ -823,13 +823,13 @@ image userTextureIDPtr sizePtr uv0Ptr uv1Ptr tintColPtr borderColPtr = liftIO do
823823
-- Negative @frame_padding@ uses default frame padding settings. Set to 0 for no padding.
824824
--
825825
-- Wraps @ImGui::ImageButton()@.
826-
imageButton :: (MonadIO m) => CString -> Ptr () -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec4 -> Ptr ImVec4 -> m Bool
827-
imageButton labelPtr userTextureIDPtr sizePtr uv0Ptr uv1Ptr bgColPtr tintColPtr = liftIO do
826+
imageButton :: (MonadIO m) => CString -> ImTextureID -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec4 -> Ptr ImVec4 -> m Bool
827+
imageButton labelPtr userTextureID sizePtr uv0Ptr uv1Ptr bgColPtr tintColPtr = liftIO do
828828
(0 /=) <$> [C.exp|
829829
bool {
830830
ImageButton(
831831
$(char* labelPtr),
832-
$(void* userTextureIDPtr),
832+
$(ImTextureID userTextureID),
833833
*$(ImVec2* sizePtr),
834834
*$(ImVec2* uv0Ptr),
835835
*$(ImVec2* uv1Ptr),

src/DearImGui/Raw/Context.hs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,22 @@ imguiContext :: Context
3030
imguiContext = mempty
3131
{ ctxTypesTable = enumerationsTypesTable <>
3232
Map.fromList
33-
[ ( TypeName "ImVec2", [t| ImVec2 |] )
34-
, ( TypeName "ImVec3", [t| ImVec3 |] )
35-
, ( TypeName "ImVec4", [t| ImVec4 |] )
36-
, ( TypeName "ImU32", [t| ImU32 |] )
37-
, ( TypeName "ImGuiID", [t| ImGuiID |] )
38-
, ( TypeName "ImWchar", [t| ImWchar |] )
39-
, ( TypeName "ImDrawList", [t| ImDrawList |] )
40-
, ( TypeName "ImGuiContext", [t| ImGuiContext |] )
33+
[ ( TypeName "ImDrawList", [t| ImDrawList |] )
4134
, ( TypeName "ImFont", [t| ImFont |] )
4235
, ( TypeName "ImFontConfig", [t| ImFontConfig |] )
4336
, ( TypeName "ImFontGlyphRangesBuilder", [t| ImFontGlyphRangesBuilder |] )
37+
, ( TypeName "ImGuiContext", [t| ImGuiContext |] )
38+
, ( TypeName "ImGuiID", [t| ImGuiID |] )
39+
, ( TypeName "ImGuiKeyChord", [t| Int |] )
4440
, ( TypeName "ImGuiListClipper", [t| ImGuiListClipper |] )
45-
, ( TypeName "ImGuiTableSortSpecs", [t| ImGuiTableSortSpecs |] )
4641
, ( TypeName "ImGuiPayload", [t| ImGuiPayload |] )
47-
, ( TypeName "ImGuiKeyChord", [t| Int |] )
42+
, ( TypeName "ImGuiTableSortSpecs", [t| ImGuiTableSortSpecs |] )
43+
, ( TypeName "ImTextureID", [t| ImTextureID |] )
44+
, ( TypeName "ImU32", [t| ImU32 |] )
45+
, ( TypeName "ImU64", [t| ImU64 |] )
46+
, ( TypeName "ImVec2", [t| ImVec2 |] )
47+
, ( TypeName "ImVec3", [t| ImVec3 |] )
48+
, ( TypeName "ImVec4", [t| ImVec4 |] )
49+
, ( TypeName "ImWchar", [t| ImWchar |] )
4850
]
4951
}

src/DearImGui/Raw/DrawList.hs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,12 @@ getClipRectMax (DrawList drawList) = liftIO do
199199
|]
200200

201201

202-
pushTextureID :: MonadIO m => DrawList -> Ptr () -> m ()
203-
pushTextureID (DrawList drawList) userTextureIDPtr = liftIO do
202+
pushTextureID :: MonadIO m => DrawList -> ImTextureID -> m ()
203+
pushTextureID (DrawList drawList) userTextureID = liftIO do
204204
[C.block|
205205
void {
206206
$(ImDrawList* drawList)->PushTextureID(
207-
$(void* userTextureIDPtr)
207+
$(ImTextureID userTextureID)
208208
);
209209
}
210210
|]
@@ -513,16 +513,16 @@ addBezierQuadratic (DrawList drawList) p1 p2 p3 col thickness numSegments = lift
513513
addImage
514514
:: MonadIO m
515515
=> DrawList
516-
-> Ptr ()
516+
-> ImTextureID
517517
-> Ptr ImVec2 -> Ptr ImVec2 -- Positions
518518
-> Ptr ImVec2 -> Ptr ImVec2 -- UVs
519519
-> ImU32
520520
-> m ()
521-
addImage (DrawList drawList) userTextureIDPtr p_min p_max uv_min uv_max col = liftIO do
521+
addImage (DrawList drawList) userTextureID p_min p_max uv_min uv_max col = liftIO do
522522
[C.block|
523523
void {
524524
$(ImDrawList* drawList)->AddImage(
525-
$(void* userTextureIDPtr),
525+
$(ImTextureID userTextureID),
526526
*$(ImVec2* p_min),
527527
*$(ImVec2* p_max),
528528
*$(ImVec2* uv_min),
@@ -535,16 +535,16 @@ addImage (DrawList drawList) userTextureIDPtr p_min p_max uv_min uv_max col = li
535535
addImageQuad
536536
:: MonadIO m
537537
=> DrawList
538-
-> Ptr ()
538+
-> ImTextureID
539539
-> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -- Positions
540540
-> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -- UVs
541541
-> ImU32
542542
-> m ()
543-
addImageQuad (DrawList drawList) userTextureIDPtr p1 p2 p3 p4 uv1 uv2 uv3 uv4 col = liftIO do
543+
addImageQuad (DrawList drawList) userTextureID p1 p2 p3 p4 uv1 uv2 uv3 uv4 col = liftIO do
544544
[C.block|
545545
void {
546546
$(ImDrawList* drawList)->AddImageQuad(
547-
$(void* userTextureIDPtr),
547+
$(ImTextureID userTextureID),
548548
*$(ImVec2* p1),
549549
*$(ImVec2* p2),
550550
*$(ImVec2* p3),
@@ -561,18 +561,18 @@ addImageQuad (DrawList drawList) userTextureIDPtr p1 p2 p3 p4 uv1 uv2 uv3 uv4 co
561561
addImageRounded
562562
:: MonadIO m
563563
=> DrawList
564-
-> Ptr ()
564+
-> ImTextureID
565565
-> Ptr ImVec2 -> Ptr ImVec2 -- Positions
566566
-> Ptr ImVec2 -> Ptr ImVec2 -- UVs
567567
-> ImU32
568568
-> CFloat
569569
-> ImDrawFlags
570570
-> m ()
571-
addImageRounded (DrawList drawList) userTextureIDPtr p_min p_max uv_min uv_max col rounding flags = liftIO do
571+
addImageRounded (DrawList drawList) userTextureID p_min p_max uv_min uv_max col rounding flags = liftIO do
572572
[C.block|
573573
void {
574574
$(ImDrawList* drawList)->AddImageRounded(
575-
$(void* userTextureIDPtr),
575+
$(ImTextureID userTextureID),
576576
*$(ImVec2* p_min),
577577
*$(ImVec2* p_max),
578578
*$(ImVec2* uv_min),

0 commit comments

Comments
 (0)