packages feed

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

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

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

module DearImGui.Raw.Internal.ImGuiInputEventMouseWheel
  ( ImGuiInputEventMouseWheel (..)
  , 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" "ImGuiInputEventMouseWheel" #-} ImGuiInputEventMouseWheel = ImGuiInputEventMouseWheel
  { wheelX :: Float
  , wheelY :: Float
  , mouseSource :: ImGuiMouseSource
  }
  deriving (Eq, Show)
instance Storable ImGuiInputEventMouseWheel where
  sizeOf _    = #{size ImGuiInputEventMouseWheel}
  alignment _ = #{alignment ImGuiInputEventMouseWheel}
  peek p = ImGuiInputEventMouseWheel <$> #{peek ImGuiInputEventMouseWheel, WheelX} p <*> #{peek ImGuiInputEventMouseWheel, WheelY} p <*> #{peek ImGuiInputEventMouseWheel, MouseSource} p
  poke p v = do
    #{poke ImGuiInputEventMouseWheel, WheelX} p v.wheelX
    #{poke ImGuiInputEventMouseWheel, WheelY} p v.wheelY
    #{poke ImGuiInputEventMouseWheel, MouseSource} p v.mouseSource

instance HasField "wheelX" (Ptr ImGuiInputEventMouseWheel) (Ptr Float) where
  getField = #{ptr ImGuiInputEventMouseWheel, WheelX}

instance HasField "wheelY" (Ptr ImGuiInputEventMouseWheel) (Ptr Float) where
  getField = #{ptr ImGuiInputEventMouseWheel, WheelY}

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

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

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

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