packages feed

dear-imgui-raw-1.0.0: src/DearImGui/Raw/ImFontConfig.hsc

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

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

module DearImGui.Raw.ImFontConfig
  ( ImFontConfig
  , destroy
  , init
  , nameLength
  , withDefault
  ) where

import Control.Exception (bracket_)
import DearImGui.Raw (ImS8, ImU32, ImWchar)
import DearImGui.Raw.Enums.ImFontFlags (ImFontFlags)
import DearImGui.Raw.ImFont (ImFont)
import DearImGui.Raw.ImFontLoader (ImFontLoader)
import DearImGui.Raw.ImVec2 (ImVec2)
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_nodefaultargfunctions.h"

-- structs (opaque)

data ImFontConfig
instance Storable ImFontConfig where
  sizeOf _    = #{size ImFontConfig}
  alignment _ = #{alignment ImFontConfig}
  peek _ = error "ImFontConfig: opaque struct, peek not supported in v0"
  poke _ _ = error "ImFontConfig: opaque struct, poke not supported in v0"

instance HasField "name" (Ptr ImFontConfig) (Ptr CChar) where
  getField = #{ptr ImFontConfig, Name}

nameLength :: Int
nameLength = #{const 40}

instance HasField "fontData" (Ptr ImFontConfig) (Ptr (Ptr ())) where
  getField = #{ptr ImFontConfig, FontData}

instance HasField "fontDataSize" (Ptr ImFontConfig) (Ptr CInt) where
  getField = #{ptr ImFontConfig, FontDataSize}

instance HasField "fontDataOwnedByAtlas" (Ptr ImFontConfig) (Ptr CBool) where
  getField = #{ptr ImFontConfig, FontDataOwnedByAtlas}

instance HasField "mergeMode" (Ptr ImFontConfig) (Ptr CBool) where
  getField = #{ptr ImFontConfig, MergeMode}

instance HasField "pixelSnapH" (Ptr ImFontConfig) (Ptr CBool) where
  getField = #{ptr ImFontConfig, PixelSnapH}

instance HasField "oversampleH" (Ptr ImFontConfig) (Ptr ImS8) where
  getField = #{ptr ImFontConfig, OversampleH}

instance HasField "oversampleV" (Ptr ImFontConfig) (Ptr ImS8) where
  getField = #{ptr ImFontConfig, OversampleV}

instance HasField "ellipsisChar" (Ptr ImFontConfig) (Ptr ImWchar) where
  getField = #{ptr ImFontConfig, EllipsisChar}

instance HasField "sizePixels" (Ptr ImFontConfig) (Ptr Float) where
  getField = #{ptr ImFontConfig, SizePixels}

instance HasField "glyphRanges" (Ptr ImFontConfig) (Ptr (Ptr ImWchar)) where
  getField = #{ptr ImFontConfig, GlyphRanges}

instance HasField "glyphExcludeRanges" (Ptr ImFontConfig) (Ptr (Ptr ImWchar)) where
  getField = #{ptr ImFontConfig, GlyphExcludeRanges}

instance HasField "glyphOffset" (Ptr ImFontConfig) (Ptr ImVec2) where
  getField = #{ptr ImFontConfig, GlyphOffset}

instance HasField "glyphMinAdvanceX" (Ptr ImFontConfig) (Ptr Float) where
  getField = #{ptr ImFontConfig, GlyphMinAdvanceX}

instance HasField "glyphMaxAdvanceX" (Ptr ImFontConfig) (Ptr Float) where
  getField = #{ptr ImFontConfig, GlyphMaxAdvanceX}

instance HasField "glyphExtraAdvanceX" (Ptr ImFontConfig) (Ptr Float) where
  getField = #{ptr ImFontConfig, GlyphExtraAdvanceX}

instance HasField "fontNo" (Ptr ImFontConfig) (Ptr ImU32) where
  getField = #{ptr ImFontConfig, FontNo}

instance HasField "fontLoaderFlags" (Ptr ImFontConfig) (Ptr CUInt) where
  getField = #{ptr ImFontConfig, FontLoaderFlags}

instance HasField "rasterizerMultiply" (Ptr ImFontConfig) (Ptr Float) where
  getField = #{ptr ImFontConfig, RasterizerMultiply}

instance HasField "rasterizerDensity" (Ptr ImFontConfig) (Ptr Float) where
  getField = #{ptr ImFontConfig, RasterizerDensity}

instance HasField "extraSizeScale" (Ptr ImFontConfig) (Ptr Float) where
  getField = #{ptr ImFontConfig, ExtraSizeScale}

instance HasField "flags" (Ptr ImFontConfig) (Ptr ImFontFlags) where
  getField = #{ptr ImFontConfig, Flags}

instance HasField "dstFont" (Ptr ImFontConfig) (Ptr (Ptr ImFont)) where
  getField = #{ptr ImFontConfig, DstFont}

instance HasField "fontLoader" (Ptr ImFontConfig) (Ptr (Ptr ImFontLoader)) where
  getField = #{ptr ImFontConfig, FontLoader}

instance HasField "fontLoaderData" (Ptr ImFontConfig) (Ptr (Ptr ())) where
  getField = #{ptr ImFontConfig, FontLoaderData}

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

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

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