Skip to content

Commit ccdff36

Browse files
authored
Add wchar32 and disable-obsolete flags (#127)
1 parent af6ba9e commit ccdff36

File tree

2 files changed

+41
-10
lines changed

2 files changed

+41
-10
lines changed

dear-imgui.cabal

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extra-source-files:
2424
imgui/imconfig.h,
2525
imgui/LICENSE.txt
2626

27-
common build-flags
27+
common exe-flags
2828
if flag(debug)
2929
if os(linux)
3030
ghc-options: -Wall -g -rtsopts -dcore-lint -debug
@@ -50,7 +50,6 @@ common build-flags
5050
ghc-options: -Wall -O2
5151
cc-options: -O2
5252

53-
5453
source-repository head
5554
type: git
5655
location: https://github.com/haskell-game/dear-imgui.hs
@@ -111,6 +110,22 @@ flag examples
111110
manual:
112111
True
113112

113+
flag disable-obsolete
114+
description:
115+
Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
116+
default:
117+
False
118+
manual:
119+
True
120+
121+
flag use-wchar32
122+
description:
123+
Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...)
124+
default:
125+
True
126+
manual:
127+
True
128+
114129
common common
115130
build-depends:
116131
base
@@ -157,6 +172,13 @@ library
157172
, unliftio
158173
, vector
159174

175+
if flag(disable-obsolete)
176+
cxx-options: -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS
177+
178+
if flag(use-wchar32)
179+
cxx-options: -DIMGUI_USE_WCHAR32
180+
cpp-options: -DIMGUI_USE_WCHAR32
181+
160182
if flag(opengl2)
161183
exposed-modules:
162184
DearImGui.OpenGL2
@@ -273,7 +295,7 @@ library dear-imgui-generator
273295
>= 0.2.11 && < 0.3
274296

275297
executable test
276-
import: common, build-flags
298+
import: common, exe-flags
277299
main-is: Main.hs
278300
default-language: Haskell2010
279301
if (!flag(examples) || !flag(sdl) || !flag(opengl2))
@@ -282,7 +304,7 @@ executable test
282304
build-depends: base, sdl2, gl, dear-imgui, vector
283305

284306
executable glfw
285-
import: common, build-flags
307+
import: common, exe-flags
286308
main-is: Main.hs
287309
hs-source-dirs: examples/glfw
288310
default-language: Haskell2010
@@ -292,31 +314,31 @@ executable glfw
292314
build-depends: base, GLFW-b, gl, dear-imgui, managed
293315

294316
executable readme
295-
import: common, build-flags
317+
import: common, exe-flags
296318
main-is: Readme.hs
297319
hs-source-dirs: examples
298320
build-depends: sdl2, gl, dear-imgui, managed
299321
if (!flag(examples) || !flag(sdl) || !flag(opengl2))
300322
buildable: False
301323

302324
executable fonts
303-
import: common, build-flags
325+
import: common, exe-flags
304326
main-is: Main.hs
305327
hs-source-dirs: examples/fonts
306328
build-depends: sdl2, gl, dear-imgui, managed
307329
if (!flag(examples) || !flag(sdl) || !flag(opengl2))
308330
buildable: False
309331

310332
executable image
311-
import: common, build-flags
333+
import: common, exe-flags
312334
main-is: Image.hs
313335
hs-source-dirs: examples/sdl
314336
build-depends: sdl2, gl, dear-imgui, managed, vector
315337
if (!flag(examples) || !flag(sdl) || !flag(opengl2))
316338
buildable: False
317339

318340
executable vulkan
319-
import: common, build-flags
341+
import: common, exe-flags
320342
main-is: Main.hs
321343
other-modules: Attachments, Backend, Input, Util
322344
hs-source-dirs: examples/vulkan

src/DearImGui/Structs.hs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
{-# LANGUAGE DuplicateRecordFields #-}
22
{-# LANGUAGE NamedFieldPuns #-}
3+
{-# LANGUAGE CPP #-}
34

45
module DearImGui.Structs where
56

67
-- base
78
import Data.Word
8-
( Word32, Word16 )
9+
( Word32
10+
#ifndef IMGUI_USE_WCHAR32
11+
, Word16
12+
#endif
13+
)
14+
915
import Foreign
1016
( Storable(..), castPtr, plusPtr )
1117

@@ -96,5 +102,8 @@ data ImGuiListClipper
96102
type ImU32 = Word32
97103

98104
-- | Single wide character (used mostly in glyph management)
105+
#ifdef IMGUI_USE_WCHAR32
106+
type ImWchar = Word32
107+
#else
99108
type ImWchar = Word16
100-
-- FIXME: consider IMGUI_USE_WCHAR32
109+
#endif

0 commit comments

Comments
 (0)