EasyGUI
gui.h
1 
6 /*
7  * Copyright (c) 2019 Tilen MAJERLE
8  *
9  * Permission is hereby granted, free of charge, to any person
10  * obtaining a copy of this software and associated documentation
11  * files (the "Software"), to deal in the Software without restriction,
12  * including without limitation the rights to use, copy, modify, merge,
13  * publish, distribute, sublicense, and/or sell copies of the Software,
14  * and to permit persons to whom the Software is furnished to do so,
15  * subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
23  * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  *
29  * This file is part of EasyGUI library.
30  *
31  * Author: Tilen Majerle <tilen@majerle.eu>
32  */
33 #ifndef GUI_HDR_H
34 #define GUI_HDR_H
35 
36 /* C++ detection */
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
47 /* GUI configuration */
48 #include "gui_config.h"
49 
50 /* Important GUI definitions */
51 #include "gui/gui_defs.h"
52 
53 /* Proto threads */
54 #include "gui/pt/pt.h"
55 
56 /* Include utilities */
57 #include "gui/gui_buff.h"
58 #include "gui/gui_linkedlist.h"
59 #include "gui/gui_string.h"
60 #include "gui/gui_timer.h"
61 #include "gui/gui_math.h"
62 #include "gui/gui_mem.h"
63 #include "gui/gui_translate.h"
64 
65 /* GUI Low-Level drivers */
66 #include "system/gui_ll.h"
67 #include "system/gui_sys.h"
68 
69 //#if defined(GUI_INTERNAL) || __DOXYGEN__
76 #if GUI_CFG_OS
77 #define GUI_CORE_PROTECT(p) if (p) gui_sys_protect()
78 #define GUI_CORE_UNPROTECT(p) if (p) gui_sys_unprotect()
79 #else /* GUI_CFG_OS */
80 #define GUI_CORE_PROTECT(p) GUI_UNUSED(p)
81 #define GUI_CORE_UNPROTECT(p) GUI_UNUSED(p)
82 #endif /* !GUI_CFG_OS */
83 
91 #define GUI_DEBUG(fmt, ...) printf(fmt, ##__VA_ARGS__)
92 
98 #define GUI_MEMALLOC(size) gui_mem_calloc(1, size)
99 
104 #define GUI_MEMREALLOC(ptr, size) gui_mem_realloc(ptr, size)
105 
110 #define GUI_MEMFREE(p) do { \
111  gui_mem_free(p); \
112  (p) = NULL; \
113 } while (0)
114 
122 #define GUI_MAX(x, y) ((x) > (y) ? (x) : (y))
123 
131 #define GUI_MIN(x, y) ((x) < (y) ? (x) : (y))
132 
139 #define GUI_ABS(x) ((x) >= 0 ? (x) : -(x))
140 
146 #define GUI_UNUSED(x) (void)(x)
147 
153 #define GUI_UNUSED2(x, y) { GUI_UNUSED(x); GUI_UNUSED(y); }
154 
160 #define GUI_UNUSED3(x, y, z) { GUI_UNUSED2(x, y); GUI_UNUSED(z); }
161 
167 #define GUI_UNUSED4(x, y, z, k) { GUI_UNUSED3(x, y, z); GUI_UNUSED(k); }
168 
174 #define GUI_ROUND(x) ((float)(x) + 0.5f)
175 
181 #define GUI_MEM_ALIGN(x) ((x + (GUI_CFG_MEM_ALIGNMENT - 1)) & ~(GUI_CFG_MEM_ALIGNMENT - 1))
182 
186 //#endif /* defined(GUI_INTERNAL) || __DOXYGEN__ */
187 
188 /* Include widget structure */
189 #include "widget/gui_widget.h"
190 #include "gui/gui_input.h"
191 
192 guir_t gui_init(void);
193 int32_t gui_process(void);
195 
196 #if GUI_CFG_OS || __DOXYGEN__
197 uint8_t gui_protect(const uint8_t protect);
198 uint8_t gui_unprotect(const uint8_t unprotect);
199 uint8_t gui_delay(const uint32_t ms);
200 #else /* GUI_CFG_OS || __DOXYGEN__ */
201 /* Empty macros */
202 #define gui_protect(protect)
203 #define gui_unprotect(unprotect)
204 #endif /* !(GUI_CFG_OS || __DOXYGEN__) */
205 
210 /* C++ detection */
211 #ifdef __cplusplus
212 }
213 #endif
214 
215 #endif /* GUI_HDR_H */
guir_t
Results enumeration.
Definition: gui_defs.h:167
guir_t gui_init(void)
Initializes GUI stack. In addition, it prepares memory for work with widgets on later usage and calls...
Definition: gui.c:811
uint8_t gui_unprotect(const uint8_t unprotect)
Unprotect core from multiple thread access.
Definition: gui.c:939
uint8_t gui_delay(const uint32_t ms)
Delay GUI in units of milliseconds.
Definition: gui.c:954
uint8_t gui_protect(const uint8_t protect)
Protect core from multiple thread access.
Definition: gui.c:926
int32_t gui_process(void)
Processes all drawing operations for GUI.
Definition: gui.c:876
uint8_t gui_seteventcallback(gui_eventcallback_t cb)
Set callback for global events from GUI.
Definition: gui.c:909
void(* gui_eventcallback_t)(void)
Global event callback function declaration.
Definition: gui_defs.h:270