Nuklear
Minimal-state, immediate-mode graphical user interface toolkit written in ANSI C.
 
Loading...
Searching...
No Matches
nuklear.h
1
6#ifndef NK_NUKLEAR_H_
7#define NK_NUKLEAR_H_
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12/*
13 * ==============================================================
14 *
15 * CONSTANTS
16 *
17 * ===============================================================
18 */
19
20#define NK_UNDEFINED (-1.0f)
21#define NK_UTF_INVALID 0xFFFD
22#define NK_UTF_SIZE 4
23#ifndef NK_INPUT_MAX
24 #define NK_INPUT_MAX 16
25#endif
26#ifndef NK_MAX_NUMBER_BUFFER
27 #define NK_MAX_NUMBER_BUFFER 64
28#endif
29#ifndef NK_SCROLLBAR_HIDING_TIMEOUT
30 #define NK_SCROLLBAR_HIDING_TIMEOUT 4.0f
31#endif
32/*
33 * ==============================================================
34 *
35 * HELPER
36 *
37 * ===============================================================
38 */
39
40#ifndef NK_API
41 #ifdef NK_PRIVATE
42 #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199409L))
43 #define NK_API static inline
44 #elif defined(__cplusplus)
45 #define NK_API static inline
46 #else
47 #define NK_API static
48 #endif
49 #else
50 #define NK_API extern
51 #endif
52#endif
53#ifndef NK_LIB
54 #ifdef NK_SINGLE_FILE
55 #define NK_LIB static
56 #else
57 #define NK_LIB extern
58 #endif
59#endif
60
61#define NK_INTERN static
62#define NK_STORAGE static
63#define NK_GLOBAL static
64
65#define NK_FLAG(x) (1 << (x))
66#define NK_STRINGIFY(x) #x
67#define NK_MACRO_STRINGIFY(x) NK_STRINGIFY(x)
68#define NK_STRING_JOIN_IMMEDIATE(arg1, arg2) arg1 ## arg2
69#define NK_STRING_JOIN_DELAY(arg1, arg2) NK_STRING_JOIN_IMMEDIATE(arg1, arg2)
70#define NK_STRING_JOIN(arg1, arg2) NK_STRING_JOIN_DELAY(arg1, arg2)
71
72#ifdef _MSC_VER
73 #define NK_UNIQUE_NAME(name) NK_STRING_JOIN(name,__COUNTER__)
74#else
75 #define NK_UNIQUE_NAME(name) NK_STRING_JOIN(name,__LINE__)
76#endif
77
78#ifndef NK_STATIC_ASSERT
79 #define NK_STATIC_ASSERT(exp) typedef char NK_UNIQUE_NAME(_dummy_array)[(exp)?1:-1]
80#endif
81
82#ifndef NK_FILE_LINE
83#ifdef _MSC_VER
84 #define NK_FILE_LINE __FILE__ ":" NK_MACRO_STRINGIFY(__COUNTER__)
85#else
86 #define NK_FILE_LINE __FILE__ ":" NK_MACRO_STRINGIFY(__LINE__)
87#endif
88#endif
89
90#define NK_MIN(a,b) ((a) < (b) ? (a) : (b))
91#define NK_MAX(a,b) ((a) < (b) ? (b) : (a))
92#define NK_CLAMP(i,v,x) (NK_MAX(NK_MIN(v,x), i))
93
94#ifdef NK_INCLUDE_STANDARD_VARARGS
95 #include <stdarg.h>
96 #if defined(_MSC_VER) && (_MSC_VER >= 1600) /* VS 2010 and above */
97 #include <sal.h>
98 #define NK_PRINTF_FORMAT_STRING _Printf_format_string_
99 #else
100 #define NK_PRINTF_FORMAT_STRING
101 #endif
102 #if defined(__GNUC__)
103 #define NK_PRINTF_VARARG_FUNC(fmtargnumber) __attribute__((format(__printf__, fmtargnumber, fmtargnumber+1)))
104 #define NK_PRINTF_VALIST_FUNC(fmtargnumber) __attribute__((format(__printf__, fmtargnumber, 0)))
105 #else
106 #define NK_PRINTF_VARARG_FUNC(fmtargnumber)
107 #define NK_PRINTF_VALIST_FUNC(fmtargnumber)
108 #endif
109#endif
110
111/*
112 * ===============================================================
113 *
114 * BASIC
115 *
116 * ===============================================================
117 */
118 #ifdef NK_INCLUDE_FIXED_TYPES
119 #include <stdint.h>
120 #define NK_INT8 int8_t
121 #define NK_UINT8 uint8_t
122 #define NK_INT16 int16_t
123 #define NK_UINT16 uint16_t
124 #define NK_INT32 int32_t
125 #define NK_UINT32 uint32_t
126 #define NK_SIZE_TYPE uintptr_t
127 #define NK_POINTER_TYPE uintptr_t
128#else
129 #ifndef NK_INT8
130 #define NK_INT8 signed char
131 #endif
132 #ifndef NK_UINT8
133 #define NK_UINT8 unsigned char
134 #endif
135 #ifndef NK_INT16
136 #define NK_INT16 signed short
137 #endif
138 #ifndef NK_UINT16
139 #define NK_UINT16 unsigned short
140 #endif
141 #ifndef NK_INT32
142 #if defined(_MSC_VER)
143 #define NK_INT32 __int32
144 #else
145 #define NK_INT32 signed int
146 #endif
147 #endif
148 #ifndef NK_UINT32
149 #if defined(_MSC_VER)
150 #define NK_UINT32 unsigned __int32
151 #else
152 #define NK_UINT32 unsigned int
153 #endif
154 #endif
155 #ifndef NK_SIZE_TYPE
156 #if defined(_WIN64) && defined(_MSC_VER)
157 #define NK_SIZE_TYPE unsigned __int64
158 #elif defined(_WIN64) && (defined(__MINGW64__) || defined(__clang__))
159 #define NK_SIZE_TYPE unsigned long long
160 #elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
161 #define NK_SIZE_TYPE unsigned __int32
162 #elif (defined(_WIN32) || defined(WIN32)) && (defined(__MINGW32__) || defined(__clang__))
163 #define NK_SIZE_TYPE unsigned long
164 #elif defined(__GNUC__) || defined(__clang__)
165 #if defined(__x86_64__) || defined(__ppc64__) || defined(__PPC64__) || defined(__aarch64__)
166 #define NK_SIZE_TYPE unsigned long
167 #else
168 #define NK_SIZE_TYPE unsigned int
169 #endif
170 #else
171 #define NK_SIZE_TYPE unsigned long
172 #endif
173 #endif
174 #ifndef NK_POINTER_TYPE
175 #if defined(_WIN64) && defined(_MSC_VER)
176 #define NK_POINTER_TYPE unsigned __int64
177 #elif defined(_WIN64) && (defined(__MINGW64__) || defined(__clang__))
178 #define NK_POINTER_TYPE unsigned long long
179 #elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
180 #define NK_POINTER_TYPE unsigned __int32
181 #elif (defined(_WIN32) || defined(WIN32)) && (defined(__MINGW32__) || defined(__clang__))
182 #define NK_POINTER_TYPE unsigned long
183 #elif defined(__GNUC__) || defined(__clang__)
184 #if defined(__x86_64__) || defined(__ppc64__) || defined(__PPC64__) || defined(__aarch64__)
185 #define NK_POINTER_TYPE unsigned long
186 #else
187 #define NK_POINTER_TYPE unsigned int
188 #endif
189 #else
190 #define NK_POINTER_TYPE unsigned long
191 #endif
192 #endif
193#endif
194
196#ifndef NK_BOOL
197 #ifdef NK_INCLUDE_STANDARD_BOOL
198 #include <stdbool.h>
199 #define NK_BOOL bool
200 #else
201 #define NK_BOOL int
202 #endif
203#endif
204
205typedef NK_INT8 nk_char;
206typedef NK_UINT8 nk_uchar;
207typedef NK_UINT8 nk_byte;
208typedef NK_INT16 nk_short;
209typedef NK_UINT16 nk_ushort;
210typedef NK_INT32 nk_int;
211typedef NK_UINT32 nk_uint;
212typedef NK_SIZE_TYPE nk_size;
213typedef NK_POINTER_TYPE nk_ptr;
214typedef NK_BOOL nk_bool;
215
216typedef nk_uint nk_hash;
217typedef nk_uint nk_flags;
218typedef nk_uint nk_rune;
219
220/* Make sure correct type size:
221 * This will fire with a negative subscript error if the type sizes
222 * are set incorrectly by the compiler, and compile out if not */
223NK_STATIC_ASSERT(sizeof(nk_short) == 2);
224NK_STATIC_ASSERT(sizeof(nk_ushort) == 2);
225NK_STATIC_ASSERT(sizeof(nk_uint) == 4);
226NK_STATIC_ASSERT(sizeof(nk_int) == 4);
227NK_STATIC_ASSERT(sizeof(nk_byte) == 1);
228NK_STATIC_ASSERT(sizeof(nk_flags) >= 4);
229NK_STATIC_ASSERT(sizeof(nk_rune) >= 4);
230NK_STATIC_ASSERT(sizeof(nk_size) >= sizeof(void*));
231NK_STATIC_ASSERT(sizeof(nk_ptr) >= sizeof(void*));
232NK_STATIC_ASSERT(sizeof(nk_bool) <= sizeof(int));
233
234/* ============================================================================
235 *
236 * API
237 *
238 * =========================================================================== */
239struct nk_buffer;
240struct nk_allocator;
241struct nk_command_buffer;
242struct nk_draw_command;
243struct nk_convert_config;
244struct nk_style_item;
245struct nk_text_edit;
246struct nk_draw_list;
247struct nk_user_font;
248struct nk_panel;
249struct nk_context;
250struct nk_draw_vertex_layout_element;
251struct nk_style_button;
252struct nk_style_link;
253struct nk_style_toggle;
255struct nk_style_slide;
256struct nk_style_progress;
257struct nk_style_scrollbar;
258struct nk_style_edit;
259struct nk_style_property;
260struct nk_style_chart;
261struct nk_style_combo;
262struct nk_style_tab;
264struct nk_style_window;
265
266enum {nk_false, nk_true};
267struct nk_color {nk_byte r,g,b,a;};
268struct nk_colorf {float r,g,b,a;};
269struct nk_vec2 {float x,y;};
270struct nk_vec2i {short x, y;};
271struct nk_rect {float x,y,w,h;};
272struct nk_recti {short x,y,w,h;};
273typedef char nk_glyph[NK_UTF_SIZE];
274typedef union {void *ptr; int id;} nk_handle;
275struct nk_image {nk_handle handle; nk_ushort w, h; nk_ushort region[4];};
276struct nk_nine_slice {struct nk_image img; nk_ushort l, t, r, b;};
277struct nk_cursor {struct nk_image img; struct nk_vec2 size, offset;};
278struct nk_scroll {nk_uint x, y;};
279
280/* Make sure the semantic of nk_true/nk_false is compatible with nk_bool */
281NK_STATIC_ASSERT(!((nk_bool)0) == !(nk_false));
282NK_STATIC_ASSERT(!((nk_bool)1) == !(nk_true));
283
284enum nk_heading {NK_UP, NK_RIGHT, NK_DOWN, NK_LEFT};
285enum nk_button_behavior {NK_BUTTON_DEFAULT, NK_BUTTON_REPEATER};
286enum nk_link_underline {
287 NK_LINK_UNDERLINE_NONE,
288 NK_LINK_UNDERLINE_HOVER,
289 NK_LINK_UNDERLINE_ALWAYS
290};
291enum nk_modify {NK_FIXED = nk_false, NK_MODIFIABLE = nk_true};
292enum nk_orientation {NK_VERTICAL, NK_HORIZONTAL};
293enum nk_collapse_states {NK_MINIMIZED = nk_false, NK_MAXIMIZED = nk_true};
294enum nk_show_states {NK_HIDDEN = nk_false, NK_SHOWN = nk_true};
295enum nk_chart_type {NK_CHART_LINES, NK_CHART_COLUMN, NK_CHART_MAX};
296enum nk_chart_event {NK_CHART_HOVERING = 0x01, NK_CHART_CLICKED = 0x02};
297enum nk_color_format {NK_RGB, NK_RGBA};
298enum nk_popup_type {NK_POPUP_STATIC, NK_POPUP_DYNAMIC};
299enum nk_layout_format {NK_DYNAMIC, NK_STATIC};
300enum nk_tree_type {NK_TREE_NODE, NK_TREE_TAB};
301
302enum nk_tooltip_pos {
303 NK_TOP_LEFT,
304 NK_TOP_CENTER,
305 NK_TOP_RIGHT,
306
307 NK_MIDDLE_LEFT,
308 NK_MIDDLE_CENTER,
309 NK_MIDDLE_RIGHT,
310
311 NK_BOTTOM_LEFT,
312 NK_BOTTOM_CENTER,
313 NK_BOTTOM_RIGHT
314};
315
316typedef void*(*nk_plugin_alloc)(nk_handle, void *old, nk_size);
317typedef void (*nk_plugin_free)(nk_handle, void *old);
318typedef nk_bool(*nk_plugin_filter)(const struct nk_text_edit*, nk_rune unicode);
319typedef void(*nk_plugin_paste)(nk_handle, struct nk_text_edit*);
320typedef void(*nk_plugin_copy)(nk_handle, const char*, int len);
321
323 nk_handle userdata;
324 nk_plugin_alloc alloc;
325 nk_plugin_free free;
326};
327enum nk_symbol_type {
328 NK_SYMBOL_NONE,
329 NK_SYMBOL_X,
330 NK_SYMBOL_UNDERSCORE,
331 NK_SYMBOL_CIRCLE_SOLID,
332 NK_SYMBOL_CIRCLE_OUTLINE,
333 NK_SYMBOL_RECT_SOLID,
334 NK_SYMBOL_RECT_OUTLINE,
335 NK_SYMBOL_TRIANGLE_UP,
336 NK_SYMBOL_TRIANGLE_DOWN,
337 NK_SYMBOL_TRIANGLE_LEFT,
338 NK_SYMBOL_TRIANGLE_RIGHT,
339 NK_SYMBOL_PLUS,
340 NK_SYMBOL_MINUS,
341 NK_SYMBOL_TRIANGLE_UP_OUTLINE,
342 NK_SYMBOL_TRIANGLE_DOWN_OUTLINE,
343 NK_SYMBOL_TRIANGLE_LEFT_OUTLINE,
344 NK_SYMBOL_TRIANGLE_RIGHT_OUTLINE,
345 NK_SYMBOL_CHEVRON_UP,
346 NK_SYMBOL_CHEVRON_RIGHT,
347 NK_SYMBOL_CHEVRON_DOWN,
348 NK_SYMBOL_CHEVRON_LEFT,
349 NK_SYMBOL_HAMBURGER,
350 NK_SYMBOL_MAX
351};
352/* =============================================================================
353 *
354 * CONTEXT
355 *
356 * =============================================================================*/
392#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
393
410NK_API nk_bool nk_init_default(struct nk_context*, const struct nk_user_font*);
411#endif
435NK_API nk_bool nk_init_fixed(struct nk_context*, void *memory, nk_size size, const struct nk_user_font*);
436
455NK_API nk_bool nk_init(struct nk_context*, const struct nk_allocator*, const struct nk_user_font*);
456
475NK_API nk_bool nk_init_custom(struct nk_context*, struct nk_buffer *cmds, struct nk_buffer *pool, const struct nk_user_font*);
476
490NK_API void nk_clear(struct nk_context*);
491
502NK_API void nk_free(struct nk_context*);
503
504#ifdef NK_INCLUDE_COMMAND_USERDATA
516NK_API void nk_set_user_data(struct nk_context*, nk_handle handle);
517#endif
518/* =============================================================================
519 *
520 * INPUT
521 *
522 * =============================================================================*/
587enum nk_keys {
588 NK_KEY_NONE,
589 NK_KEY_SHIFT,
590 NK_KEY_CTRL,
591 NK_KEY_DEL,
592 NK_KEY_ENTER,
593 NK_KEY_TAB,
594 NK_KEY_BACKSPACE,
595 NK_KEY_COPY,
596 NK_KEY_CUT,
597 NK_KEY_PASTE,
598 NK_KEY_UP,
599 NK_KEY_DOWN,
600 NK_KEY_LEFT,
601 NK_KEY_RIGHT,
602 /* Shortcuts: text field */
603 NK_KEY_TEXT_INSERT_MODE,
604 NK_KEY_TEXT_REPLACE_MODE,
605 NK_KEY_TEXT_RESET_MODE,
606 NK_KEY_TEXT_LINE_START,
607 NK_KEY_TEXT_LINE_END,
608 NK_KEY_TEXT_START,
609 NK_KEY_TEXT_END,
610 NK_KEY_TEXT_UNDO,
611 NK_KEY_TEXT_REDO,
612 NK_KEY_TEXT_SELECT_ALL,
613 NK_KEY_TEXT_WORD_LEFT,
614 NK_KEY_TEXT_WORD_RIGHT,
615 /* Shortcuts: scrollbar */
616 NK_KEY_SCROLL_START,
617 NK_KEY_SCROLL_END,
618 NK_KEY_SCROLL_DOWN,
619 NK_KEY_SCROLL_UP,
620 NK_KEY_ALT,
621 NK_KEY_F1,
622 NK_KEY_F2,
623 NK_KEY_F3,
624 NK_KEY_F4,
625 NK_KEY_F5,
626 NK_KEY_F6,
627 NK_KEY_F7,
628 NK_KEY_F8,
629 NK_KEY_F9,
630 NK_KEY_F10,
631 NK_KEY_F11,
632 NK_KEY_F12,
633 NK_KEY_MAX
634};
635enum nk_buttons {
636 NK_BUTTON_LEFT,
637 NK_BUTTON_MIDDLE,
638 NK_BUTTON_RIGHT,
639 NK_BUTTON_DOUBLE, /* Double click of the Left mouse button. */
640 NK_BUTTON_X1, /* Commonly used for "Back" in UI navigation. Mouse Button 4. */
641 NK_BUTTON_X2, /* Commonly used for "Forward" in UI navigation. Mouse Button 5. */
642 NK_BUTTON_MAX
643};
644
656NK_API void nk_input_begin(struct nk_context*);
657
670NK_API void nk_input_motion(struct nk_context*, int x, int y);
671
684NK_API void nk_input_key(struct nk_context*, enum nk_keys, nk_bool down);
685
700NK_API void nk_input_button(struct nk_context*, enum nk_buttons, int x, int y, nk_bool down);
701
716NK_API void nk_input_scroll(struct nk_context*, struct nk_vec2 val);
717
734NK_API void nk_input_char(struct nk_context*, char);
735
749NK_API void nk_input_glyph(struct nk_context*, const nk_glyph);
750
765NK_API void nk_input_unicode(struct nk_context*, nk_rune);
766
778NK_API void nk_input_end(struct nk_context*);
779
780/* =============================================================================
781 *
782 * DRAWING
783 *
784 * =============================================================================*/
1011enum nk_anti_aliasing {NK_ANTI_ALIASING_OFF, NK_ANTI_ALIASING_ON};
1012enum nk_convert_result {
1013 NK_CONVERT_SUCCESS = 0,
1014 NK_CONVERT_INVALID_PARAM = 1,
1015 NK_CONVERT_COMMAND_BUFFER_FULL = NK_FLAG(1),
1016 NK_CONVERT_VERTEX_BUFFER_FULL = NK_FLAG(2),
1017 NK_CONVERT_ELEMENT_BUFFER_FULL = NK_FLAG(3)
1018};
1020 nk_handle texture;
1021 struct nk_vec2 uv;
1022};
1024 float global_alpha;
1025 enum nk_anti_aliasing line_AA;
1026 enum nk_anti_aliasing shape_AA;
1031 const struct nk_draw_vertex_layout_element *vertex_layout;
1032 nk_size vertex_size;
1034};
1035
1049NK_API const struct nk_command* nk__begin(struct nk_context*);
1050
1064NK_API const struct nk_command* nk__next(struct nk_context*, const struct nk_command*);
1065
1076#define nk_foreach(c, ctx) for((c) = nk__begin(ctx); (c) != 0; (c) = nk__next(ctx,c))
1077
1078#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
1079
1109NK_API nk_flags nk_convert(struct nk_context*, struct nk_buffer *cmds, struct nk_buffer *vertices, struct nk_buffer *elements, const struct nk_convert_config*);
1110
1124NK_API const struct nk_draw_command* nk__draw_begin(const struct nk_context*, const struct nk_buffer*);
1125
1143NK_API const struct nk_draw_command* nk__draw_end(const struct nk_context*, const struct nk_buffer*);
1144
1162NK_API const struct nk_draw_command* nk__draw_next(const struct nk_draw_command*, const struct nk_buffer*, const struct nk_context*);
1163
1179#define nk_draw_foreach(cmd,ctx, b) for((cmd)=nk__draw_begin(ctx, b); (cmd)!=0; (cmd)=nk__draw_next(cmd, b, ctx))
1180#endif
1181
1182/* =============================================================================
1183 *
1184 * WINDOW
1185 *
1186 * =============================================================================*/
1335enum nk_panel_flags {
1336 NK_WINDOW_BORDER = NK_FLAG(0),
1337 NK_WINDOW_MOVABLE = NK_FLAG(1),
1338 NK_WINDOW_SCALABLE = NK_FLAG(2),
1339 NK_WINDOW_CLOSABLE = NK_FLAG(3),
1340 NK_WINDOW_MINIMIZABLE = NK_FLAG(4),
1341 NK_WINDOW_NO_SCROLLBAR = NK_FLAG(5),
1342 NK_WINDOW_TITLE = NK_FLAG(6),
1343 NK_WINDOW_SCROLL_AUTO_HIDE = NK_FLAG(7),
1344 NK_WINDOW_BACKGROUND = NK_FLAG(8),
1345 NK_WINDOW_SCALE_LEFT = NK_FLAG(9),
1346 NK_WINDOW_NO_INPUT = NK_FLAG(10)
1347};
1348
1369NK_API nk_bool nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags);
1370
1392NK_API nk_bool nk_begin_titled(struct nk_context *ctx, const char *name, const char *title, struct nk_rect bounds, nk_flags flags);
1393
1408NK_API void nk_end(struct nk_context *ctx);
1409
1426NK_API struct nk_window *nk_window_find(const struct nk_context *ctx, const char *name);
1427
1445NK_API struct nk_rect nk_window_get_bounds(const struct nk_context *ctx);
1446
1464NK_API struct nk_vec2 nk_window_get_position(const struct nk_context *ctx);
1465
1483NK_API struct nk_vec2 nk_window_get_size(const struct nk_context *ctx);
1484
1501NK_API float nk_window_get_width(const struct nk_context *ctx);
1502
1520NK_API float nk_window_get_height(const struct nk_context* ctx);
1521
1541NK_API struct nk_panel* nk_window_get_panel(const struct nk_context* ctx);
1542
1562NK_API struct nk_rect nk_window_get_content_region(const struct nk_context* ctx);
1563
1583NK_API struct nk_vec2 nk_window_get_content_region_min(const struct nk_context *ctx);
1584
1604NK_API struct nk_vec2 nk_window_get_content_region_max(const struct nk_context *ctx);
1605
1624NK_API struct nk_vec2 nk_window_get_content_region_size(const struct nk_context *ctx);
1625
1643NK_API struct nk_command_buffer* nk_window_get_canvas(const struct nk_context* ctx);
1644
1661NK_API void nk_window_get_scroll(const struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y);
1662
1679NK_API nk_bool nk_window_has_focus(const struct nk_context *ctx);
1680
1697NK_API nk_bool nk_window_is_hovered(const struct nk_context *ctx);
1698
1715NK_API nk_bool nk_window_is_collapsed(const struct nk_context *ctx, const char *name);
1716
1732NK_API nk_bool nk_window_is_closed(const struct nk_context *ctx, const char* name);
1733
1749NK_API nk_bool nk_window_is_hidden(const struct nk_context *ctx, const char* name);
1750
1765NK_API nk_bool nk_window_is_active(const struct nk_context *ctx, const char* name);
1766
1780NK_API nk_bool nk_window_is_any_hovered(const struct nk_context *ctx);
1781
1798NK_API nk_bool nk_item_is_any_active(const struct nk_context *ctx);
1799
1814NK_API void nk_window_set_bounds(struct nk_context *ctx, const char *name, struct nk_rect bounds);
1815
1830NK_API void nk_window_set_position(struct nk_context *ctx, const char *name, struct nk_vec2 pos);
1831
1846NK_API void nk_window_set_size(struct nk_context *ctx, const char *name, struct nk_vec2 size);
1847
1861NK_API void nk_window_set_focus(struct nk_context *ctx, const char *name);
1862
1879NK_API void nk_window_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y);
1880
1894NK_API void nk_window_close(struct nk_context *ctx, const char *name);
1895
1910NK_API void nk_window_collapse(struct nk_context *ctx, const char *name, enum nk_collapse_states state);
1911
1927NK_API void nk_window_collapse_if(struct nk_context *ctx, const char *name, enum nk_collapse_states state, int cond);
1928
1942NK_API void nk_window_show(struct nk_context *ctx, const char *name, enum nk_show_states state);
1943
1959NK_API void nk_window_show_if(struct nk_context *ctx, const char *name, enum nk_show_states state, int cond);
1960
1974NK_API void nk_rule_horizontal(struct nk_context *ctx, struct nk_color color, nk_bool rounding);
1975
1976/* =============================================================================
1977 *
1978 * LAYOUT
1979 *
1980 * =============================================================================*/
2248enum nk_widget_align {
2249 NK_WIDGET_ALIGN_LEFT = 0x01,
2250 NK_WIDGET_ALIGN_CENTERED = 0x02,
2251 NK_WIDGET_ALIGN_RIGHT = 0x04,
2252 NK_WIDGET_ALIGN_TOP = 0x08,
2253 NK_WIDGET_ALIGN_MIDDLE = 0x10,
2254 NK_WIDGET_ALIGN_BOTTOM = 0x20
2255};
2256enum nk_widget_alignment {
2257 NK_WIDGET_LEFT = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_LEFT,
2258 NK_WIDGET_CENTERED = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_CENTERED,
2259 NK_WIDGET_RIGHT = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_RIGHT
2260};
2261
2274NK_API void nk_layout_set_min_row_height(struct nk_context*, float height);
2275
2284NK_API void nk_layout_reset_min_row_height(struct nk_context*);
2285
2298NK_API struct nk_rect nk_layout_widget_bounds(const struct nk_context *ctx);
2299
2313NK_API float nk_layout_ratio_from_pixel(const struct nk_context *ctx, float pixel_width);
2314
2329NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols);
2330
2346NK_API void nk_layout_row_static(struct nk_context *ctx, float height, int item_width, int cols);
2347
2361NK_API void nk_layout_row_begin(struct nk_context *ctx, enum nk_layout_format fmt, float row_height, int cols);
2362
2374NK_API void nk_layout_row_push(struct nk_context*, float value);
2375
2386NK_API void nk_layout_row_end(struct nk_context*);
2387
2401NK_API void nk_layout_row(struct nk_context*, enum nk_layout_format, float height, int cols, const float *ratio);
2402
2415NK_API void nk_layout_row_template_begin(struct nk_context*, float row_height);
2416
2429NK_API void nk_layout_row_template_push_dynamic(struct nk_context*);
2430
2443NK_API void nk_layout_row_template_push_variable(struct nk_context*, float min_width);
2444
2457NK_API void nk_layout_row_template_push_static(struct nk_context*, float width);
2458
2470NK_API void nk_layout_row_template_end(struct nk_context*);
2471
2486NK_API void nk_layout_space_begin(struct nk_context*, enum nk_layout_format, float height, int widget_count);
2487
2500NK_API void nk_layout_space_push(struct nk_context*, struct nk_rect bounds);
2501
2513NK_API void nk_layout_space_end(struct nk_context*);
2514
2528NK_API struct nk_rect nk_layout_space_bounds(const struct nk_context *ctx);
2529
2544NK_API struct nk_vec2 nk_layout_space_to_screen(const struct nk_context* ctx, struct nk_vec2 vec);
2545
2560NK_API struct nk_vec2 nk_layout_space_to_local(const struct nk_context *ctx, struct nk_vec2 vec);
2561
2576NK_API struct nk_rect nk_layout_space_rect_to_screen(const struct nk_context *ctx, struct nk_rect bounds);
2577
2592NK_API struct nk_rect nk_layout_space_rect_to_local(const struct nk_context *ctx, struct nk_rect bounds);
2593
2606NK_API void nk_spacer(struct nk_context *ctx);
2607
2608
2609/* =============================================================================
2610 *
2611 * GROUP
2612 *
2613 * =============================================================================*/
2713NK_API nk_bool nk_group_begin(struct nk_context*, const char *title, nk_flags);
2714
2728NK_API nk_bool nk_group_begin_titled(struct nk_context*, const char *name, const char *title, nk_flags);
2729
2741NK_API void nk_group_end(struct nk_context*);
2742
2761NK_API nk_bool nk_group_scrolled_offset_begin(struct nk_context*, nk_uint *x_offset, nk_uint *y_offset, const char *title, nk_flags flags);
2762
2780NK_API nk_bool nk_group_scrolled_begin(struct nk_context*, struct nk_scroll *off, const char *title, nk_flags);
2781
2793NK_API void nk_group_scrolled_end(struct nk_context*);
2794
2809NK_API void nk_group_get_scroll(struct nk_context*, const char *id, nk_uint *x_offset, nk_uint *y_offset);
2810
2825NK_API void nk_group_set_scroll(struct nk_context*, const char *id, nk_uint x_offset, nk_uint y_offset);
2826
2827/* =============================================================================
2828 *
2829 * TREE
2830 *
2831 * =============================================================================*/
2918#define nk_tree_push(ctx, type, title, state) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
2919
2937#define nk_tree_push_id(ctx, type, title, state, id) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
2938
2959NK_API nk_bool nk_tree_push_hashed(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states initial_state, const char *hash, int len,int seed);
2960
2982#define nk_tree_image_push(ctx, type, img, title, state) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
2983
3004#define nk_tree_image_push_id(ctx, type, img, title, state, id) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
3005
3027NK_API nk_bool nk_tree_image_push_hashed(struct nk_context*, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states initial_state, const char *hash, int len,int seed);
3028
3040NK_API void nk_tree_pop(struct nk_context*);
3041
3058NK_API nk_bool nk_tree_state_push(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states *state);
3059
3077NK_API nk_bool nk_tree_state_image_push(struct nk_context*, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states *state);
3078
3090NK_API void nk_tree_state_pop(struct nk_context*);
3091
3092#define nk_tree_element_push(ctx, type, title, state, sel) nk_tree_element_push_hashed(ctx, type, title, state, sel, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
3093#define nk_tree_element_push_id(ctx, type, title, state, sel, id) nk_tree_element_push_hashed(ctx, type, title, state, sel, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
3094NK_API nk_bool nk_tree_element_push_hashed(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states initial_state, nk_bool *selected, const char *hash, int len, int seed);
3095NK_API nk_bool nk_tree_element_image_push_hashed(struct nk_context*, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states initial_state, nk_bool *selected, const char *hash, int len,int seed);
3096NK_API void nk_tree_element_pop(struct nk_context*);
3097
3098/* =============================================================================
3099 *
3100 * LIST VIEW
3101 *
3102 * ============================================================================= */
3104/* public: */
3105 int begin, end, count;
3106/* private: */
3107 int total_height;
3108 struct nk_context *ctx;
3109 nk_uint *scroll_pointer;
3110 nk_uint scroll_value;
3111};
3112NK_API nk_bool nk_list_view_begin(struct nk_context*, struct nk_list_view *out, const char *id, nk_flags, int row_height, int row_count);
3113NK_API void nk_list_view_end(struct nk_list_view*);
3114/* =============================================================================
3115 *
3116 * WIDGET
3117 *
3118 * ============================================================================= */
3119enum nk_widget_layout_states {
3120 NK_WIDGET_INVALID,
3121 NK_WIDGET_VALID,
3122 NK_WIDGET_ROM,
3123 NK_WIDGET_DISABLED
3124};
3125enum nk_widget_states {
3126 NK_WIDGET_STATE_MODIFIED = NK_FLAG(1),
3127 NK_WIDGET_STATE_INACTIVE = NK_FLAG(2),
3128 NK_WIDGET_STATE_ENTERED = NK_FLAG(3),
3129 NK_WIDGET_STATE_HOVER = NK_FLAG(4),
3130 NK_WIDGET_STATE_ACTIVED = NK_FLAG(5),
3131 NK_WIDGET_STATE_LEFT = NK_FLAG(6),
3132 NK_WIDGET_STATE_HOVERED = NK_WIDGET_STATE_HOVER|NK_WIDGET_STATE_MODIFIED,
3133 NK_WIDGET_STATE_ACTIVE = NK_WIDGET_STATE_ACTIVED|NK_WIDGET_STATE_MODIFIED
3134};
3135NK_API enum nk_widget_layout_states nk_widget(struct nk_rect*, const struct nk_context*);
3136#define nk_widget_fitting(bounds, ctx, padding) nk_widget(bounds, ctx)
3137NK_API struct nk_rect nk_widget_bounds(const struct nk_context*);
3138NK_API struct nk_vec2 nk_widget_position(const struct nk_context*);
3139NK_API struct nk_vec2 nk_widget_size(const struct nk_context*);
3140NK_API float nk_widget_width(const struct nk_context*);
3141NK_API float nk_widget_height(const struct nk_context*);
3142NK_API nk_bool nk_widget_is_hovered(const struct nk_context*);
3143NK_API nk_bool nk_widget_is_mouse_clicked(const struct nk_context*, enum nk_buttons);
3144NK_API nk_bool nk_widget_has_mouse_click_down(const struct nk_context*, enum nk_buttons, nk_bool down);
3145NK_API void nk_spacing(struct nk_context*, int cols);
3146NK_API void nk_widget_disable_begin(struct nk_context* ctx);
3147NK_API void nk_widget_disable_end(struct nk_context* ctx);
3148/* =============================================================================
3149 *
3150 * TEXT
3151 *
3152 * ============================================================================= */
3153enum nk_text_align {
3154 NK_TEXT_ALIGN_LEFT = 0x01,
3155 NK_TEXT_ALIGN_CENTERED = 0x02,
3156 NK_TEXT_ALIGN_RIGHT = 0x04,
3157 NK_TEXT_ALIGN_TOP = 0x08,
3158 NK_TEXT_ALIGN_MIDDLE = 0x10,
3159 NK_TEXT_ALIGN_BOTTOM = 0x20
3160};
3161enum nk_text_alignment {
3162 NK_TEXT_LEFT = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_LEFT,
3163 NK_TEXT_CENTERED = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_CENTERED,
3164 NK_TEXT_RIGHT = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_RIGHT
3165};
3166NK_API void nk_text(struct nk_context*, const char*, int, nk_flags);
3167NK_API void nk_text_colored(struct nk_context*, const char*, int, nk_flags, struct nk_color);
3168NK_API void nk_text_wrap(struct nk_context*, const char*, int);
3169NK_API void nk_text_wrap_colored(struct nk_context*, const char*, int, struct nk_color);
3170NK_API void nk_label(struct nk_context*, const char*, nk_flags align);
3171NK_API void nk_label_colored(struct nk_context*, const char*, nk_flags align, struct nk_color);
3172NK_API void nk_label_wrap(struct nk_context*, const char*);
3173NK_API void nk_label_colored_wrap(struct nk_context*, const char*, struct nk_color);
3174NK_API void nk_image(struct nk_context*, struct nk_image);
3175NK_API void nk_image_color(struct nk_context*, struct nk_image, struct nk_color);
3176#ifdef NK_INCLUDE_STANDARD_VARARGS
3177NK_API void nk_labelf(struct nk_context*, nk_flags, NK_PRINTF_FORMAT_STRING const char*, ...) NK_PRINTF_VARARG_FUNC(3);
3178NK_API void nk_labelf_colored(struct nk_context*, nk_flags, struct nk_color, NK_PRINTF_FORMAT_STRING const char*,...) NK_PRINTF_VARARG_FUNC(4);
3179NK_API void nk_labelf_wrap(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*,...) NK_PRINTF_VARARG_FUNC(2);
3180NK_API void nk_labelf_colored_wrap(struct nk_context*, struct nk_color, NK_PRINTF_FORMAT_STRING const char*,...) NK_PRINTF_VARARG_FUNC(3);
3181NK_API void nk_labelfv(struct nk_context*, nk_flags, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(3);
3182NK_API void nk_labelfv_colored(struct nk_context*, nk_flags, struct nk_color, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(4);
3183NK_API void nk_labelfv_wrap(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(2);
3184NK_API void nk_labelfv_colored_wrap(struct nk_context*, struct nk_color, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(3);
3185NK_API void nk_value_bool(struct nk_context*, const char *prefix, int);
3186NK_API void nk_value_int(struct nk_context*, const char *prefix, int);
3187NK_API void nk_value_uint(struct nk_context*, const char *prefix, unsigned int);
3188NK_API void nk_value_float(struct nk_context*, const char *prefix, float);
3189NK_API void nk_value_color_byte(struct nk_context*, const char *prefix, struct nk_color);
3190NK_API void nk_value_color_float(struct nk_context*, const char *prefix, struct nk_color);
3191NK_API void nk_value_color_hex(struct nk_context*, const char *prefix, struct nk_color);
3192#endif
3193/* =============================================================================
3194 *
3195 * LINK
3196 *
3197 * ============================================================================= */
3198NK_API nk_bool nk_link_text(struct nk_context*, const char *title, int len, nk_flags align);
3199NK_API nk_bool nk_link_label(struct nk_context*, const char *title, nk_flags align);
3200NK_API nk_bool nk_link_text_styled(struct nk_context*, const struct nk_style_link*, const char *title, int len, nk_flags align);
3201NK_API nk_bool nk_link_label_styled(struct nk_context*, const struct nk_style_link*, const char *title, nk_flags align);
3202NK_API nk_bool nk_link_text_underline(struct nk_context*, const char *title, int len, nk_flags align, enum nk_link_underline);
3203NK_API nk_bool nk_link_label_underline(struct nk_context*, const char *title, nk_flags align, enum nk_link_underline);
3204NK_API nk_bool nk_link_text_hover_underline(struct nk_context*, const char *title, int len, nk_flags align);
3205NK_API nk_bool nk_link_label_hover_underline(struct nk_context*, const char *title, nk_flags align);
3206NK_API nk_bool nk_link_text_no_underline(struct nk_context*, const char *title, int len, nk_flags align);
3207NK_API nk_bool nk_link_label_no_underline(struct nk_context*, const char *title, nk_flags align);
3208NK_API nk_bool nk_link_text_colored(struct nk_context*, const char *title, int len, nk_flags align, struct nk_color);
3209NK_API nk_bool nk_link_label_colored(struct nk_context*, const char *title, nk_flags align, struct nk_color);
3210/* =============================================================================
3211 *
3212 * BUTTON
3213 *
3214 * ============================================================================= */
3215NK_API nk_bool nk_button_text(struct nk_context*, const char *title, int len);
3216NK_API nk_bool nk_button_label(struct nk_context*, const char *title);
3217NK_API nk_bool nk_button_color(struct nk_context*, struct nk_color);
3218NK_API nk_bool nk_button_symbol(struct nk_context*, enum nk_symbol_type);
3219NK_API nk_bool nk_button_image(struct nk_context*, struct nk_image img);
3220NK_API nk_bool nk_button_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags text_alignment);
3221NK_API nk_bool nk_button_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3222NK_API nk_bool nk_button_image_label(struct nk_context*, struct nk_image img, const char*, nk_flags text_alignment);
3223NK_API nk_bool nk_button_image_text(struct nk_context*, struct nk_image img, const char*, int, nk_flags alignment);
3224NK_API nk_bool nk_button_text_styled(struct nk_context*, const struct nk_style_button*, const char *title, int len);
3225NK_API nk_bool nk_button_label_styled(struct nk_context*, const struct nk_style_button*, const char *title);
3226NK_API nk_bool nk_button_symbol_styled(struct nk_context*, const struct nk_style_button*, enum nk_symbol_type);
3227NK_API nk_bool nk_button_image_styled(struct nk_context*, const struct nk_style_button*, struct nk_image img);
3228NK_API nk_bool nk_button_symbol_text_styled(struct nk_context*,const struct nk_style_button*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3229NK_API nk_bool nk_button_symbol_label_styled(struct nk_context *ctx, const struct nk_style_button *style, enum nk_symbol_type symbol, const char *title, nk_flags align);
3230NK_API nk_bool nk_button_image_label_styled(struct nk_context*,const struct nk_style_button*, struct nk_image img, const char*, nk_flags text_alignment);
3231NK_API nk_bool nk_button_image_text_styled(struct nk_context*,const struct nk_style_button*, struct nk_image img, const char*, int, nk_flags alignment);
3232NK_API void nk_button_set_behavior(struct nk_context*, enum nk_button_behavior);
3233NK_API nk_bool nk_button_push_behavior(struct nk_context*, enum nk_button_behavior);
3234NK_API nk_bool nk_button_pop_behavior(struct nk_context*);
3235/* =============================================================================
3236 *
3237 * CHECKBOX
3238 *
3239 * ============================================================================= */
3240NK_API nk_bool nk_check_label(struct nk_context*, const char*, nk_bool active);
3241NK_API nk_bool nk_check_text(struct nk_context*, const char*, int, nk_bool active);
3242NK_API nk_bool nk_check_text_align(struct nk_context*, const char*, int, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
3243NK_API unsigned nk_check_flags_label(struct nk_context*, const char*, unsigned int flags, unsigned int value);
3244NK_API unsigned nk_check_flags_text(struct nk_context*, const char*, int, unsigned int flags, unsigned int value);
3245NK_API nk_bool nk_checkbox_label(struct nk_context*, const char*, nk_bool *active);
3246NK_API nk_bool nk_checkbox_label_align(struct nk_context *ctx, const char *label, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
3247NK_API nk_bool nk_checkbox_text(struct nk_context*, const char*, int, nk_bool *active);
3248NK_API nk_bool nk_checkbox_text_align(struct nk_context *ctx, const char *text, int len, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
3249NK_API nk_bool nk_checkbox_flags_label(struct nk_context*, const char*, unsigned int *flags, unsigned int value);
3250NK_API nk_bool nk_checkbox_flags_text(struct nk_context*, const char*, int, unsigned int *flags, unsigned int value);
3251/* =============================================================================
3252 *
3253 * RADIO BUTTON
3254 *
3255 * ============================================================================= */
3256NK_API nk_bool nk_radio_label(struct nk_context*, const char*, nk_bool *active);
3257NK_API nk_bool nk_radio_label_align(struct nk_context *ctx, const char *label, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
3258NK_API nk_bool nk_radio_text(struct nk_context*, const char*, int, nk_bool *active);
3259NK_API nk_bool nk_radio_text_align(struct nk_context *ctx, const char *text, int len, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
3260NK_API nk_bool nk_option_label(struct nk_context*, const char*, nk_bool active);
3261NK_API nk_bool nk_option_label_align(struct nk_context *ctx, const char *label, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
3262NK_API nk_bool nk_option_text(struct nk_context*, const char*, int, nk_bool active);
3263NK_API nk_bool nk_option_text_align(struct nk_context *ctx, const char *text, int len, nk_bool is_active, nk_flags widget_alignment, nk_flags text_alignment);
3264/* =============================================================================
3265 *
3266 * SELECTABLE
3267 *
3268 * ============================================================================= */
3269NK_API nk_bool nk_selectable_label(struct nk_context*, const char*, nk_flags align, nk_bool *value);
3270NK_API nk_bool nk_selectable_text(struct nk_context*, const char*, int, nk_flags align, nk_bool *value);
3271NK_API nk_bool nk_selectable_image_label(struct nk_context*,struct nk_image, const char*, nk_flags align, nk_bool *value);
3272NK_API nk_bool nk_selectable_image_text(struct nk_context*,struct nk_image, const char*, int, nk_flags align, nk_bool *value);
3273NK_API nk_bool nk_selectable_symbol_label(struct nk_context*,enum nk_symbol_type, const char*, nk_flags align, nk_bool *value);
3274NK_API nk_bool nk_selectable_symbol_text(struct nk_context*,enum nk_symbol_type, const char*, int, nk_flags align, nk_bool *value);
3275
3276NK_API nk_bool nk_select_label(struct nk_context*, const char*, nk_flags align, nk_bool value);
3277NK_API nk_bool nk_select_text(struct nk_context*, const char*, int, nk_flags align, nk_bool value);
3278NK_API nk_bool nk_select_image_label(struct nk_context*, struct nk_image,const char*, nk_flags align, nk_bool value);
3279NK_API nk_bool nk_select_image_text(struct nk_context*, struct nk_image,const char*, int, nk_flags align, nk_bool value);
3280NK_API nk_bool nk_select_symbol_label(struct nk_context*,enum nk_symbol_type, const char*, nk_flags align, nk_bool value);
3281NK_API nk_bool nk_select_symbol_text(struct nk_context*,enum nk_symbol_type, const char*, int, nk_flags align, nk_bool value);
3282
3283/* =============================================================================
3284 *
3285 * SLIDER
3286 *
3287 * ============================================================================= */
3288NK_API float nk_slide_float(struct nk_context*, float min, float val, float max, float step);
3289NK_API int nk_slide_int(struct nk_context*, int min, int val, int max, int step);
3290NK_API nk_bool nk_slider_float(struct nk_context*, float min, float *val, float max, float step);
3291NK_API nk_bool nk_slider_int(struct nk_context*, int min, int *val, int max, int step);
3292
3293/* =============================================================================
3294 *
3295 * KNOB
3296 *
3297 * ============================================================================= */
3298NK_API nk_bool nk_knob_float(struct nk_context*, float min, float *val, float max, float step, enum nk_heading zero_direction, float dead_zone_degrees);
3299NK_API nk_bool nk_knob_int(struct nk_context*, int min, int *val, int max, int step, enum nk_heading zero_direction, float dead_zone_degrees);
3300
3301/* =============================================================================
3302 *
3303 * PROGRESSBAR
3304 *
3305 * ============================================================================= */
3306NK_API nk_bool nk_progress(struct nk_context*, nk_size *cur, nk_size max, nk_bool modifyable);
3307NK_API nk_size nk_prog(struct nk_context*, nk_size cur, nk_size max, nk_bool modifyable);
3308
3309/* =============================================================================
3310 *
3311 * COLOR PICKER
3312 *
3313 * ============================================================================= */
3314NK_API struct nk_colorf nk_color_picker(struct nk_context*, struct nk_colorf, enum nk_color_format);
3315NK_API nk_bool nk_color_pick(struct nk_context*, struct nk_colorf*, enum nk_color_format);
3316/* =============================================================================
3317 *
3318 * PROPERTIES
3319 *
3320 * =============================================================================*/
3414NK_API nk_bool nk_property_int(struct nk_context*, const char *name, int min, int *val, int max, int step, float inc_per_pixel);
3415
3438NK_API nk_bool nk_property_float(struct nk_context*, const char *name, float min, float *val, float max, float step, float inc_per_pixel);
3439
3462NK_API nk_bool nk_property_double(struct nk_context*, const char *name, double min, double *val, double max, double step, float inc_per_pixel);
3463
3484NK_API int nk_propertyi(struct nk_context*, const char *name, int min, int val, int max, int step, float inc_per_pixel);
3485
3506NK_API float nk_propertyf(struct nk_context*, const char *name, float min, float val, float max, float step, float inc_per_pixel);
3507
3528NK_API double nk_propertyd(struct nk_context*, const char *name, double min, double val, double max, double step, float inc_per_pixel);
3529
3530/* =============================================================================
3531 *
3532 * TEXT EDIT
3533 *
3534 * ============================================================================= */
3535enum nk_edit_flags {
3536 NK_EDIT_DEFAULT = 0,
3537 NK_EDIT_READ_ONLY = NK_FLAG(0),
3538 NK_EDIT_AUTO_SELECT = NK_FLAG(1),
3539 NK_EDIT_SIG_ENTER = NK_FLAG(2),
3540 NK_EDIT_ALLOW_TAB = NK_FLAG(3),
3541 NK_EDIT_NO_CURSOR = NK_FLAG(4),
3542 NK_EDIT_SELECTABLE = NK_FLAG(5),
3543 NK_EDIT_CLIPBOARD = NK_FLAG(6),
3544 NK_EDIT_CTRL_ENTER_NEWLINE = NK_FLAG(7),
3545 NK_EDIT_NO_HORIZONTAL_SCROLL = NK_FLAG(8),
3546 NK_EDIT_ALWAYS_INSERT_MODE = NK_FLAG(9),
3547 NK_EDIT_MULTILINE = NK_FLAG(10),
3548 NK_EDIT_GOTO_END_ON_ACTIVATE = NK_FLAG(11)
3549};
3550enum nk_edit_types {
3551 NK_EDIT_SIMPLE = NK_EDIT_ALWAYS_INSERT_MODE,
3552 NK_EDIT_FIELD = NK_EDIT_SIMPLE|NK_EDIT_SELECTABLE|NK_EDIT_CLIPBOARD,
3553 NK_EDIT_BOX = NK_EDIT_ALWAYS_INSERT_MODE| NK_EDIT_SELECTABLE| NK_EDIT_MULTILINE|NK_EDIT_ALLOW_TAB|NK_EDIT_CLIPBOARD,
3554 NK_EDIT_EDITOR = NK_EDIT_SELECTABLE|NK_EDIT_MULTILINE|NK_EDIT_ALLOW_TAB| NK_EDIT_CLIPBOARD
3555};
3556enum nk_edit_events {
3557 NK_EDIT_ACTIVE = NK_FLAG(0),
3558 NK_EDIT_INACTIVE = NK_FLAG(1),
3559 NK_EDIT_ACTIVATED = NK_FLAG(2),
3560 NK_EDIT_DEACTIVATED = NK_FLAG(3),
3561 NK_EDIT_COMMITTED = NK_FLAG(4)
3562};
3563
3564#define NK_EDIT_COMMITED NK_EDIT_COMMITTED
3565
3566NK_API nk_flags nk_edit_string(struct nk_context*, nk_flags, char *buffer, int *len, int max, nk_plugin_filter);
3567NK_API nk_flags nk_edit_string_zero_terminated(struct nk_context*, nk_flags, char *buffer, int max, nk_plugin_filter);
3568NK_API nk_flags nk_edit_buffer(struct nk_context*, nk_flags, struct nk_text_edit*, nk_plugin_filter);
3569NK_API void nk_edit_focus(struct nk_context*, nk_flags flags);
3570NK_API void nk_edit_unfocus(struct nk_context*);
3571/* =============================================================================
3572 *
3573 * CHART
3574 *
3575 * ============================================================================= */
3576NK_API nk_bool nk_chart_begin(struct nk_context*, enum nk_chart_type, int num, float min, float max);
3577NK_API nk_bool nk_chart_begin_colored(struct nk_context*, enum nk_chart_type, struct nk_color, struct nk_color active, int num, float min, float max);
3578NK_API void nk_chart_add_slot(struct nk_context *ctx, const enum nk_chart_type, int count, float min_value, float max_value);
3579NK_API void nk_chart_add_slot_colored(struct nk_context *ctx, const enum nk_chart_type, struct nk_color, struct nk_color active, int count, float min_value, float max_value);
3580NK_API nk_flags nk_chart_push(struct nk_context*, float);
3581NK_API nk_flags nk_chart_push_slot(struct nk_context*, float, int);
3582NK_API void nk_chart_end(struct nk_context*);
3583NK_API void nk_plot(struct nk_context*, enum nk_chart_type, const float *values, int count, int offset);
3584NK_API void nk_plot_function(struct nk_context*, enum nk_chart_type, void *userdata, float(*value_getter)(void* user, int index), int count, int offset);
3585/* =============================================================================
3586 *
3587 * POPUP
3588 *
3589 * ============================================================================= */
3590NK_API nk_bool nk_popup_begin(struct nk_context*, enum nk_popup_type, const char*, nk_flags, struct nk_rect bounds);
3591NK_API void nk_popup_close(struct nk_context*);
3592NK_API void nk_popup_end(struct nk_context*);
3593NK_API void nk_popup_get_scroll(const struct nk_context*, nk_uint *offset_x, nk_uint *offset_y);
3594NK_API void nk_popup_set_scroll(struct nk_context*, nk_uint offset_x, nk_uint offset_y);
3595/* =============================================================================
3596 *
3597 * COMBOBOX
3598 *
3599 * ============================================================================= */
3600NK_API int nk_combo(struct nk_context*, const char *const *items, int count, int selected, int item_height, struct nk_vec2 size);
3601NK_API int nk_combo_separator(struct nk_context*, const char *items_separated_by_separator, int separator, int selected, int count, int item_height, struct nk_vec2 size);
3602NK_API int nk_combo_string(struct nk_context*, const char *items_separated_by_zeros, int selected, int count, int item_height, struct nk_vec2 size);
3603NK_API int nk_combo_callback(struct nk_context*, void(*item_getter)(void*, int, const char**), void *userdata, int selected, int count, int item_height, struct nk_vec2 size);
3604NK_API nk_bool nk_combobox(struct nk_context*, const char *const *items, int count, int *selected, int item_height, struct nk_vec2 size);
3605NK_API nk_bool nk_combobox_string(struct nk_context*, const char *items_separated_by_zeros, int *selected, int count, int item_height, struct nk_vec2 size);
3606NK_API nk_bool nk_combobox_separator(struct nk_context*, const char *items_separated_by_separator, int separator, int *selected, int count, int item_height, struct nk_vec2 size);
3607NK_API nk_bool nk_combobox_callback(struct nk_context*, void(*item_getter)(void*, int, const char**), void*, int *selected, int count, int item_height, struct nk_vec2 size);
3608/* =============================================================================
3609 *
3610 * ABSTRACT COMBOBOX
3611 *
3612 * ============================================================================= */
3613NK_API nk_bool nk_combo_begin_text(struct nk_context*, const char *selected, int, struct nk_vec2 size);
3614NK_API nk_bool nk_combo_begin_label(struct nk_context*, const char *selected, struct nk_vec2 size);
3615NK_API nk_bool nk_combo_begin_color(struct nk_context*, struct nk_color color, struct nk_vec2 size);
3616NK_API nk_bool nk_combo_begin_symbol(struct nk_context*, enum nk_symbol_type, struct nk_vec2 size);
3617NK_API nk_bool nk_combo_begin_symbol_label(struct nk_context*, const char *selected, enum nk_symbol_type, struct nk_vec2 size);
3618NK_API nk_bool nk_combo_begin_symbol_text(struct nk_context*, const char *selected, int, enum nk_symbol_type, struct nk_vec2 size);
3619NK_API nk_bool nk_combo_begin_image(struct nk_context*, struct nk_image img, struct nk_vec2 size);
3620NK_API nk_bool nk_combo_begin_image_label(struct nk_context*, const char *selected, struct nk_image, struct nk_vec2 size);
3621NK_API nk_bool nk_combo_begin_image_text(struct nk_context*, const char *selected, int, struct nk_image, struct nk_vec2 size);
3622NK_API nk_bool nk_combo_item_label(struct nk_context*, const char*, nk_flags alignment);
3623NK_API nk_bool nk_combo_item_text(struct nk_context*, const char*,int, nk_flags alignment);
3624NK_API nk_bool nk_combo_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
3625NK_API nk_bool nk_combo_item_image_text(struct nk_context*, struct nk_image, const char*, int,nk_flags alignment);
3626NK_API nk_bool nk_combo_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
3627NK_API nk_bool nk_combo_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3628NK_API void nk_combo_close(struct nk_context*);
3629NK_API void nk_combo_end(struct nk_context*);
3630/* =============================================================================
3631 *
3632 * CONTEXTUAL
3633 *
3634 * ============================================================================= */
3635NK_API nk_bool nk_contextual_begin(struct nk_context*, nk_flags, struct nk_vec2, struct nk_rect trigger_bounds);
3636NK_API nk_bool nk_contextual_item_text(struct nk_context*, const char*, int,nk_flags align);
3637NK_API nk_bool nk_contextual_item_label(struct nk_context*, const char*, nk_flags align);
3638NK_API nk_bool nk_contextual_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
3639NK_API nk_bool nk_contextual_item_image_text(struct nk_context*, struct nk_image, const char*, int len, nk_flags alignment);
3640NK_API nk_bool nk_contextual_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
3641NK_API nk_bool nk_contextual_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3642NK_API void nk_contextual_close(struct nk_context*);
3643NK_API void nk_contextual_end(struct nk_context*);
3644/* =============================================================================
3645 *
3646 * TOOLTIP
3647 *
3648 * ============================================================================= */
3649NK_API void nk_tooltip(struct nk_context*, const char*);
3650NK_API void nk_tooltip_offset(struct nk_context *ctx, const char *text, enum nk_tooltip_pos position, struct nk_vec2 offset);
3651NK_API void nk_do_tooltip(struct nk_context*, const char*, struct nk_rect);
3652NK_API void nk_do_tooltip_delay(struct nk_context*, const char*, struct nk_rect, float*);
3653NK_API void nk_do_tooltip_delay_clicked(struct nk_context*, const char*, struct nk_rect, float* timer, nk_bool*);
3654#ifdef NK_INCLUDE_STANDARD_VARARGS
3655NK_API void nk_tooltipf(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*, ...) NK_PRINTF_VARARG_FUNC(2);
3656NK_API void nk_tooltipfv(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(2);
3657NK_API void nk_tooltipf_offset(struct nk_context*, enum nk_tooltip_pos, struct nk_vec2, NK_PRINTF_FORMAT_STRING const char*, ...) NK_PRINTF_VARARG_FUNC(4);
3658NK_API void nk_tooltipfv_offset(struct nk_context*, enum nk_tooltip_pos, struct nk_vec2, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(4);
3659#endif
3660NK_API nk_bool nk_tooltip_begin(struct nk_context*, float width);
3661NK_API nk_bool nk_tooltip_begin_offset(struct nk_context*, float, enum nk_tooltip_pos, struct nk_vec2);
3662NK_API void nk_tooltip_end(struct nk_context*);
3663/* =============================================================================
3664 *
3665 * MENU
3666 *
3667 * ============================================================================= */
3668NK_API void nk_menubar_begin(struct nk_context*);
3669NK_API void nk_menubar_end(struct nk_context*);
3670NK_API nk_bool nk_menu_begin_text(struct nk_context*, const char* title, int title_len, nk_flags align, struct nk_vec2 size);
3671NK_API nk_bool nk_menu_begin_label(struct nk_context*, const char*, nk_flags align, struct nk_vec2 size);
3672NK_API nk_bool nk_menu_begin_image(struct nk_context*, const char*, struct nk_image, struct nk_vec2 size);
3673NK_API nk_bool nk_menu_begin_image_text(struct nk_context*, const char*, int,nk_flags align,struct nk_image, struct nk_vec2 size);
3674NK_API nk_bool nk_menu_begin_image_label(struct nk_context*, const char*, nk_flags align,struct nk_image, struct nk_vec2 size);
3675NK_API nk_bool nk_menu_begin_symbol(struct nk_context*, const char*, enum nk_symbol_type, struct nk_vec2 size);
3676NK_API nk_bool nk_menu_begin_symbol_text(struct nk_context*, const char*, int,nk_flags align,enum nk_symbol_type, struct nk_vec2 size);
3677NK_API nk_bool nk_menu_begin_symbol_label(struct nk_context*, const char*, nk_flags align,enum nk_symbol_type, struct nk_vec2 size);
3678NK_API nk_bool nk_menu_item_text(struct nk_context*, const char*, int,nk_flags align);
3679NK_API nk_bool nk_menu_item_label(struct nk_context*, const char*, nk_flags alignment);
3680NK_API nk_bool nk_menu_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
3681NK_API nk_bool nk_menu_item_image_text(struct nk_context*, struct nk_image, const char*, int len, nk_flags alignment);
3682NK_API nk_bool nk_menu_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3683NK_API nk_bool nk_menu_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
3684NK_API void nk_menu_close(struct nk_context*);
3685NK_API void nk_menu_end(struct nk_context*);
3686/* =============================================================================
3687 *
3688 * STYLE
3689 *
3690 * ============================================================================= */
3691
3692#define NK_WIDGET_DISABLED_FACTOR 0.5f
3693
3694enum nk_style_colors {
3695 NK_COLOR_TEXT,
3696 NK_COLOR_WINDOW,
3697 NK_COLOR_HEADER,
3698 NK_COLOR_BORDER,
3699 NK_COLOR_BUTTON,
3700 NK_COLOR_BUTTON_HOVER,
3701 NK_COLOR_BUTTON_ACTIVE,
3702 NK_COLOR_TOGGLE,
3703 NK_COLOR_TOGGLE_HOVER,
3704 NK_COLOR_TOGGLE_CURSOR,
3705 NK_COLOR_SELECT,
3706 NK_COLOR_SELECT_ACTIVE,
3707 NK_COLOR_SLIDER,
3708 NK_COLOR_SLIDER_CURSOR,
3709 NK_COLOR_SLIDER_CURSOR_HOVER,
3710 NK_COLOR_SLIDER_CURSOR_ACTIVE,
3711 NK_COLOR_PROPERTY,
3712 NK_COLOR_EDIT,
3713 NK_COLOR_EDIT_CURSOR,
3714 NK_COLOR_COMBO,
3715 NK_COLOR_CHART,
3716 NK_COLOR_CHART_COLOR,
3717 NK_COLOR_CHART_COLOR_HIGHLIGHT,
3718 NK_COLOR_SCROLLBAR,
3719 NK_COLOR_SCROLLBAR_CURSOR,
3720 NK_COLOR_SCROLLBAR_CURSOR_HOVER,
3721 NK_COLOR_SCROLLBAR_CURSOR_ACTIVE,
3722 NK_COLOR_TAB_HEADER,
3723 NK_COLOR_KNOB,
3724 NK_COLOR_KNOB_CURSOR,
3725 NK_COLOR_KNOB_CURSOR_HOVER,
3726 NK_COLOR_KNOB_CURSOR_ACTIVE,
3727 NK_COLOR_COUNT
3728};
3729enum nk_style_cursor {
3730 NK_CURSOR_ARROW,
3731 NK_CURSOR_TEXT,
3732 NK_CURSOR_MOVE,
3733 NK_CURSOR_RESIZE_VERTICAL,
3734 NK_CURSOR_RESIZE_HORIZONTAL,
3735 NK_CURSOR_RESIZE_TOP_LEFT_DOWN_RIGHT,
3736 NK_CURSOR_RESIZE_TOP_RIGHT_DOWN_LEFT,
3737 NK_CURSOR_COUNT
3738};
3739NK_API void nk_style_default(struct nk_context*);
3740NK_API void nk_style_from_table(struct nk_context*, const struct nk_color*);
3741NK_API void nk_style_load_cursor(struct nk_context*, enum nk_style_cursor, const struct nk_cursor*);
3742NK_API void nk_style_load_all_cursors(struct nk_context*, const struct nk_cursor*);
3743NK_API const char* nk_style_get_color_by_name(enum nk_style_colors);
3744NK_API void nk_style_set_font(struct nk_context*, const struct nk_user_font*);
3745NK_API nk_bool nk_style_set_cursor(struct nk_context*, enum nk_style_cursor);
3746NK_API void nk_style_show_cursor(struct nk_context*);
3747NK_API void nk_style_hide_cursor(struct nk_context*);
3748
3749NK_API nk_bool nk_style_push_font(struct nk_context*, const struct nk_user_font*);
3750NK_API nk_bool nk_style_push_float(struct nk_context*, float*, float);
3751NK_API nk_bool nk_style_push_vec2(struct nk_context*, struct nk_vec2*, struct nk_vec2);
3752NK_API nk_bool nk_style_push_style_item(struct nk_context*, struct nk_style_item*, struct nk_style_item);
3753NK_API nk_bool nk_style_push_flags(struct nk_context*, nk_flags*, nk_flags);
3754NK_API nk_bool nk_style_push_color(struct nk_context*, struct nk_color*, struct nk_color);
3755
3756NK_API nk_bool nk_style_pop_font(struct nk_context*);
3757NK_API nk_bool nk_style_pop_float(struct nk_context*);
3758NK_API nk_bool nk_style_pop_vec2(struct nk_context*);
3759NK_API nk_bool nk_style_pop_style_item(struct nk_context*);
3760NK_API nk_bool nk_style_pop_flags(struct nk_context*);
3761NK_API nk_bool nk_style_pop_color(struct nk_context*);
3762/* =============================================================================
3763 *
3764 * COLOR
3765 *
3766 * ============================================================================= */
3767NK_API struct nk_color nk_rgb(int r, int g, int b);
3768NK_API struct nk_color nk_rgb_iv(const int *rgb);
3769NK_API struct nk_color nk_rgb_bv(const nk_byte* rgb);
3770NK_API struct nk_color nk_rgb_f(float r, float g, float b);
3771NK_API struct nk_color nk_rgb_fv(const float *rgb);
3772NK_API struct nk_color nk_rgb_cf(struct nk_colorf c);
3773NK_API struct nk_color nk_rgb_hex(const char *rgb);
3774NK_API struct nk_color nk_rgb_factor(struct nk_color col, float factor);
3775
3776NK_API struct nk_color nk_rgba(int r, int g, int b, int a);
3777NK_API struct nk_color nk_rgba_u32(nk_uint);
3778NK_API struct nk_color nk_rgba_iv(const int *rgba);
3779NK_API struct nk_color nk_rgba_bv(const nk_byte *rgba);
3780NK_API struct nk_color nk_rgba_f(float r, float g, float b, float a);
3781NK_API struct nk_color nk_rgba_fv(const float *rgba);
3782NK_API struct nk_color nk_rgba_cf(struct nk_colorf c);
3783NK_API struct nk_color nk_rgba_hex(const char *rgb);
3784
3785NK_API struct nk_colorf nk_hsva_colorf(float h, float s, float v, float a);
3786NK_API struct nk_colorf nk_hsva_colorfv(const float *c);
3787NK_API void nk_colorf_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_colorf in);
3788NK_API void nk_colorf_hsva_fv(float *hsva, struct nk_colorf in);
3789
3790NK_API struct nk_color nk_hsv(int h, int s, int v);
3791NK_API struct nk_color nk_hsv_iv(const int *hsv);
3792NK_API struct nk_color nk_hsv_bv(const nk_byte *hsv);
3793NK_API struct nk_color nk_hsv_f(float h, float s, float v);
3794NK_API struct nk_color nk_hsv_fv(const float *hsv);
3795
3796NK_API struct nk_color nk_hsva(int h, int s, int v, int a);
3797NK_API struct nk_color nk_hsva_iv(const int *hsva);
3798NK_API struct nk_color nk_hsva_bv(const nk_byte *hsva);
3799NK_API struct nk_color nk_hsva_f(float h, float s, float v, float a);
3800NK_API struct nk_color nk_hsva_fv(const float *hsva);
3801
3802/* color (conversion nuklear --> user) */
3803NK_API void nk_color_f(float *r, float *g, float *b, float *a, struct nk_color);
3804NK_API void nk_color_fv(float *rgba_out, struct nk_color);
3805NK_API struct nk_colorf nk_color_cf(struct nk_color);
3806NK_API void nk_color_d(double *r, double *g, double *b, double *a, struct nk_color);
3807NK_API void nk_color_dv(double *rgba_out, struct nk_color);
3808
3809NK_API nk_uint nk_color_u32(struct nk_color);
3810NK_API void nk_color_hex_rgba(char *output, struct nk_color);
3811NK_API void nk_color_hex_rgb(char *output, struct nk_color);
3812
3813NK_API void nk_color_hsv_i(int *out_h, int *out_s, int *out_v, struct nk_color);
3814NK_API void nk_color_hsv_b(nk_byte *out_h, nk_byte *out_s, nk_byte *out_v, struct nk_color);
3815NK_API void nk_color_hsv_iv(int *hsv_out, struct nk_color);
3816NK_API void nk_color_hsv_bv(nk_byte *hsv_out, struct nk_color);
3817NK_API void nk_color_hsv_f(float *out_h, float *out_s, float *out_v, struct nk_color);
3818NK_API void nk_color_hsv_fv(float *hsv_out, struct nk_color);
3819
3820NK_API void nk_color_hsva_i(int *h, int *s, int *v, int *a, struct nk_color);
3821NK_API void nk_color_hsva_b(nk_byte *h, nk_byte *s, nk_byte *v, nk_byte *a, struct nk_color);
3822NK_API void nk_color_hsva_iv(int *hsva_out, struct nk_color);
3823NK_API void nk_color_hsva_bv(nk_byte *hsva_out, struct nk_color);
3824NK_API void nk_color_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_color);
3825NK_API void nk_color_hsva_fv(float *hsva_out, struct nk_color);
3826/* =============================================================================
3827 *
3828 * IMAGE
3829 *
3830 * ============================================================================= */
3831NK_API nk_handle nk_handle_ptr(void*);
3832NK_API nk_handle nk_handle_id(int);
3833NK_API struct nk_image nk_image_handle(nk_handle);
3834NK_API struct nk_image nk_image_ptr(void*);
3835NK_API struct nk_image nk_image_id(int);
3836NK_API nk_bool nk_image_is_subimage(const struct nk_image* img);
3837NK_API struct nk_image nk_subimage_ptr(void*, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
3838NK_API struct nk_image nk_subimage_id(int, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
3839NK_API struct nk_image nk_subimage_handle(nk_handle, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
3840/* =============================================================================
3841 *
3842 * 9-SLICE
3843 *
3844 * ============================================================================= */
3845NK_API struct nk_nine_slice nk_nine_slice_handle(nk_handle, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3846NK_API struct nk_nine_slice nk_nine_slice_ptr(void*, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3847NK_API struct nk_nine_slice nk_nine_slice_id(int, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3848NK_API int nk_nine_slice_is_sub9slice(const struct nk_nine_slice* img);
3849NK_API struct nk_nine_slice nk_sub9slice_ptr(void*, nk_ushort w, nk_ushort h, struct nk_rect sub_region, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3850NK_API struct nk_nine_slice nk_sub9slice_id(int, nk_ushort w, nk_ushort h, struct nk_rect sub_region, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3851NK_API struct nk_nine_slice nk_sub9slice_handle(nk_handle, nk_ushort w, nk_ushort h, struct nk_rect sub_region, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3852/* =============================================================================
3853 *
3854 * MATH
3855 *
3856 * ============================================================================= */
3857NK_API nk_hash nk_murmur_hash(const void *key, int len, nk_hash seed);
3858NK_API void nk_triangle_from_direction(struct nk_vec2 *result, struct nk_rect r, float pad_x, float pad_y, enum nk_heading);
3859
3860NK_API struct nk_vec2 nk_vec2(float x, float y);
3861NK_API struct nk_vec2 nk_vec2i(int x, int y);
3862NK_API struct nk_vec2 nk_vec2v(const float *xy);
3863NK_API struct nk_vec2 nk_vec2iv(const int *xy);
3864
3865NK_API struct nk_rect nk_get_null_rect(void);
3866NK_API struct nk_rect nk_rect(float x, float y, float w, float h);
3867NK_API struct nk_rect nk_recti(int x, int y, int w, int h);
3868NK_API struct nk_rect nk_recta(struct nk_vec2 pos, struct nk_vec2 size);
3869NK_API struct nk_rect nk_rectv(const float *xywh);
3870NK_API struct nk_rect nk_rectiv(const int *xywh);
3871NK_API struct nk_vec2 nk_rect_pos(struct nk_rect);
3872NK_API struct nk_vec2 nk_rect_size(struct nk_rect);
3873/* =============================================================================
3874 *
3875 * STRING
3876 *
3877 * ============================================================================= */
3878NK_API int nk_strlen(const char *str);
3879NK_API int nk_stricmp(const char *s1, const char *s2);
3880NK_API int nk_stricmpn(const char *s1, const char *s2, int n);
3881NK_API int nk_strtoi(const char *str, char **endptr);
3882NK_API float nk_strtof(const char *str, char **endptr);
3883#ifndef NK_STRTOD
3884#define NK_STRTOD nk_strtod
3885#define NK_STRTOD_NEEDED
3886NK_API double nk_strtod(const char *str, char **endptr);
3887#endif
3888NK_API int nk_strfilter(const char *text, const char *regexp);
3889NK_API int nk_strmatch_fuzzy_string(char const *str, char const *pattern, int *out_score);
3890NK_API int nk_strmatch_fuzzy_text(const char *txt, int txt_len, const char *pattern, int *out_score);
3891/* =============================================================================
3892 *
3893 * UTF-8
3894 *
3895 * ============================================================================= */
3896NK_API int nk_utf_decode(const char*, nk_rune*, int);
3897NK_API int nk_utf_encode(nk_rune, char*, int);
3898NK_API int nk_utf_len(const char*, int byte_len);
3899NK_API const char* nk_utf_at(const char *buffer, int length, int index, nk_rune *unicode, int *len);
3900/* ===============================================================
3901 *
3902 * FONT
3903 *
3904 * ===============================================================*/
4057struct nk_user_font_glyph;
4058typedef float(*nk_text_width_f)(nk_handle, float h, const char*, int len);
4059typedef void(*nk_query_font_glyph_f)(nk_handle handle, float font_height,
4060 struct nk_user_font_glyph *glyph,
4061 nk_rune codepoint, nk_rune next_codepoint);
4062
4063#if defined(NK_INCLUDE_VERTEX_BUFFER_OUTPUT) || defined(NK_INCLUDE_SOFTWARE_FONT)
4064struct nk_user_font_glyph {
4065 struct nk_vec2 uv[2];
4066 struct nk_vec2 offset;
4067 float width, height;
4068 float xadvance;
4069};
4070#endif
4071
4073 nk_handle userdata;
4074 float height;
4075 nk_text_width_f width;
4076#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
4077 nk_query_font_glyph_f query;
4078 nk_handle texture;
4079#endif
4080};
4081
4082#ifdef NK_INCLUDE_FONT_BAKING
4083enum nk_font_coord_type {
4084 NK_COORD_UV,
4085 NK_COORD_PIXEL
4086};
4087
4088struct nk_font;
4089struct nk_baked_font {
4090 float height;
4091 float ascent;
4092 float descent;
4093 nk_rune glyph_offset;
4094 nk_rune glyph_count;
4095 const nk_rune *ranges;
4096};
4097
4098struct nk_font_config {
4099 struct nk_font_config *next;
4100 void *ttf_blob;
4101 nk_size ttf_size;
4103 unsigned char ttf_data_owned_by_atlas;
4104 unsigned char merge_mode;
4105 unsigned char pixel_snap;
4106 unsigned char oversample_v, oversample_h;
4107 unsigned char padding[3];
4108
4109 float size;
4110 enum nk_font_coord_type coord_type;
4111 struct nk_vec2 spacing;
4112 const nk_rune *range;
4113 struct nk_baked_font *font;
4114 nk_rune fallback_glyph;
4115 struct nk_font_config *n;
4116 struct nk_font_config *p;
4117};
4118
4119struct nk_font_glyph {
4120 nk_rune codepoint;
4121 float xadvance;
4122 float x0, y0, x1, y1, w, h;
4123 float u0, v0, u1, v1;
4124};
4125
4126struct nk_font {
4127 struct nk_font *next;
4128 struct nk_user_font handle;
4129 struct nk_baked_font info;
4130 float scale;
4131 struct nk_font_glyph *glyphs;
4132 const struct nk_font_glyph *fallback;
4133 nk_rune fallback_codepoint;
4134 nk_handle texture;
4135 struct nk_font_config *config;
4136};
4137
4138enum nk_font_atlas_format {
4139 NK_FONT_ATLAS_ALPHA8,
4140 NK_FONT_ATLAS_RGBA32
4141};
4142
4143struct nk_font_atlas {
4144 void *pixel;
4145 int tex_width;
4146 int tex_height;
4147
4148 struct nk_allocator permanent;
4149 struct nk_allocator temporary;
4150
4151 struct nk_recti custom;
4152 struct nk_cursor cursors[NK_CURSOR_COUNT];
4153
4154 int glyph_count;
4155 struct nk_font_glyph *glyphs;
4156 struct nk_font *default_font;
4157 struct nk_font *fonts;
4158 struct nk_font_config *config;
4159 int font_num;
4160};
4161
4163NK_API const nk_rune *nk_font_default_glyph_ranges(void);
4164NK_API const nk_rune *nk_font_chinese_glyph_ranges(void);
4165NK_API const nk_rune *nk_font_cyrillic_glyph_ranges(void);
4166NK_API const nk_rune *nk_font_korean_glyph_ranges(void);
4167
4168#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4169NK_API void nk_font_atlas_init_default(struct nk_font_atlas*);
4170#endif
4171NK_API void nk_font_atlas_init(struct nk_font_atlas*, const struct nk_allocator*);
4172NK_API void nk_font_atlas_init_custom(struct nk_font_atlas*, const struct nk_allocator *persistent, const struct nk_allocator *transient);
4173NK_API void nk_font_atlas_begin(struct nk_font_atlas*);
4174NK_API struct nk_font_config nk_font_config(float pixel_height);
4175NK_API struct nk_font *nk_font_atlas_add(struct nk_font_atlas*, const struct nk_font_config*);
4176#ifdef NK_INCLUDE_DEFAULT_FONT
4177NK_API struct nk_font* nk_font_atlas_add_default(struct nk_font_atlas*, float height, const struct nk_font_config*);
4178#endif
4179NK_API struct nk_font* nk_font_atlas_add_from_memory(struct nk_font_atlas *atlas, void *memory, nk_size size, float height, const struct nk_font_config *config);
4180#ifdef NK_INCLUDE_STANDARD_IO
4181NK_API struct nk_font* nk_font_atlas_add_from_file(struct nk_font_atlas *atlas, const char *file_path, float height, const struct nk_font_config*);
4182#endif
4183NK_API struct nk_font *nk_font_atlas_add_compressed(struct nk_font_atlas*, void *memory, nk_size size, float height, const struct nk_font_config*);
4184NK_API struct nk_font* nk_font_atlas_add_compressed_base85(struct nk_font_atlas*, const char *data, float height, const struct nk_font_config *config);
4185NK_API const void* nk_font_atlas_bake(struct nk_font_atlas*, int *width, int *height, enum nk_font_atlas_format);
4186NK_API void nk_font_atlas_end(struct nk_font_atlas*, nk_handle tex, struct nk_draw_null_texture*);
4187NK_API const struct nk_font_glyph* nk_font_find_glyph(const struct nk_font*, nk_rune unicode);
4188NK_API void nk_font_atlas_cleanup(struct nk_font_atlas *atlas);
4189NK_API void nk_font_atlas_clear(struct nk_font_atlas*);
4190
4191#endif
4192
4193/* ==============================================================
4194 *
4195 * MEMORY BUFFER
4196 *
4197 * ===============================================================*/
4230 void *memory;
4231 unsigned int type;
4232 nk_size size;
4233 nk_size allocated;
4234 nk_size needed;
4235 nk_size calls;
4236};
4237
4238enum nk_allocation_type {
4239 NK_BUFFER_FIXED,
4240 NK_BUFFER_DYNAMIC
4241};
4242
4243enum nk_buffer_allocation_type {
4244 NK_BUFFER_FRONT,
4245 NK_BUFFER_BACK,
4246 NK_BUFFER_MAX
4247};
4248
4250 nk_bool active;
4251 nk_size offset;
4252};
4253
4254struct nk_memory {void *ptr;nk_size size;};
4256 struct nk_buffer_marker marker[NK_BUFFER_MAX];
4258 enum nk_allocation_type type;
4261 nk_size allocated;
4262 nk_size needed;
4263 nk_size calls;
4264 nk_size size;
4265};
4266
4267#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4268NK_API void nk_buffer_init_default(struct nk_buffer*);
4269#endif
4270NK_API void nk_buffer_init(struct nk_buffer*, const struct nk_allocator*, nk_size size);
4271NK_API void nk_buffer_init_fixed(struct nk_buffer*, void *memory, nk_size size);
4272NK_API void nk_buffer_info(struct nk_memory_status*, const struct nk_buffer*);
4273NK_API void nk_buffer_push(struct nk_buffer*, enum nk_buffer_allocation_type type, const void *memory, nk_size size, nk_size align);
4274NK_API void nk_buffer_mark(struct nk_buffer*, enum nk_buffer_allocation_type type);
4275NK_API void nk_buffer_reset(struct nk_buffer*, enum nk_buffer_allocation_type type);
4276NK_API void nk_buffer_clear(struct nk_buffer*);
4277NK_API void nk_buffer_free(struct nk_buffer*);
4278NK_API void *nk_buffer_memory(struct nk_buffer*);
4279NK_API const void *nk_buffer_memory_const(const struct nk_buffer*);
4280NK_API nk_size nk_buffer_total(const struct nk_buffer*);
4281
4282/* ==============================================================
4283 *
4284 * STRING
4285 *
4286 * ===============================================================*/
4292struct nk_str {
4293 struct nk_buffer buffer;
4294 int len;
4295};
4296
4297#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4298NK_API void nk_str_init_default(struct nk_str*);
4299#endif
4300NK_API void nk_str_init(struct nk_str*, const struct nk_allocator*, nk_size size);
4301NK_API void nk_str_init_fixed(struct nk_str*, void *memory, nk_size size);
4302NK_API void nk_str_clear(struct nk_str*);
4303NK_API void nk_str_free(struct nk_str*);
4304
4305NK_API int nk_str_append_text_char(struct nk_str*, const char*, int);
4306NK_API int nk_str_append_str_char(struct nk_str*, const char*);
4307NK_API int nk_str_append_text_utf8(struct nk_str*, const char*, int);
4308NK_API int nk_str_append_str_utf8(struct nk_str*, const char*);
4309NK_API int nk_str_append_text_runes(struct nk_str*, const nk_rune*, int);
4310NK_API int nk_str_append_str_runes(struct nk_str*, const nk_rune*);
4311
4312NK_API int nk_str_insert_at_char(struct nk_str*, int pos, const char*, int);
4313NK_API int nk_str_insert_at_rune(struct nk_str*, int pos, const char*, int);
4314
4315NK_API int nk_str_insert_text_char(struct nk_str*, int pos, const char*, int);
4316NK_API int nk_str_insert_str_char(struct nk_str*, int pos, const char*);
4317NK_API int nk_str_insert_text_utf8(struct nk_str*, int pos, const char*, int);
4318NK_API int nk_str_insert_str_utf8(struct nk_str*, int pos, const char*);
4319NK_API int nk_str_insert_text_runes(struct nk_str*, int pos, const nk_rune*, int);
4320NK_API int nk_str_insert_str_runes(struct nk_str*, int pos, const nk_rune*);
4321
4322NK_API void nk_str_remove_chars(struct nk_str*, int len);
4323NK_API void nk_str_remove_runes(struct nk_str *str, int len);
4324NK_API void nk_str_delete_chars(struct nk_str*, int pos, int len);
4325NK_API void nk_str_delete_runes(struct nk_str*, int pos, int len);
4326
4327NK_API char *nk_str_at_char(struct nk_str*, int pos);
4328NK_API char *nk_str_at_rune(struct nk_str*, int pos, nk_rune *unicode, int *len);
4329NK_API nk_rune nk_str_rune_at(const struct nk_str*, int pos);
4330NK_API const char *nk_str_at_char_const(const struct nk_str*, int pos);
4331NK_API const char *nk_str_at_const(const struct nk_str*, int pos, nk_rune *unicode, int *len);
4332
4333NK_API char *nk_str_get(struct nk_str*);
4334NK_API const char *nk_str_get_const(const struct nk_str*);
4335NK_API int nk_str_len(const struct nk_str*);
4336NK_API int nk_str_len_char(const struct nk_str*);
4337
4338/* ===============================================================
4339 *
4340 * TEXT EDITOR
4341 *
4342 * ===============================================================*/
4369#ifndef NK_TEXTEDIT_UNDOSTATECOUNT
4370#define NK_TEXTEDIT_UNDOSTATECOUNT 99
4371#endif
4372
4373#ifndef NK_TEXTEDIT_UNDOCHARCOUNT
4374#define NK_TEXTEDIT_UNDOCHARCOUNT 999
4375#endif
4376
4377struct nk_text_edit;
4379 nk_handle userdata;
4380 nk_plugin_paste paste;
4381 nk_plugin_copy copy;
4382};
4383
4385 int where;
4386 short insert_length;
4387 short delete_length;
4388 short char_storage;
4389};
4390
4392 struct nk_text_undo_record undo_rec[NK_TEXTEDIT_UNDOSTATECOUNT];
4393 nk_rune undo_char[NK_TEXTEDIT_UNDOCHARCOUNT];
4394 short undo_point;
4395 short redo_point;
4396 short undo_char_point;
4397 short redo_char_point;
4398};
4399
4400enum nk_text_edit_type {
4401 NK_TEXT_EDIT_SINGLE_LINE,
4402 NK_TEXT_EDIT_MULTI_LINE
4403};
4404
4405enum nk_text_edit_mode {
4406 NK_TEXT_EDIT_MODE_VIEW,
4407 NK_TEXT_EDIT_MODE_INSERT,
4408 NK_TEXT_EDIT_MODE_REPLACE
4409};
4410
4412 struct nk_clipboard clip;
4413 struct nk_str string;
4414 nk_plugin_filter filter;
4415 struct nk_vec2 scrollbar;
4416
4417 int cursor;
4418 int select_start;
4419 int select_end;
4420 unsigned char mode;
4421 unsigned char cursor_at_end_of_line;
4422 unsigned char initialized;
4423 unsigned char has_preferred_x;
4424 unsigned char single_line;
4425 unsigned char active;
4426 unsigned char padding1;
4427 float preferred_x;
4428 struct nk_text_undo_state undo;
4429};
4430
4432NK_API nk_bool nk_filter_default(const struct nk_text_edit*, nk_rune unicode);
4433NK_API nk_bool nk_filter_ascii(const struct nk_text_edit*, nk_rune unicode);
4434NK_API nk_bool nk_filter_float(const struct nk_text_edit*, nk_rune unicode);
4435NK_API nk_bool nk_filter_decimal(const struct nk_text_edit*, nk_rune unicode);
4436NK_API nk_bool nk_filter_hex(const struct nk_text_edit*, nk_rune unicode);
4437NK_API nk_bool nk_filter_oct(const struct nk_text_edit*, nk_rune unicode);
4438NK_API nk_bool nk_filter_binary(const struct nk_text_edit*, nk_rune unicode);
4439
4441#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4442NK_API void nk_textedit_init_default(struct nk_text_edit*);
4443#endif
4444NK_API void nk_textedit_init(struct nk_text_edit*, const struct nk_allocator*, nk_size size);
4445NK_API void nk_textedit_init_fixed(struct nk_text_edit*, void *memory, nk_size size);
4446NK_API void nk_textedit_free(struct nk_text_edit*);
4447NK_API void nk_textedit_text(struct nk_text_edit*, const char*, int total_len);
4448NK_API void nk_textedit_delete(struct nk_text_edit*, int where, int len);
4449NK_API void nk_textedit_delete_selection(struct nk_text_edit*);
4450NK_API void nk_textedit_select_all(struct nk_text_edit*);
4451NK_API nk_bool nk_textedit_cut(struct nk_text_edit*);
4452NK_API nk_bool nk_textedit_paste(struct nk_text_edit*, char const*, int len);
4453NK_API void nk_textedit_undo(struct nk_text_edit*);
4454NK_API void nk_textedit_redo(struct nk_text_edit*);
4455
4456/* ===============================================================
4457 *
4458 * DRAWING
4459 *
4460 * ===============================================================*/
4510enum nk_command_type {
4511 NK_COMMAND_NOP,
4512 NK_COMMAND_SCISSOR,
4513 NK_COMMAND_LINE,
4514 NK_COMMAND_CURVE,
4515 NK_COMMAND_RECT,
4516 NK_COMMAND_RECT_FILLED,
4517 NK_COMMAND_RECT_MULTI_COLOR,
4518 NK_COMMAND_CIRCLE,
4519 NK_COMMAND_CIRCLE_FILLED,
4520 NK_COMMAND_ARC,
4521 NK_COMMAND_ARC_FILLED,
4522 NK_COMMAND_TRIANGLE,
4523 NK_COMMAND_TRIANGLE_FILLED,
4524 NK_COMMAND_POLYGON,
4525 NK_COMMAND_POLYGON_FILLED,
4526 NK_COMMAND_POLYLINE,
4527 NK_COMMAND_TEXT,
4528 NK_COMMAND_IMAGE,
4529 NK_COMMAND_CUSTOM
4530};
4531
4534 enum nk_command_type type;
4535 nk_size next;
4536#ifdef NK_INCLUDE_COMMAND_USERDATA
4537 nk_handle userdata;
4538#endif
4539};
4540
4542 struct nk_command header;
4543 short x, y;
4544 unsigned short w, h;
4545};
4546
4548 struct nk_command header;
4549 unsigned short line_thickness;
4550 struct nk_vec2i begin;
4551 struct nk_vec2i end;
4552 struct nk_color color;
4553};
4554
4556 struct nk_command header;
4557 unsigned short line_thickness;
4558 struct nk_vec2i begin;
4559 struct nk_vec2i end;
4560 struct nk_vec2i ctrl[2];
4561 struct nk_color color;
4562};
4563
4565 struct nk_command header;
4566 unsigned short rounding;
4567 unsigned short line_thickness;
4568 short x, y;
4569 unsigned short w, h;
4570 struct nk_color color;
4571};
4572
4574 struct nk_command header;
4575 unsigned short rounding;
4576 short x, y;
4577 unsigned short w, h;
4578 struct nk_color color;
4579};
4580
4582 struct nk_command header;
4583 short x, y;
4584 unsigned short w, h;
4585 struct nk_color left;
4586 struct nk_color top;
4587 struct nk_color bottom;
4588 struct nk_color right;
4589};
4590
4592 struct nk_command header;
4593 unsigned short line_thickness;
4594 struct nk_vec2i a;
4595 struct nk_vec2i b;
4596 struct nk_vec2i c;
4597 struct nk_color color;
4598};
4599
4601 struct nk_command header;
4602 struct nk_vec2i a;
4603 struct nk_vec2i b;
4604 struct nk_vec2i c;
4605 struct nk_color color;
4606};
4607
4609 struct nk_command header;
4610 short x, y;
4611 unsigned short line_thickness;
4612 unsigned short w, h;
4613 struct nk_color color;
4614};
4615
4617 struct nk_command header;
4618 short x, y;
4619 unsigned short w, h;
4620 struct nk_color color;
4621};
4622
4624 struct nk_command header;
4625 short cx, cy;
4626 unsigned short r;
4627 unsigned short line_thickness;
4628 float a[2];
4629 struct nk_color color;
4630};
4631
4633 struct nk_command header;
4634 short cx, cy;
4635 unsigned short r;
4636 float a[2];
4637 struct nk_color color;
4638};
4639
4641 struct nk_command header;
4642 struct nk_color color;
4643 unsigned short line_thickness;
4644 unsigned short point_count;
4645 struct nk_vec2i points[1];
4646};
4647
4649 struct nk_command header;
4650 struct nk_color color;
4651 unsigned short point_count;
4652 struct nk_vec2i points[1];
4653};
4654
4656 struct nk_command header;
4657 struct nk_color color;
4658 unsigned short line_thickness;
4659 unsigned short point_count;
4660 struct nk_vec2i points[1];
4661};
4662
4664 struct nk_command header;
4665 short x, y;
4666 unsigned short w, h;
4667 struct nk_image img;
4668 struct nk_color col;
4669};
4670
4671typedef void (*nk_command_custom_callback)(void *canvas, short x,short y,
4672 unsigned short w, unsigned short h, nk_handle callback_data);
4674 struct nk_command header;
4675 short x, y;
4676 unsigned short w, h;
4677 nk_handle callback_data;
4678 nk_command_custom_callback callback;
4679};
4680
4682 struct nk_command header;
4683 const struct nk_user_font *font;
4684 struct nk_color background;
4685 struct nk_color foreground;
4686 short x, y;
4687 unsigned short w, h;
4688 float height;
4689 int length;
4690 char string[2];
4691};
4692
4693enum nk_command_clipping {
4694 NK_CLIPPING_OFF = nk_false,
4695 NK_CLIPPING_ON = nk_true
4696};
4697
4699 struct nk_buffer *base;
4700 struct nk_rect clip;
4701 int use_clipping;
4702 nk_handle userdata;
4703 nk_size begin, end, last;
4704};
4705
4707NK_API void nk_stroke_line(struct nk_command_buffer *b, float x0, float y0, float x1, float y1, float line_thickness, struct nk_color);
4708NK_API void nk_stroke_curve(struct nk_command_buffer*, float, float, float, float, float, float, float, float, float line_thickness, struct nk_color);
4709NK_API void nk_stroke_rect(struct nk_command_buffer*, struct nk_rect, float rounding, float line_thickness, struct nk_color);
4710NK_API void nk_stroke_circle(struct nk_command_buffer*, struct nk_rect, float line_thickness, struct nk_color);
4711NK_API void nk_stroke_arc(struct nk_command_buffer*, float cx, float cy, float radius, float a_min, float a_max, float line_thickness, struct nk_color);
4712NK_API void nk_stroke_triangle(struct nk_command_buffer*, float, float, float, float, float, float, float line_thichness, struct nk_color);
4713NK_API void nk_stroke_polyline(struct nk_command_buffer*, const float *points, int point_count, float line_thickness, struct nk_color col);
4714NK_API void nk_stroke_polygon(struct nk_command_buffer*, const float *points, int point_count, float line_thickness, struct nk_color);
4715
4717NK_API void nk_fill_rect(struct nk_command_buffer*, struct nk_rect, float rounding, struct nk_color);
4718NK_API void nk_fill_rect_multi_color(struct nk_command_buffer*, struct nk_rect, struct nk_color left, struct nk_color top, struct nk_color right, struct nk_color bottom);
4719NK_API void nk_fill_circle(struct nk_command_buffer*, struct nk_rect, struct nk_color);
4720NK_API void nk_fill_arc(struct nk_command_buffer*, float cx, float cy, float radius, float a_min, float a_max, struct nk_color);
4721NK_API void nk_fill_triangle(struct nk_command_buffer*, float x0, float y0, float x1, float y1, float x2, float y2, struct nk_color);
4722NK_API void nk_fill_polygon(struct nk_command_buffer*, const float *points, int point_count, struct nk_color);
4723
4725NK_API void nk_draw_image(struct nk_command_buffer*, struct nk_rect, const struct nk_image*, struct nk_color);
4726NK_API void nk_draw_nine_slice(struct nk_command_buffer*, struct nk_rect, const struct nk_nine_slice*, struct nk_color);
4727NK_API void nk_draw_text(struct nk_command_buffer*, struct nk_rect, const char *text, int len, const struct nk_user_font*, struct nk_color, struct nk_color);
4728NK_API void nk_push_scissor(struct nk_command_buffer*, struct nk_rect);
4729NK_API void nk_push_custom(struct nk_command_buffer*, struct nk_rect, nk_command_custom_callback, nk_handle usr);
4730
4731/* ===============================================================
4732 *
4733 * INPUT
4734 *
4735 * ===============================================================*/
4737 nk_bool down;
4738 unsigned int clicked;
4739 struct nk_vec2 clicked_pos;
4740};
4741struct nk_mouse {
4742 struct nk_mouse_button buttons[NK_BUTTON_MAX];
4743 struct nk_vec2 pos;
4744#ifdef NK_BUTTON_TRIGGER_ON_RELEASE
4745 struct nk_vec2 down_pos;
4746#endif
4747 struct nk_vec2 prev;
4748 struct nk_vec2 delta;
4749 struct nk_vec2 scroll_delta;
4750 unsigned char grab;
4751 unsigned char grabbed;
4752 unsigned char ungrab;
4753};
4754
4755struct nk_key {
4756 nk_bool down;
4757 unsigned int clicked;
4758};
4760 struct nk_key keys[NK_KEY_MAX];
4761 char text[NK_INPUT_MAX];
4762 int text_len;
4763};
4764
4765struct nk_input {
4766 struct nk_keyboard keyboard;
4767 struct nk_mouse mouse;
4768};
4769
4770NK_API nk_bool nk_input_has_mouse_click(const struct nk_input*, enum nk_buttons);
4771NK_API nk_bool nk_input_has_mouse_click_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
4772NK_API nk_bool nk_input_has_mouse_click_in_button_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
4773NK_API nk_bool nk_input_has_mouse_click_down_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect, nk_bool down);
4774NK_API nk_bool nk_input_is_mouse_click_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
4775NK_API nk_bool nk_input_is_mouse_click_down_in_rect(const struct nk_input *i, enum nk_buttons id, struct nk_rect b, nk_bool down);
4776NK_API nk_bool nk_input_any_mouse_click_in_rect(const struct nk_input*, struct nk_rect);
4777NK_API nk_bool nk_input_is_mouse_prev_hovering_rect(const struct nk_input*, struct nk_rect);
4778NK_API nk_bool nk_input_is_mouse_hovering_rect(const struct nk_input*, struct nk_rect);
4779NK_API nk_bool nk_input_is_mouse_hovering_still_rect(const struct nk_input*, struct nk_rect);
4780NK_API nk_bool nk_input_is_mouse_hovering_delay_rect(const struct nk_context*, struct nk_rect, float*, float);
4781NK_API nk_bool nk_input_is_mouse_hovering_still_delay_rect(const struct nk_context*, struct nk_rect, float*, float);
4782NK_API nk_bool nk_input_is_mouse_hovering_still_delay_clicked_rect(const struct nk_context*, struct nk_rect, float*, float, nk_bool*);
4783NK_API nk_bool nk_input_is_mouse_moved(const struct nk_input*);
4784NK_API nk_bool nk_input_mouse_clicked(const struct nk_input*, enum nk_buttons, struct nk_rect);
4785NK_API nk_bool nk_input_is_mouse_down(const struct nk_input*, enum nk_buttons);
4786NK_API nk_bool nk_input_is_mouse_pressed(const struct nk_input*, enum nk_buttons);
4787NK_API nk_bool nk_input_is_mouse_released(const struct nk_input*, enum nk_buttons);
4788NK_API nk_bool nk_input_is_key_pressed(const struct nk_input*, enum nk_keys);
4789NK_API nk_bool nk_input_is_key_released(const struct nk_input*, enum nk_keys);
4790NK_API nk_bool nk_input_is_key_down(const struct nk_input*, enum nk_keys);
4791
4792/* ===============================================================
4793 *
4794 * DRAW LIST
4795 *
4796 * ===============================================================*/
4797#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
4814#ifdef NK_UINT_DRAW_INDEX
4815typedef nk_uint nk_draw_index;
4816#else
4817typedef nk_ushort nk_draw_index;
4818#endif
4819enum nk_draw_list_stroke {
4820 NK_STROKE_OPEN = nk_false, /***< build up path has no connection back to the beginning */
4821 NK_STROKE_CLOSED = nk_true /***< build up path has a connection back to the beginning */
4822};
4823
4824enum nk_draw_vertex_layout_attribute {
4825 NK_VERTEX_POSITION,
4826 NK_VERTEX_COLOR,
4827 NK_VERTEX_TEXCOORD,
4828 NK_VERTEX_ATTRIBUTE_COUNT
4829};
4830
4831enum nk_draw_vertex_layout_format {
4832 NK_FORMAT_SCHAR,
4833 NK_FORMAT_SSHORT,
4834 NK_FORMAT_SINT,
4835 NK_FORMAT_UCHAR,
4836 NK_FORMAT_USHORT,
4837 NK_FORMAT_UINT,
4838 NK_FORMAT_FLOAT,
4839 NK_FORMAT_DOUBLE,
4840
4841NK_FORMAT_COLOR_BEGIN,
4842 NK_FORMAT_R8G8B8 = NK_FORMAT_COLOR_BEGIN,
4843 NK_FORMAT_R16G15B16,
4844 NK_FORMAT_R32G32B32,
4845
4846 NK_FORMAT_R8G8B8A8,
4847 NK_FORMAT_B8G8R8A8,
4848 NK_FORMAT_R16G15B16A16,
4849 NK_FORMAT_R32G32B32A32,
4850 NK_FORMAT_R32G32B32A32_FLOAT,
4851 NK_FORMAT_R32G32B32A32_DOUBLE,
4852
4853 NK_FORMAT_RGB32,
4854 NK_FORMAT_RGBA32,
4855NK_FORMAT_COLOR_END = NK_FORMAT_RGBA32,
4856 NK_FORMAT_COUNT
4857};
4858
4859#define NK_VERTEX_LAYOUT_END NK_VERTEX_ATTRIBUTE_COUNT,NK_FORMAT_COUNT,0
4860struct nk_draw_vertex_layout_element {
4861 enum nk_draw_vertex_layout_attribute attribute;
4862 enum nk_draw_vertex_layout_format format;
4863 nk_size offset;
4864};
4865
4866struct nk_draw_command {
4867 unsigned int elem_count;
4868 struct nk_rect clip_rect;
4869 nk_handle texture;
4870#ifdef NK_INCLUDE_COMMAND_USERDATA
4871 nk_handle userdata;
4872#endif
4873};
4874
4875struct nk_draw_list {
4876 struct nk_rect clip_rect;
4877 struct nk_vec2 circle_vtx[12];
4878 struct nk_convert_config config;
4879
4880 struct nk_buffer *buffer;
4881 struct nk_buffer *vertices;
4882 struct nk_buffer *elements;
4883
4884 unsigned int element_count;
4885 unsigned int vertex_count;
4886 unsigned int cmd_count;
4887 nk_size cmd_offset;
4888
4889 unsigned int path_count;
4890 unsigned int path_offset;
4891
4892 enum nk_anti_aliasing line_AA;
4893 enum nk_anti_aliasing shape_AA;
4894
4895#ifdef NK_INCLUDE_COMMAND_USERDATA
4896 nk_handle userdata;
4897#endif
4898};
4899
4900/* draw list */
4901NK_API void nk_draw_list_init(struct nk_draw_list*);
4902NK_API void nk_draw_list_setup(struct nk_draw_list*, const struct nk_convert_config*, struct nk_buffer *cmds, struct nk_buffer *vertices, struct nk_buffer *elements, enum nk_anti_aliasing line_aa,enum nk_anti_aliasing shape_aa);
4903
4904/* drawing */
4905#define nk_draw_list_foreach(cmd, can, b) for((cmd)=nk__draw_list_begin(can, b); (cmd)!=0; (cmd)=nk__draw_list_next(cmd, b, can))
4906NK_API const struct nk_draw_command* nk__draw_list_begin(const struct nk_draw_list*, const struct nk_buffer*);
4907NK_API const struct nk_draw_command* nk__draw_list_next(const struct nk_draw_command*, const struct nk_buffer*, const struct nk_draw_list*);
4908NK_API const struct nk_draw_command* nk__draw_list_end(const struct nk_draw_list*, const struct nk_buffer*);
4909
4910/* path */
4911NK_API void nk_draw_list_path_clear(struct nk_draw_list*);
4912NK_API void nk_draw_list_path_line_to(struct nk_draw_list*, struct nk_vec2 pos);
4913NK_API void nk_draw_list_path_arc_to_fast(struct nk_draw_list*, struct nk_vec2 center, float radius, int a_min, int a_max);
4914NK_API void nk_draw_list_path_arc_to(struct nk_draw_list*, struct nk_vec2 center, float radius, float a_min, float a_max, unsigned int segments);
4915NK_API void nk_draw_list_path_rect_to(struct nk_draw_list*, struct nk_vec2 a, struct nk_vec2 b, float rounding);
4916NK_API void nk_draw_list_path_curve_to(struct nk_draw_list*, struct nk_vec2 p2, struct nk_vec2 p3, struct nk_vec2 p4, unsigned int num_segments);
4917NK_API void nk_draw_list_path_fill(struct nk_draw_list*, struct nk_color);
4918NK_API void nk_draw_list_path_stroke(struct nk_draw_list*, struct nk_color, enum nk_draw_list_stroke closed, float thickness);
4919
4920/* stroke */
4921NK_API void nk_draw_list_stroke_line(struct nk_draw_list*, struct nk_vec2 a, struct nk_vec2 b, struct nk_color, float thickness);
4922NK_API void nk_draw_list_stroke_rect(struct nk_draw_list*, struct nk_rect rect, struct nk_color, float rounding, float thickness);
4923NK_API void nk_draw_list_stroke_triangle(struct nk_draw_list*, struct nk_vec2 a, struct nk_vec2 b, struct nk_vec2 c, struct nk_color, float thickness);
4924NK_API void nk_draw_list_stroke_circle(struct nk_draw_list*, struct nk_vec2 center, float radius, struct nk_color, unsigned int segs, float thickness);
4925NK_API void nk_draw_list_stroke_curve(struct nk_draw_list*, struct nk_vec2 p0, struct nk_vec2 cp0, struct nk_vec2 cp1, struct nk_vec2 p1, struct nk_color, unsigned int segments, float thickness);
4926NK_API void nk_draw_list_stroke_poly_line(struct nk_draw_list*, const struct nk_vec2 *pnts, const unsigned int cnt, struct nk_color, enum nk_draw_list_stroke, float thickness, enum nk_anti_aliasing);
4927
4928/* fill */
4929NK_API void nk_draw_list_fill_rect(struct nk_draw_list*, struct nk_rect rect, struct nk_color, float rounding);
4930NK_API void nk_draw_list_fill_rect_multi_color(struct nk_draw_list*, struct nk_rect rect, struct nk_color left, struct nk_color top, struct nk_color right, struct nk_color bottom);
4931NK_API void nk_draw_list_fill_triangle(struct nk_draw_list*, struct nk_vec2 a, struct nk_vec2 b, struct nk_vec2 c, struct nk_color);
4932NK_API void nk_draw_list_fill_circle(struct nk_draw_list*, struct nk_vec2 center, float radius, struct nk_color col, unsigned int segs);
4933NK_API void nk_draw_list_fill_poly_convex(struct nk_draw_list*, const struct nk_vec2 *points, const unsigned int count, struct nk_color, enum nk_anti_aliasing);
4934
4935/* misc */
4936NK_API void nk_draw_list_add_image(struct nk_draw_list*, struct nk_image texture, struct nk_rect rect, struct nk_color);
4937NK_API void nk_draw_list_add_text(struct nk_draw_list*, const struct nk_user_font*, struct nk_rect, const char *text, int len, float font_height, struct nk_color);
4938#ifdef NK_INCLUDE_COMMAND_USERDATA
4939NK_API void nk_draw_list_push_userdata(struct nk_draw_list*, nk_handle userdata);
4940#endif
4941
4942#endif
4943
4944/* ===============================================================
4945 *
4946 * GUI
4947 *
4948 * ===============================================================*/
4949enum nk_style_item_type {
4950 NK_STYLE_ITEM_COLOR,
4951 NK_STYLE_ITEM_IMAGE,
4952 NK_STYLE_ITEM_NINE_SLICE
4953};
4954
4956 struct nk_color color;
4957 struct nk_image image;
4958 struct nk_nine_slice slice;
4959};
4960
4962 enum nk_style_item_type type;
4963 union nk_style_item_data data;
4964};
4965
4967 struct nk_color color;
4968 struct nk_vec2 padding;
4969 float color_factor;
4970 float disabled_factor;
4971};
4972
4974 struct nk_color text_normal;
4975 struct nk_color text_hover;
4976 struct nk_color text_active;
4977 enum nk_link_underline underline;
4978 float underline_thickness;
4979 struct nk_vec2 padding;
4980 struct nk_vec2 touch_padding;
4981 float color_factor;
4982 float disabled_factor;
4983};
4984
4986 /* background */
4987 struct nk_style_item normal;
4988 struct nk_style_item hover;
4989 struct nk_style_item active;
4990 struct nk_color border_color;
4991 float color_factor_background;
4992
4993 /* text */
4994 struct nk_color text_background;
4995 struct nk_color text_normal;
4996 struct nk_color text_hover;
4997 struct nk_color text_active;
4998 nk_flags text_alignment;
4999 float color_factor_text;
5000
5001 /* properties */
5002 float border;
5003 float rounding;
5004 struct nk_vec2 padding;
5005 struct nk_vec2 image_padding;
5006 struct nk_vec2 touch_padding;
5007 float disabled_factor;
5008
5009 /* optional user callbacks */
5010 nk_handle userdata;
5011 void(*draw_begin)(struct nk_command_buffer*, nk_handle userdata);
5012 void(*draw_end)(struct nk_command_buffer*, nk_handle userdata);
5013};
5014
5016 /* background */
5017 struct nk_style_item normal;
5018 struct nk_style_item hover;
5019 struct nk_style_item active;
5020 struct nk_color border_color;
5021
5022 /* cursor */
5023 struct nk_style_item cursor_normal;
5024 struct nk_style_item cursor_hover;
5025
5026 /* text */
5027 struct nk_color text_normal;
5028 struct nk_color text_hover;
5029 struct nk_color text_active;
5030 struct nk_color text_background;
5031 nk_flags text_alignment;
5032
5033 /* properties */
5034 struct nk_vec2 padding;
5035 struct nk_vec2 touch_padding;
5036 float spacing;
5037 float border;
5038 float color_factor;
5039 float disabled_factor;
5040
5041 /* optional user callbacks */
5042 nk_handle userdata;
5043 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5044 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5045};
5046
5048 /* background (inactive) */
5049 struct nk_style_item normal;
5050 struct nk_style_item hover;
5051 struct nk_style_item pressed;
5052
5053 /* background (active) */
5054 struct nk_style_item normal_active;
5055 struct nk_style_item hover_active;
5056 struct nk_style_item pressed_active;
5057
5058 /* text color (inactive) */
5059 struct nk_color text_normal;
5060 struct nk_color text_hover;
5061 struct nk_color text_pressed;
5062
5063 /* text color (active) */
5064 struct nk_color text_normal_active;
5065 struct nk_color text_hover_active;
5066 struct nk_color text_pressed_active;
5067 struct nk_color text_background;
5068 nk_flags text_alignment;
5069
5070 /* properties */
5071 float rounding;
5072 struct nk_vec2 padding;
5073 struct nk_vec2 touch_padding;
5074 struct nk_vec2 image_padding;
5075 float color_factor;
5076 float disabled_factor;
5077
5078 /* optional user callbacks */
5079 nk_handle userdata;
5080 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5081 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5082};
5083
5085 /* background */
5086 struct nk_style_item normal;
5087 struct nk_style_item hover;
5088 struct nk_style_item active;
5089 struct nk_color border_color;
5090
5091 /* background bar */
5092 struct nk_color bar_normal;
5093 struct nk_color bar_hover;
5094 struct nk_color bar_active;
5095 struct nk_color bar_filled;
5096
5097 /* cursor */
5098 struct nk_style_item cursor_normal;
5099 struct nk_style_item cursor_hover;
5100 struct nk_style_item cursor_active;
5101
5102 /* properties */
5103 float border;
5104 float rounding;
5105 float bar_height;
5106 struct nk_vec2 padding;
5107 struct nk_vec2 spacing;
5108 struct nk_vec2 cursor_size; /* NOTE y has no effect on vertex buffer backends */
5109 float color_factor;
5110 float disabled_factor;
5111
5112 /* optional buttons */
5113 int show_buttons;
5114 struct nk_style_button inc_button;
5115 struct nk_style_button dec_button;
5116 enum nk_symbol_type inc_symbol;
5117 enum nk_symbol_type dec_symbol;
5118
5119 /* optional user callbacks */
5120 nk_handle userdata;
5121 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5122 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5123};
5124
5126 /* background */
5127 struct nk_style_item normal;
5128 struct nk_style_item hover;
5129 struct nk_style_item active;
5130 struct nk_color border_color;
5131
5132 /* knob */
5133 struct nk_color knob_normal;
5134 struct nk_color knob_hover;
5135 struct nk_color knob_active;
5136 struct nk_color knob_border_color;
5137
5138 /* cursor */
5139 struct nk_color cursor_normal;
5140 struct nk_color cursor_hover;
5141 struct nk_color cursor_active;
5142
5143 /* properties */
5144 float border;
5145 float knob_border;
5146 struct nk_vec2 padding;
5147 struct nk_vec2 spacing;
5148 float cursor_width;
5149 float color_factor;
5150 float disabled_factor;
5151
5152 /* optional user callbacks */
5153 nk_handle userdata;
5154 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5155 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5156};
5157
5159 /* background */
5160 struct nk_style_item normal;
5161 struct nk_style_item hover;
5162 struct nk_style_item active;
5163 struct nk_color border_color;
5164
5165 /* cursor */
5166 struct nk_style_item cursor_normal;
5167 struct nk_style_item cursor_hover;
5168 struct nk_style_item cursor_active;
5169 struct nk_color cursor_border_color;
5170
5171 /* properties */
5172 float rounding;
5173 float border;
5174 float cursor_border;
5175 float cursor_rounding;
5176 struct nk_vec2 padding;
5177 float color_factor;
5178 float disabled_factor;
5179
5180 /* optional user callbacks */
5181 nk_handle userdata;
5182 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5183 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5184};
5185
5187 /* background */
5188 struct nk_style_item normal;
5189 struct nk_style_item hover;
5190 struct nk_style_item active;
5191 struct nk_color border_color;
5192
5193 /* cursor */
5194 struct nk_style_item cursor_normal;
5195 struct nk_style_item cursor_hover;
5196 struct nk_style_item cursor_active;
5197 struct nk_color cursor_border_color;
5198
5199 /* properties */
5200 float border;
5201 float rounding;
5202 float border_cursor;
5203 float rounding_cursor;
5204 struct nk_vec2 padding;
5205 float color_factor;
5206 float disabled_factor;
5207
5208 /* optional buttons */
5209 int show_buttons;
5210 struct nk_style_button inc_button;
5211 struct nk_style_button dec_button;
5212 enum nk_symbol_type inc_symbol;
5213 enum nk_symbol_type dec_symbol;
5214
5215 /* optional user callbacks */
5216 nk_handle userdata;
5217 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5218 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5219};
5220
5222 /* background */
5223 struct nk_style_item normal;
5224 struct nk_style_item hover;
5225 struct nk_style_item active;
5226 struct nk_color border_color;
5227 struct nk_style_scrollbar scrollbar;
5228
5229 /* cursor */
5230 struct nk_color cursor_normal;
5231 struct nk_color cursor_hover;
5232 struct nk_color cursor_text_normal;
5233 struct nk_color cursor_text_hover;
5234
5235 /* text (unselected) */
5236 struct nk_color text_normal;
5237 struct nk_color text_hover;
5238 struct nk_color text_active;
5239
5240 /* text (selected) */
5241 struct nk_color selected_normal;
5242 struct nk_color selected_hover;
5243 struct nk_color selected_text_normal;
5244 struct nk_color selected_text_hover;
5245
5246 /* properties */
5247 float border;
5248 float rounding;
5249 float cursor_size;
5250 struct nk_vec2 scrollbar_size;
5251 struct nk_vec2 padding;
5252 float row_padding;
5253 float color_factor;
5254 float disabled_factor;
5255};
5256
5258 /* background */
5259 struct nk_style_item normal;
5260 struct nk_style_item hover;
5261 struct nk_style_item active;
5262 struct nk_color border_color;
5263
5264 /* text */
5265 struct nk_color label_normal;
5266 struct nk_color label_hover;
5267 struct nk_color label_active;
5268
5269 /* symbols */
5270 enum nk_symbol_type sym_left;
5271 enum nk_symbol_type sym_right;
5272
5273 /* properties */
5274 float border;
5275 float rounding;
5276 struct nk_vec2 padding;
5277 float color_factor;
5278 float disabled_factor;
5279
5280 struct nk_style_edit edit;
5281 struct nk_style_button inc_button;
5282 struct nk_style_button dec_button;
5283
5284 /* optional user callbacks */
5285 nk_handle userdata;
5286 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5287 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5288};
5289
5291 /* colors */
5292 struct nk_style_item background;
5293 struct nk_color border_color;
5294 struct nk_color selected_color;
5295 struct nk_color color;
5296
5297 /* properties */
5298 float border;
5299 float rounding;
5300 struct nk_vec2 padding;
5301 float color_factor;
5302 float disabled_factor;
5303 nk_bool show_markers;
5304};
5305
5307 /* background */
5308 struct nk_style_item normal;
5309 struct nk_style_item hover;
5310 struct nk_style_item active;
5311 struct nk_color border_color;
5312
5313 /* label */
5314 struct nk_color label_normal;
5315 struct nk_color label_hover;
5316 struct nk_color label_active;
5317
5318 /* symbol */
5319 struct nk_color symbol_normal;
5320 struct nk_color symbol_hover;
5321 struct nk_color symbol_active;
5322
5323 /* button */
5324 struct nk_style_button button;
5325 enum nk_symbol_type sym_normal;
5326 enum nk_symbol_type sym_hover;
5327 enum nk_symbol_type sym_active;
5328
5329 /* properties */
5330 float border;
5331 float rounding;
5332 struct nk_vec2 content_padding;
5333 struct nk_vec2 button_padding;
5334 struct nk_vec2 spacing;
5335 float color_factor;
5336 float disabled_factor;
5337};
5338
5340 /* background */
5341 struct nk_style_item background;
5342 struct nk_color border_color;
5343 struct nk_color text;
5344
5345 /* button */
5346 struct nk_style_button tab_maximize_button;
5347 struct nk_style_button tab_minimize_button;
5348 struct nk_style_button node_maximize_button;
5349 struct nk_style_button node_minimize_button;
5350 enum nk_symbol_type sym_minimize;
5351 enum nk_symbol_type sym_maximize;
5352
5353 /* properties */
5354 float border;
5355 float rounding;
5356 float indent;
5357 struct nk_vec2 padding;
5358 struct nk_vec2 spacing;
5359 float color_factor;
5360 float disabled_factor;
5361};
5362
5363enum nk_style_header_align {
5364 NK_HEADER_LEFT,
5365 NK_HEADER_RIGHT
5366};
5368 /* background */
5369 struct nk_style_item normal;
5370 struct nk_style_item hover;
5371 struct nk_style_item active;
5372
5373 /* button */
5374 struct nk_style_button close_button;
5375 struct nk_style_button minimize_button;
5376 enum nk_symbol_type close_symbol;
5377 enum nk_symbol_type minimize_symbol;
5378 enum nk_symbol_type maximize_symbol;
5379
5380 /* title */
5381 struct nk_color label_normal;
5382 struct nk_color label_hover;
5383 struct nk_color label_active;
5384
5385 /* properties */
5386 enum nk_style_header_align align;
5387 struct nk_vec2 padding;
5388 struct nk_vec2 label_padding;
5389 struct nk_vec2 spacing;
5390};
5391
5393 struct nk_style_window_header header;
5394 struct nk_style_item fixed_background;
5395 struct nk_color background;
5396
5397 struct nk_color border_color;
5398 struct nk_color popup_border_color;
5399 struct nk_color combo_border_color;
5400 struct nk_color contextual_border_color;
5401 struct nk_color menu_border_color;
5402 struct nk_color group_border_color;
5403 struct nk_color tooltip_border_color;
5404 struct nk_style_item scaler;
5405
5406 float border;
5407 float combo_border;
5408 float contextual_border;
5409 float menu_border;
5410 float group_border;
5411 float tooltip_border;
5412 float popup_border;
5413 float min_row_height_padding;
5414
5415 float rounding;
5416 struct nk_vec2 spacing;
5417 struct nk_vec2 scrollbar_size;
5418 struct nk_vec2 min_size;
5419
5420 struct nk_vec2 padding;
5421 struct nk_vec2 group_padding;
5422 struct nk_vec2 popup_padding;
5423 struct nk_vec2 combo_padding;
5424 struct nk_vec2 contextual_padding;
5425 struct nk_vec2 menu_padding;
5426 struct nk_vec2 tooltip_padding;
5427
5428 enum nk_tooltip_pos tooltip_origin;
5429 struct nk_vec2 tooltip_offset;
5430 float tooltip_delay;
5431};
5432
5433struct nk_style {
5434 const struct nk_user_font *font;
5435 const struct nk_cursor *cursors[NK_CURSOR_COUNT];
5436 const struct nk_cursor *cursor_active;
5437 struct nk_cursor *cursor_last;
5438 int cursor_visible;
5439
5440 struct nk_style_text text;
5441 struct nk_style_link link;
5442 struct nk_style_button button;
5443 struct nk_style_button contextual_button;
5444 struct nk_style_button menu_button;
5445 struct nk_style_toggle option;
5446 struct nk_style_toggle checkbox;
5447 struct nk_style_selectable selectable;
5448 struct nk_style_slider slider;
5449 struct nk_style_knob knob;
5450 struct nk_style_progress progress;
5451 struct nk_style_property property;
5452 struct nk_style_edit edit;
5453 struct nk_style_chart chart;
5454 struct nk_style_scrollbar scrollh;
5455 struct nk_style_scrollbar scrollv;
5456 struct nk_style_tab tab;
5457 struct nk_style_combo combo;
5458 struct nk_style_window window;
5459};
5460
5461NK_API struct nk_style_item nk_style_item_color(struct nk_color);
5462NK_API struct nk_style_item nk_style_item_image(struct nk_image img);
5463NK_API struct nk_style_item nk_style_item_nine_slice(struct nk_nine_slice slice);
5464NK_API struct nk_style_item nk_style_item_hide(void);
5465
5466/*==============================================================
5467 * PANEL
5468 * =============================================================*/
5469#ifndef NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS
5470#define NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS 16
5471#endif
5472#ifndef NK_CHART_MAX_SLOT
5473#define NK_CHART_MAX_SLOT 4
5474#endif
5475
5476enum nk_panel_type {
5477 NK_PANEL_NONE = 0,
5478 NK_PANEL_WINDOW = NK_FLAG(0),
5479 NK_PANEL_GROUP = NK_FLAG(1),
5480 NK_PANEL_POPUP = NK_FLAG(2),
5481 NK_PANEL_CONTEXTUAL = NK_FLAG(4),
5482 NK_PANEL_COMBO = NK_FLAG(5),
5483 NK_PANEL_MENU = NK_FLAG(6),
5484 NK_PANEL_TOOLTIP = NK_FLAG(7)
5485};
5486enum nk_panel_set {
5487 NK_PANEL_SET_NONBLOCK = NK_PANEL_CONTEXTUAL|NK_PANEL_COMBO|NK_PANEL_MENU|NK_PANEL_TOOLTIP,
5488 NK_PANEL_SET_POPUP = NK_PANEL_SET_NONBLOCK|NK_PANEL_POPUP,
5489 NK_PANEL_SET_SUB = NK_PANEL_SET_POPUP|NK_PANEL_GROUP
5490};
5491
5493 enum nk_chart_type type;
5494 struct nk_color color;
5495 struct nk_color highlight;
5496 float min, max, range;
5497 int count;
5498 struct nk_vec2 last;
5499 int index;
5500 nk_bool show_markers;
5501};
5502
5503struct nk_chart {
5504 int slot;
5505 float x, y, w, h;
5506 struct nk_chart_slot slots[NK_CHART_MAX_SLOT];
5507};
5508
5509enum nk_panel_row_layout_type {
5510 NK_LAYOUT_DYNAMIC_FIXED = 0,
5511 NK_LAYOUT_DYNAMIC_ROW,
5512 NK_LAYOUT_DYNAMIC_FREE,
5513 NK_LAYOUT_DYNAMIC,
5514 NK_LAYOUT_STATIC_FIXED,
5515 NK_LAYOUT_STATIC_ROW,
5516 NK_LAYOUT_STATIC_FREE,
5517 NK_LAYOUT_STATIC,
5518 NK_LAYOUT_TEMPLATE,
5519 NK_LAYOUT_COUNT
5520};
5522 enum nk_panel_row_layout_type type;
5523 int index;
5524 float height;
5525 float min_height;
5526 int columns;
5527 const float *ratio;
5528 float item_width;
5529 float item_height;
5530 float item_offset;
5531 float filled;
5532 struct nk_rect item;
5533 int tree_depth;
5534 float templates[NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS];
5535};
5536
5538 nk_size begin;
5539 nk_size parent;
5540 nk_size last;
5541 nk_size end;
5542 nk_bool active;
5543};
5544
5546 float x, y, w, h;
5547 struct nk_scroll offset;
5548};
5549
5550struct nk_panel {
5551 enum nk_panel_type type;
5552 nk_flags flags;
5553 struct nk_rect bounds;
5554 nk_uint *offset_x;
5555 nk_uint *offset_y;
5556 float at_x, at_y, max_x;
5557 float footer_height;
5558 float header_height;
5559 float border;
5560 unsigned int has_scrolling;
5561 struct nk_rect clip;
5562 struct nk_menu_state menu;
5563 struct nk_row_layout row;
5564 struct nk_chart chart;
5565 struct nk_command_buffer *buffer;
5566 struct nk_panel *parent;
5567};
5568
5569/*==============================================================
5570 * WINDOW
5571 * =============================================================*/
5572#ifndef NK_WINDOW_MAX_NAME
5573#define NK_WINDOW_MAX_NAME 64
5574#endif
5575
5576struct nk_table;
5577enum nk_window_flags {
5578 NK_WINDOW_PRIVATE = NK_FLAG(11),
5579 NK_WINDOW_DYNAMIC = NK_WINDOW_PRIVATE,
5580 NK_WINDOW_ROM = NK_FLAG(12),
5581 NK_WINDOW_NOT_INTERACTIVE = NK_WINDOW_ROM|NK_WINDOW_NO_INPUT,
5582 NK_WINDOW_HIDDEN = NK_FLAG(13),
5583 NK_WINDOW_CLOSED = NK_FLAG(14),
5584 NK_WINDOW_MINIMIZED = NK_FLAG(15),
5585 NK_WINDOW_REMOVE_ROM = NK_FLAG(16)
5586};
5587
5589 struct nk_window *win;
5590 enum nk_panel_type type;
5591 struct nk_popup_buffer buf;
5592 nk_hash name;
5593 nk_bool active;
5594 unsigned combo_count;
5595 unsigned con_count, con_old;
5596 unsigned active_con;
5597 struct nk_rect header;
5598};
5599
5601 nk_hash name;
5602 unsigned int seq;
5603 unsigned int old;
5604 int active, prev;
5605 int cursor;
5606 int sel_start;
5607 int sel_end;
5608 struct nk_scroll scrollbar;
5609 unsigned char mode;
5610 unsigned char single_line;
5611};
5612
5614 int active, prev;
5615 char buffer[NK_MAX_NUMBER_BUFFER];
5616 int length;
5617 int cursor;
5618 int select_start;
5619 int select_end;
5620 nk_hash name;
5621 unsigned int seq;
5622 unsigned int old;
5623 int state;
5624 int prev_state;
5625 nk_hash prev_name;
5626 char prev_buffer[NK_MAX_NUMBER_BUFFER];
5627 int prev_length;
5628};
5629
5631 unsigned int seq;
5632 nk_hash name;
5633 char name_string[NK_WINDOW_MAX_NAME];
5634 nk_flags flags;
5635
5636 struct nk_rect bounds;
5637 struct nk_scroll scrollbar;
5638 struct nk_command_buffer buffer;
5639 struct nk_panel *layout;
5640 float scrollbar_hiding_timer;
5641
5642 /* persistent widget state */
5643 struct nk_property_state property;
5644 struct nk_popup_state popup;
5645 struct nk_edit_state edit;
5646 unsigned int scrolled;
5647 nk_bool widgets_disabled;
5648
5649 struct nk_table *tables;
5650 unsigned int table_count;
5651
5652 /* window list hooks */
5653 struct nk_window *next;
5654 struct nk_window *prev;
5655 struct nk_window *parent;
5656};
5657
5658/*==============================================================
5659 * STACK
5660 * =============================================================*/
5688#ifndef NK_BUTTON_BEHAVIOR_STACK_SIZE
5689#define NK_BUTTON_BEHAVIOR_STACK_SIZE 8
5690#endif
5691
5692#ifndef NK_FONT_STACK_SIZE
5693#define NK_FONT_STACK_SIZE 8
5694#endif
5695
5696#ifndef NK_STYLE_ITEM_STACK_SIZE
5697#define NK_STYLE_ITEM_STACK_SIZE 16
5698#endif
5699
5700#ifndef NK_FLOAT_STACK_SIZE
5701#define NK_FLOAT_STACK_SIZE 32
5702#endif
5703
5704#ifndef NK_VECTOR_STACK_SIZE
5705#define NK_VECTOR_STACK_SIZE 16
5706#endif
5707
5708#ifndef NK_FLAGS_STACK_SIZE
5709#define NK_FLAGS_STACK_SIZE 32
5710#endif
5711
5712#ifndef NK_COLOR_STACK_SIZE
5713#define NK_COLOR_STACK_SIZE 32
5714#endif
5715
5716#define NK_CONFIGURATION_STACK_TYPE(prefix, name, type)\
5717 struct nk_config_stack_##name##_element {\
5718 prefix##_##type *address;\
5719 prefix##_##type old_value;\
5720 }
5721#define NK_CONFIG_STACK(type,size)\
5722 struct nk_config_stack_##type {\
5723 int head;\
5724 struct nk_config_stack_##type##_element elements[size];\
5725 }
5726
5727#define nk_float float
5728NK_CONFIGURATION_STACK_TYPE(struct nk, style_item, style_item);
5729NK_CONFIGURATION_STACK_TYPE(nk ,float, float);
5730NK_CONFIGURATION_STACK_TYPE(struct nk, vec2, vec2);
5731NK_CONFIGURATION_STACK_TYPE(nk ,flags, flags);
5732NK_CONFIGURATION_STACK_TYPE(struct nk, color, color);
5733NK_CONFIGURATION_STACK_TYPE(const struct nk, user_font, user_font*);
5734NK_CONFIGURATION_STACK_TYPE(enum nk, button_behavior, button_behavior);
5735
5736NK_CONFIG_STACK(style_item, NK_STYLE_ITEM_STACK_SIZE);
5737NK_CONFIG_STACK(float, NK_FLOAT_STACK_SIZE);
5738NK_CONFIG_STACK(vec2, NK_VECTOR_STACK_SIZE);
5739NK_CONFIG_STACK(flags, NK_FLAGS_STACK_SIZE);
5740NK_CONFIG_STACK(color, NK_COLOR_STACK_SIZE);
5741NK_CONFIG_STACK(user_font, NK_FONT_STACK_SIZE);
5742NK_CONFIG_STACK(button_behavior, NK_BUTTON_BEHAVIOR_STACK_SIZE);
5743
5745 struct nk_config_stack_style_item style_items;
5746 struct nk_config_stack_float floats;
5747 struct nk_config_stack_vec2 vectors;
5748 struct nk_config_stack_flags flags;
5749 struct nk_config_stack_color colors;
5750 struct nk_config_stack_user_font fonts;
5751 struct nk_config_stack_button_behavior button_behaviors;
5752};
5753
5754/*==============================================================
5755 * CONTEXT
5756 * =============================================================*/
5757#define NK_VALUE_PAGE_CAPACITY \
5758 (((NK_MAX(sizeof(struct nk_window),sizeof(struct nk_panel)) / sizeof(nk_uint))) / 2)
5759
5760struct nk_table {
5761 unsigned int seq;
5762 unsigned int size;
5763 nk_hash keys[NK_VALUE_PAGE_CAPACITY];
5764 nk_uint values[NK_VALUE_PAGE_CAPACITY];
5765 struct nk_table *next, *prev;
5766};
5767
5769 struct nk_table tbl;
5770 struct nk_panel pan;
5771 struct nk_window win;
5772};
5773
5775 union nk_page_data data;
5776 struct nk_page_element *next;
5777 struct nk_page_element *prev;
5778};
5779
5780struct nk_page {
5781 unsigned int size;
5782 struct nk_page *next;
5783 struct nk_page_element win[1];
5784};
5785
5786struct nk_pool {
5787 struct nk_allocator alloc;
5788 enum nk_allocation_type type;
5789 unsigned int page_count;
5790 struct nk_page *pages;
5791 struct nk_page_element *freelist;
5792 unsigned capacity;
5793 nk_size size;
5794 nk_size cap;
5795};
5796
5798/* public: can be accessed freely */
5799 struct nk_input input;
5800 struct nk_style style;
5801 struct nk_buffer memory;
5802 struct nk_clipboard clip;
5803 nk_flags last_widget_state;
5804 enum nk_button_behavior button_behavior;
5805 struct nk_configuration_stacks stacks;
5806 float delta_time_seconds;
5807
5808/* private:
5809 should only be accessed if you
5810 know what you are doing */
5811#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
5812 struct nk_draw_list draw_list;
5813#endif
5814#ifdef NK_INCLUDE_COMMAND_USERDATA
5815 nk_handle userdata;
5816#endif
5824
5827 int use_pool;
5828 struct nk_pool pool;
5829 struct nk_window *begin;
5830 struct nk_window *end;
5831 struct nk_window *active;
5832 struct nk_window *current;
5833 struct nk_page_element *freelist;
5834 unsigned int count;
5835 unsigned int seq;
5836};
5837
5838/* ==============================================================
5839 * MATH
5840 * =============================================================== */
5841#define NK_PI 3.141592654f
5842#define NK_PI_HALF 1.570796326f
5843#define NK_UTF_INVALID 0xFFFD
5844/* Digits after decimal for nk_property_float/double display. Overridable before include. */
5845#ifndef NK_MAX_FLOAT_PRECISION
5846#define NK_MAX_FLOAT_PRECISION 2
5847#endif
5848
5849#define NK_UNUSED(x) ((void)(x))
5850#define NK_SATURATE(x) (NK_MAX(0, NK_MIN(1.0f, x)))
5851#define NK_LEN(a) (sizeof(a)/sizeof(a)[0])
5852#define NK_ABS(a) (((a) < 0) ? -(a) : (a))
5853#define NK_BETWEEN(x, a, b) ((a) <= (x) && (x) < (b))
5854#define NK_INBOX(px, py, x, y, w, h)\
5855 (NK_BETWEEN(px,x,x+w) && NK_BETWEEN(py,y,y+h))
5856#define NK_INTERSECT(x0, y0, w0, h0, x1, y1, w1, h1) \
5857 ((x1 < (x0 + w0)) && (x0 < (x1 + w1)) && \
5858 (y1 < (y0 + h0)) && (y0 < (y1 + h1)))
5859#define NK_CONTAINS(x, y, w, h, bx, by, bw, bh)\
5860 (NK_INBOX(x,y, bx, by, bw, bh) && NK_INBOX(x+w,y+h, bx, by, bw, bh))
5861
5862#define nk_vec2_sub(a, b) nk_vec2((a).x - (b).x, (a).y - (b).y)
5863#define nk_vec2_add(a, b) nk_vec2((a).x + (b).x, (a).y + (b).y)
5864#define nk_vec2_len_sqr(a) ((a).x*(a).x+(a).y*(a).y)
5865#define nk_vec2_muls(a, t) nk_vec2((a).x * (t), (a).y * (t))
5866
5867#define nk_ptr_add(t, p, i) ((t*)((void*)((nk_byte*)(p) + (i))))
5868#define nk_ptr_add_const(t, p, i) ((const t*)((const void*)((const nk_byte*)(p) + (i))))
5869#define nk_zero_struct(s) nk_zero(&s, sizeof(s))
5870
5871/* ==============================================================
5872 * ALIGNMENT
5873 * =============================================================== */
5874/* Pointer to Integer type conversion for pointer alignment */
5875#if defined(__PTRDIFF_TYPE__) /* This case should work for GCC*/
5876# define NK_UINT_TO_PTR(x) ((void*)(__PTRDIFF_TYPE__)(x))
5877# define NK_PTR_TO_UINT(x) ((nk_size)(__PTRDIFF_TYPE__)(x))
5878#elif !defined(__GNUC__) /* works for compilers other than LLVM */
5879# define NK_UINT_TO_PTR(x) ((void*)&((char*)0)[x])
5880# define NK_PTR_TO_UINT(x) ((nk_size)(((char*)x)-(char*)0))
5881#elif defined(NK_USE_FIXED_TYPES) /* used if we have <stdint.h> */
5882# define NK_UINT_TO_PTR(x) ((void*)(uintptr_t)(x))
5883# define NK_PTR_TO_UINT(x) ((uintptr_t)(x))
5884#else /* generates warning but works */
5885# define NK_UINT_TO_PTR(x) ((void*)(x))
5886# define NK_PTR_TO_UINT(x) ((nk_size)(x))
5887#endif
5888
5889#define NK_ALIGN_PTR(x, mask)\
5890 (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x) + (mask-1)) & ~(mask-1))))
5891#define NK_ALIGN_PTR_BACK(x, mask)\
5892 (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x)) & ~(mask-1))))
5893
5894#if ((defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)) && !defined(__EMSCRIPTEN__)
5895#define NK_OFFSETOF(st,m) (__builtin_offsetof(st,m))
5896#else
5897#define NK_OFFSETOF(st,m) ((nk_ptr)&(((st*)0)->m))
5898#endif
5899
5900#ifdef __cplusplus
5901}
5902#endif
5903
5904#ifdef __cplusplus
5905template<typename T> struct nk_alignof;
5906template<typename T, int size_diff> struct nk_helper{enum {value = size_diff};};
5907template<typename T> struct nk_helper<T,0>{enum {value = nk_alignof<T>::value};};
5908template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {
5909 diff = sizeof(Big) - sizeof(T), value = nk_helper<Big, diff>::value};};
5910#define NK_ALIGNOF(t) (nk_alignof<t>::value)
5911#else
5912#define NK_ALIGNOF(t) NK_OFFSETOF(struct {char c; t _h;}, _h)
5913#endif
5914
5915#define NK_CONTAINER_OF(ptr,type,member)\
5916 (type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member)))
5917
5918
5919
5920#endif /* NK_NUKLEAR_H_ */
struct nk_allocator pool
!< buffer marker to free a buffer to a certain offset
Definition nuklear.h:4257
struct nk_memory memory
!< memory management type
Definition nuklear.h:4259
enum nk_allocation_type type
!< allocator callback for dynamic buffers
Definition nuklear.h:4258
nk_size needed
!< total amount of memory allocated
Definition nuklear.h:4262
nk_size size
!< number of allocation calls
Definition nuklear.h:4264
nk_size allocated
!< growing factor for dynamic memory management
Definition nuklear.h:4261
float grow_factor
!< memory and size of the current memory block
Definition nuklear.h:4260
nk_size calls
!< totally consumed memory given that enough memory is present
Definition nuklear.h:4263
command base and header of every command inside the buffer
Definition nuklear.h:4533
int build
windows
Definition nuklear.h:5826
struct nk_text_edit text_edit
text editor objects are quite big because of an internal undo/redo stack.
Definition nuklear.h:5821
struct nk_command_buffer overlay
draw buffer used for overlay drawing operation like cursor
Definition nuklear.h:5823
enum nk_anti_aliasing shape_AA
!< line anti-aliasing flag can be turned off if you are tight on memory
Definition nuklear.h:1026
enum nk_anti_aliasing line_AA
!< global alpha value
Definition nuklear.h:1025
nk_size vertex_alignment
!< sizeof one vertex for vertex packing
Definition nuklear.h:1033
nk_size vertex_size
!< describes the vertex output format and packing
Definition nuklear.h:1032
const struct nk_draw_vertex_layout_element * vertex_layout
!< handle to texture with a white pixel for shape drawing
Definition nuklear.h:1031
unsigned arc_segment_count
!< number of segments used for circles: default to 22
Definition nuklear.h:1028
unsigned circle_segment_count
!< shape anti-aliasing flag can be turned off if you are tight on memory
Definition nuklear.h:1027
unsigned curve_segment_count
!< number of segments used for arcs: default to 22
Definition nuklear.h:1029
struct nk_draw_null_texture tex_null
!< number of segments used for curves: default to 22
Definition nuklear.h:1030
struct nk_vec2 uv
!< texture handle to a texture with a white pixel
Definition nuklear.h:1021
Basic string buffer which is only used in context with the text editor to manage and manipulate dynam...
Definition nuklear.h:4292
nk_text_width_f width
!< max height of the font
Definition nuklear.h:4075
float height
!< user provided font handle
Definition nuklear.h:4074