{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)

Extra alignment parameters for the memory of video buffers. This
structure is usually used to configure the bufferpool if it supports the
'GI.GstVideo.Constants.BUFFER_POOL_OPTION_VIDEO_ALIGNMENT'.
-}

#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
       && !defined(__HADDOCK_VERSION__))

module GI.GstVideo.Structs.VideoAlignment
    (

-- * Exported types
    VideoAlignment(..)                      ,
    newZeroVideoAlignment                   ,
    noVideoAlignment                        ,


 -- * Methods
-- ** reset #method:reset#

#if ENABLE_OVERLOADING
    VideoAlignmentResetMethodInfo           ,
#endif
    videoAlignmentReset                     ,




 -- * Properties
-- ** paddingBottom #attr:paddingBottom#
{- | extra pixels on the bottom
-}
    getVideoAlignmentPaddingBottom          ,
    setVideoAlignmentPaddingBottom          ,
#if ENABLE_OVERLOADING
    videoAlignment_paddingBottom            ,
#endif


-- ** paddingLeft #attr:paddingLeft#
{- | extra pixels on the left side
-}
    getVideoAlignmentPaddingLeft            ,
    setVideoAlignmentPaddingLeft            ,
#if ENABLE_OVERLOADING
    videoAlignment_paddingLeft              ,
#endif


-- ** paddingRight #attr:paddingRight#
{- | extra pixels on the right side
-}
    getVideoAlignmentPaddingRight           ,
    setVideoAlignmentPaddingRight           ,
#if ENABLE_OVERLOADING
    videoAlignment_paddingRight             ,
#endif


-- ** paddingTop #attr:paddingTop#
{- | extra pixels on the top
-}
    getVideoAlignmentPaddingTop             ,
    setVideoAlignmentPaddingTop             ,
#if ENABLE_OVERLOADING
    videoAlignment_paddingTop               ,
#endif




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL


-- | Memory-managed wrapper type.
newtype VideoAlignment = VideoAlignment (ManagedPtr VideoAlignment)
instance WrappedPtr VideoAlignment where
    wrappedPtrCalloc = callocBytes 32
    wrappedPtrCopy = \p -> withManagedPtr p (copyBytes 32 >=> wrapPtr VideoAlignment)
    wrappedPtrFree = Just ptr_to_g_free

-- | Construct a `VideoAlignment` struct initialized to zero.
newZeroVideoAlignment :: MonadIO m => m VideoAlignment
newZeroVideoAlignment = liftIO $ wrappedPtrCalloc >>= wrapPtr VideoAlignment

instance tag ~ 'AttrSet => Constructible VideoAlignment tag where
    new _ attrs = do
        o <- newZeroVideoAlignment
        GI.Attributes.set o attrs
        return o


-- | A convenience alias for `Nothing` :: `Maybe` `VideoAlignment`.
noVideoAlignment :: Maybe VideoAlignment
noVideoAlignment = Nothing

{- |
Get the value of the “@padding_top@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' videoAlignment #paddingTop
@
-}
getVideoAlignmentPaddingTop :: MonadIO m => VideoAlignment -> m Word32
getVideoAlignmentPaddingTop s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO Word32
    return val

{- |
Set the value of the “@padding_top@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' videoAlignment [ #paddingTop 'Data.GI.Base.Attributes.:=' value ]
@
-}
setVideoAlignmentPaddingTop :: MonadIO m => VideoAlignment -> Word32 -> m ()
setVideoAlignmentPaddingTop s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 0) (val :: Word32)

#if ENABLE_OVERLOADING
data VideoAlignmentPaddingTopFieldInfo
instance AttrInfo VideoAlignmentPaddingTopFieldInfo where
    type AttrAllowedOps VideoAlignmentPaddingTopFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint VideoAlignmentPaddingTopFieldInfo = (~) Word32
    type AttrBaseTypeConstraint VideoAlignmentPaddingTopFieldInfo = (~) VideoAlignment
    type AttrGetType VideoAlignmentPaddingTopFieldInfo = Word32
    type AttrLabel VideoAlignmentPaddingTopFieldInfo = "padding_top"
    type AttrOrigin VideoAlignmentPaddingTopFieldInfo = VideoAlignment
    attrGet _ = getVideoAlignmentPaddingTop
    attrSet _ = setVideoAlignmentPaddingTop
    attrConstruct = undefined
    attrClear _ = undefined

videoAlignment_paddingTop :: AttrLabelProxy "paddingTop"
videoAlignment_paddingTop = AttrLabelProxy

#endif


{- |
Get the value of the “@padding_bottom@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' videoAlignment #paddingBottom
@
-}
getVideoAlignmentPaddingBottom :: MonadIO m => VideoAlignment -> m Word32
getVideoAlignmentPaddingBottom s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 4) :: IO Word32
    return val

{- |
Set the value of the “@padding_bottom@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' videoAlignment [ #paddingBottom 'Data.GI.Base.Attributes.:=' value ]
@
-}
setVideoAlignmentPaddingBottom :: MonadIO m => VideoAlignment -> Word32 -> m ()
setVideoAlignmentPaddingBottom s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 4) (val :: Word32)

#if ENABLE_OVERLOADING
data VideoAlignmentPaddingBottomFieldInfo
instance AttrInfo VideoAlignmentPaddingBottomFieldInfo where
    type AttrAllowedOps VideoAlignmentPaddingBottomFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint VideoAlignmentPaddingBottomFieldInfo = (~) Word32
    type AttrBaseTypeConstraint VideoAlignmentPaddingBottomFieldInfo = (~) VideoAlignment
    type AttrGetType VideoAlignmentPaddingBottomFieldInfo = Word32
    type AttrLabel VideoAlignmentPaddingBottomFieldInfo = "padding_bottom"
    type AttrOrigin VideoAlignmentPaddingBottomFieldInfo = VideoAlignment
    attrGet _ = getVideoAlignmentPaddingBottom
    attrSet _ = setVideoAlignmentPaddingBottom
    attrConstruct = undefined
    attrClear _ = undefined

videoAlignment_paddingBottom :: AttrLabelProxy "paddingBottom"
videoAlignment_paddingBottom = AttrLabelProxy

#endif


{- |
Get the value of the “@padding_left@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' videoAlignment #paddingLeft
@
-}
getVideoAlignmentPaddingLeft :: MonadIO m => VideoAlignment -> m Word32
getVideoAlignmentPaddingLeft s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO Word32
    return val

{- |
Set the value of the “@padding_left@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' videoAlignment [ #paddingLeft 'Data.GI.Base.Attributes.:=' value ]
@
-}
setVideoAlignmentPaddingLeft :: MonadIO m => VideoAlignment -> Word32 -> m ()
setVideoAlignmentPaddingLeft s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 8) (val :: Word32)

#if ENABLE_OVERLOADING
data VideoAlignmentPaddingLeftFieldInfo
instance AttrInfo VideoAlignmentPaddingLeftFieldInfo where
    type AttrAllowedOps VideoAlignmentPaddingLeftFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint VideoAlignmentPaddingLeftFieldInfo = (~) Word32
    type AttrBaseTypeConstraint VideoAlignmentPaddingLeftFieldInfo = (~) VideoAlignment
    type AttrGetType VideoAlignmentPaddingLeftFieldInfo = Word32
    type AttrLabel VideoAlignmentPaddingLeftFieldInfo = "padding_left"
    type AttrOrigin VideoAlignmentPaddingLeftFieldInfo = VideoAlignment
    attrGet _ = getVideoAlignmentPaddingLeft
    attrSet _ = setVideoAlignmentPaddingLeft
    attrConstruct = undefined
    attrClear _ = undefined

videoAlignment_paddingLeft :: AttrLabelProxy "paddingLeft"
videoAlignment_paddingLeft = AttrLabelProxy

#endif


{- |
Get the value of the “@padding_right@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' videoAlignment #paddingRight
@
-}
getVideoAlignmentPaddingRight :: MonadIO m => VideoAlignment -> m Word32
getVideoAlignmentPaddingRight s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 12) :: IO Word32
    return val

{- |
Set the value of the “@padding_right@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' videoAlignment [ #paddingRight 'Data.GI.Base.Attributes.:=' value ]
@
-}
setVideoAlignmentPaddingRight :: MonadIO m => VideoAlignment -> Word32 -> m ()
setVideoAlignmentPaddingRight s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 12) (val :: Word32)

#if ENABLE_OVERLOADING
data VideoAlignmentPaddingRightFieldInfo
instance AttrInfo VideoAlignmentPaddingRightFieldInfo where
    type AttrAllowedOps VideoAlignmentPaddingRightFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint VideoAlignmentPaddingRightFieldInfo = (~) Word32
    type AttrBaseTypeConstraint VideoAlignmentPaddingRightFieldInfo = (~) VideoAlignment
    type AttrGetType VideoAlignmentPaddingRightFieldInfo = Word32
    type AttrLabel VideoAlignmentPaddingRightFieldInfo = "padding_right"
    type AttrOrigin VideoAlignmentPaddingRightFieldInfo = VideoAlignment
    attrGet _ = getVideoAlignmentPaddingRight
    attrSet _ = setVideoAlignmentPaddingRight
    attrConstruct = undefined
    attrClear _ = undefined

videoAlignment_paddingRight :: AttrLabelProxy "paddingRight"
videoAlignment_paddingRight = AttrLabelProxy

#endif


-- XXX Skipped attribute for "VideoAlignment:stride_align" :: Not implemented: "Don't know how to unpack C array of type TCArray False 4 (-1) (TBasicType TUInt)"

#if ENABLE_OVERLOADING
instance O.HasAttributeList VideoAlignment
type instance O.AttributeList VideoAlignment = VideoAlignmentAttributeList
type VideoAlignmentAttributeList = ('[ '("paddingTop", VideoAlignmentPaddingTopFieldInfo), '("paddingBottom", VideoAlignmentPaddingBottomFieldInfo), '("paddingLeft", VideoAlignmentPaddingLeftFieldInfo), '("paddingRight", VideoAlignmentPaddingRightFieldInfo)] :: [(Symbol, *)])
#endif

-- method VideoAlignment::reset
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "align", argType = TInterface (Name {namespace = "GstVideo", name = "VideoAlignment"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstVideoAlignment", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_video_alignment_reset" gst_video_alignment_reset ::
    Ptr VideoAlignment ->                   -- align : TInterface (Name {namespace = "GstVideo", name = "VideoAlignment"})
    IO ()

{- |
Set /@align@/ to its default values with no padding and no alignment.
-}
videoAlignmentReset ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    VideoAlignment
    {- ^ /@align@/: a 'GI.GstVideo.Structs.VideoAlignment.VideoAlignment' -}
    -> m ()
videoAlignmentReset align = liftIO $ do
    align' <- unsafeManagedPtrGetPtr align
    gst_video_alignment_reset align'
    touchManagedPtr align
    return ()

#if ENABLE_OVERLOADING
data VideoAlignmentResetMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo VideoAlignmentResetMethodInfo VideoAlignment signature where
    overloadedMethod _ = videoAlignmentReset

#endif

#if ENABLE_OVERLOADING
type family ResolveVideoAlignmentMethod (t :: Symbol) (o :: *) :: * where
    ResolveVideoAlignmentMethod "reset" o = VideoAlignmentResetMethodInfo
    ResolveVideoAlignmentMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveVideoAlignmentMethod t VideoAlignment, O.MethodInfo info VideoAlignment p) => OL.IsLabel t (VideoAlignment -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

#endif