shape

shape.nim

Header file for the shaped window API.

Types

WindowShapeMode* {...}{.size: sizeof(cint).} = enum
  ShapeModeDefault,         ## The default mode, a binarized alpha cutoff of 1.
  ShapeModeBinarizeAlpha,   ## A binarized alpha cutoff with a given integer value.
  ShapeModeReverseBinarizeAlpha, ## A binarized alpha cutoff with a given integer value,
                                  ## 
                                  ## but with the opposite comparison.
  ShapeModeColorKey          ## A color key is applied.
An enum denoting the specific type of contents present in an WindowShapeParams union.
WindowShapeParams* {...}{.union.} = object
  binarizationCutoff*: uint8 ## A cutoff alpha value for binarization
                             ## of the window shape's alpha channel.
  colorKey*: Color
A union containing parameters for shaped windows.
WindowShapeModeObj* = object
  mode*: WindowShapeMode     ## The mode of these window-shape parameters.
  parameters*: WindowShapeParams ## Window-shape parameters.
  
A struct that tags the WindowShapeParams union with an enum describing the type of its contents.

Consts

NONSHAPEABLE_WINDOW* = -1
INVALID_SHAPE_ARGUMENT* = -2
WINDOW_LACKS_SHAPE* = -3

Procs

proc createShapedWindow*(title: cstring; x: cuint; y: cuint; w: cuint; h: cuint;
                         flags: uint32): Window {...}{.cdecl,
    importc: "SDL_CreateShapedWindow", dynlib: SDL2_LIB.}

Create a window that can be shaped with the specified position, dimensions, and flags.

title The title of the window, in UTF-8 encoding.

x The x position of the window, WINDOWPOS_CENTERED, or WINDOWPOS_UNDEFINED.

y The y position of the window, WINDOWPOS_CENTERED, or WINDOWPOS_UNDEFINED.

w The width of the window.

h The height of the window.

flags
The flags for the window, a mask of WINDOW_BORDERLESS with any of the following:
  • WINDOW_OPENGL,
  • WINDOW_INPUT_GRABBED,
  • WINDOW_HIDDEN,
  • WINDOW_RESIZABLE,
  • WINDOW_MAXIMIZED,
  • WINDOW_MINIMIZED,
  • WINDOW_BORDERLESS is always set,
  • WINDOW_FULLSCREEN is always unset.

Return The window created, or nil if window creation failed.

See also:

destroyWindow()

proc isShapedWindow*(window: Window): bool {...}{.cdecl,
    importc: "SDL_IsShapedWindow", dynlib: SDL2_LIB.}

Return whether the given window is a shaped window.

window The window to query for being shaped.

Return true if the window is a window that can be shaped, false if the window is unshaped or nil.

See also:

createShapedWindow()

proc setWindowShape*(window: Window; shape: Surface;
                     shape_mode: ptr WindowShapeModeObj): cint {...}{.cdecl,
    importc: "SDL_SetWindowShape", dynlib: SDL2_LIB.}

Set the shape and parameters of a shaped window.

window The shaped window whose parameters should be set.

shape A surface encoding the desired shape for the window.

shape_mode The parameters to set for the shaped window.

Return 0 on success, INVALID_SHAPE_ARGUMENT on an invalid shape argument, or NONSHAPEABLE_WINDOW if the Window given does not reference a valid shaped window.

See also:

WindowShapeMode

getShapedWindowMode()

proc getShapedWindowMode*(window: Window; shape_mode: ptr WindowShapeModeObj): cint {...}{.
    cdecl, importc: "SDL_GetShapedWindowMode", dynlib: SDL2_LIB.}

Get the shape parameters of a shaped window.

window The shaped window whose parameters should be retrieved.

shape_mode An empty shape-mode structure to fill, or nil to check whether the window has a shape.

Return 0 if the window has a shape and, provided shape_mode was not nil, shape_mode has been filled with the mode data, NONSHAPEABLE_WINDOW if the Window given is not a shaped window, or WINDOW_LACKS_SHAPE if the Window given is a shapeable window currently lacking a shape.

See also:

WindowShapeMode

setWindowShape()

Templates

template shapeModeAlpha*(mode: untyped): untyped