1 /*
2  * Copyright (c) 2016 Derelict Developers
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  *   notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  *   notice, this list of conditions and the following disclaimer in the
14  *   documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the names 'Derelict', 'DerelictLibui', nor the names of its contributors
17  *   may be used to endorse or promote products derived from this software
18  *   without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 module derelict.libui.funcs;
33 
34 private
35 {
36     import derelict.util.system;
37     import derelict.libui.types;
38 }
39 
40 alias cstring = const(char)*;
41 
42 extern(C) @nogc nothrow
43 {
44     alias da_uiInit = cstring function(uiInitOptions *options);
45     alias da_uiUninit = void function();
46 
47     alias da_uiFreeInitError = void function(const char *err);
48 
49     alias da_uiMain = void function();
50     alias da_uiQuit = void function();
51 /+
52 // TODO write a test for this after adding multiline entries
53 _UI_EXTERN void uiQueueMain(void (*f)(void *data), void *data);
54 
55 _UI_EXTERN void uiOnShouldQuit(int (*f)(void *data), void *data);
56 
57 _UI_EXTERN void uiFreeText(char *text);
58 +/
59 
60     alias da_uiControlDestroy = void function(uiControl *);
61 /+
62 _UI_EXTERN uintptr_t uiControlHandle(uiControl *);
63 _UI_EXTERN uiControl *uiControlParent(uiControl *);
64 _UI_EXTERN void uiControlSetParent(uiControl *, uiControl *);
65 _UI_EXTERN int uiControlToplevel(uiControl *);
66 _UI_EXTERN int uiControlVisible(uiControl *);
67 +/
68     alias da_uiControlShow = void function(uiControl *);
69 /+
70 _UI_EXTERN void uiControlHide(uiControl *);
71 _UI_EXTERN int uiControlEnabled(uiControl *);
72 _UI_EXTERN void uiControlEnable(uiControl *);
73 _UI_EXTERN void uiControlDisable(uiControl *);+/
74 
75 alias onWindowClosingFunction = int function(uiWindow* w, void* data) nothrow;
76 
77 //_UI_EXTERN char *uiWindowTitle(uiWindow *w);
78 //_UI_EXTERN void uiWindowSetTitle(uiWindow *w, const char *title);
79     alias da_uiWindowOnClosing = void function(uiWindow *w, onWindowClosingFunction f, void* data);
80     alias da_uiWindowSetChild = void function(uiWindow *w, uiControl *child);
81     alias da_uiWindowMargined = int function(uiWindow *w);
82     alias da_uiWindowSetMargined = void function(uiWindow *w, int margined);
83     alias da_uiNewWindow = uiWindow* function(cstring title, int width, int height, int hasMenubar);
84 
85     //_UI_EXTERN void uiColorButtonColor(uiColorButton *b, double *r, double *g, double *bl, double *a);
86 //_UI_EXTERN void uiColorButtonSetColor(uiColorButton *b, double r, double g, double bl, double a);
87 //_UI_EXTERN void uiColorButtonOnChanged(uiColorButton *b, void (*f)(uiColorButton *, void *), void *data);
88     alias da_uiNewColorButton = uiColorButton* function();
89 }
90 
91 __gshared
92 {
93     da_uiInit uiInit;
94     da_uiUninit uiUninit;
95 
96     da_uiFreeInitError uiFreeInitError;
97     da_uiMain uiMain;
98     da_uiQuit uiQuit;
99 
100     da_uiControlDestroy uiControlDestroy;
101     da_uiControlShow uiControlShow;
102 
103     da_uiWindowOnClosing uiWindowOnClosing;
104     da_uiWindowSetChild uiWindowSetChild;
105     da_uiWindowMargined uiWindowMargined;
106     da_uiWindowSetMargined uiWindowSetMargined;
107     da_uiNewWindow uiNewWindow;
108 
109     da_uiNewColorButton uiNewColorButton;
110 }