mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2025-07-04 20:18:47 +02:00
Wrap @ImGui::ColorPicker3()@
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
{-# language DuplicateRecordFields #-}
|
||||
{-# language NamedFieldPuns #-}
|
||||
{-# language OverloadedStrings #-}
|
||||
{-# language TemplateHaskell #-}
|
||||
@ -10,6 +11,26 @@ import qualified Data.Map.Strict as Map
|
||||
import Foreign
|
||||
|
||||
|
||||
data ImVec3 = ImVec3 { x, y, z :: {-# unpack #-} !Float }
|
||||
|
||||
|
||||
instance Storable ImVec3 where
|
||||
sizeOf ~ImVec3{x, y, z} = sizeOf x + sizeOf y + sizeOf z
|
||||
|
||||
alignment _ = 0
|
||||
|
||||
poke ptr ImVec3{ x, y, z } = do
|
||||
poke (castPtr ptr `plusPtr` (sizeOf x * 0)) x
|
||||
poke (castPtr ptr `plusPtr` (sizeOf x * 1)) y
|
||||
poke (castPtr ptr `plusPtr` (sizeOf x * 2)) z
|
||||
|
||||
peek ptr = do
|
||||
x <- peek (castPtr ptr )
|
||||
y <- peek (castPtr ptr `plusPtr` (sizeOf x * 1))
|
||||
z <- peek (castPtr ptr `plusPtr` (sizeOf x * 2))
|
||||
return ImVec3{ x, y, z }
|
||||
|
||||
|
||||
data ImVec4 = ImVec4 { x, y, z, w :: {-# unpack #-} !Float }
|
||||
|
||||
|
||||
@ -35,6 +56,7 @@ instance Storable ImVec4 where
|
||||
imguiContext :: Context
|
||||
imguiContext = mempty
|
||||
{ ctxTypesTable = Map.fromList
|
||||
[ ( TypeName "ImVec4", [t| ImVec4 |] )
|
||||
[ ( TypeName "ImVec3", [t| ImVec3 |] )
|
||||
, ( TypeName "ImVec4", [t| ImVec4 |] )
|
||||
]
|
||||
}
|
||||
|
Reference in New Issue
Block a user