packages feed

dear-imgui-raw-internal-1.0.0: src/DearImGui/Raw/Internal/ImGuiInputEventMousePos.hsc

{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE PatternSynonyms #-}

-- This file was generated by dear-bindings-ffi. Do not edit by hand.

module DearImGui.Raw.Internal.ImGuiInputEventMousePos
  ( ImGuiInputEventMousePos (..)
  , destroy
  , init
  , withDefault
  ) where

import Control.Exception (bracket_)
import DearImGui.Raw.Enums.ImGuiMouseSource (ImGuiMouseSource)
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_internal.h"

-- structs (opaque)

data {-# CTYPE "dcimgui_nodefaultargfunctions_internal.h" "ImGuiInputEventMousePos" #-} ImGuiInputEventMousePos = ImGuiInputEventMousePos
  { posX :: Float
  , posY :: Float
  , mouseSource :: ImGuiMouseSource
  }
  deriving (Eq, Show)
instance Storable ImGuiInputEventMousePos where
  sizeOf _    = #{size ImGuiInputEventMousePos}
  alignment _ = #{alignment ImGuiInputEventMousePos}
  peek p = ImGuiInputEventMousePos <$> #{peek ImGuiInputEventMousePos, PosX} p <*> #{peek ImGuiInputEventMousePos, PosY} p <*> #{peek ImGuiInputEventMousePos, MouseSource} p
  poke p v = do
    #{poke ImGuiInputEventMousePos, PosX} p v.posX
    #{poke ImGuiInputEventMousePos, PosY} p v.posY
    #{poke ImGuiInputEventMousePos, MouseSource} p v.mouseSource

instance HasField "posX" (Ptr ImGuiInputEventMousePos) (Ptr Float) where
  getField = #{ptr ImGuiInputEventMousePos, PosX}

instance HasField "posY" (Ptr ImGuiInputEventMousePos) (Ptr Float) where
  getField = #{ptr ImGuiInputEventMousePos, PosY}

instance HasField "mouseSource" (Ptr ImGuiInputEventMousePos) (Ptr ImGuiMouseSource) where
  getField = #{ptr ImGuiInputEventMousePos, MouseSource}

foreign import capi unsafe "DearImGuiWrappers.h ImGuiInputEventMousePos_Init_wrap"
  init
    :: Ptr ImGuiInputEventMousePos
    -> IO ()

foreign import capi unsafe "DearImGuiWrappers.h ImGuiInputEventMousePos_Destroy_wrap"
  destroy
    :: Ptr ImGuiInputEventMousePos
    -> IO ()

withDefault :: (Ptr ImGuiInputEventMousePos -> IO a) -> IO a
withDefault k = alloca $ \p -> bracket_ (init p) (destroy p) (k p)