{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE PatternSynonyms #-}
-- This file was generated by dear-bindings-ffi. Do not edit by hand.
module DearImGui.Raw.ImPlot.Range
( Range (..)
, clamp
, contains
, destroy
, init
, size
, withDefault
) where
import Control.Exception (bracket_)
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_implot.h"
-- structs (opaque)
-- by-value
data {-# CTYPE "dcimgui_implot.h" "ImPlotRange" #-} Range = Range
{ min :: Double
, max :: Double
}
deriving (Eq, Show)
instance Storable Range where
sizeOf _ = #{size ImPlotRange}
alignment _ = #{alignment ImPlotRange}
peek p = Range <$> #{peek ImPlotRange, Min} p <*> #{peek ImPlotRange, Max} p
poke p v = do
#{poke ImPlotRange, Min} p v.min
#{poke ImPlotRange, Max} p v.max
instance HasField "min" (Ptr Range) (Ptr Double) where
getField = #{ptr ImPlotRange, Min}
instance HasField "max" (Ptr Range) (Ptr Double) where
getField = #{ptr ImPlotRange, Max}
foreign import capi unsafe "DearImGuiWrappers.h ImPlotRange_Init_wrap"
init
:: Ptr Range
-> IO ()
foreign import capi unsafe "DearImGuiWrappers.h ImPlotRange_Destroy_wrap"
destroy
:: Ptr Range
-> IO ()
withDefault :: (Ptr Range -> IO a) -> IO a
withDefault k = alloca $ \p -> bracket_ (init p) (destroy p) (k p)
-- functions
-- C: double Clamp(const ImPlotRange* self, double value)
foreign import capi unsafe "dcimgui_implot.h ImPlotRange_Clamp"
clamp
:: (Ptr Range) -- ^ self
-> Double -- ^ value
-> IO Double
-- C: bool Contains(const ImPlotRange* self, double value)
foreign import capi unsafe "dcimgui_implot.h ImPlotRange_Contains"
contains
:: (Ptr Range) -- ^ self
-> Double -- ^ value
-> IO CBool
-- C: double Size(const ImPlotRange* self)
foreign import capi unsafe "dcimgui_implot.h ImPlotRange_Size"
size
:: (Ptr Range) -- ^ self
-> IO Double