{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE StandaloneDeriving #-} {-# OPTIONS_HADDOCK hide #-} -------------------------------------------------------------------------------- #include #include -------------------------------------------------------------------------------- module Bindings.Yoga where import Data.Data (Data) import Data.Typeable (Typeable) import Foreign.C.Types (CFloat(..), CInt(..), CUInt(..)) import Foreign.Ptr (FunPtr, Ptr, plusPtr) import Foreign.Storable (Storable(..)) import Prelude (Eq, IO, Show) import Prelude (($), return) -------------------------------------------------------------------------------- #starttype struct YGSize #field width , CFloat #field height , CFloat #stoptype deriving instance Typeable C'YGSize #opaque_t YGNode deriving instance Typeable C'YGNode deriving instance Data C'YGNode #callback_t YGMeasureFunc, Ptr -> CFloat -> CInt -> CFloat -> CInt -> IO (Ptr ) #callback_t YGPrintFunc, Ptr -> IO () {-- typedef int (*YGLogger)(YGLogLevel level, const char *format, va_list args); WIN_EXPORT void YGSetLogger(YGLogger logger); WIN_EXPORT void YGLog(YGLogLevel level, const char *message, ...); typedef void *(*YGMalloc)(size_t size); typedef void *(*YGCalloc)(size_t count, size_t size); typedef void *(*YGRealloc)(void *ptr, size_t size); typedef void (*YGFree)(void *ptr); WIN_EXPORT void YGSetMemoryFuncs(YGMalloc ygmalloc, YGCalloc yccalloc, YGRealloc ygrealloc, YGFree ygfree); -} #ccall YGNodeNew, IO (Ptr ) #ccall YGNodeFree, Ptr -> IO () #ccall YGNodeFreeRecursive, Ptr -> IO () #ccall YGNodeReset, Ptr -> IO () #ccall YGNodeGetInstanceCount, IO (CInt) #ccall YGNodeInsertChild, Ptr -> Ptr -> CUInt -> IO () #ccall YGNodeRemoveChild, Ptr -> Ptr -> IO () #ccall YGNodeGetChild, Ptr -> CUInt -> IO (Ptr ) #ccall YGNodeCalculateLayout, Ptr -> CFloat -> CFloat -> CInt -> IO () -- Mark a node as dirty. Only valid for nodes with a custom measure function -- set. -- YG knows when to mark all other nodes as dirty but because nodes with -- measure functions -- depends on information not known to YG they must perform this dirty -- marking manually. #ccall YGNodeMarkDirty, Ptr -> IO () #ccall YGNodeIsDirty, Ptr -> IO CInt #ccall YGNodePrint, Ptr -> CInt -> IO () #ccall YGNodeCanUseCachedMeasurement, CInt -> CFloat -> CInt -> CFloat -> CInt -> CFloat -> CInt -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> IO CInt #ccall YGNodeCopyStyle, Ptr -> Ptr -> IO () #ccall YGNodeSetContext, Ptr -> Ptr () -> IO () #ccall YGNodeGetContext, Ptr -> IO (Ptr ()) #ccall YGNodeSetMeasureFunc, Ptr -> Ptr -> IO () #ccall YGNodeGetMeasureFunc, Ptr -> IO (Ptr ) #ccall YGNodeSetPrintFunc, Ptr -> Ptr -> IO () #ccall YGNodeGetPrintFunc, Ptr -> IO (Ptr ) #ccall YGNodeSetHasNewLayout, Ptr -> CInt -> IO () #ccall YGNodeGetHasNewLayout, Ptr -> IO CInt #ccall YGNodeStyleSetDirection, Ptr -> CInt -> IO () #ccall YGNodeStyleGetDirection, Ptr -> IO CInt #ccall YGNodeStyleSetFlexDirection, Ptr -> CInt -> IO () #ccall YGNodeStyleGetFlexDirection, Ptr -> IO CInt #ccall YGNodeStyleSetJustifyContent, Ptr -> CInt -> IO () #ccall YGNodeStyleGetJustifyContent, Ptr -> IO CInt #ccall YGNodeStyleSetAlignContent, Ptr -> CInt -> IO () #ccall YGNodeStyleGetAlignContent, Ptr -> IO CInt #ccall YGNodeStyleSetAlignItems, Ptr -> CInt -> IO () #ccall YGNodeStyleGetAlignItems, Ptr -> IO CInt #ccall YGNodeStyleSetAlignSelf, Ptr -> CInt -> IO () #ccall YGNodeStyleGetAlignSelf, Ptr -> IO CInt #ccall YGNodeStyleSetPositionType, Ptr -> CInt -> IO () #ccall YGNodeStyleGetPositionType, Ptr -> IO CInt #ccall YGNodeStyleSetFlexWrap, Ptr -> CInt -> IO () #ccall YGNodeStyleGetFlexWrap, Ptr -> IO CInt #ccall YGNodeStyleSetOverflow, Ptr -> CInt -> IO () #ccall YGNodeStyleGetOverflow, Ptr -> IO CInt #ccall YGNodeStyleSetFlex, Ptr -> CFloat -> IO () #ccall YGNodeStyleSetFlexGrow, Ptr -> CFloat -> IO () #ccall YGNodeStyleGetFlexGrow, Ptr -> IO CFloat #ccall YGNodeStyleSetFlexShrink, Ptr -> CFloat -> IO () #ccall YGNodeStyleGetFlexShrink, Ptr -> IO CFloat #ccall YGNodeStyleSetFlexBasis, Ptr -> CFloat -> IO () #ccall YGNodeStyleGetFlexBasis, Ptr -> IO CFloat #ccall YGNodeStyleSetPosition, Ptr -> CInt -> CFloat -> IO () #ccall YGNodeStyleGetPosition, Ptr -> CInt -> IO CFloat #ccall YGNodeStyleSetMargin, Ptr -> CInt -> CFloat -> IO () #ccall YGNodeStyleGetMargin, Ptr -> CInt -> IO CFloat #ccall YGNodeStyleSetPadding, Ptr -> CInt -> CFloat -> IO () #ccall YGNodeStyleGetPadding, Ptr -> CInt -> IO CFloat #ccall YGNodeStyleSetBorder, Ptr -> CInt -> CFloat -> IO () #ccall YGNodeStyleGetBorder, Ptr -> CInt -> IO CFloat #ccall YGNodeStyleSetWidth, Ptr -> CFloat -> IO () #ccall YGNodeStyleGetWidth, Ptr -> IO CFloat #ccall YGNodeStyleSetHeight, Ptr -> CFloat -> IO () #ccall YGNodeStyleGetHeight, Ptr -> IO CFloat #ccall YGNodeStyleSetMinWidth, Ptr -> CFloat -> IO () #ccall YGNodeStyleGetMinWidth, Ptr -> IO CFloat #ccall YGNodeStyleSetMinHeight, Ptr -> CFloat -> IO () #ccall YGNodeStyleGetMinHeight, Ptr -> IO CFloat #ccall YGNodeStyleSetMaxWidth, Ptr -> CFloat -> IO () #ccall YGNodeStyleGetMaxWidth, Ptr -> IO CFloat #ccall YGNodeStyleSetMaxHeight, Ptr -> CFloat -> IO () #ccall YGNodeStyleGetMaxHeight, Ptr -> IO CFloat -- Yoga specific properties, not compatible with flexbox specification -- Aspect ratio control the size of the undefined dimension of a node. -- - On a node with a set width/height aspect ratio control the size of the unset dimension -- - On a node with a set flex basis aspect ratio controls the size of the node in the cross axis if -- unset -- - On a node with a measure function aspect ratio works as though the measure function measures -- the flex basis -- - On a node with flex grow/shrink aspect ratio controls the size of the node in the cross axis if -- unset -- - Aspect ratio takes min/max dimensions into account #ccall YGNodeStyleSetAspectRatio, Ptr -> CFloat -> IO () #ccall YGNodeStyleGetAspectRatio, Ptr -> IO CFloat #ccall YGNodeLayoutGetLeft, Ptr -> IO CFloat #ccall YGNodeLayoutGetTop, Ptr -> IO CFloat #ccall YGNodeLayoutGetRight, Ptr -> IO CFloat #ccall YGNodeLayoutGetBottom, Ptr -> IO CFloat #ccall YGNodeLayoutGetWidth, Ptr -> IO CFloat #ccall YGNodeLayoutGetHeight, Ptr -> IO CFloat #ccall YGNodeLayoutGetDirection, Ptr -> IO CInt