From ccdff36774870ff646b714e380d428017fd5306b Mon Sep 17 00:00:00 2001 From: Alexander Bondarenko <486682+dpwiz@users.noreply.github.com> Date: Sun, 13 Feb 2022 19:05:49 +0300 Subject: [PATCH] Add wchar32 and disable-obsolete flags (#127) --- dear-imgui.cabal | 38 ++++++++++++++++++++++++++++++-------- src/DearImGui/Structs.hs | 13 +++++++++++-- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/dear-imgui.cabal b/dear-imgui.cabal index fb65d7c..a5236a6 100644 --- a/dear-imgui.cabal +++ b/dear-imgui.cabal @@ -24,7 +24,7 @@ extra-source-files: imgui/imconfig.h, imgui/LICENSE.txt -common build-flags +common exe-flags if flag(debug) if os(linux) ghc-options: -Wall -g -rtsopts -dcore-lint -debug @@ -50,7 +50,6 @@ common build-flags ghc-options: -Wall -O2 cc-options: -O2 - source-repository head type: git location: https://github.com/haskell-game/dear-imgui.hs @@ -111,6 +110,22 @@ flag examples manual: True +flag disable-obsolete + description: + Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names. + default: + False + manual: + True + +flag use-wchar32 + description: + 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...) + default: + True + manual: + True + common common build-depends: base @@ -157,6 +172,13 @@ library , unliftio , vector + if flag(disable-obsolete) + cxx-options: -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS + + if flag(use-wchar32) + cxx-options: -DIMGUI_USE_WCHAR32 + cpp-options: -DIMGUI_USE_WCHAR32 + if flag(opengl2) exposed-modules: DearImGui.OpenGL2 @@ -273,7 +295,7 @@ library dear-imgui-generator >= 0.2.11 && < 0.3 executable test - import: common, build-flags + import: common, exe-flags main-is: Main.hs default-language: Haskell2010 if (!flag(examples) || !flag(sdl) || !flag(opengl2)) @@ -282,7 +304,7 @@ executable test build-depends: base, sdl2, gl, dear-imgui, vector executable glfw - import: common, build-flags + import: common, exe-flags main-is: Main.hs hs-source-dirs: examples/glfw default-language: Haskell2010 @@ -292,7 +314,7 @@ executable glfw build-depends: base, GLFW-b, gl, dear-imgui, managed executable readme - import: common, build-flags + import: common, exe-flags main-is: Readme.hs hs-source-dirs: examples build-depends: sdl2, gl, dear-imgui, managed @@ -300,7 +322,7 @@ executable readme buildable: False executable fonts - import: common, build-flags + import: common, exe-flags main-is: Main.hs hs-source-dirs: examples/fonts build-depends: sdl2, gl, dear-imgui, managed @@ -308,7 +330,7 @@ executable fonts buildable: False executable image - import: common, build-flags + import: common, exe-flags main-is: Image.hs hs-source-dirs: examples/sdl build-depends: sdl2, gl, dear-imgui, managed, vector @@ -316,7 +338,7 @@ executable image buildable: False executable vulkan - import: common, build-flags + import: common, exe-flags main-is: Main.hs other-modules: Attachments, Backend, Input, Util hs-source-dirs: examples/vulkan diff --git a/src/DearImGui/Structs.hs b/src/DearImGui/Structs.hs index 1b99b4b..f4acfe7 100644 --- a/src/DearImGui/Structs.hs +++ b/src/DearImGui/Structs.hs @@ -1,11 +1,17 @@ {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE CPP #-} module DearImGui.Structs where -- base import Data.Word - ( Word32, Word16 ) + ( Word32 +#ifndef IMGUI_USE_WCHAR32 + , Word16 +#endif + ) + import Foreign ( Storable(..), castPtr, plusPtr ) @@ -96,5 +102,8 @@ data ImGuiListClipper type ImU32 = Word32 -- | Single wide character (used mostly in glyph management) +#ifdef IMGUI_USE_WCHAR32 +type ImWchar = Word32 +#else type ImWchar = Word16 --- FIXME: consider IMGUI_USE_WCHAR32 +#endif