mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2025-07-04 12:08:48 +02:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
78bb5ecb8d | |||
397cea7bd9 |
7
.github/workflows/build.yaml
vendored
7
.github/workflows/build.yaml
vendored
@ -13,4 +13,9 @@ jobs:
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-unstable
|
||||
|
||||
- run: nix-build -A hsPkgs.dear-imgui.components.exes --option trusted-public-keys "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" --option substituters "https://hydra.iohk.io https://iohk.cachix.org https://cache.nixos.org/"
|
||||
- uses: cachix/cachix-action@v8
|
||||
with:
|
||||
name: hs-dear-imgui
|
||||
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
||||
|
||||
- run: nix-build -A hsPkgs.dear-imgui.components.exes
|
||||
|
6
Main.hs
6
Main.hs
@ -5,6 +5,7 @@
|
||||
|
||||
module Main (main) where
|
||||
|
||||
import Data.StateVar
|
||||
import Data.IORef
|
||||
import DearImGui
|
||||
import DearImGui.OpenGL
|
||||
@ -23,6 +24,11 @@ main = do
|
||||
bracket createContext destroyContext \_imguiContext ->
|
||||
bracket_ (sdl2InitForOpenGL w glContext) sdl2Shutdown $
|
||||
bracket_ openGL2Init openGL2Shutdown do
|
||||
iniFilename $= Just "imgui_state.ini"
|
||||
|
||||
putStr "State stored in: "
|
||||
get iniFilename >>= print
|
||||
|
||||
checkVersion
|
||||
styleColorsLight
|
||||
|
||||
|
@ -120,7 +120,7 @@ library
|
||||
executable test
|
||||
main-is: Main.hs
|
||||
default-language: Haskell2010
|
||||
build-depends: base, sdl2, gl, dear-imgui
|
||||
build-depends: base, sdl2, gl, dear-imgui, StateVar
|
||||
ghc-options: -Wall
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
{-# LANGUAGE BlockArguments #-}
|
||||
{-# LANGUAGE DuplicateRecordFields #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
{-# LANGUAGE NamedFieldPuns #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE PatternSynonyms #-}
|
||||
@ -27,6 +28,9 @@ module DearImGui
|
||||
, getDrawData
|
||||
, checkVersion
|
||||
|
||||
-- ** @ImGUIIO@
|
||||
, iniFilename
|
||||
|
||||
-- * Demo, Debug, Information
|
||||
, showDemoWindow
|
||||
, showMetricsWindow
|
||||
@ -126,7 +130,7 @@ import qualified Language.C.Inline.Cpp as Cpp
|
||||
|
||||
-- StateVar
|
||||
import Data.StateVar
|
||||
( HasGetter(get), HasSetter, ($=!) )
|
||||
( HasGetter(get), HasSetter, StateVar(..), ($=!) )
|
||||
|
||||
-- transformers
|
||||
import Control.Monad.IO.Class
|
||||
@ -196,6 +200,24 @@ checkVersion = liftIO do
|
||||
[C.exp| void { IMGUI_CHECKVERSION(); } |]
|
||||
|
||||
|
||||
-- | Path to @.ini@ file. Set to 'Nothing' to disable automatic .ini
|
||||
-- loading/saving, if e.g. you want to manually load/save from memory.
|
||||
iniFilename :: StateVar (Maybe String)
|
||||
iniFilename = StateVar getter setter
|
||||
where
|
||||
getter = do
|
||||
cStr <- [C.exp| const char* { GetIO().IniFilename } |]
|
||||
if cStr == nullPtr then return Nothing else Just <$> peekCString cStr
|
||||
|
||||
setter = \case
|
||||
Nothing ->
|
||||
[C.block| void { GetIO().IniFilename = $(char* nullPtr); } |]
|
||||
|
||||
Just str -> do
|
||||
strPtr <- newCString str
|
||||
[C.block| void { GetIO().IniFilename = $(char* strPtr); } |]
|
||||
|
||||
|
||||
-- | Create demo window. Demonstrate most ImGui features. Call this to learn
|
||||
-- about the library! Try to make it always available in your application!
|
||||
showDemoWindow :: MonadIO m => m ()
|
||||
|
Reference in New Issue
Block a user