mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2025-07-04 20:18:47 +02:00
Compare commits
13 Commits
sharedLib
...
imgui-1.89
Author | SHA1 | Date | |
---|---|---|---|
6195b32afd | |||
8368192370 | |||
ea3ad959f9 | |||
0cc654f190 | |||
8697aa3a0a | |||
802bdb72fe | |||
69a463d98b | |||
9bb66f0113 | |||
68e30d98ad | |||
52142bbf7e | |||
d933248a2c | |||
258777f8c7 | |||
cd99938f97 |
8
.github/workflows/build.yaml
vendored
8
.github/workflows/build.yaml
vendored
@ -4,19 +4,19 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2.3.4
|
- uses: actions/checkout@v2.4.0
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
submodules: true
|
submodules: true
|
||||||
|
|
||||||
- uses: cachix/install-nix-action@v16
|
- uses: cachix/install-nix-action@v20
|
||||||
with:
|
with:
|
||||||
nix_path: nixpkgs=channel:nixos-unstable
|
nix_path: nixpkgs=channel:nixos-unstable
|
||||||
|
|
||||||
- uses: cachix/cachix-action@v10
|
- uses: cachix/cachix-action@v12
|
||||||
with:
|
with:
|
||||||
name: hs-dear-imgui
|
name: hs-dear-imgui
|
||||||
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
||||||
|
|
||||||
- run: nix-build --version
|
- run: nix-build --version
|
||||||
- run: nix-build -A hsPkgs.dear-imgui.components.exes
|
- run: nix-build -A hsPkgs.dear-imgui.components.exes
|
||||||
|
14
ChangeLog.md
14
ChangeLog.md
@ -1,5 +1,17 @@
|
|||||||
# Changelog for dear-imgui
|
# Changelog for dear-imgui
|
||||||
|
|
||||||
|
## [2.1.3]
|
||||||
|
|
||||||
|
- Fixed off-by-1 in internal Text wrapper.
|
||||||
|
- Fixed sliderFloat* Raw calls
|
||||||
|
- Added `formatPtr` to Raw.dragFloat* and Raw.sliderFloat*
|
||||||
|
|
||||||
|
## [2.1.2]
|
||||||
|
|
||||||
|
- Fixed glfw example build flags.
|
||||||
|
- Added `plotLines`.
|
||||||
|
- Added `setNextItemOpen`.
|
||||||
|
|
||||||
## [2.1.1]
|
## [2.1.1]
|
||||||
|
|
||||||
- Build flag fix for MacOS.
|
- Build flag fix for MacOS.
|
||||||
@ -93,6 +105,8 @@ Initial Hackage release based on [1.83].
|
|||||||
[2.0.0]: https://github.com/haskell-game/dear-imgui.hs/tree/v2.0.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.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
|
[2.1.1]: https://github.com/haskell-game/dear-imgui.hs/tree/v2.1.1
|
||||||
|
[2.1.2]: https://github.com/haskell-game/dear-imgui.hs/tree/v2.1.2
|
||||||
|
[2.1.3]: https://github.com/haskell-game/dear-imgui.hs/tree/v2.1.3
|
||||||
|
|
||||||
[1.87]: https://github.com/ocornut/imgui/releases/tag/v1.87
|
[1.87]: https://github.com/ocornut/imgui/releases/tag/v1.87
|
||||||
[1.86]: https://github.com/ocornut/imgui/releases/tag/v1.86
|
[1.86]: https://github.com/ocornut/imgui/releases/tag/v1.86
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
packages: *.cabal
|
packages: *.cabal
|
||||||
package dear-imgui
|
package dear-imgui
|
||||||
flags: +sdl2 +glfw +opengl2 +opengl3 +vulkan +examples
|
flags: +sdl +glfw +opengl2 +opengl3 +vulkan +examples
|
||||||
ghc-options: -Wall -Wcompat -fno-warn-unused-do-bind
|
ghc-options: -Wall -Wcompat -fno-warn-unused-do-bind
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
cabal-version: 3.0
|
cabal-version: 3.0
|
||||||
|
|
||||||
name: dear-imgui
|
name: dear-imgui
|
||||||
version: 2.1.1
|
version: 2.1.3
|
||||||
author: Oliver Charles
|
author: Oliver Charles
|
||||||
maintainer: ollie@ocharles.org.uk, aenor.realm@gmail.com
|
maintainer: ollie@ocharles.org.uk, aenor.realm@gmail.com
|
||||||
license: BSD-3-Clause
|
license: BSD-3-Clause
|
||||||
@ -140,7 +140,7 @@ flag use-ImDrawIdx32
|
|||||||
common common
|
common common
|
||||||
build-depends:
|
build-depends:
|
||||||
base
|
base
|
||||||
>= 4.12 && < 4.17
|
>= 4.12 && < 4.19
|
||||||
default-language:
|
default-language:
|
||||||
Haskell2010
|
Haskell2010
|
||||||
|
|
||||||
@ -159,8 +159,8 @@ library
|
|||||||
DearImGui.Raw.Font.GlyphRanges
|
DearImGui.Raw.Font.GlyphRanges
|
||||||
DearImGui.Raw.IO
|
DearImGui.Raw.IO
|
||||||
DearImGui.Raw.ListClipper
|
DearImGui.Raw.ListClipper
|
||||||
|
DearImGui.Raw.Context
|
||||||
other-modules:
|
other-modules:
|
||||||
DearImGui.Context
|
|
||||||
DearImGui.Enums
|
DearImGui.Enums
|
||||||
DearImGui.Structs
|
DearImGui.Structs
|
||||||
cxx-options: -std=c++11
|
cxx-options: -std=c++11
|
||||||
@ -243,7 +243,7 @@ library
|
|||||||
build-depends:
|
build-depends:
|
||||||
sdl2
|
sdl2
|
||||||
cxx-sources:
|
cxx-sources:
|
||||||
imgui/backends/imgui_impl_sdl.cpp
|
imgui/backends/imgui_impl_sdl2.cpp
|
||||||
|
|
||||||
if os(windows) || os(darwin)
|
if os(windows) || os(darwin)
|
||||||
extra-libraries:
|
extra-libraries:
|
||||||
@ -291,7 +291,7 @@ library dear-imgui-generator
|
|||||||
, DearImGui.Generator.Types
|
, DearImGui.Generator.Types
|
||||||
build-depends:
|
build-depends:
|
||||||
template-haskell
|
template-haskell
|
||||||
>= 2.15 && < 2.19
|
>= 2.15 && < 2.21
|
||||||
, containers
|
, containers
|
||||||
^>= 0.6.2.1
|
^>= 0.6.2.1
|
||||||
, directory
|
, directory
|
||||||
@ -311,7 +311,7 @@ library dear-imgui-generator
|
|||||||
, th-lift
|
, th-lift
|
||||||
>= 0.7 && < 0.9
|
>= 0.7 && < 0.9
|
||||||
, transformers
|
, transformers
|
||||||
>= 0.5.6 && < 0.6
|
>= 0.5.6 && < 0.7
|
||||||
, unordered-containers
|
, unordered-containers
|
||||||
>= 0.2.11 && < 0.3
|
>= 0.2.11 && < 0.3
|
||||||
|
|
||||||
@ -355,7 +355,7 @@ executable image
|
|||||||
main-is: Image.hs
|
main-is: Image.hs
|
||||||
hs-source-dirs: examples/sdl
|
hs-source-dirs: examples/sdl
|
||||||
build-depends: sdl2, gl, dear-imgui, managed, vector
|
build-depends: sdl2, gl, dear-imgui, managed, vector
|
||||||
if (!flag(examples) || !flag(sdl) || !flag(opengl2))
|
if (!flag(examples) || !flag(sdl) || !flag(opengl3))
|
||||||
buildable: False
|
buildable: False
|
||||||
|
|
||||||
executable vulkan
|
executable vulkan
|
||||||
@ -382,7 +382,7 @@ executable vulkan
|
|||||||
, text-short
|
, text-short
|
||||||
^>= 0.1.3
|
^>= 0.1.3
|
||||||
, transformers
|
, transformers
|
||||||
^>= 0.5.6.2
|
>= 0.5.6 && < 0.7
|
||||||
, unliftio
|
, unliftio
|
||||||
>= 0.2.13 && < 0.2.19
|
>= 0.2.13 && < 0.2.19
|
||||||
, unliftio-core
|
, unliftio-core
|
||||||
@ -390,8 +390,9 @@ executable vulkan
|
|||||||
, vector
|
, vector
|
||||||
^>= 0.12.1.2
|
^>= 0.12.1.2
|
||||||
, vulkan
|
, vulkan
|
||||||
^>= 3.9
|
>= 3.12
|
||||||
, vulkan-utils
|
, vulkan-utils
|
||||||
^>= 0.4.1
|
>= 0.5
|
||||||
, VulkanMemoryAllocator
|
, VulkanMemoryAllocator
|
||||||
|
>= 0.7.1
|
||||||
, JuicyPixels
|
, JuicyPixels
|
||||||
|
@ -60,7 +60,7 @@ import Data.Text
|
|||||||
( Text )
|
( Text )
|
||||||
import qualified Data.Text as Text
|
import qualified Data.Text as Text
|
||||||
( all, any, breakOn, drop, dropWhile, dropWhileEnd
|
( all, any, breakOn, drop, dropWhile, dropWhileEnd
|
||||||
, length, stripPrefix, unlines, unpack
|
, length, stripPrefix, unlines, unpack, pack
|
||||||
)
|
)
|
||||||
|
|
||||||
-- transformers
|
-- transformers
|
||||||
@ -81,6 +81,8 @@ import DearImGui.Generator.Tokeniser
|
|||||||
import DearImGui.Generator.Types
|
import DearImGui.Generator.Types
|
||||||
( Comment(..), Enumeration(..), Headers(..) )
|
( Comment(..), Enumeration(..), Headers(..) )
|
||||||
|
|
||||||
|
import qualified Text.Show as Text
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Parse error type.
|
-- Parse error type.
|
||||||
|
|
||||||
@ -90,7 +92,9 @@ data CustomParseError
|
|||||||
, problems :: ![Text]
|
, problems :: ![Text]
|
||||||
}
|
}
|
||||||
| MissingForwardDeclaration
|
| MissingForwardDeclaration
|
||||||
{ enumName :: !Text }
|
{ enumName :: !Text
|
||||||
|
, library :: HashMap Text ( TH.Name, Comment )
|
||||||
|
}
|
||||||
| UnexpectedSection
|
| UnexpectedSection
|
||||||
{ sectionName :: !Text
|
{ sectionName :: !Text
|
||||||
, problem :: ![Text]
|
, problem :: ![Text]
|
||||||
@ -101,8 +105,9 @@ instance ShowErrorComponent CustomParseError where
|
|||||||
showErrorComponent ( Couldn'tLookupEnumValues { enumName, problems } ) = Text.unpack $
|
showErrorComponent ( Couldn'tLookupEnumValues { enumName, problems } ) = Text.unpack $
|
||||||
"Couldn't lookup the following values in enum " <> enumName <> ":\n"
|
"Couldn't lookup the following values in enum " <> enumName <> ":\n"
|
||||||
<> Text.unlines ( map ( " - " <> ) problems )
|
<> Text.unlines ( map ( " - " <> ) problems )
|
||||||
showErrorComponent ( MissingForwardDeclaration { enumName } ) = Text.unpack $
|
showErrorComponent ( MissingForwardDeclaration { enumName, library } ) = Text.unpack $
|
||||||
"Missing forward declaration for enum named " <> enumName
|
"Missing forward declaration for enum named " <> enumName <> "\n"
|
||||||
|
<> "In Library: " <> Text.pack ( Text.show library)
|
||||||
showErrorComponent ( UnexpectedSection { sectionName, problem } ) = Text.unpack $
|
showErrorComponent ( UnexpectedSection { sectionName, problem } ) = Text.unpack $
|
||||||
"Unexpected section name.\n\
|
"Unexpected section name.\n\
|
||||||
\Expected: " <> sectionName <> "\n\
|
\Expected: " <> sectionName <> "\n\
|
||||||
@ -124,6 +129,7 @@ headers = do
|
|||||||
( _defines, basicEnums ) <- partitionEithers <$>
|
( _defines, basicEnums ) <- partitionEithers <$>
|
||||||
manyTill
|
manyTill
|
||||||
( ( Left <$> try ignoreDefine )
|
( ( Left <$> try ignoreDefine )
|
||||||
|
<|> ( Left <$> try cppConditional )
|
||||||
<|> ( Right <$> enumeration enumNamesAndTypes )
|
<|> ( Right <$> enumeration enumNamesAndTypes )
|
||||||
)
|
)
|
||||||
( namedSection "Helpers: Memory allocations macros, ImVector<>" )
|
( namedSection "Helpers: Memory allocations macros, ImVector<>" )
|
||||||
@ -134,7 +140,7 @@ headers = do
|
|||||||
|
|
||||||
_ <- skipManyTill anySingle ( namedSection "Misc data structures" )
|
_ <- skipManyTill anySingle ( namedSection "Misc data structures" )
|
||||||
|
|
||||||
_ <- skipManyTill anySingle ( namedSection "Helpers (ImGuiOnceUponAFrame, ImGuiTextFilter, ImGuiTextBuffer, ImGuiStorage, ImGuiListClipper, ImColor)" )
|
_ <- skipManyTill anySingle ( namedSection "Helpers (ImGuiOnceUponAFrame, ImGuiTextFilter, ImGuiTextBuffer, ImGuiStorage, ImGuiListClipper, Math Operators, ImColor)" )
|
||||||
|
|
||||||
_ <- skipManyTill anySingle ( namedSection "Drawing API (ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListSplitter, ImDrawListFlags, ImDrawList, ImDrawData)" )
|
_ <- skipManyTill anySingle ( namedSection "Drawing API (ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListSplitter, ImDrawListFlags, ImDrawList, ImDrawData)" )
|
||||||
skipManyTill anySingle ( try . lookAhead $ many comment *> keyword "enum" )
|
skipManyTill anySingle ( try . lookAhead $ many comment *> keyword "enum" )
|
||||||
@ -171,14 +177,24 @@ forwardDeclarations = do
|
|||||||
pure ( structName, doc )
|
pure ( structName, doc )
|
||||||
_ <- many comment
|
_ <- many comment
|
||||||
enums <- many do
|
enums <- many do
|
||||||
|
keyword "enum"
|
||||||
|
enumName <- identifier
|
||||||
|
symbol ":"
|
||||||
|
ty <- cTypeName
|
||||||
|
reservedSymbol ';'
|
||||||
|
doc <- commentText <$> comment
|
||||||
|
pure ( enumName, ( ty, CommentText <$> Text.drop 2 . snd $ Text.breakOn "//" doc ) )
|
||||||
|
_ <- many comment
|
||||||
|
typedefs <- many do
|
||||||
keyword "typedef"
|
keyword "typedef"
|
||||||
ty <- cTypeName
|
ty <- cTypeName
|
||||||
enumName <- identifier
|
enumName <- identifier
|
||||||
reservedSymbol ';'
|
reservedSymbol ';'
|
||||||
doc <- commentText <$> comment
|
doc <- commentText <$> comment
|
||||||
|
_ <- many comment
|
||||||
pure ( enumName, ( ty, CommentText <$> Text.drop 2 . snd $ Text.breakOn "//" doc ) )
|
pure ( enumName, ( ty, CommentText <$> Text.drop 2 . snd $ Text.breakOn "//" doc ) )
|
||||||
-- Stopping after simple structs and enums for now.
|
-- Stopping after simple structs and enums for now.
|
||||||
pure ( HashMap.fromList structs, HashMap.fromList enums )
|
pure ( HashMap.fromList structs, HashMap.fromList (enums <> typedefs) )
|
||||||
|
|
||||||
cTypeName :: MonadParsec e [Tok] m => m TH.Name
|
cTypeName :: MonadParsec e [Tok] m => m TH.Name
|
||||||
cTypeName = keyword "int" $> ''CInt
|
cTypeName = keyword "int" $> ''CInt
|
||||||
@ -200,6 +216,7 @@ enumeration enumNamesAndTypes = do
|
|||||||
keyword "enum"
|
keyword "enum"
|
||||||
pure inlineDocs
|
pure inlineDocs
|
||||||
fullEnumName <- identifier
|
fullEnumName <- identifier
|
||||||
|
_ <- try $ (symbol ":" >> cTypeName >> pure ()) <|> pure ()
|
||||||
let
|
let
|
||||||
enumName :: Text
|
enumName :: Text
|
||||||
enumName = Text.dropWhileEnd ( == '_' ) fullEnumName
|
enumName = Text.dropWhileEnd ( == '_' ) fullEnumName
|
||||||
@ -207,7 +224,7 @@ enumeration enumNamesAndTypes = do
|
|||||||
enumTypeName = ()
|
enumTypeName = ()
|
||||||
( underlyingType, forwardDoc ) <- case HashMap.lookup enumName enumNamesAndTypes of
|
( underlyingType, forwardDoc ) <- case HashMap.lookup enumName enumNamesAndTypes of
|
||||||
Just res -> pure res
|
Just res -> pure res
|
||||||
Nothing -> customFailure ( MissingForwardDeclaration { enumName } )
|
Nothing -> customFailure ( MissingForwardDeclaration { enumName, library=enumNamesAndTypes } )
|
||||||
let
|
let
|
||||||
docs :: [Comment]
|
docs :: [Comment]
|
||||||
docs = forwardDoc : CommentText "" : inlineDocs
|
docs = forwardDoc : CommentText "" : inlineDocs
|
||||||
|
2
imgui
2
imgui
Submodule imgui updated: 9aae45eb4a...d4ddc46e77
@ -110,6 +110,7 @@ module DearImGui
|
|||||||
, Raw.endGroup
|
, Raw.endGroup
|
||||||
|
|
||||||
, setCursorPos
|
, setCursorPos
|
||||||
|
, Raw.getCursorPos
|
||||||
, Raw.alignTextToFramePadding
|
, Raw.alignTextToFramePadding
|
||||||
|
|
||||||
-- * ID stack
|
-- * ID stack
|
||||||
@ -646,7 +647,7 @@ dragFloat desc ref speed minValue maxValue = liftIO do
|
|||||||
currentValue <- get ref
|
currentValue <- get ref
|
||||||
with (realToFrac currentValue) \floatPtr -> do
|
with (realToFrac currentValue) \floatPtr -> do
|
||||||
changed <- Text.withCString desc \descPtr ->
|
changed <- Text.withCString desc \descPtr ->
|
||||||
Raw.dragFloat descPtr floatPtr (CFloat speed) (CFloat minValue) (CFloat maxValue)
|
Raw.dragFloat descPtr floatPtr (CFloat speed) (CFloat minValue) (CFloat maxValue) nullPtr
|
||||||
|
|
||||||
when changed do
|
when changed do
|
||||||
newValue <- peek floatPtr
|
newValue <- peek floatPtr
|
||||||
@ -661,7 +662,7 @@ dragFloat2 desc ref speed minValue maxValue = liftIO do
|
|||||||
(x, y) <- get ref
|
(x, y) <- get ref
|
||||||
withArray [ realToFrac x, realToFrac y ] \floatPtr -> do
|
withArray [ realToFrac x, realToFrac y ] \floatPtr -> do
|
||||||
changed <- Text.withCString desc \descPtr ->
|
changed <- Text.withCString desc \descPtr ->
|
||||||
Raw.dragFloat2 descPtr floatPtr (CFloat speed) (CFloat minValue) (CFloat maxValue)
|
Raw.dragFloat2 descPtr floatPtr (CFloat speed) (CFloat minValue) (CFloat maxValue) nullPtr
|
||||||
|
|
||||||
when changed do
|
when changed do
|
||||||
[x', y'] <- peekArray 2 floatPtr
|
[x', y'] <- peekArray 2 floatPtr
|
||||||
@ -675,7 +676,7 @@ dragFloat3 desc ref speed minValue maxValue = liftIO do
|
|||||||
(x, y, z) <- get ref
|
(x, y, z) <- get ref
|
||||||
withArray [ realToFrac x, realToFrac y, realToFrac z ] \floatPtr -> do
|
withArray [ realToFrac x, realToFrac y, realToFrac z ] \floatPtr -> do
|
||||||
changed <- Text.withCString desc \descPtr ->
|
changed <- Text.withCString desc \descPtr ->
|
||||||
Raw.dragFloat3 descPtr floatPtr (CFloat speed) (CFloat minValue) (CFloat maxValue)
|
Raw.dragFloat3 descPtr floatPtr (CFloat speed) (CFloat minValue) (CFloat maxValue) nullPtr
|
||||||
|
|
||||||
when changed do
|
when changed do
|
||||||
[x', y', z'] <- peekArray 3 floatPtr
|
[x', y', z'] <- peekArray 3 floatPtr
|
||||||
@ -690,7 +691,7 @@ dragFloat4 desc ref speed minValue maxValue = liftIO do
|
|||||||
(x, y, z, u) <- get ref
|
(x, y, z, u) <- get ref
|
||||||
withArray [ realToFrac x, realToFrac y, realToFrac z, realToFrac u ] \floatPtr -> do
|
withArray [ realToFrac x, realToFrac y, realToFrac z, realToFrac u ] \floatPtr -> do
|
||||||
changed <- Text.withCString desc \descPtr ->
|
changed <- Text.withCString desc \descPtr ->
|
||||||
Raw.dragFloat4 descPtr floatPtr (CFloat speed) (CFloat minValue) (CFloat maxValue)
|
Raw.dragFloat4 descPtr floatPtr (CFloat speed) (CFloat minValue) (CFloat maxValue) nullPtr
|
||||||
|
|
||||||
when changed do
|
when changed do
|
||||||
[x', y', z', u'] <- peekArray 4 floatPtr
|
[x', y', z', u'] <- peekArray 4 floatPtr
|
||||||
@ -969,7 +970,7 @@ sliderFloat desc ref minValue maxValue = liftIO do
|
|||||||
currentValue <- get ref
|
currentValue <- get ref
|
||||||
with (realToFrac currentValue) \floatPtr -> do
|
with (realToFrac currentValue) \floatPtr -> do
|
||||||
changed <- Text.withCString desc \descPtr ->
|
changed <- Text.withCString desc \descPtr ->
|
||||||
Raw.sliderFloat descPtr floatPtr (CFloat minValue) (CFloat maxValue)
|
Raw.sliderFloat descPtr floatPtr (CFloat minValue) (CFloat maxValue) nullPtr
|
||||||
|
|
||||||
when changed do
|
when changed do
|
||||||
newValue <- peek floatPtr
|
newValue <- peek floatPtr
|
||||||
@ -983,7 +984,7 @@ sliderFloat2 desc ref minValue maxValue = liftIO do
|
|||||||
(x, y) <- get ref
|
(x, y) <- get ref
|
||||||
withArray [ realToFrac x, realToFrac y ] \floatPtr -> do
|
withArray [ realToFrac x, realToFrac y ] \floatPtr -> do
|
||||||
changed <- Text.withCString desc \descPtr ->
|
changed <- Text.withCString desc \descPtr ->
|
||||||
Raw.sliderFloat descPtr floatPtr (CFloat minValue) (CFloat maxValue)
|
Raw.sliderFloat2 descPtr floatPtr (CFloat minValue) (CFloat maxValue) nullPtr
|
||||||
|
|
||||||
when changed do
|
when changed do
|
||||||
[x', y'] <- peekArray 2 floatPtr
|
[x', y'] <- peekArray 2 floatPtr
|
||||||
@ -997,7 +998,7 @@ sliderFloat3 desc ref minValue maxValue = liftIO do
|
|||||||
(x, y, z) <- get ref
|
(x, y, z) <- get ref
|
||||||
withArray [ realToFrac x, realToFrac y, realToFrac z ] \floatPtr -> do
|
withArray [ realToFrac x, realToFrac y, realToFrac z ] \floatPtr -> do
|
||||||
changed <- Text.withCString desc \descPtr ->
|
changed <- Text.withCString desc \descPtr ->
|
||||||
Raw.sliderFloat descPtr floatPtr (CFloat minValue) (CFloat maxValue)
|
Raw.sliderFloat3 descPtr floatPtr (CFloat minValue) (CFloat maxValue) nullPtr
|
||||||
|
|
||||||
when changed do
|
when changed do
|
||||||
[x', y', z'] <- peekArray 3 floatPtr
|
[x', y', z'] <- peekArray 3 floatPtr
|
||||||
@ -1011,7 +1012,7 @@ sliderFloat4 desc ref minValue maxValue = liftIO do
|
|||||||
(x, y, z, u) <- get ref
|
(x, y, z, u) <- get ref
|
||||||
withArray [ realToFrac x, realToFrac y, realToFrac z, realToFrac u ] \floatPtr -> do
|
withArray [ realToFrac x, realToFrac y, realToFrac z, realToFrac u ] \floatPtr -> do
|
||||||
changed <- Text.withCString desc \descPtr ->
|
changed <- Text.withCString desc \descPtr ->
|
||||||
Raw.sliderFloat descPtr floatPtr (CFloat minValue) (CFloat maxValue)
|
Raw.sliderFloat4 descPtr floatPtr (CFloat minValue) (CFloat maxValue) nullPtr
|
||||||
|
|
||||||
when changed do
|
when changed do
|
||||||
[x', y', z', u'] <- peekArray 4 floatPtr
|
[x', y', z', u'] <- peekArray 4 floatPtr
|
||||||
|
@ -13,7 +13,6 @@ module DearImGui.Internal.Text
|
|||||||
) where
|
) where
|
||||||
|
|
||||||
-- base
|
-- base
|
||||||
import Control.Monad.IO.Class (liftIO)
|
|
||||||
import Foreign (nullPtr, plusPtr)
|
import Foreign (nullPtr, plusPtr)
|
||||||
import Foreign.C.String (CString)
|
import Foreign.C.String (CString)
|
||||||
import qualified GHC.Foreign as Foreign
|
import qualified GHC.Foreign as Foreign
|
||||||
@ -26,35 +25,40 @@ import Data.Text.Foreign (withCStringLen)
|
|||||||
-- unliftio-core
|
-- unliftio-core
|
||||||
import UnliftIO (MonadUnliftIO, UnliftIO(..), withUnliftIO)
|
import UnliftIO (MonadUnliftIO, UnliftIO(..), withUnliftIO)
|
||||||
|
|
||||||
#if MIN_VERSION_text(2,0,0)
|
#if MIN_VERSION_text(2,0,1)
|
||||||
|
-- XXX: just wrap the provided combinator
|
||||||
|
|
||||||
|
import qualified Data.Text.Foreign as Text
|
||||||
|
|
||||||
|
withCString :: MonadUnliftIO m => Text -> (CString -> m a) -> m a
|
||||||
|
withCString text action =
|
||||||
|
withUnliftIO $ \(UnliftIO unlift) ->
|
||||||
|
Text.withCString text $ \buf ->
|
||||||
|
unlift $ action buf
|
||||||
|
|
||||||
|
#elif MIN_VERSION_text(2,0,0)
|
||||||
|
-- XXX: the text is UTF-8, alas no withCString is available
|
||||||
|
|
||||||
import Data.Text.Foreign (lengthWord8, unsafeCopyToPtr)
|
import Data.Text.Foreign (lengthWord8, unsafeCopyToPtr)
|
||||||
import Data.Word (Word8)
|
import Data.Word (Word8)
|
||||||
import Foreign (castPtr, free, mallocBytes, pokeByteOff)
|
import Foreign (allocaBytes, castPtr, pokeByteOff)
|
||||||
import UnliftIO.Exception (bracket)
|
|
||||||
|
|
||||||
withCString :: MonadUnliftIO m => Text -> (CString -> m a) -> m a
|
withCString :: MonadUnliftIO m => Text -> (CString -> m a) -> m a
|
||||||
withCString t = bracket create destroy
|
withCString t@(Text _arr _off len) action =
|
||||||
where
|
withUnliftIO $ \(UnliftIO unlift) ->
|
||||||
size0 = lengthWord8 t + 1
|
allocaBytes (len + 1) $ \buf -> do
|
||||||
|
unsafeCopyToPtr t buf
|
||||||
create = liftIO $ do
|
pokeByteOff buf len (0 :: Word8)
|
||||||
ptr <- mallocBytes size0
|
unlift $ action (castPtr buf)
|
||||||
unsafeCopyToPtr t (castPtr ptr)
|
|
||||||
pokeByteOff ptr size0 (0 :: Word8)
|
|
||||||
pure ptr
|
|
||||||
|
|
||||||
destroy ptr =
|
|
||||||
liftIO $ free ptr
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
-- XXX: the text is UTF-16, let GHC do it
|
||||||
|
|
||||||
withCString :: MonadUnliftIO m => Text -> (CString -> m a) -> m a
|
withCString :: MonadUnliftIO m => Text -> (CString -> m a) -> m a
|
||||||
withCString t action = do
|
withCString t action = do
|
||||||
withUnliftIO $ \(UnliftIO unlift) ->
|
withUnliftIO $ \(UnliftIO unlift) ->
|
||||||
liftIO $
|
Foreign.withCString utf8 (unpack t) $ \textPtr ->
|
||||||
Foreign.withCString utf8 (unpack t) $ \textPtr ->
|
unlift $ action textPtr
|
||||||
unlift $ action textPtr
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -90,6 +90,7 @@ module DearImGui.Raw
|
|||||||
, popItemWidth
|
, popItemWidth
|
||||||
, beginGroup
|
, beginGroup
|
||||||
, endGroup
|
, endGroup
|
||||||
|
, getCursorPos
|
||||||
, setCursorPos
|
, setCursorPos
|
||||||
, getCursorScreenPos
|
, getCursorScreenPos
|
||||||
, alignTextToFramePadding
|
, alignTextToFramePadding
|
||||||
@ -264,7 +265,7 @@ import System.IO.Unsafe
|
|||||||
( unsafePerformIO )
|
( unsafePerformIO )
|
||||||
|
|
||||||
-- dear-imgui
|
-- dear-imgui
|
||||||
import DearImGui.Context
|
import DearImGui.Raw.Context
|
||||||
( imguiContext )
|
( imguiContext )
|
||||||
import DearImGui.Enums
|
import DearImGui.Enums
|
||||||
import DearImGui.Structs
|
import DearImGui.Structs
|
||||||
@ -693,27 +694,27 @@ combo labelPtr iPtr itemsPtr itemsLen = liftIO do
|
|||||||
|
|
||||||
|
|
||||||
-- | Wraps @ImGui::DragFloat()@
|
-- | Wraps @ImGui::DragFloat()@
|
||||||
dragFloat :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CFloat -> m Bool
|
dragFloat :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CFloat -> CString -> m Bool
|
||||||
dragFloat descPtr floatPtr speed minValue maxValue = liftIO do
|
dragFloat descPtr floatPtr speed minValue maxValue formatPtr = liftIO do
|
||||||
(0 /=) <$> [C.exp| bool { DragFloat( $(char* descPtr), $(float* floatPtr), $(float speed), $(float minValue), $(float maxValue)) } |]
|
(0 /=) <$> [C.exp| bool { DragFloat( $(char* descPtr), $(float* floatPtr), $(float speed), $(float minValue), $(float maxValue), $(char* formatPtr)) } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Wraps @ImGui::DragFloat2()@
|
-- | Wraps @ImGui::DragFloat2()@
|
||||||
dragFloat2 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CFloat -> m Bool
|
dragFloat2 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CFloat -> CString -> m Bool
|
||||||
dragFloat2 descPtr floatPtr speed minValue maxValue = liftIO do
|
dragFloat2 descPtr floatPtr speed minValue maxValue formatPtr = liftIO do
|
||||||
(0 /=) <$> [C.exp| bool { DragFloat2( $(char* descPtr), $(float* floatPtr), $(float speed), $(float minValue), $(float maxValue)) } |]
|
(0 /=) <$> [C.exp| bool { DragFloat2( $(char* descPtr), $(float* floatPtr), $(float speed), $(float minValue), $(float maxValue), $(char* formatPtr)) } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Wraps @ImGui::DragFloat3()@
|
-- | Wraps @ImGui::DragFloat3()@
|
||||||
dragFloat3 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CFloat -> m Bool
|
dragFloat3 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CFloat -> CString -> m Bool
|
||||||
dragFloat3 descPtr floatPtr speed minValue maxValue = liftIO do
|
dragFloat3 descPtr floatPtr speed minValue maxValue formatPtr = liftIO do
|
||||||
(0 /=) <$> [C.exp| bool { DragFloat3( $(char* descPtr), $(float* floatPtr), $(float speed), $(float minValue), $(float maxValue)) } |]
|
(0 /=) <$> [C.exp| bool { DragFloat3( $(char* descPtr), $(float* floatPtr), $(float speed), $(float minValue), $(float maxValue), $(char* formatPtr)) } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Wraps @ImGui::DragFloat4()@
|
-- | Wraps @ImGui::DragFloat4()@
|
||||||
dragFloat4 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CFloat -> m Bool
|
dragFloat4 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CFloat -> CString -> m Bool
|
||||||
dragFloat4 descPtr floatPtr speed minValue maxValue = liftIO do
|
dragFloat4 descPtr floatPtr speed minValue maxValue formatPtr = liftIO do
|
||||||
(0 /=) <$> [C.exp| bool { DragFloat4( $(char* descPtr), $(float* floatPtr), $(float speed), $(float minValue), $(float maxValue)) } |]
|
(0 /=) <$> [C.exp| bool { DragFloat4( $(char* descPtr), $(float* floatPtr), $(float speed), $(float minValue), $(float maxValue), $(char* formatPtr)) } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Wraps @ImGui::DragFloatRange2()@
|
-- | Wraps @ImGui::DragFloatRange2()@
|
||||||
@ -853,27 +854,27 @@ dragScalarN labelPtr dataType dataPtr components vSpeed minPtr maxPtr formatPtr
|
|||||||
maxPtr_ = castPtr maxPtr
|
maxPtr_ = castPtr maxPtr
|
||||||
|
|
||||||
-- | Wraps @ImGui::SliderFloat()@
|
-- | Wraps @ImGui::SliderFloat()@
|
||||||
sliderFloat :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> m Bool
|
sliderFloat :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CString -> m Bool
|
||||||
sliderFloat descPtr floatPtr minValue maxValue = liftIO do
|
sliderFloat descPtr floatPtr minValue maxValue formatPtr = liftIO do
|
||||||
(0 /=) <$> [C.exp| bool { SliderFloat( $(char* descPtr), $(float* floatPtr), $(float minValue), $(float maxValue)) } |]
|
(0 /=) <$> [C.exp| bool { SliderFloat( $(char* descPtr), $(float* floatPtr), $(float minValue), $(float maxValue), $(char* formatPtr)) } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Wraps @ImGui::SliderFloat2()@
|
-- | Wraps @ImGui::SliderFloat2()@
|
||||||
sliderFloat2 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> m Bool
|
sliderFloat2 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CString -> m Bool
|
||||||
sliderFloat2 descPtr floatPtr minValue maxValue = liftIO do
|
sliderFloat2 descPtr floatPtr minValue maxValue formatPtr = liftIO do
|
||||||
(0 /=) <$> [C.exp| bool { SliderFloat2( $(char* descPtr), $(float* floatPtr), $(float minValue), $(float maxValue)) } |]
|
(0 /=) <$> [C.exp| bool { SliderFloat2( $(char* descPtr), $(float* floatPtr), $(float minValue), $(float maxValue), $(char* formatPtr)) } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Wraps @ImGui::SliderFloat3()@
|
-- | Wraps @ImGui::SliderFloat3()@
|
||||||
sliderFloat3 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> m Bool
|
sliderFloat3 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CString -> m Bool
|
||||||
sliderFloat3 descPtr floatPtr minValue maxValue = liftIO do
|
sliderFloat3 descPtr floatPtr minValue maxValue formatPtr = liftIO do
|
||||||
(0 /=) <$> [C.exp| bool { SliderFloat3( $(char* descPtr), $(float* floatPtr), $(float minValue), $(float maxValue)) } |]
|
(0 /=) <$> [C.exp| bool { SliderFloat3( $(char* descPtr), $(float* floatPtr), $(float minValue), $(float maxValue), $(char* formatPtr)) } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Wraps @ImGui::SliderFloat4()@
|
-- | Wraps @ImGui::SliderFloat4()@
|
||||||
sliderFloat4 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> m Bool
|
sliderFloat4 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CString -> m Bool
|
||||||
sliderFloat4 descPtr floatPtr minValue maxValue = liftIO do
|
sliderFloat4 descPtr floatPtr minValue maxValue formatPtr = liftIO do
|
||||||
(0 /=) <$> [C.exp| bool { SliderFloat4( $(char* descPtr), $(float* floatPtr), $(float minValue), $(float maxValue)) } |]
|
(0 /=) <$> [C.exp| bool { SliderFloat4( $(char* descPtr), $(float* floatPtr), $(float minValue), $(float maxValue), $(char* formatPtr)) } |]
|
||||||
|
|
||||||
-- | Wraps @ImGui::SliderAngle()@
|
-- | Wraps @ImGui::SliderAngle()@
|
||||||
sliderAngle :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CString -> ImGuiSliderFlags -> m Bool
|
sliderAngle :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CString -> ImGuiSliderFlags -> m Bool
|
||||||
@ -1671,6 +1672,20 @@ setCursorPos :: (MonadIO m) => Ptr ImVec2 -> m ()
|
|||||||
setCursorPos posPtr = liftIO do
|
setCursorPos posPtr = liftIO do
|
||||||
[C.exp| void { SetCursorPos(*$(ImVec2* posPtr)) } |]
|
[C.exp| void { SetCursorPos(*$(ImVec2* posPtr)) } |]
|
||||||
|
|
||||||
|
-- | Get cursor position in window-local coordinates.
|
||||||
|
--
|
||||||
|
-- Useful to overlap draw using 'setCursorPos'.
|
||||||
|
--
|
||||||
|
-- Wraps @ImGui::SetCursorPos()@
|
||||||
|
getCursorPos :: (MonadIO m) => m ImVec2
|
||||||
|
getCursorPos = liftIO do
|
||||||
|
C.withPtr_ \ptr ->
|
||||||
|
[C.block|
|
||||||
|
void {
|
||||||
|
*$(ImVec2 * ptr) = GetCursorPos();
|
||||||
|
}
|
||||||
|
|]
|
||||||
|
|
||||||
-- | Cursor position in absolute coordinates.
|
-- | Cursor position in absolute coordinates.
|
||||||
--
|
--
|
||||||
-- Useful to work with 'DrawList' API.
|
-- Useful to work with 'DrawList' API.
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
{-# language PatternSynonyms #-}
|
{-# language PatternSynonyms #-}
|
||||||
{-# language TemplateHaskell #-}
|
{-# language TemplateHaskell #-}
|
||||||
|
|
||||||
module DearImGui.Context where
|
module DearImGui.Raw.Context where
|
||||||
|
|
||||||
-- containers
|
-- containers
|
||||||
import qualified Data.Map.Strict as Map
|
import qualified Data.Map.Strict as Map
|
@ -115,7 +115,7 @@ import Foreign hiding (new)
|
|||||||
import Foreign.C
|
import Foreign.C
|
||||||
|
|
||||||
-- dear-imgui
|
-- dear-imgui
|
||||||
import DearImGui.Context
|
import DearImGui.Raw.Context
|
||||||
( imguiContext )
|
( imguiContext )
|
||||||
import DearImGui.Enums
|
import DearImGui.Enums
|
||||||
import DearImGui.Structs
|
import DearImGui.Structs
|
||||||
|
@ -41,7 +41,7 @@ import Foreign ( Ptr, castPtr )
|
|||||||
import Foreign.C
|
import Foreign.C
|
||||||
|
|
||||||
-- dear-imgui
|
-- dear-imgui
|
||||||
import DearImGui.Context
|
import DearImGui.Raw.Context
|
||||||
( imguiContext )
|
( imguiContext )
|
||||||
import DearImGui.Structs
|
import DearImGui.Structs
|
||||||
import DearImGui.Raw.Font.Config
|
import DearImGui.Raw.Font.Config
|
||||||
|
@ -46,7 +46,7 @@ import Foreign ( Ptr )
|
|||||||
import Foreign.C
|
import Foreign.C
|
||||||
|
|
||||||
-- dear-imgui
|
-- dear-imgui
|
||||||
import DearImGui.Context
|
import DearImGui.Raw.Context
|
||||||
( imguiContext )
|
( imguiContext )
|
||||||
import DearImGui.Structs
|
import DearImGui.Structs
|
||||||
import DearImGui.Raw.Font.GlyphRanges
|
import DearImGui.Raw.Font.GlyphRanges
|
||||||
|
@ -75,7 +75,7 @@ import Foreign.C
|
|||||||
import System.IO.Unsafe (unsafePerformIO)
|
import System.IO.Unsafe (unsafePerformIO)
|
||||||
|
|
||||||
-- dear-imgui
|
-- dear-imgui
|
||||||
import DearImGui.Context
|
import DearImGui.Raw.Context
|
||||||
( imguiContext )
|
( imguiContext )
|
||||||
import DearImGui.Structs
|
import DearImGui.Structs
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ import Foreign.C
|
|||||||
)
|
)
|
||||||
|
|
||||||
-- dear-imgui
|
-- dear-imgui
|
||||||
import DearImGui.Context
|
import DearImGui.Raw.Context
|
||||||
( imguiContext )
|
( imguiContext )
|
||||||
-- import DearImGui.Enums
|
-- import DearImGui.Enums
|
||||||
-- import DearImGui.Structs
|
-- import DearImGui.Structs
|
||||||
|
@ -59,7 +59,7 @@ import Foreign.C
|
|||||||
import System.IO.Unsafe (unsafePerformIO)
|
import System.IO.Unsafe (unsafePerformIO)
|
||||||
|
|
||||||
-- dear-imgui
|
-- dear-imgui
|
||||||
import DearImGui.Context
|
import DearImGui.Raw.Context
|
||||||
( imguiContext )
|
( imguiContext )
|
||||||
import DearImGui.Structs
|
import DearImGui.Structs
|
||||||
( ImGuiListClipper )
|
( ImGuiListClipper )
|
||||||
|
@ -50,7 +50,7 @@ import Control.Monad.IO.Class
|
|||||||
|
|
||||||
C.context (Cpp.cppCtx <> C.bsCtx)
|
C.context (Cpp.cppCtx <> C.bsCtx)
|
||||||
C.include "imgui.h"
|
C.include "imgui.h"
|
||||||
C.include "backends/imgui_impl_sdl.h"
|
C.include "backends/imgui_impl_sdl2.h"
|
||||||
C.include "SDL.h"
|
C.include "SDL.h"
|
||||||
Cpp.using "namespace ImGui"
|
Cpp.using "namespace ImGui"
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ import Control.Monad.IO.Class
|
|||||||
C.context (Cpp.cppCtx <> C.bsCtx)
|
C.context (Cpp.cppCtx <> C.bsCtx)
|
||||||
C.include "imgui.h"
|
C.include "imgui.h"
|
||||||
C.include "backends/imgui_impl_opengl2.h"
|
C.include "backends/imgui_impl_opengl2.h"
|
||||||
C.include "backends/imgui_impl_sdl.h"
|
C.include "backends/imgui_impl_sdl2.h"
|
||||||
C.include "SDL.h"
|
C.include "SDL.h"
|
||||||
C.include "SDL_opengl.h"
|
C.include "SDL_opengl.h"
|
||||||
Cpp.using "namespace ImGui"
|
Cpp.using "namespace ImGui"
|
||||||
|
@ -33,7 +33,7 @@ import Control.Monad.IO.Class ( MonadIO, liftIO )
|
|||||||
C.context Cpp.cppCtx
|
C.context Cpp.cppCtx
|
||||||
C.include "imgui.h"
|
C.include "imgui.h"
|
||||||
C.include "backends/imgui_impl_vulkan.h"
|
C.include "backends/imgui_impl_vulkan.h"
|
||||||
C.include "backends/imgui_impl_sdl.h"
|
C.include "backends/imgui_impl_sdl2.h"
|
||||||
C.include "SDL.h"
|
C.include "SDL.h"
|
||||||
C.include "SDL_vulkan.h"
|
C.include "SDL_vulkan.h"
|
||||||
Cpp.using "namespace ImGui"
|
Cpp.using "namespace ImGui"
|
||||||
|
Reference in New Issue
Block a user