13 Commits

Author SHA1 Message Date
6195b32afd upgraded imgui to v1.89.7; Downstream-breakage **possible** 2023-07-17 17:50:17 +02:00
8368192370 Allow base-4.19 for ghc-9.6 (#177)
Co-authored-by: Alexander Bondarenko <486682+dpwiz@users.noreply.github.com>
2023-07-02 21:54:03 +00:00
ea3ad959f9 Add getCursorPos (#176) 2023-07-03 00:48:44 +03:00
0cc654f190 Update bound for ghc-9.6 (#174)
* Update bound for ghc-9.6

* Update ci action versions
2023-05-07 17:44:13 +03:00
8697aa3a0a Expose DearImGui.Raw.Context (#172) 2023-01-15 15:27:15 +02:00
802bdb72fe Fix cabal flag for image example (#170) 2022-12-24 12:21:51 +02:00
69a463d98b Fix vulkan versions to a fresh set (#168)
vulkan, vulkan-utils and VMA can be too old/new for each other.
This cuts a fresh, known-to-work set of lower bounds.
2022-12-12 18:33:48 +00:00
9bb66f0113 Fix the text fix and prepare 2.1.3 (#167) 2022-12-12 19:57:54 +02:00
68e30d98ad Fix off-by-one bug in string null termination (#166)
Backport withCString fix and use text version when available
2022-12-12 18:20:39 +03:00
52142bbf7e Add formatPtr to Raw.dragFloat* and Raw.sliderFloat* (#165) 2022-12-05 17:47:21 +03:00
d933248a2c This change fixes the high level API to use the right Raw call (#164) 2022-12-02 17:50:04 +02:00
258777f8c7 Fix sdl flag in cabal.project (#163) 2022-11-30 17:08:06 +00:00
cd99938f97 Prepare v2.1.2 (#162) 2022-11-30 16:32:44 +00:00
19 changed files with 176 additions and 124 deletions

View File

@ -4,19 +4,19 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v2.4.0
with:
persist-credentials: false
submodules: true
- uses: cachix/install-nix-action@v16
- uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v10
- uses: cachix/cachix-action@v12
with:
name: hs-dear-imgui
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix-build --version
- run: nix-build --version
- run: nix-build -A hsPkgs.dear-imgui.components.exes

View File

@ -1,5 +1,17 @@
# 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]
- 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.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.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.86]: https://github.com/ocornut/imgui/releases/tag/v1.86

View File

@ -1,4 +1,4 @@
packages: *.cabal
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

View File

@ -1,7 +1,7 @@
cabal-version: 3.0
name: dear-imgui
version: 2.1.1
version: 2.1.3
author: Oliver Charles
maintainer: ollie@ocharles.org.uk, aenor.realm@gmail.com
license: BSD-3-Clause
@ -13,10 +13,11 @@ description:
Set package flags according to your needs.
build-type: Simple
extra-source-files:
README.md,
ChangeLog.md,
ChangeLog.md
extra-source-files:
imgui/*.h,
imgui/backends/*.h,
imgui/backends/*.mm,
@ -139,7 +140,7 @@ flag use-ImDrawIdx32
common common
build-depends:
base
>= 4.12 && < 4.17
>= 4.12 && < 4.19
default-language:
Haskell2010
@ -147,7 +148,6 @@ library
import: common
hs-source-dirs:
src
generator
exposed-modules:
DearImGui
DearImGui.FontAtlas
@ -159,17 +159,10 @@ library
DearImGui.Raw.Font.GlyphRanges
DearImGui.Raw.IO
DearImGui.Raw.ListClipper
DearImGui.Raw.Context
other-modules:
DearImGui.Context
DearImGui.Enums
DearImGui.Structs
DearImGui.Generator
DearImGui.Generator.Parser
DearImGui.Generator.Tokeniser
DearImGui.Generator.Types
ghc-options:
-static -dynamic-too
-- create both libHSdear-imgui... .a and .so
cxx-options: -std=c++11
cxx-sources:
imgui/imgui.cpp
@ -177,47 +170,20 @@ library
imgui/imgui_draw.cpp
imgui/imgui_tables.cpp
imgui/imgui_widgets.cpp
install-includes:
imgui.h
imgui_internal.h
imstb_rectpack.h
imstb_textedit.h
imstb_truetype.h
extra-libraries:
stdc++
include-dirs:
imgui
build-depends:
managed
dear-imgui-generator
, containers
, managed
, inline-c
, inline-c-cpp
, StateVar
, unliftio
, vector
-- for the generator:
, template-haskell
>= 2.15 && < 2.19
, containers
^>= 0.6.2.1
, directory
>= 1.3 && < 1.4
, filepath
>= 1.4 && < 1.5
, inline-c
>= 0.9.0.0 && < 0.10
, megaparsec
>= 9.0 && < 9.3
, parser-combinators
>= 1.2.0 && < 1.4
, scientific
>= 0.3.6.2 && < 0.3.8
, text
>= 1.2.4 && < 2.1
, th-lift
>= 0.7 && < 0.9
, transformers
>= 0.5.6 && < 0.6
, unordered-containers
>= 0.2.11 && < 0.3
if os(darwin)
ghc-options:
@ -277,7 +243,7 @@ library
build-depends:
sdl2
cxx-sources:
imgui/backends/imgui_impl_sdl.cpp
imgui/backends/imgui_impl_sdl2.cpp
if os(windows) || os(darwin)
extra-libraries:
@ -315,6 +281,40 @@ library
exposed-modules:
DearImGui.GLFW.Vulkan
library dear-imgui-generator
import: common
hs-source-dirs: generator
exposed-modules:
DearImGui.Generator
, DearImGui.Generator.Parser
, DearImGui.Generator.Tokeniser
, DearImGui.Generator.Types
build-depends:
template-haskell
>= 2.15 && < 2.21
, containers
^>= 0.6.2.1
, directory
>= 1.3 && < 1.4
, filepath
>= 1.4 && < 1.5
, inline-c
>= 0.9.0.0 && < 0.10
, megaparsec
>= 9.0 && < 9.3
, parser-combinators
>= 1.2.0 && < 1.4
, scientific
>= 0.3.6.2 && < 0.3.8
, text
>= 1.2.4 && < 2.1
, th-lift
>= 0.7 && < 0.9
, transformers
>= 0.5.6 && < 0.7
, unordered-containers
>= 0.2.11 && < 0.3
executable test
import: common, exe-flags
main-is: Main.hs
@ -355,7 +355,7 @@ executable image
main-is: Image.hs
hs-source-dirs: examples/sdl
build-depends: sdl2, gl, dear-imgui, managed, vector
if (!flag(examples) || !flag(sdl) || !flag(opengl2))
if (!flag(examples) || !flag(sdl) || !flag(opengl3))
buildable: False
executable vulkan
@ -382,7 +382,7 @@ executable vulkan
, text-short
^>= 0.1.3
, transformers
^>= 0.5.6.2
>= 0.5.6 && < 0.7
, unliftio
>= 0.2.13 && < 0.2.19
, unliftio-core
@ -390,8 +390,9 @@ executable vulkan
, vector
^>= 0.12.1.2
, vulkan
^>= 3.9
>= 3.12
, vulkan-utils
^>= 0.4.1
>= 0.5
, VulkanMemoryAllocator
>= 0.7.1
, JuicyPixels

View File

@ -60,7 +60,7 @@ import Data.Text
( Text )
import qualified Data.Text as Text
( all, any, breakOn, drop, dropWhile, dropWhileEnd
, length, stripPrefix, unlines, unpack
, length, stripPrefix, unlines, unpack, pack
)
-- transformers
@ -81,6 +81,8 @@ import DearImGui.Generator.Tokeniser
import DearImGui.Generator.Types
( Comment(..), Enumeration(..), Headers(..) )
import qualified Text.Show as Text
--------------------------------------------------------------------------------
-- Parse error type.
@ -90,7 +92,9 @@ data CustomParseError
, problems :: ![Text]
}
| MissingForwardDeclaration
{ enumName :: !Text }
{ enumName :: !Text
, library :: HashMap Text ( TH.Name, Comment )
}
| UnexpectedSection
{ sectionName :: !Text
, problem :: ![Text]
@ -101,8 +105,9 @@ instance ShowErrorComponent CustomParseError where
showErrorComponent ( Couldn'tLookupEnumValues { enumName, problems } ) = Text.unpack $
"Couldn't lookup the following values in enum " <> enumName <> ":\n"
<> Text.unlines ( map ( " - " <> ) problems )
showErrorComponent ( MissingForwardDeclaration { enumName } ) = Text.unpack $
"Missing forward declaration for enum named " <> enumName
showErrorComponent ( MissingForwardDeclaration { enumName, library } ) = Text.unpack $
"Missing forward declaration for enum named " <> enumName <> "\n"
<> "In Library: " <> Text.pack ( Text.show library)
showErrorComponent ( UnexpectedSection { sectionName, problem } ) = Text.unpack $
"Unexpected section name.\n\
\Expected: " <> sectionName <> "\n\
@ -124,6 +129,7 @@ headers = do
( _defines, basicEnums ) <- partitionEithers <$>
manyTill
( ( Left <$> try ignoreDefine )
<|> ( Left <$> try cppConditional )
<|> ( Right <$> enumeration enumNamesAndTypes )
)
( namedSection "Helpers: Memory allocations macros, ImVector<>" )
@ -134,7 +140,7 @@ headers = do
_ <- 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 ( try . lookAhead $ many comment *> keyword "enum" )
@ -171,14 +177,24 @@ forwardDeclarations = do
pure ( structName, doc )
_ <- many comment
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"
ty <- cTypeName
enumName <- identifier
reservedSymbol ';'
doc <- commentText <$> comment
_ <- many comment
pure ( enumName, ( ty, CommentText <$> Text.drop 2 . snd $ Text.breakOn "//" doc ) )
-- 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 = keyword "int" $> ''CInt
@ -200,6 +216,7 @@ enumeration enumNamesAndTypes = do
keyword "enum"
pure inlineDocs
fullEnumName <- identifier
_ <- try $ (symbol ":" >> cTypeName >> pure ()) <|> pure ()
let
enumName :: Text
enumName = Text.dropWhileEnd ( == '_' ) fullEnumName
@ -207,7 +224,7 @@ enumeration enumNamesAndTypes = do
enumTypeName = ()
( underlyingType, forwardDoc ) <- case HashMap.lookup enumName enumNamesAndTypes of
Just res -> pure res
Nothing -> customFailure ( MissingForwardDeclaration { enumName } )
Nothing -> customFailure ( MissingForwardDeclaration { enumName, library=enumNamesAndTypes } )
let
docs :: [Comment]
docs = forwardDoc : CommentText "" : inlineDocs

2
imgui

Submodule imgui updated: 9aae45eb4a...d4ddc46e77

View File

@ -110,6 +110,7 @@ module DearImGui
, Raw.endGroup
, setCursorPos
, Raw.getCursorPos
, Raw.alignTextToFramePadding
-- * ID stack
@ -646,7 +647,7 @@ dragFloat desc ref speed minValue maxValue = liftIO do
currentValue <- get ref
with (realToFrac currentValue) \floatPtr -> do
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
newValue <- peek floatPtr
@ -661,7 +662,7 @@ dragFloat2 desc ref speed minValue maxValue = liftIO do
(x, y) <- get ref
withArray [ realToFrac x, realToFrac y ] \floatPtr -> do
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
[x', y'] <- peekArray 2 floatPtr
@ -675,7 +676,7 @@ dragFloat3 desc ref speed minValue maxValue = liftIO do
(x, y, z) <- get ref
withArray [ realToFrac x, realToFrac y, realToFrac z ] \floatPtr -> do
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
[x', y', z'] <- peekArray 3 floatPtr
@ -690,7 +691,7 @@ dragFloat4 desc ref speed minValue maxValue = liftIO do
(x, y, z, u) <- get ref
withArray [ realToFrac x, realToFrac y, realToFrac z, realToFrac u ] \floatPtr -> do
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
[x', y', z', u'] <- peekArray 4 floatPtr
@ -969,7 +970,7 @@ sliderFloat desc ref minValue maxValue = liftIO do
currentValue <- get ref
with (realToFrac currentValue) \floatPtr -> do
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
newValue <- peek floatPtr
@ -983,7 +984,7 @@ sliderFloat2 desc ref minValue maxValue = liftIO do
(x, y) <- get ref
withArray [ realToFrac x, realToFrac y ] \floatPtr -> do
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
[x', y'] <- peekArray 2 floatPtr
@ -997,7 +998,7 @@ sliderFloat3 desc ref minValue maxValue = liftIO do
(x, y, z) <- get ref
withArray [ realToFrac x, realToFrac y, realToFrac z ] \floatPtr -> do
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
[x', y', z'] <- peekArray 3 floatPtr
@ -1011,7 +1012,7 @@ sliderFloat4 desc ref minValue maxValue = liftIO do
(x, y, z, u) <- get ref
withArray [ realToFrac x, realToFrac y, realToFrac z, realToFrac u ] \floatPtr -> do
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
[x', y', z', u'] <- peekArray 4 floatPtr

View File

@ -13,7 +13,6 @@ module DearImGui.Internal.Text
) where
-- base
import Control.Monad.IO.Class (liftIO)
import Foreign (nullPtr, plusPtr)
import Foreign.C.String (CString)
import qualified GHC.Foreign as Foreign
@ -26,35 +25,40 @@ import Data.Text.Foreign (withCStringLen)
-- unliftio-core
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.Word (Word8)
import Foreign (castPtr, free, mallocBytes, pokeByteOff)
import UnliftIO.Exception (bracket)
import Foreign (allocaBytes, castPtr, pokeByteOff)
withCString :: MonadUnliftIO m => Text -> (CString -> m a) -> m a
withCString t = bracket create destroy
where
size0 = lengthWord8 t + 1
create = liftIO $ do
ptr <- mallocBytes size0
unsafeCopyToPtr t (castPtr ptr)
pokeByteOff ptr size0 (0 :: Word8)
pure ptr
destroy ptr =
liftIO $ free ptr
withCString t@(Text _arr _off len) action =
withUnliftIO $ \(UnliftIO unlift) ->
allocaBytes (len + 1) $ \buf -> do
unsafeCopyToPtr t buf
pokeByteOff buf len (0 :: Word8)
unlift $ action (castPtr buf)
#else
-- XXX: the text is UTF-16, let GHC do it
withCString :: MonadUnliftIO m => Text -> (CString -> m a) -> m a
withCString t action = do
withUnliftIO $ \(UnliftIO unlift) ->
liftIO $
Foreign.withCString utf8 (unpack t) $ \textPtr ->
unlift $ action textPtr
Foreign.withCString utf8 (unpack t) $ \textPtr ->
unlift $ action textPtr
#endif

View File

@ -90,6 +90,7 @@ module DearImGui.Raw
, popItemWidth
, beginGroup
, endGroup
, getCursorPos
, setCursorPos
, getCursorScreenPos
, alignTextToFramePadding
@ -264,7 +265,7 @@ import System.IO.Unsafe
( unsafePerformIO )
-- dear-imgui
import DearImGui.Context
import DearImGui.Raw.Context
( imguiContext )
import DearImGui.Enums
import DearImGui.Structs
@ -693,27 +694,27 @@ combo labelPtr iPtr itemsPtr itemsLen = liftIO do
-- | Wraps @ImGui::DragFloat()@
dragFloat :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CFloat -> m Bool
dragFloat descPtr floatPtr speed minValue maxValue = liftIO do
(0 /=) <$> [C.exp| bool { DragFloat( $(char* descPtr), $(float* floatPtr), $(float speed), $(float minValue), $(float maxValue)) } |]
dragFloat :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CFloat -> CString -> m Bool
dragFloat descPtr floatPtr speed minValue maxValue formatPtr = liftIO do
(0 /=) <$> [C.exp| bool { DragFloat( $(char* descPtr), $(float* floatPtr), $(float speed), $(float minValue), $(float maxValue), $(char* formatPtr)) } |]
-- | Wraps @ImGui::DragFloat2()@
dragFloat2 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CFloat -> m Bool
dragFloat2 descPtr floatPtr speed minValue maxValue = liftIO do
(0 /=) <$> [C.exp| bool { DragFloat2( $(char* descPtr), $(float* floatPtr), $(float speed), $(float minValue), $(float maxValue)) } |]
dragFloat2 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CFloat -> CString -> m Bool
dragFloat2 descPtr floatPtr speed minValue maxValue formatPtr = liftIO do
(0 /=) <$> [C.exp| bool { DragFloat2( $(char* descPtr), $(float* floatPtr), $(float speed), $(float minValue), $(float maxValue), $(char* formatPtr)) } |]
-- | Wraps @ImGui::DragFloat3()@
dragFloat3 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CFloat -> m Bool
dragFloat3 descPtr floatPtr speed minValue maxValue = liftIO do
(0 /=) <$> [C.exp| bool { DragFloat3( $(char* descPtr), $(float* floatPtr), $(float speed), $(float minValue), $(float maxValue)) } |]
dragFloat3 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CFloat -> CString -> m Bool
dragFloat3 descPtr floatPtr speed minValue maxValue formatPtr = liftIO do
(0 /=) <$> [C.exp| bool { DragFloat3( $(char* descPtr), $(float* floatPtr), $(float speed), $(float minValue), $(float maxValue), $(char* formatPtr)) } |]
-- | Wraps @ImGui::DragFloat4()@
dragFloat4 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CFloat -> m Bool
dragFloat4 descPtr floatPtr speed minValue maxValue = liftIO do
(0 /=) <$> [C.exp| bool { DragFloat4( $(char* descPtr), $(float* floatPtr), $(float speed), $(float minValue), $(float maxValue)) } |]
dragFloat4 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CFloat -> CString -> m Bool
dragFloat4 descPtr floatPtr speed minValue maxValue formatPtr = liftIO do
(0 /=) <$> [C.exp| bool { DragFloat4( $(char* descPtr), $(float* floatPtr), $(float speed), $(float minValue), $(float maxValue), $(char* formatPtr)) } |]
-- | Wraps @ImGui::DragFloatRange2()@
@ -853,27 +854,27 @@ dragScalarN labelPtr dataType dataPtr components vSpeed minPtr maxPtr formatPtr
maxPtr_ = castPtr maxPtr
-- | Wraps @ImGui::SliderFloat()@
sliderFloat :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> m Bool
sliderFloat descPtr floatPtr minValue maxValue = liftIO do
(0 /=) <$> [C.exp| bool { SliderFloat( $(char* descPtr), $(float* floatPtr), $(float minValue), $(float maxValue)) } |]
sliderFloat :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CString -> m Bool
sliderFloat descPtr floatPtr minValue maxValue formatPtr = liftIO do
(0 /=) <$> [C.exp| bool { SliderFloat( $(char* descPtr), $(float* floatPtr), $(float minValue), $(float maxValue), $(char* formatPtr)) } |]
-- | Wraps @ImGui::SliderFloat2()@
sliderFloat2 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> m Bool
sliderFloat2 descPtr floatPtr minValue maxValue = liftIO do
(0 /=) <$> [C.exp| bool { SliderFloat2( $(char* descPtr), $(float* floatPtr), $(float minValue), $(float maxValue)) } |]
sliderFloat2 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CString -> m Bool
sliderFloat2 descPtr floatPtr minValue maxValue formatPtr = liftIO do
(0 /=) <$> [C.exp| bool { SliderFloat2( $(char* descPtr), $(float* floatPtr), $(float minValue), $(float maxValue), $(char* formatPtr)) } |]
-- | Wraps @ImGui::SliderFloat3()@
sliderFloat3 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> m Bool
sliderFloat3 descPtr floatPtr minValue maxValue = liftIO do
(0 /=) <$> [C.exp| bool { SliderFloat3( $(char* descPtr), $(float* floatPtr), $(float minValue), $(float maxValue)) } |]
sliderFloat3 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CString -> m Bool
sliderFloat3 descPtr floatPtr minValue maxValue formatPtr = liftIO do
(0 /=) <$> [C.exp| bool { SliderFloat3( $(char* descPtr), $(float* floatPtr), $(float minValue), $(float maxValue), $(char* formatPtr)) } |]
-- | Wraps @ImGui::SliderFloat4()@
sliderFloat4 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> m Bool
sliderFloat4 descPtr floatPtr minValue maxValue = liftIO do
(0 /=) <$> [C.exp| bool { SliderFloat4( $(char* descPtr), $(float* floatPtr), $(float minValue), $(float maxValue)) } |]
sliderFloat4 :: (MonadIO m) => CString -> Ptr CFloat -> CFloat -> CFloat -> CString -> m Bool
sliderFloat4 descPtr floatPtr minValue maxValue formatPtr = liftIO do
(0 /=) <$> [C.exp| bool { SliderFloat4( $(char* descPtr), $(float* floatPtr), $(float minValue), $(float maxValue), $(char* formatPtr)) } |]
-- | Wraps @ImGui::SliderAngle()@
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
[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.
--
-- Useful to work with 'DrawList' API.

View File

@ -6,7 +6,7 @@
{-# language PatternSynonyms #-}
{-# language TemplateHaskell #-}
module DearImGui.Context where
module DearImGui.Raw.Context where
-- containers
import qualified Data.Map.Strict as Map

View File

@ -115,7 +115,7 @@ import Foreign hiding (new)
import Foreign.C
-- dear-imgui
import DearImGui.Context
import DearImGui.Raw.Context
( imguiContext )
import DearImGui.Enums
import DearImGui.Structs

View File

@ -41,7 +41,7 @@ import Foreign ( Ptr, castPtr )
import Foreign.C
-- dear-imgui
import DearImGui.Context
import DearImGui.Raw.Context
( imguiContext )
import DearImGui.Structs
import DearImGui.Raw.Font.Config

View File

@ -46,7 +46,7 @@ import Foreign ( Ptr )
import Foreign.C
-- dear-imgui
import DearImGui.Context
import DearImGui.Raw.Context
( imguiContext )
import DearImGui.Structs
import DearImGui.Raw.Font.GlyphRanges

View File

@ -75,7 +75,7 @@ import Foreign.C
import System.IO.Unsafe (unsafePerformIO)
-- dear-imgui
import DearImGui.Context
import DearImGui.Raw.Context
( imguiContext )
import DearImGui.Structs

View File

@ -39,7 +39,7 @@ import Foreign.C
)
-- dear-imgui
import DearImGui.Context
import DearImGui.Raw.Context
( imguiContext )
-- import DearImGui.Enums
-- import DearImGui.Structs

View File

@ -59,7 +59,7 @@ import Foreign.C
import System.IO.Unsafe (unsafePerformIO)
-- dear-imgui
import DearImGui.Context
import DearImGui.Raw.Context
( imguiContext )
import DearImGui.Structs
( ImGuiListClipper )

View File

@ -50,7 +50,7 @@ import Control.Monad.IO.Class
C.context (Cpp.cppCtx <> C.bsCtx)
C.include "imgui.h"
C.include "backends/imgui_impl_sdl.h"
C.include "backends/imgui_impl_sdl2.h"
C.include "SDL.h"
Cpp.using "namespace ImGui"

View File

@ -42,7 +42,7 @@ import Control.Monad.IO.Class
C.context (Cpp.cppCtx <> C.bsCtx)
C.include "imgui.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_opengl.h"
Cpp.using "namespace ImGui"

View File

@ -33,7 +33,7 @@ import Control.Monad.IO.Class ( MonadIO, liftIO )
C.context Cpp.cppCtx
C.include "imgui.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_vulkan.h"
Cpp.using "namespace ImGui"