mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2025-07-07 21:39:55 +02:00
Stubbing out ImGui::ColorButton() and ImVec4
This commit is contained in:
@ -62,6 +62,9 @@ module DearImGui
|
||||
, beginCombo
|
||||
, endCombo
|
||||
|
||||
-- * Color Editor/Picker
|
||||
, colorButton
|
||||
|
||||
-- ** Selectables
|
||||
, selectable
|
||||
|
||||
@ -97,6 +100,7 @@ module DearImGui
|
||||
, pattern ImGuiDirRight
|
||||
, pattern ImGuiDirUp
|
||||
, pattern ImGuiDirDown
|
||||
, ImVec4(..)
|
||||
)
|
||||
where
|
||||
|
||||
@ -105,6 +109,9 @@ import Data.Bool
|
||||
import Foreign
|
||||
import Foreign.C
|
||||
|
||||
-- dear-imgui
|
||||
import DearImGui.Context
|
||||
|
||||
-- inline-c
|
||||
import qualified Language.C.Inline as C
|
||||
|
||||
@ -120,7 +127,7 @@ import Control.Monad.IO.Class
|
||||
( MonadIO, liftIO )
|
||||
|
||||
|
||||
C.context (Cpp.cppCtx <> C.bsCtx)
|
||||
C.context (Cpp.cppCtx <> C.bsCtx <> imguiContext)
|
||||
C.include "imgui.h"
|
||||
Cpp.using "namespace ImGui"
|
||||
|
||||
@ -367,6 +374,22 @@ endCombo = liftIO do
|
||||
[C.exp| void { EndCombo() } |]
|
||||
|
||||
|
||||
-- | Display a color square/button, hover for details, return true when pressed.
|
||||
--
|
||||
-- | Wraps @ImGui::ColorButton()@.
|
||||
colorButton :: (MonadIO m, HasSetter ref ImVec4, HasGetter ref ImVec4) => String -> ref -> m Bool
|
||||
colorButton desc ref = liftIO do
|
||||
currentValue <- get ref
|
||||
with currentValue \refPtr -> do
|
||||
changed <- withCString desc \descPtr ->
|
||||
(1 == ) <$> [C.exp| bool { ColorButton( $(char* descPtr), *$(ImVec4 *refPtr) ) } |]
|
||||
|
||||
newValue <- peek refPtr
|
||||
ref $=! newValue
|
||||
|
||||
return changed
|
||||
|
||||
|
||||
-- | Wraps @ImGui::Selectable()@.
|
||||
selectable :: MonadIO m => String -> m Bool
|
||||
selectable label = liftIO do
|
||||
|
Reference in New Issue
Block a user