dear-imgui-raw-1.0.0: src/DearImGui/Raw/ImFontAtlasRect.hsc
{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE PatternSynonyms #-}
-- This file was generated by dear-bindings-ffi. Do not edit by hand.
module DearImGui.Raw.ImFontAtlasRect
( Id
, ImFontAtlasRect (..)
, destroy
, init
, withDefault
) where
import Control.Exception (bracket_)
import DearImGui.Raw.ImVec2 (ImVec2)
import Foreign.C.Types
import Foreign.Marshal.Alloc (alloca)
import Foreign.Ptr (Ptr, plusPtr)
import Foreign.Storable (Storable (..))
import GHC.Records (HasField (..))
import Prelude hiding (init)
#include "dcimgui_nodefaultargfunctions.h"
-- typedefs
-- | An opaque identifier to a rectangle in the atlas. -1 when invalid.
-- The rectangle may move and UV may be invalidated, use GetCustomRect() to retrieve it.
type Id = CInt
-- structs (opaque)
data {-# CTYPE "dcimgui_nodefaultargfunctions.h" "ImFontAtlasRect" #-} ImFontAtlasRect = ImFontAtlasRect
{ x :: CUShort
, y :: CUShort
, w :: CUShort
, h :: CUShort
, uv0 :: ImVec2
, uv1 :: ImVec2
}
deriving (Eq, Show)
instance Storable ImFontAtlasRect where
sizeOf _ = #{size ImFontAtlasRect}
alignment _ = #{alignment ImFontAtlasRect}
peek p = ImFontAtlasRect <$> #{peek ImFontAtlasRect, x} p <*> #{peek ImFontAtlasRect, y} p <*> #{peek ImFontAtlasRect, w} p <*> #{peek ImFontAtlasRect, h} p <*> #{peek ImFontAtlasRect, uv0} p <*> #{peek ImFontAtlasRect, uv1} p
poke p v = do
#{poke ImFontAtlasRect, x} p v.x
#{poke ImFontAtlasRect, y} p v.y
#{poke ImFontAtlasRect, w} p v.w
#{poke ImFontAtlasRect, h} p v.h
#{poke ImFontAtlasRect, uv0} p v.uv0
#{poke ImFontAtlasRect, uv1} p v.uv1
instance HasField "x" (Ptr ImFontAtlasRect) (Ptr CUShort) where
getField = #{ptr ImFontAtlasRect, x}
instance HasField "y" (Ptr ImFontAtlasRect) (Ptr CUShort) where
getField = #{ptr ImFontAtlasRect, y}
instance HasField "w" (Ptr ImFontAtlasRect) (Ptr CUShort) where
getField = #{ptr ImFontAtlasRect, w}
instance HasField "h" (Ptr ImFontAtlasRect) (Ptr CUShort) where
getField = #{ptr ImFontAtlasRect, h}
instance HasField "uv0" (Ptr ImFontAtlasRect) (Ptr ImVec2) where
getField = #{ptr ImFontAtlasRect, uv0}
instance HasField "uv1" (Ptr ImFontAtlasRect) (Ptr ImVec2) where
getField = #{ptr ImFontAtlasRect, uv1}
foreign import capi unsafe "DearImGuiWrappers.h ImFontAtlasRect_Init_wrap"
init
:: Ptr ImFontAtlasRect
-> IO ()
foreign import capi unsafe "DearImGuiWrappers.h ImFontAtlasRect_Destroy_wrap"
destroy
:: Ptr ImFontAtlasRect
-> IO ()
withDefault :: (Ptr ImFontAtlasRect -> IO a) -> IO a
withDefault k = alloca $ \p -> bracket_ (init p) (destroy p) (k p)