1 /+
2 +            Copyright 2022 – 2024 Aya Partridge
3 +          Copyright 2018 - 2022 Michael D. Parker
4 + Distributed under the Boost Software License, Version 1.0.
5 +     (See accompanying file LICENSE_1_0.txt or copy at
6 +           http://www.boost.org/LICENSE_1_0.txt)
7 +/
8 module sdl.shape;
9 
10 import bindbc.sdl.config;
11 import bindbc.sdl.codegen;
12 
13 import sdl.pixels: SDL_Color;
14 import sdl.stdinc: SDL_bool;
15 import sdl.surface: SDL_Surface;
16 import sdl.video;
17 
18 enum{
19 	SDL_NONSHAPEABLE_WINDOW     = -1,
20 	SDL_INVALID_SHAPE_ARGUMENT  = -2,
21 	SDL_WINDOW_LACKS_SHAPE      = -3,
22 }
23 
24 alias WindowShapeMode = int;
25 enum: WindowShapeMode{
26 	ShapeModeDefault               = 0,
27 	ShapeModeBinarizeAlpha         = 1,
28 	ShapeModeBinariseAlpha         = ShapeModeBinarizeAlpha,
29 	ShapeModeReverseBinarizeAlpha  = 2,
30 	ShapeModeReverseBinariseAlpha  = ShapeModeReverseBinarizeAlpha,
31 	ShapeModeColorKey              = 3,
32 	ShapeModeColourKey             = ShapeModeColorKey,
33 	
34 }
35 
36 enum SDL_SHAPEMODEALPHA(WindowShapeMode mode) = (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha);
37 
38 union SDL_WindowShapeParams{
39 	ubyte binarizationCutoff;
40 	alias binarisationCutoff = binarizationCutoff;
41 	SDL_Color colorKey;
42 	alias colourKey = colorKey;
43 }
44 
45 struct SDL_WindowShapeMode{
46 	WindowShapeMode mode;
47 	SDL_WindowShapeParams parameters;
48 }
49 
50 mixin(joinFnBinds((){
51 	FnBind[] ret = [
52 		{q{SDL_Window*}, q{SDL_CreateShapedWindow}, q{const(char)* title, uint x, uint y, uint w, uint h, SDL_WindowFlags flags}},
53 		{q{SDL_bool}, q{SDL_IsShapedWindow}, q{const(SDL_Window)* window}},
54 		{q{int}, q{SDL_SetWindowShape}, q{SDL_Window* window, SDL_Surface* shape, SDL_WindowShapeMode* shapeMode}},
55 		{q{int}, q{SDL_GetShapedWindowMode}, q{SDL_Window* window, SDL_WindowShapeMode* shapeMode}},
56 	];
57 	return ret;
58 }()));